Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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…
Copy link to clipboard
Copied
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);
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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);
Copy link to clipboard
Copied
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
Find more inspiration, events, and resources on the new Adobe Community
Explore Now