Highlighted

Applescript resize frame

New Here ,
Apr 02, 2020

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

Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

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

TOPICS
Scripting

Views

71

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Applescript resize frame

New Here ,
Apr 02, 2020

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

Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

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

TOPICS
Scripting

Views

72

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 02, 2020 0
Adobe Community Professional ,
Apr 02, 2020

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 02, 2020 1
New Here ,
Apr 02, 2020

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 02, 2020 0
Adobe Community Professional ,
Apr 03, 2020

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 03, 2020 0
Adobe Community Professional ,
Apr 02, 2020

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 02, 2020 0
New Here ,
Apr 18, 2020

Copy link to clipboard

Copied

Sorry for my late response. But thank you very much Manan. That worked!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 18, 2020 0