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

How to rotate selection with javascript?

New Here ,
Dec 21, 2009 Dec 21, 2009

Hi,

i can't figure out how to simple rotate selected object with javascript. I read the 'Illustrator CS3 scripting guide' and wrote this code:

var myObject = app.activeDocument.selection;
myObject.rotate(30);

but it isn't working (Error24: myObject.rotate is not a function). Please someone tell me what am I doing wrong here.

TOPICS
Scripting
2.6K
Translate
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
Adobe
Guide ,
Dec 21, 2009 Dec 21, 2009

Selection is an Array of objects you will probably need loop thru each object in your selection array

Translate
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 ,
Dec 21, 2009 Dec 21, 2009

Thank you very much, you point me in the right direction. This code works for me:

var mySelection = app.activeDocument.selection;
var myObject = mySelection[0];
myObject.rotate(-2);

Translate
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 ,
Dec 22, 2009 Dec 22, 2009
LATEST

That is going to rotate the first item of your selection (OK if you only have one item selected) the other option for multi items would be to move them into new group item, rotate this (as it has a rotate method) then move items back out of group.

Translate
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