Create a group of all items with scripting

Participant ,
Mar 17, 2020 Mar 17, 2020

Copy link to clipboard

Copied

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.

TOPICS
Scripting

Views

1.4K

Likes

Translate

Translate

Report

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
LEGEND ,
Mar 17, 2020 Mar 17, 2020

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

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
Participant ,
Mar 18, 2020 Mar 18, 2020

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

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
LEGEND ,
Mar 18, 2020 Mar 18, 2020

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

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 Professional ,
Mar 19, 2020 Mar 19, 2020

Copy link to clipboard

Copied

if(app.activeDocument.selection.length)
{
    app.executeMenuCommand("group");
}
else
{
    alert("Please select some items first.");
}

Likes

Translate

Translate

Report

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
Enthusiast ,
Mar 19, 2020 Mar 19, 2020

Copy link to clipboard

Copied

 

 

//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);

 

 

 

 

 

Likes

Translate

Translate

Report

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 ,
Jan 15, 2021 Jan 15, 2021

Copy link to clipboard

Copied

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!

Likes

Translate

Translate

Report

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
Enthusiast ,
Jan 15, 2021 Jan 15, 2021

Copy link to clipboard

Copied

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.  

Likes

Translate

Translate

Report

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 ,
Jan 15, 2021 Jan 15, 2021

Copy link to clipboard

Copied

Hello, thank you for the answer, that makes a lot of sense. I was wondering if perhaps you could help me with an issue related to this thread. I used your answer for adding a pathItem object to a groupItem object in a script, and it worked wonderfully, so thank you for that.

However, I now have a script where I want to group all elements into 3 distinct GroupItem elements, depending on their vertical location in the artboard (PDF file). I have tried running this code but I get this error, perhaps you know what I am doing wrong:

ExtendScriptError.png

 

Thank you so much!

Likes

Translate

Translate

Report

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
Enthusiast ,
Jan 15, 2021 Jan 15, 2021

Copy link to clipboard

Copied

Likes

Translate

Translate

Report

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 ,
Feb 23, 2021 Feb 23, 2021

Copy link to clipboard

Copied

LATEST

Thank you so much! This solved my problem!

Likes

Translate

Translate

Report

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