• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Resize by value with Applescript?

Advocate ,
Jul 25, 2017 Jul 25, 2017

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!

TOPICS
Scripting

Views

754

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
community guidelines

correct answers 1 Correct answer

People's Champ , Jul 25, 2017 Jul 25, 2017

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

...

Votes

Translate

Translate
People's Champ ,
Jul 25, 2017 Jul 25, 2017

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

Votes

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
community guidelines
Advocate ,
Jul 25, 2017 Jul 25, 2017

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!

Votes

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
community guidelines
People's Champ ,
Jul 26, 2017 Jul 26, 2017

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.

Votes

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
community guidelines
Advocate ,
Jul 26, 2017 Jul 26, 2017

Copy link to clipboard

Copied

LATEST

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*.

Votes

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
community guidelines