Copy link to clipboard
Copied
How can I exclude TextFrame on MasterPages running the following code?
function main() {
targetFrames = [];
var doc = app.activeDocument;
var allTextFrames = doc.textFrames;
// we only want the text frames in specific LAYER
for (var i = 0; i < allTextFrames.length; i++)
if (allTextFrames[i].itemLayer.name == targetLayout)
targetFrames.push(allTextFrames[i]);
Hi @lux65, you can check if the `parentPage` is on a `MasterSpread`, like this:
var targetFrames = [];
var doc = app.activeDocument;
var allTextFrames = doc.textFrames;
// we don't want text frames on master pages
for (var i = 0; i < allTextFrames.length; i++)
if ('MasterSpread' !== allTextFrames[i].parentPage.parent.constructor.name)
targetFrames.push(allTextFrames[i]);
Copy link to clipboard
Copied
Hi @lux65, you can check if the `parentPage` is on a `MasterSpread`, like this:
var targetFrames = [];
var doc = app.activeDocument;
var allTextFrames = doc.textFrames;
// we don't want text frames on master pages
for (var i = 0; i < allTextFrames.length; i++)
if ('MasterSpread' !== allTextFrames[i].parentPage.parent.constructor.name)
targetFrames.push(allTextFrames[i]);
Copy link to clipboard
Copied
Hi @lux65 , You can also target the document pages—something like this would skip the text frames on the masters:
var tf = app.activeDocument.pages.everyItem().textFrames.everyItem().getElements();
for (var i = 0; i < tf.length; i++){
if (tf[i].itemLayer.name == "Layer 1") {
$.writeln("Do Something")
}
};