Skip to main content
jdegheest
Participant
May 20, 2014
Answered

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

  • May 20, 2014
  • 1 reply
  • 660 views

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

This topic has been closed for replies.
Correct answer Chinnadk

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

1 reply

Chinnadk
ChinnadkCorrect answer
Legend
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

jdegheest
jdegheestAuthor
Participant
May 20, 2014

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