Highlighted

recursively loop through selected groups and text and paths

Explorer ,
Dec 22, 2018

Copy link to clipboard

Copied

I have an issue with looping multi-selected items these items are texts, paths and groups I'm trying to figure it out how to loop through all of these types like over again whenever they have a child " grouped to apply an action like changing the fill

function loop(){

var sel = app.activeDocument.selection;

var calltype;

for (var i = 0; i < sel.length; i++)     {

alert(sel.typename);

switch (sel.typename) {

case "TextFrame":

//loopTextFeame(sel);

break;

case "PathItem":

//loopTextFeame(sel);

break;

case "CompoundPathItem":

loopCompoundPathItem(sel);

break;

case "GroupItem":

//loopTextFeame(sel);

break;

}

}

}

function loopCompoundPathItem(obj){

  for (var i = 0; i < obj.groupItems.length; i++)     {

alert(obj.typenames)

switch (obj.typename) {

case "TextFrame":

//loopTextFeame(sel);

break;

case "PathItem":

//loopTextFeame(sel);

break;

case "CompoundPathItem":

loopCompoundPathItem(obj);

break;

case "groupItems":

loopCompoundPathItem(obj);

break;

case "GroupItem":

//loopTextFeame(sel);

break;

}

}

}

TOPICS
Scripting

Views

585

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

recursively loop through selected groups and text and paths

Explorer ,
Dec 22, 2018

Copy link to clipboard

Copied

I have an issue with looping multi-selected items these items are texts, paths and groups I'm trying to figure it out how to loop through all of these types like over again whenever they have a child " grouped to apply an action like changing the fill

function loop(){

var sel = app.activeDocument.selection;

var calltype;

for (var i = 0; i < sel.length; i++)     {

alert(sel.typename);

switch (sel.typename) {

case "TextFrame":

//loopTextFeame(sel);

break;

case "PathItem":

//loopTextFeame(sel);

break;

case "CompoundPathItem":

loopCompoundPathItem(sel);

break;

case "GroupItem":

//loopTextFeame(sel);

break;

}

}

}

function loopCompoundPathItem(obj){

  for (var i = 0; i < obj.groupItems.length; i++)     {

alert(obj.typenames)

switch (obj.typename) {

case "TextFrame":

//loopTextFeame(sel);

break;

case "PathItem":

//loopTextFeame(sel);

break;

case "CompoundPathItem":

loopCompoundPathItem(obj);

break;

case "groupItems":

loopCompoundPathItem(obj);

break;

case "GroupItem":

//loopTextFeame(sel);

break;

}

}

}

TOPICS
Scripting

Views

586

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
Dec 22, 2018 0
Explorer ,
Dec 23, 2018

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
Reply
Loading...
Dec 23, 2018 1
Most Valuable Participant ,
Dec 23, 2018

Copy link to clipboard

Copied

another good source (for pre CS6) http://cy.cyworld.com/home/24313188/post/2801831

or with CS6+ also should help:

app.executeMenuCommand ('ungroup');

Have fun

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
Reply
Loading...
Dec 23, 2018 1
Explorer ,
Dec 23, 2018

Copy link to clipboard

Copied

I won't ungroup them. i was about to apply an action on all of the found objects text shapes groups and items under etc...

that post helps a lot

you can repeat this code for each object type you want to apply action on!

by changing textFrames to  pathItems  for example

if (groupRef.textFrames.length > 0) {

for (var i = 0 ; i < groupRef.textFrames.length; i++) {

textItemsList.push (groupRef.textFrames)

}

}

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
Reply
Loading...
Dec 23, 2018 1
New Here ,
Oct 15, 2020

Copy link to clipboard

Copied

The link in the correct answer (https://forums.adobe.com/thread/445843) doesn't link properly, it takes me to Adobe's community home page (https://community.adobe.com/). How can I find the helpful answer that used to live at the above link?

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
Reply
Loading...
Oct 15, 2020 1