• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Move text frames to a separate layer

Explorer ,
Nov 06, 2012 Nov 06, 2012

Copy link to clipboard

Copied

I am new to Indesign scripting. I have an simple task, which needs your help.

Task: I want to move all the text frames which contains a particular swatches applied to the content. I had wirtten the below script, but it's not working. The execution get finished without errors, but the result in nothing happened.

var mydoc=app.documents.item(0);

var mytexts=mydoc.stories.everyItem().paragraphs.everyItem().getElements();

 

for (i=0;i<mytexts.length;i++) {

    var mytext=mytexts;

   

    if (mytext.contents.fillColor=="swatches"){

    mytext.parentTextFrames.everyItem().itemLayer=mydoc.layers.item("test");

    }

}

Hope you experts will rectify this.

Thanks much in advance

TOPICS
Scripting

Views

985

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
Enthusiast ,
Nov 06, 2012 Nov 06, 2012

Copy link to clipboard

Copied

Hi,

you've gone to far 😉 'content' is always the end of the road ... the pargraph itsself has got the property fillColor

... 

  if (mytext.fillColor.name  == "mySwatchName"){...

But, what if the paragraph has  more then one fillColor¿ You'll only get the first in use.

If important for your work -> think about doing a search.

Hans-Gerd Claßen

Votes

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
Contributor ,
Nov 07, 2012 Nov 07, 2012

Copy link to clipboard

Copied

hi sundar,

i tried,,

var mydoc=app.documents.item(0);

var mytexts=mydoc.stories.everyItem().paragraphs.everyItem().getElements( );

for (i=0;i<mytexts.length;i++) {

    var mytext=mytexts;

  

    if (mytext.fillColor.name  == "blue") {

   mytext.parentTextFrames.everyItem().itemLayer=mydoc.layers.item("blue layer");

    }

}

but the error message is.  mytext.parentTextFrames.everyItem is not a function. highlighting the above boldened text. can you help on this

Votes

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
Explorer ,
Nov 08, 2012 Nov 08, 2012

Copy link to clipboard

Copied

LATEST

Yes you're right!.

Votes

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