Skip to main content
Inspiring
October 26, 2022
Answered

JavaScript to resize a selected object in Illustrator!

  • October 26, 2022
  • 1 reply
  • 3345 views

Hello Everyone!

 

I need your help with a JavaSrcript that can resize a selected object (frame/image/lineart etc) in a calculated way i.e.
a) Width of the selected object should become equal to the width of the Document/Artboard.
b) Height should become [sqrt(documentWidth * documentHeight) * 0.08]

 

Thanks in advance.

Masood

Correct answer femkeblanco
app.selection[0].width = app.activeDocument.width;
app.selection[0].height = Math.sqrt(app.activeDocument.width * app.activeDocument.height) * 0.08;

1 reply

femkeblanco
femkeblancoCorrect answer
Legend
October 26, 2022
app.selection[0].width = app.activeDocument.width;
app.selection[0].height = Math.sqrt(app.activeDocument.width * app.activeDocument.height) * 0.08;
Inspiring
October 26, 2022

Thanks, a lot, very quick, much appreciated.

The code is working fine on empty frames, but not on the ones with clipping masks. Can you please check this.

Inspiring
October 26, 2022

…and

How can I change only one side (height/width) and make the other side reduce/enlarge proportionally. If I'm applying the script on a frame with an image.