Copy link to clipboard
Copied
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
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
...Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
I know why. I had to add this:
myScale = eval (myScale);
before this:
myArt.horizontalScale = myScale;
myArt.verticalScale = myScale;
Yulia
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
My number is coming from dialog box, so I think, script perceives it as string.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more