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

How to group items

Explorer ,
Jun 02, 2011 Jun 02, 2011

Sorry if this has been asked before, but search isn't working.

I would like to group two items, a TextFrame and a PathItem.  I know how to create a group, but I can't figure out how to remove the items from their current position and put them in the new group I just created.  Since TextFrameItems is read only, I can't store to it.  I can create a new TextFrameItem with the add() method, but I can't put the old item into it.  If I can make a copy in the new group, I think I can just use remove() to take it out of its old position.

TOPICS
Scripting
1.7K
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
Community Beginner ,
Jun 03, 2011 Jun 03, 2011

I'm rather new to the Illustrator objects, but the TextFrameItem and PathItem classes both have a "duplicate" method. I would suspect this would be of use to you.

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 ,
Jun 03, 2011 Jun 03, 2011

Ben, there is a 'move' command… You can reference any page item no matter it's container and move it relative to another referenced object… There is no need to duplicate to location then remove the old one… That would just be less efficient… You can also change the zorder this moves an object up or down but is relative to the parent container object… As in 'Move to Front' & 'Move forward' etc in the GUI…

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
Community Expert ,
Jun 03, 2011 Jun 03, 2011

asumming there's a path item and a text item

var idoc = app.activeDocument;

var igroup = idoc.groupItems.add();

var iframe = idoc.textFrames[0];

var ipath = idoc.pathItems[0];

iframe.moveToBeginning(igroup);

ipath.moveToBeginning(igroup);

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
Explorer ,
Jun 03, 2011 Jun 03, 2011

Thanks.  The key is "moveToBeginning," which is not documented.  It is mentioned under Brush in AICS5 Scripting Reference: Javascript.  With that piece of information, I found this thread that also explains it.

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
Community Expert ,
Jun 03, 2011 Jun 03, 2011

as Mark suggested, you could have used the Move Method, which is fully documented

var idoc = app.activeDocument;
var igroup = idoc.groupItems.add();

var iframe = idoc.textFrames[0];
var ipath = idoc.pathItems[0];
/*
iframe.moveToBeginning(igroup);
ipath.moveToBeginning(igroup);
*/
iframe.move(igroup, ElementPlacement.PLACEATBEGINNING);
ipath.move(igroup, ElementPlacement.PLACEATBEGINNING);
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
Community Expert ,
Mar 30, 2019 Mar 30, 2019
LATEST

https://forums.adobe.com/people/Big+RA  wrote

Thanks.  The key is "moveToBeginning," which is not documented.  It is mentioned under Brush in AICS5 Scripting Reference: Javascript.  With that piece of information, I found Group existing objects using Scripting API ?  that also explains it.

Hi Big RA,

method moveToBeginning() still is not listed in the OMV's DOM documentation of Illustrator CC 2019 version 23.

But I found it used in sample code for CS2 in AICS2-JavaScriptGuide.pdf and all other Illustrator scripting guides at:

Illustrator Scripting | Adobe Developer Connection

Regards,
Uwe

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