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.
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;
}
}
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
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
Copy link to clipboard
Copied
I had to change this line:
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 ==)