Copy link to clipboard
Copied
Hello Scripters,
i need a tiny bit of help to finish the last bit of a quick-and-dirty.
tell application "Adobe InDesign CC 2017"
set mySel to selection
set myitem to item 1 of mySel
resize myitem …
• I need my selected item (a picture frame) be exactly 9 mm (milimeters) in heigth, width scaling proportional, using the anchor upper left.
Thanks in advance!
You can use resize or transform with a simple math. However that will not work nicely if item is rotated or skewed or both.
Dealing with geometry inside indesign is actually a science topic by itself…
...tell application "Adobe InDesign CC 2017"
set sel to selection
if (count of items in sel) = 0 then
display dialog "You need one item to be selected"
else
set doc to active document
set sel to item 1 of sel
set vb to visible bounds of sel
set uncertainHeight to ((item 3 of vb) - (item 1 of
Copy link to clipboard
Copied
You can use resize or transform with a simple math. However that will not work nicely if item is rotated or skewed or both.
Dealing with geometry inside indesign is actually a science topic by itself…
tell application "Adobe InDesign CC 2017"
set sel to selection
if (count of items in sel) = 0 then
display dialog "You need one item to be selected"
else
set doc to active document
set sel to item 1 of sel
set vb to visible bounds of sel
set uncertainHeight to ((item 3 of vb) - (item 1 of vb))
set ratio to 9 / uncertainHeight
--Using matrix
set myTransformationMatrix to make transformation matrix with properties {horizontal scale factor:ratio, vertical scale factor:ratio}
tell sel to transform in pasteboard coordinates from center anchor with matrix myTransformationMatrix
--OR using resize
--tell sel to resize in pasteboard coordinates from center anchor by multiplying current dimensions by values {ratio, ratio}
end if
end tell
Copy link to clipboard
Copied
Good job Loic.Aigon !
And I never was close to that code you delivered . Also I didnt know about uncertainHeight, would come in handy in future.
Have a nice day!
Copy link to clipboard
Copied
Once again, uncertainHeight stands for what it means i.e. a possible value for the height. If the item is rotated or skewed or both that will throw a wrong value. Normally it would imply dealing with internal object geometry for stronger results.
Copy link to clipboard
Copied
Thanks for the warning, I'll be careful with my script. But since its for a logo exchange routine, nothing will be skewed or rotated *phew*.