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

Looking Script to rotate objects

Contributor ,
Aug 11, 2022 Aug 11, 2022

Copy link to clipboard

Copied

Hello Friends,

 

I am looking an illustrator script, which will rotate the selected objects. by its current rotate angle * 0

 

is this possible ?

TOPICS
Scripting

Views

694

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 2 Correct answers

Enthusiast , Aug 11, 2022 Aug 11, 2022

I have a script in the archive, unfortunately I do not know its author 🙂
rotate.gif

 

doc = app.activeDocument;
sel = doc.selection;

first = 1;
ang = 0;
for (i = 0; i < sel.length; i++) {
  if (sel[i].typename == "GroupItem" || sel[i].typename == "PathItem" || sel[i].typename == "CompoundPathItem") {
    currGroup = sel[i];

    getFP = FindFirstPath(currGroup);
    currpath = getFP[1];

    if (getFP[0] == 1) {
      p1 = currpath.pathPoints[0].anchor;
      p2 = currpath.pathPoints[1].anchor;

      delt
...

Votes

Translate

Translate
Community Expert , Aug 12, 2022 Aug 12, 2022

Also see:

 

https://community.adobe.com/t5/illustrator-discussions/rotation/m-p/12443669

 

Apart from that, there is a very good script called Circular, provided by Alexander Ladygin. It has an option to reset rotations.

 

https://github.com/alexander-ladygin/illustrator-scripts

 

Votes

Translate

Translate
Adobe
Community Expert ,
Aug 11, 2022 Aug 11, 2022

Copy link to clipboard

Copied

var selection = app.activeDocument.selection;

for(var s=0;s<selection.length;s++)

{

    selection[0].rotate(0);

}

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
Contributor ,
Aug 11, 2022 Aug 11, 2022

Copy link to clipboard

Copied

Thank you for your reply. I test the code but it doesn't work in my case. I am attaching the screenshot the problem I am facing and the solution is expecting.

Please Refer the attached screenshot.Rotate_test.png

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
Enthusiast ,
Aug 11, 2022 Aug 11, 2022

Copy link to clipboard

Copied

I have a script in the archive, unfortunately I do not know its author 🙂
rotate.gif

 

doc = app.activeDocument;
sel = doc.selection;

first = 1;
ang = 0;
for (i = 0; i < sel.length; i++) {
  if (sel[i].typename == "GroupItem" || sel[i].typename == "PathItem" || sel[i].typename == "CompoundPathItem") {
    currGroup = sel[i];

    getFP = FindFirstPath(currGroup);
    currpath = getFP[1];

    if (getFP[0] == 1) {
      p1 = currpath.pathPoints[0].anchor;
      p2 = currpath.pathPoints[1].anchor;

      deltax = p1[0] - p2[0];
      deltay = p1[1] - p2[1];

      currang = Math.atan(deltay / deltax);
      if (deltax < 0)
        currang += Math.PI;

      if (first) {
        first = 0;

        ang = currang;
      } else {
        currGroup.rotate((ang - currang) * 180 / Math.PI);
      }
    }
  }
}

function FindFirstPath(workGroup) {
  if (workGroup.typename == "PathItem")
    return [1, workGroup];

  if (workGroup.typename == "CompoundPathItem")
    return [1, workGroup.pathItems[0]];

  nSubPathes = workGroup.pathItems.length;
  if (nSubPathes > 0)
    return [1, workGroup.pathItems[0]];

  nSubPathes = workGroup.compoundPathItems.length;
  if (nSubPathes > 0)
    return [1, workGroup.compoundPathItems[0].pathItems[0]];

  nSubGroups = workGroup.groupItems.length;
  if (nSubGroups == 0)
    return [0, 0];
  var currRet = [0, 0];
  for (iGroup = 0; iGroup < nSubGroups; iGroup++) {
    currRet = FindFirstPath(workGroup.groupItems[iGroup]);
    if (currRet[0] == 1)
      break;
  }
  return currRet;
}

 

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
Contributor ,
Aug 11, 2022 Aug 11, 2022

Copy link to clipboard

Copied

Thank you so much Sergey Osokin, this works perfectly as I want. only one issue in this is we have to maintain the stacking order of layers. The reference group (here is the pink object) always should be at top before run the script. I never forget this is 2nd time you given me correct solution. Thanks lot 🙂

soltuion.png

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
Contributor ,
Aug 11, 2022 Aug 11, 2022

Copy link to clipboard

Copied

And Reference object must be selected, while selecting others object to rotate

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 ,
Aug 12, 2022 Aug 12, 2022

Copy link to clipboard

Copied

quote

I have a script in the archive, unfortunately I do not know its author 🙂


By @Sergey Osokin

 

could it be from xpmycpc?

http://www.cnprint.org/bbs/showthread.php?t=259352

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
Enthusiast ,
Aug 12, 2022 Aug 12, 2022

Copy link to clipboard

Copied

Maybe. No other sources can be found. I will add this link to my local JS file.

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
Mentor ,
Aug 12, 2022 Aug 12, 2022

Copy link to clipboard

Copied

Now that's cool, thanks.

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 ,
Aug 11, 2022 Aug 11, 2022

Copy link to clipboard

Copied

but rotating by 0 or rotating by angle*0 would not apply any rotation, right?

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 ,
Aug 11, 2022 Aug 11, 2022

Copy link to clipboard

Copied

that is my understanding. doesn't matter what the current rotation is.. if you multiply it by zero, no rotation will occur. 

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
Guide ,
Aug 11, 2022 Aug 11, 2022

Copy link to clipboard

Copied

I think they might have meant ° (degree symbol), as opposed to 0 (zero).

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 ,
Aug 11, 2022 Aug 11, 2022

Copy link to clipboard

Copied

it makes sense, you might be 100% right

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 ,
Aug 11, 2022 Aug 11, 2022

Copy link to clipboard

Copied

I still don't think that would be enough information to provide any help. Unless they're asking for something to "rotate again" by just doubling the existing rotation angle? 

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
Contributor ,
Aug 11, 2022 Aug 11, 2022

Copy link to clipboard

Copied

Thank you for reply. Please refer the shared screenshot

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 ,
Aug 12, 2022 Aug 12, 2022

Copy link to clipboard

Copied

Also see:

 

https://community.adobe.com/t5/illustrator-discussions/rotation/m-p/12443669

 

Apart from that, there is a very good script called Circular, provided by Alexander Ladygin. It has an option to reset rotations.

 

https://github.com/alexander-ladygin/illustrator-scripts

 

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
Contributor ,
Aug 18, 2022 Aug 18, 2022

Copy link to clipboard

Copied

LATEST

I am really very thankful to all, who replies on my query. and my problem is solved now 🙂

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