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

Problem with rotate function.

New Here ,
Aug 25, 2010 Aug 25, 2010

Copy link to clipboard

Copied

rotatingText.jpg

I got a problem with the rotate function. When I rotate an (text) object (point text but same behavior with area text) on the GUI of Illustrator, the resize bounds around (see screenshot) is rotated as well so that you can resize it as used to. If I rotate the same object by JavaScript, the resize bounds are NOT rotated along with. How can I get the same effect as with the GUI-way by JavaScript as thats the result I need? And where is my thinking error. Here is the code I used for the rotation:


var docRef = app.activeDocument;
var sRef = docRef.selection[0];

sRef.rotate(20, true, true, true, true, Transformation.TOPLEFT);

TOPICS
Scripting

Views

1.1K

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

correct answers 1 Correct answer

Advocate , Apr 20, 2023 Apr 20, 2023

@Jens_D_ 

@CarlosCanto 

after some tinkering, i think i perhaps have found a solution for the bounding box issue. The way we can keep it, is by also adding tags. I tried using them seperate, but adding tags by themselves doesnt work. Thats why i run the rotate function as well.

 

I first got that tags name by running it on an object which had rotation. first i though what a weird name, but BB probably stands for BoundBox

 

var doc = app.activeDocument;
if (app.documents.length > 0) {
    for (var i = 
...

Votes

Translate

Translate
Community Expert ,
Aug 30, 2010 Aug 30, 2010

Copy link to clipboard

Copied

Hi Jens, I had the same problem, no matter what I tried, rotating via scripting keeps resetting the bounding box. I resolved it by recording an action to rotate the object, same results as if rotated manually. If you still need to rotate via scripting, VBS and AppleSript can execute Actions from script, JS can not.

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 ,
Aug 30, 2010 Aug 30, 2010

Copy link to clipboard

Copied

Hello CarlosCanto, thats bad news because I cant use an action as the angle to rotate the objekt ist determinend at runtime ... as well as I have to use javascript for the integration of several scripts 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
Advocate ,
Apr 20, 2023 Apr 20, 2023

Copy link to clipboard

Copied

@Jens_D_ 

@CarlosCanto 

after some tinkering, i think i perhaps have found a solution for the bounding box issue. The way we can keep it, is by also adding tags. I tried using them seperate, but adding tags by themselves doesnt work. Thats why i run the rotate function as well.

 

I first got that tags name by running it on an object which had rotation. first i though what a weird name, but BB probably stands for BoundBox

 

var doc = app.activeDocument;
if (app.documents.length > 0) {
    for (var i = 0; i < doc.selection.length; i++) {
        
        var ob = doc.selection[i]
        tags = ob.tags;
        tags.add()
        ob.tags[0].name = "BBAccumRotation"
        var pi = Math.PI;
        // var degrees * (pi/180);
        // ob.tags[0].value = (10* 180 / Math.PI)
        ob.tags[0].value = 10* (pi/180);
        ob.rotate(ob.tags[0].value * 180 / Math.PI, true)
}
}

 

 

I quickly made a screengrab showing the difference. This was for a script replace objects with a symbol and also apply rotation. I wanted to keep how the boundingbox shows, thats why it doesnt show with either transformation matrix or rotate function
added boundingbox rotation.gif

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 20, 2023 Apr 20, 2023

Copy link to clipboard

Copied

LATEST

Hi @schroef , it seems to work! great find, thanks for sharing

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
Advocate ,
Apr 20, 2023 Apr 20, 2023

Copy link to clipboard

Copied

@CarlosCanto , @Jens_D_ 

I bumped into this, using transformationMatrix. This actually keeps the rotation

This is the example of Adobe help docs

// Tranforms all art in a document using translation and rotation matrices,
// moves art half an inch to the right and 1.5 inches up on the page
if (app.documents.length > 0) {
  var moveMatrix = app.getTranslationMatrix(0.5, 1.5);

  // Add a rotation to the translation, 10 degrees counter clockwise
  var totalMatrix = concatenateRotationMatrix(moveMatrix, 10);

  // apply the transformation to all art in the document
  var doc = app.activeDocument;
  for (var i = 0; i < doc.pageItems.length; i++) {
    doc.pageItems[i].transform(totalMatrix);
  }
}

 

Found here; https://ai-scripting.docsforadobe.dev/jsobjref/Matrix.html


 

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
Advocate ,
Apr 20, 2023 Apr 20, 2023

Copy link to clipboard

Copied

Its seems it doesnt always work. on pathItems it seems to work. With symbols. the boundingbox seems to get reset again 

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