Copy link to clipboard
Copied
I am using currently using a script to move specificly named text frames and page items to their corresponding layers (It's for making a catalog with multiple languages)
it looks like this:
---------------------------------------------------------------
app.documents[0].textFrames.item("NL").itemLayer ="NL";
app.documents[0].textFrames.item("FR").itemLayer ="FR";
app.documents[0].textFrames.item("ES").itemLayer ="ES";
app.documents[0].textFrames.item("DE").itemLayer ="DE";
app.documents[0].textFrames.item("PL").itemLayer ="PL";
app.documents[0].textFrames.item("BASE").itemLayer ="BASE";
app.documents[0].pageItems.item("BASE").itemLayer = "BASE";
---------------------------------------------------------------
So this works fine. All items have been labeled beforehand and put into a sort of template that we use over and over again (we're using EasyCatalog so if you don't know what I'm talking about, it does make a lot of sense to do it this way)
What I feel is missing is a piece of code that can detect the items without any script labels, because there's always a lot of manual work to be done too, and new items - which have no script label - can get stranded on the wrong layers if you're not paying attention.
So basicly, I would like that all frames without labels, get moved to the layer "BASE". It seems possible, but I can't find any good examples anywhere...
Hi,
Try this.
var txfms = app.activeDocument.pages.everyItem().textFrames.everyItem().getElements();
for(var i =0;i<txfms.length;i++)
{
if(txfms.label == "")
{
txfms.itemLayer = "BASE";
}
}
Regards,
Chinna
Copy link to clipboard
Copied
Hi,
Try this.
var txfms = app.activeDocument.pages.everyItem().textFrames.everyItem().getElements();
for(var i =0;i<txfms.length;i++)
{
if(txfms.label == "")
{
txfms.itemLayer = "BASE";
}
}
Regards,
Chinna
Copy link to clipboard
Copied
Okay, this was an amazingly fast, simply and correct reply! thx!
Copy link to clipboard
Copied
I was trying to use your code to move textframes with label "HideMe" onto the BC_Index layer using the code below in Indesign 2019. I don't get an error message but nothing is happening.
Copy link to clipboard
Copied
Try the following, the forum migration corrupted some codes
var txfms = app.activeDocument.pages.everyItem().textFrames.everyItem().getElements();
for(var i =0;i < txfms.length;i++)
{
if(txfms[i].label = "HideMe")
{
txfms[i].itemLayer = "BC_Index";
}
}
-Manan