Skip to content Skip to sidebar Skip to footer

Selecting Textframes Inside Of A Group In Indesign Cs6

Similar to my earlier problems with finding a textFrame on a page based on its geometricBounds or by part of its name, I now am running into the problem of finding textFrames if th

Solution 1:

Groups on a page are page.groups ... but you don't need this anyway. Fabian's answer is good, but it doesn't take groups-in-groups into account -- nor clipping masks, nor text frames inside tables and footnotes (etc.).

Here is an alternative approach: allPageItems is pretty much guaranteed to return all page items, of all kinds and persuasion, inside groups or other frames or whatnot. You can inspect, then process, each of them in turn, or build an array of text frames to work with at leisure:

allframes = app.activeDocument.allPageItems;
textframes = [];
for (i=0; i<allframes.length; i++)
{
    if (allframes[i] instanceof TextFrame)
        textframes.push(allframes[i]);
}
alert (textframes.length);

Solution 2:

Try this:

// this script needs:// - a document with one page// - some groups with textframes in it on the first pagevar pg = app.activeDocument.pages[0];
var groups = pg.groups;

var tf_ingroup_counter =0;
for(var g =0; g < groups.length;g++){
    var grp = groups[g];

        for(var t =0; t < grp.textFrames.length;t++){
            var tf = grp.textFrames[t];
                if(tf instanceof TextFrame){
                    tf_ingroup_counter++;
                    }             
        }
    }

alert("I found on page "+ pg.name +"\n"+ pg.textFrames.length 
            +" textframes\nOh and there are also "+tf_ingroup_counter+" hidden in groups");

Solution 3:

Your task to get all the text frames in the layer or the document. Whether those text frames are in a group or not. This is done through the property of allPageItems. For instance use this:-

var items=app.activeDocument.allPageItems;

this will give you all the text frames in the item and within group also. Now you can do any manupulations. You can check the items on the debug console which will give all the types of the objects.And then you can check for the textframe

items[i].constructor.name =='TextFrame'

and now you can store each object in type array.

Post a Comment for "Selecting Textframes Inside Of A Group In Indesign Cs6"