9
Explorer
,
/t5/indesign-discussions/exclude-master-objects-in-a-script/td-p/14493294
Mar 16, 2024
Mar 16, 2024
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]);
TOPICS
How to
,
Scripting
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
Community Expert
,
Mar 16, 2024
Mar 16, 2024
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]);
2
Replies
2
Community Expert
,
/t5/indesign-discussions/exclude-master-objects-in-a-script/m-p/14493322#M566284
Mar 16, 2024
Mar 16, 2024
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]);
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Community Expert
,
LATEST
/t5/indesign-discussions/exclude-master-objects-in-a-script/m-p/14493415#M566290
Mar 16, 2024
Mar 16, 2024
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")
}
};
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more