Skip to main content
Inspiring
July 13, 2022
Answered

How to add an object that exists in a document to an existing group in a document?

  • July 13, 2022
  • 1 reply
  • 241 views

the Illustrator Scripting Guide has an example of creating a group of pathItems
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
var triangleGroup = app.activeDocument.groupItems.add();

// Create a triangle and add text, the new art is created inside the group
var trianglePath = triangleGroup.pathItems.add();
trianglePath.setEntirePath(Array(Array(100, 100), Array(300, 100), Array(200, Math.tan(1.0471975) * 100 + 100)));
trianglePath.closed = true;
trianglePath.stroked = true;
trianglePath.filled = false;
trianglePath.strokeWidth = 3;
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

But it shows the process for newly created pathItems

Let's say that in the scene there is an pathItem called "Line01". How to add this pathItem to the group "Group 01"???

 
This topic has been closed for replies.
Correct answer CarlosCanto

try this

 

var idoc = app.activeDocument;
idoc.pageItems["Line01"].move (idoc.pageItems["Group 01"], ElementPlacement.PLACEATBEGINNING);

1 reply

CarlosCanto
Community Expert
CarlosCantoCommunity ExpertCorrect answer
Community Expert
July 13, 2022

try this

 

var idoc = app.activeDocument;
idoc.pageItems["Line01"].move (idoc.pageItems["Group 01"], ElementPlacement.PLACEATBEGINNING);