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

Resize artwork in indesign CS6, javascript

Participant ,
Aug 20, 2018 Aug 20, 2018

Hi,

I get user's input through dialog how much to enlarge or reduce artwork in % and than re-scale it based on that. When indesign does it in UI, it allows user to go back to 100% by just inputting 100% into re-size window. How can I access this information through my script, because right now if artwork was resized to 110%, request for 100% will not do anything in my script:

var myRectangle = myDoc.pages

.rectangles[0];

var myArt = myRectangle.graphics[0];

         var  xScale = myScale / 100;   

         var  yScale = myScale / 100;   

      

         myArt.horizontalScale = myArt.horizontalScale * xScale;    

          myArt.verticalScale = myArt.verticalScale * yScale; 

Thank you.

Yulia

TOPICS
Scripting
1.4K
Translate
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

Community Expert , Aug 21, 2018 Aug 21, 2018

Hi Yulia,

Try the following it should work

var myRectangle = myDoc.pages

.rectangles[0]; 

var myArt = myRectangle.graphics[0]; 

 

var  xScale = myScale ;     

var  yScale = myScale ;     

        

myArt.horizontalScale = xScale;      

myArt.verticalScale = yScale;

What you were doing is setting the scale with respect to the current scale, now if you set the scale initially at 5% it would have the correct result but after that if you send 100 as my scale value it will have no effect and the scale wo

...
Translate
Community Expert ,
Aug 21, 2018 Aug 21, 2018

Hi Yulia,

Try the following it should work

var myRectangle = myDoc.pages

.rectangles[0]; 

var myArt = myRectangle.graphics[0]; 

 

var  xScale = myScale ;     

var  yScale = myScale ;     

        

myArt.horizontalScale = xScale;      

myArt.verticalScale = yScale;

What you were doing is setting the scale with respect to the current scale, now if you set the scale initially at 5% it would have the correct result but after that if you send 100 as my scale value it will have no effect and the scale would remain 5, as xScale/yScale would be 1.

-Manan

Translate
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
Participant ,
Aug 21, 2018 Aug 21, 2018

Thank you, Manan,

It makes perfect sense.

But for whatever reason when I try to run it, it stops at the line:

myArt.horizontalScale = xScale;

Thank you.

Yulia

Translate
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
Participant ,
Aug 21, 2018 Aug 21, 2018

I know why. I had to add this:

myScale = eval (myScale);

before this:

myArt.horizontalScale = myScale;  

myArt.verticalScale = myScale;

Yulia

Translate
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
Community Expert ,
Aug 21, 2018 Aug 21, 2018

i used a number value for setting myScale and it worked without eval. What value does your myScale hold before you run eval over it?

Translate
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
Participant ,
Aug 22, 2018 Aug 22, 2018
LATEST

My number is coming from dialog box, so I think, script perceives it as string.

Translate
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