how to move frame with undefined script label to specific layer?

New Here ,
May 20, 2014 May 20, 2014

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...

TOPICS
Scripting

Views

354

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , May 20, 2014 May 20, 2014
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

Likes

Translate

Translate
Enthusiast ,
May 20, 2014 May 20, 2014

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 20, 2014 May 20, 2014

Copy link to clipboard

Copied

Okay, this was an amazingly fast, simply and correct reply! thx!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 05, 2021 Nov 05, 2021

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.

 

var txfms = app.activeDocument.pages.everyItem().textFrames.everyItem().getElements();

for(var i =0;i<txfms.length;i++)
{
if(txfms.label = "HideMe")
{
txfms.itemLayer = "BC_Index";
}
}

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Nov 05, 2021 Nov 05, 2021

Copy link to clipboard

Copied

LATEST

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines