Copy link to clipboard
Copied
Hello. Very new to Applescript. Just trying to resize multiple image frames on a page to 50mm x 20mm. I'm not sure where I'm going wrong.
tell application "Adobe InDesign 2020"
set myDoc to active document
set myRect to selection
tell myDoc
set geometric bounds of myRect to {50, 20, 0, 0}
end tell
end tell
I did not look into the code that was setting the geomteric bounds as i thought you had that figured. Try the following
tell application "Adobe InDesign 2020"
set myRect to every item in selection
repeat with pi in myRect
set gb to geometric bounds of pi
set geometric bounds of pi to {item 1 of gb, item 2 of gb, (item 1 of gb) + 50, (item 2 of gb) + 20}
end repeat
end tell
And pi is just a variable that i am using to iterate the pageitems in the selection
-Manan
Copy link to clipboard
Copied
Try the following
tell application "Adobe InDesign 2020"
set myRect to every item in selection
repeat with pi in myRect
set geometric bounds of pi to {50, 20, 0, 0}
end repeat
end tell
P.S. :- I am not proficient in AppleScript, so this might be a crude solution
-Manan
Copy link to clipboard
Copied
Thanks for the response Manan. I tried your solution just now, but I'm afraid the rectangles all seem to relocate off the page and on top of each other (aligned with the top, right corner of the page). The image within each frame remains in its original location, but the frames move. Also, I have added the measurements incorrectly. Should be 20, 50, 0, 0.
And what is pi if I may ask?
Thank you for the effort though.
Copy link to clipboard
Copied
Also you might need to set the ruler units—is it 50 inches or 50 points? And {20, 50, 0, 0} would rotate the object 180 degrees, is that what you want? The bounds list is {y1, x1, y2, x2}, so do you want the frame to be 20 x 50? In that case it would be {0, 0, 50, 20}
tell application "Adobe InDesign 2020"
--set the rulers to points
set properties of view preferences to {horizontal measurement units:points, vertical measurement units:points}
set myRect to every item in selection
repeat with pi in myRect
--get the current bounds
set {y1, x1, y2, x2} to geometric bounds of pi
--keep y1 & x1 unchanged and add 50 to y1 to change the height
--and add 20 to x1 to change the width
set geometric bounds of pi to {y1, x1, y1 + 50, x1 + 20}
end repeat
end tell
Copy link to clipboard
Copied
I did not look into the code that was setting the geomteric bounds as i thought you had that figured. Try the following
tell application "Adobe InDesign 2020"
set myRect to every item in selection
repeat with pi in myRect
set gb to geometric bounds of pi
set geometric bounds of pi to {item 1 of gb, item 2 of gb, (item 1 of gb) + 50, (item 2 of gb) + 20}
end repeat
end tell
And pi is just a variable that i am using to iterate the pageitems in the selection
-Manan
Copy link to clipboard
Copied
Sorry for my late response. But thank you very much Manan. That worked!