Copy link to clipboard
Copied
Oi!
I have a simple little script for rotating selected object.
It does the same if selected with 'Selection Tool' or 'Direct Selection Tool'.
In both cases the text in the object is rotating with the object.
var mySelection = app.selection;
if (mySelection.length > 0) {
var myAngle = -90;
var myCenter = [mySelection[0].geometricBounds[1], mySelection[0].geometricBounds[0]];
var myTransform = app.transformationMatrices.add({counterclockwiseRotationAngle: myAngle, anchorPoint: myCenter});
mySelection[0].transform(CoordinateSpaces.PASTEBOARD_COORDINATES, AnchorPoint.CENTER_ANCHOR, myTransform);
}
If I manually rotate with 'Rotate 90° CW' (see the attached video):
'Selection Tool' rotates also the text.
'Direct Selection Tool' does not rotate the text.
Any ideas how to put it in a script?
Copy link to clipboard
Copied
With Direct Selection Tool you are moving points of the Object - not the Object itself.
I'm away from my computer so can't check - but I think you would have to move each PathPoint of the Path separately.
Copy link to clipboard
Copied
I guess, I should do the rotation for each PathPoint of the Path separately by 90 degrees CW with respect to the centroid of the object, but my knowledge of scripting is at a very basic level.
Thank you for your comments!
Copy link to clipboard
Copied
You need to get a reference to the object inside the rectangle. How was that page item put together?
Copy link to clipboard
Copied