Skip to main content
Inspiring
March 18, 2020
Question

Create a group of all items with scripting

  • March 18, 2020
  • 3 replies
  • 6684 views

Is there anyway to create a group of all my pathItems and then move that group?  Something like this.

var allPathItems = app.activeDocument.pathItems;

var myGroup = group add allPathItems

myGroup.left = 500

 

Obviously the above is not actual proper syntax but just an idea of what I want to do.  So I can easily move everything on a layer into a certain area.

This topic has been closed for replies.

3 replies

femkeblanco
Legend
March 19, 2020

 

 

//create group
var group = activeDocument.groupItems.add();
//add all path items to group
for (i = 0; i < activeDocument.pathItems.length; i++) {
  activeDocument.pathItems[i].moveToEnd(group);
}
//move group 50 mm to left
group.translate(-50*2.835, 0);

 

 

 

 

 

Karl Fabian5F97
Inspiring
January 15, 2021

Hello,

 

Thank you for this answer. I have a questions regarding the .moveToEnd function. I cannot find it in nor in the "Adobe Illustrator CC Scripting Reference: JavaScript" nor in the general Illustrator Scripting Guide. If I am not incorrect it is not part of the official documentation.

 

What does this mean? Is it part of some external library? I am wondering because it would be great to knwo fi there are more useful functions such as that one which can't be found under the documentation.

 

Thank you!

femkeblanco
Legend
January 15, 2021

moveToEnd and moveToBeginning(document/layer/groupItem/compoundPathItem) appear to be legacy functions from Illustrator 10. I wonder if they were meant to be deprecated and replaced by move(). I find them more intuitive than move() with its two arguments and they still work. Unfortunately, I can't find the Illustrator 10 JS documentation.  

Disposition_Dev
Legend
March 19, 2020
if(app.activeDocument.selection.length)
{
    app.executeMenuCommand("group");
}
else
{
    alert("Please select some items first.");
}
JJMack
Community Expert
Community Expert
March 18, 2020

You question makes not sense to me .  There are Layer Groups  Photoshop.s Layer sets and there are layer comps.  A Path can have many closed path items that combine in different modes. You can merge paths using paste path and merge shape layers. I do not know of any groups of paths in Photoshop other than the Path Palette.  Your statement "var myGroup = group add allPathItems"   does not look like a valid Photoshop DOM JavaScript statement to me.  What is  a you idea of your group object .left about is 500 some unit like percent, pixels or other and what is it relative to?  However, I have a lot to learn about Adobe Photoshop DOM and JavaScript I just hack at it.  

 

If it a new feature you want use Adobe Feedback site idea 

JJMack
OhmsGAuthor
Inspiring
March 18, 2020

@JJMack, hi thanks for your response.  This is question for Illustrator not Photoshop.  It's in the Illustrator section.

JJMack
Community Expert
Community Expert
March 18, 2020

You should use the Ai forum then its has its own scripting users over there illustrator.   I can believe a vector editor like Ai may have Path groups. I see thih thread has beemmovet overt to Ai forum now.

JJMack