Skip to main content
dsomrz
Known Participant
November 13, 2024
Question

Align Script

  • November 13, 2024
  • 3 replies
  • 309 views

Trying to develop a script that will align an object horizontally center and vertically to bottom.

This is what I have but can't get it to align to the bottom

 

tell application "Adobe InDesign 2025"

                set selList to selection --assumes more than one item selected

                tell document 1

                                align align distribute items selList align option horizontal centers

                                align align distribute items selList align option vertical centers

                end tell

end tell

This topic has been closed for replies.

3 replies

Community Expert
November 16, 2024
tell application "Adobe InDesign 2025"
    set selList to selection -- assumes items are selected
    tell document 1
        -- Align horizontally to center
        align align distribute items selList align option horizontal centers

        -- Align vertically to bottom
        align align distribute items selList align option bottom edges
    end tell
end tell

 

as per @leo.r 

dsomrz
dsomrzAuthor
Known Participant
November 18, 2024

Thank you. I got this from someone. it aligns the image to the page centered horizontally and vertically .1875" from the bottom of the page.

 
// Align a page item relative to the page
 
(function () {
 
var frame = app.selection[0];
 
var pb = frame.parentPage.bounds;
var pageVCentre = pb[2]/2;
var pageHCentre = pb[3]/2;
 
var gb = frame.geometricBounds;
var frameVCentre = gb[0] + ((gb[2]-gb[0])/2);
var frameHCentre = gb[1] + ((gb[3]-gb[1])/2);
var frameBottom = gb[2];
 
frame.move (undefined, [
pageHCentre - frameHCentre, // x-move
//pageVCentre - frameVCentre  // y-move, frame bottom to page centre
//pageVCentre - frameBottom   // y-move, frame bottom to page centre
pb[2] - frameBottom - 0.1875   // y-move, frame bottom to page bottom
]);
 
}());
leo.r
Community Expert
Community Expert
November 16, 2024

have you tried bottom edges?

kglad
Community Expert
Community Expert
November 13, 2024

in the future, to find the best place to post your message, use the list here, https://community.adobe.com/

p.s. i don't think the adobe website, and forums in particular, are easy to navigate, so don't spend a lot of time searching that forum list. do your best and we'll move the post (like this one has already been moved) if it helps you get responses.



<"moved from using the community">