• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

How to select only ungrouped texts.

Explorer ,
Feb 14, 2021 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

384

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

correct answers 1 Correct answer

Community Expert , Feb 14, 2021 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

Votes

Translate

Translate
Adobe
Community Expert ,
Feb 14, 2021 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

Votes

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 ,
Feb 14, 2021 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.

Votes

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
Community Expert ,
Feb 14, 2021 Feb 14, 2021

Copy link to clipboard

Copied

LATEST

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 ==)

Votes

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