Looking Script to rotate objects

Explorer ,
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

204

Likes

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

Participant , 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
...

Likes

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

 

Likes

Translate

Translate
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);

}

Likes

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
Explorer ,
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

Likes

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
Participant ,
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;
}

 

Likes

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
Explorer ,
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

Likes

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

Copy link to clipboard

Copied

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

Likes

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

Likes

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
Participant ,
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.

Likes

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

Copy link to clipboard

Copied

Now that's cool, thanks.

Likes

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?

Likes

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. 

Likes

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

Copy link to clipboard

Copied

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

Likes

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

Likes

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? 

Likes

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

Copy link to clipboard

Copied

Thank you for reply. Please refer the shared screenshot

Likes

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

 

Likes

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
Explorer ,
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 🙂

Likes

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