Copy link to clipboard
Copied
Hi,
Recently I started to have unusual problem: frames are not displayed in the size they are set in geometric Bounds. One page would do it correctly another would stretch the frame. One computer would do it correctly another would stretch. Any idea what is going on and how I can make it work:
myTextBkg = myDoc.pages[0].rectangles.add (myDoc.layers.item ("Template"));
myTextBkg.geometricBounds = [myY-.05045, myX-.4102, myY+0.05045, myX+0.4102];
If myY = 1 in, and myX = 1 in, I should have:
myTextBkg.geometricBounds = [1-.05045, 1-.4102, 1+0.05045, 1+0.4102];
myTextBkg.geometricBounds = [0.94955, 0.5898, 1.05045, 1.4102];
This:
Instead of this:
Thank you for your help.
Yulia
Copy link to clipboard
Copied
Are you sure all users are using the same units ?
Copy link to clipboard
Copied
Yes,
and would it use different units for width to height? It's showing 3 sides correctly. And it only extends to the right in all cases.
Copy link to clipboard
Copied
Actually I just tried 2nd width value with variable only:
myTextBkg.geometricBounds = [myY-.05045, myX-.4102, myY+0.05045, myX+0.4102];
and it worked correctly. It looks like when I add 0.4102 to it, it adds few inches instead of 0.4102, like it's deducting it from document width.
Copy link to clipboard
Copied
I just tried it with +0 and it added same few extra inches to it:
myTextBkg.geometricBounds = [myY-.05045, myX-.4102, myY+0.05045, myX+0];
Copy link to clipboard
Copied
and I reassigned inches to document preferences:
myDoc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.inches;
myDoc.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.inches;
Still same thing.
Copy link to clipboard
Copied
I figured it out. The value for myX variable comes from dialog box, and it must be occasionally does not recognize it as numeric value, so it just guessing a number.
I added this to it:
myX = eval (myX);
And it's now working.
Yulia
Copy link to clipboard
Copied
I was suspecting something like that but it was hard to assume without details
FWIW, you can easily convert strings to numbers without eval:
var myString = "1";
var myNum = Number( myString );
or
var myNum = parseFloat ( myString );