JavaScript for rotating 'Direct Selection'
- 4 replies
- 818 views
- Translate
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?
