Skip to main content
Inspiring
March 28, 2024
Answered

Assigning shortcut to Horizontal Distribute Center has no effect

  • March 28, 2024
  • 4 replies
  • 1108 views

Hello,

I have changed page size for a whole document and now I have to reposition a lot of PDF pages.

The action that is doing what I need is Distribute Horizontal Center.

When I go to Edit > Keyboard Shortcuts, in my custom set, and add a shortcut to this function (found in the Object Editing section), then Save, OK... it doesn't work... 

The shortcut assignment has been accepted no problem.

What am I missing?

 

If this is not working, is there a way to select ALL links of a certain kind, or all links belonging to the same file throughout the document, and then apply this distribution to them? 

I can certainly go one by one but it feels unoptimised at best.

Thank you

This topic has been closed for replies.
Correct answer rob day

Ah! One thing I forgot: is there a way, by extending the same script as above, to have it select all PDFs in the document? My PDFs are musical scores that are inserted as links inside of the INDD document, so any PDF should correspond to what I need to edit. 


You should be able to loop through the spreads and get their PDFs. Try this:

 

var s = app.activeDocument.spreads
var ag;
var a = [];
for (var i = 0; i < s.length; i++){
    ag = s[i].allPageItems;
    for (var j = 0; j < ag.length; j++){
        if (ag[j].constructor.name == "PDF") {
            a.push(ag[j].parent);
        } 
    }; 
    if (a.length > 0) {
        app.activeDocument.distribute(a, DistributeOptions.HORIZONTAL_CENTERS, AlignDistributeBounds.SPREAD_BOUNDS)
    } 
    a = [];
}; 

4 replies

rob day
Community Expert
Community Expert
March 28, 2024

Hi @Inélsòre , I see the same—Horizontal Page Align Center works for a single page item.

 

Distribute can be scripted, this works for me—you can assign key commands to scripts saved in your Scripts folder.

 

try {
    app.activeDocument.distribute(app.activeDocument.selection, DistributeOptions.HORIZONTAL_CENTERS, AlignDistributeBounds.PAGE_BOUNDS)
}catch(e) {
    alert("Select Some Page Items")
}  

 

 

James Gifford—NitroPress
Legend
March 28, 2024

Yes, that's a different command than  first discussed. The various "distribute horizontally" commands all work if more than one object is selected.

rob day
Community Expert
Community Expert
March 28, 2024

The various "distribute horizontally" commands all work if more than one object is selected.

 

Yes, this works for me when I use the panel:

 

 

 

But if I assign a key command to Horizontal Distribute Center, the key command does not work with any selections:

 

 

 

 

James Gifford—NitroPress
Legend
March 28, 2024

The assignment works fine for me (Win11, v19.3, assign 'Horizontal Distribute Center" to Ctrl-Alt-F10, context 'default,' save as my custom key set.)

 

The mapping of saved keys to any one working situation can be cranky. Make sure it's saved to an active set using the correct context. Somewhat oddball key combos are often preferable to ones that might be mapped to standard shortcuts.

Inspiring
March 28, 2024

I'm sorry, but I tried many different shortcuts, and every one of them was marked as "unassigned" (I guess that means it's free to use?).

No one of them works. I tried at least 10 different available combinations. None work...

Do you see anything wrong here? This is after creating a new Set and pressing the Assign button.

leo.r
Community Expert
Community Expert
March 28, 2024
quote

Hello,

I have changed page size for a whole document and now I have to reposition a lot of PDF pages.

The action that is doing what I need is Distribute Horizontal Center.

When I go to Edit > Keyboard Shortcuts, in my custom set, and add a shortcut to this function (found in the Object Editing section), then Save, OK... it doesn't work... 

The shortcut assignment has been accepted no problem.

What am I missing?


By @Inélsòre

 

I tried to assign a shortcut to this function and the shortcut worked as expected.

 

What kind of shortcut did you assign? What versions of InDesign and operating system are you using?

Inspiring
March 28, 2024

I'm using InDesign 19.3 on macOS 14.4.1

I tried Ctrl-D and Cmd-Option-D. 

None of them worked.

Robert at ID-Tasker
Legend
March 28, 2024
quote

[...] If this is not working, is there a way to select ALL links of a certain kind, or all links belonging to the same file throughout the document, and then apply this distribution to them? 

I can certainly go one by one but it feels unoptimised at best.


By @Inélsòre

 

PC - easy, but not free - Mac - no idea.