Copy link to clipboard
Copied
Hi all,
I got issue with moving object position when Perspective Grid is showing.
Is there any way if the document is showing Perspective Grid or not?
Document object has some function to control Perspective Grid,
but it seems no function or property to tell if currently Perspective Grid is shown or not.
getPerspectiveActivePlane() returns same value either Perspective Grid is displayed or not.
Test Code |
---|
var _x1 = app.selection[0].left; $.writeln("_x1 = " + _x1); app.selection[0].left = 200; // set manually var _x2 = app.selection[0].left; $.writeln("_x2 = " + _x2); app.selection[0].left = _x1; // revert to original value var _x3 = app.selection[0].left; $.writeln("_x3 = " + _x3); |
Result with Perspective Grid is shown (I think bug) |
---|
_x1 = 214.392303466797 _x2 = 212.934600830078 _x3 = 213.081192016602 |
Note: It does not set to 200. Even original value cannot set again.
Result without Perspective Grid or hidden (expected behavior) |
---|
_x1 = 214.392303466797 _x2 = 200 _x3 = 214.392303466797 |
Thank you,
Naoki
Copy link to clipboard
Copied
I too was unable to find a boolean property regarding whether or not the perspective grid is visible. However there are document methods that allow you to show or hide the perspective grid. So if the goal is to make sure it's not on, at least for the execution of your script, you could do something like this:
var docRef = app.activeDocument;
docRef.hidePerspectiveGrid();
//do the rest of your code
//if you want the grid back after the script is finished, you could do this
docRef.showPerspectiveGrid();
Copy link to clipboard
Copied
Another possibility to consider is that if you use the GUI to set the position of something, it will set the geometricBounds of the object to that particular position, and when you then read the "left" property, you are reading the visibleBounds of the object.
So if the object you're measuring has a stroke, you will get seemingly incorrect results. Let us know if this is a possible issue and we can dive deeper to see if we can't pinpoint the problem.
Copy link to clipboard
Copied
Thank you very much for the additional info.
I have simple transform operation code for just scaling. In general target object has stroke.
The code was used 4 position properties (left, width, top, height)
It seems working fine until issue found with perspective grid.
One work around is that disabling above scaling when perspective grid view is shown.
I think I should try resize() function.
Thank you,
Naoki
Copy link to clipboard
Copied
williamadowling​ Thank you very much for the pointer. For my case overwriting show/hide is not a goal. I just want to disable positioning operation (left, width, top, height) when perspective grid is shown.
Copy link to clipboard
Copied
Hmm. I'm sorry, then I don't really have a solution.. I'll keep thinking about it and hopefully i can come up with something. Otherwise, good luck.