• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

JavaScript for rotating 'Direct Selection'

New Here ,
Apr 20, 2023 Apr 20, 2023

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?

TOPICS
Scripting

Views

425

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 20, 2023 Apr 20, 2023

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.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 21, 2023 Apr 21, 2023

Copy link to clipboard

Copied

LATEST

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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 21, 2023 Apr 21, 2023

Copy link to clipboard

Copied

You need to get a reference to the object inside the rectangle. How was that page item put together?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 21, 2023 Apr 21, 2023

Copy link to clipboard

Copied

Attached .indd (Adobe InDesign CC 2017.1 Release).
It explains how I created the object.

Thank you for your comments!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines