How to select only ungrouped texts.

Community Beginner ,
Feb 14, 2021

Copy link to clipboard

Copied

I am trying to select only non-grouped texts, some of the text of grouped with a text, and some text grouped with a shape I want to select just an ungrouped text.

 

Screenshot_021421_012651_PM.jpg

 

Currently, I using this code but it is too slow when the project is full of elements.

 

// app.executeMenuCommand ('Text Objects menu item'); //Select all texts
app.executeMenuCommand ('selectall'); //Select All


// !Deselect All Text inside Groups
var myDoc = app.activeDocument;
var objects =  myDoc.selection;
for (var i=0; i<objects.length; i++) {
	if (objects[i].typename != "TextFrame"){
			objects[i].selected = false;
	}
}

 

 
TOPICS
Scripting

Views

102

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

1 Correct Answer

Engaged , Feb 14, 2021
m1b Engaged , Feb 14, 2021
Hi BRODZELi, Try this:  // clear selection selection = []; // get all text frames var textFrames = app.activeDocument.textFrames; // grouped text frames will have a 'GroupItem' as parent for (var i = 0; i < textFrames.length; i++) { if (textFrames[i].parent.typename == "Layer") { textFrames[i].selected = true; } }  It should only select text frames that aren't grouped. - Mark

Likes

Translate

Translate
Jump to answer Jump to answer
Engaged ,
Feb 14, 2021

Copy link to clipboard

Copied

Hi BRODZELi,

 

Try this:

 

 

// clear selection
selection = [];

// get all text frames
var textFrames = app.activeDocument.textFrames;

// grouped text frames will have a 'GroupItem' as parent
for (var i = 0; i < textFrames.length; i++) {
    if (textFrames[i].parent.typename == "Layer") {
        textFrames[i].selected = true;
    }
}

 

 

It should only select text frames that aren't grouped. - Mark

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
Feb 14, 2021

Copy link to clipboard

Copied

I had to change this line:

if (textFrames[i].parent.typename != "Layer") {
to:
if (textFrames[i].parent.typename == "Layer") {
 
to get the "ungrouped" text to be selected.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
m1b LATEST
Engaged ,
Feb 14, 2021

Copy link to clipboard

Copied

Oops, thanks for the pick-up! Fixed.

 

(At the last minute I tried another way, using parent != 'GroupItem' and forgot to change the operator back to ==)

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more