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

Moving text frame to separate layer

Contributor ,
Nov 07, 2012 Nov 07, 2012

Copy link to clipboard

Copied

Hi,

Can anyone help on this. While running script for moving text frame with blue fill color to blue layer,, the error is;

mytext.parentTextFrames.everyItem is not a function.   please solve.

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");

    }

}

thanks

rajnikanth

TOPICS
Scripting

Views

1.7K

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

Copy link to clipboard

Copied

give it a loop

...

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

var tf =    mytext.parentTextFrames;

l = tf.length;

while(l--){tf.itemLayer = mydoc.layers.item("blue layer");}

    }

}

...

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

now....

the error highlighted on here....

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

"undefined is not an object"

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

Copy link to clipboard

Copied

whole script¿

Guess it's a last empty paragraph. Any errorhandling in your script?

please post the whole script your using

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

Copy link to clipboard

Copied

Hi -hans-

Please check this out! the whole script////

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") {

var tf = mytext.parentTextFrames;

l = tf.length;

while(l--){tf.itemLayer = mydoc.layers.item("blue layer");}

    }

}

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

Copy link to clipboard

Copied

Hi,

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

for i = myTexts.length the script must error, cause javascript starts counting 0. Has to be 'i<mytexts.length'

wrap your mainscript in a simple 'try{ mainscript}catch (e){optionally errorhandling here}' to avoid the script aborting.

As remembered in the other but equal post: You'll only get the first used color of the paragraph, there may be more ... so it might not be the rigth approach to ask for 'paragraph.fillColor.name'

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

Copy link to clipboard

Copied

thanks you so much Hans-Gerd Claßen,

i m happy now.!

can i get help for moving object for the same fill colour "blue" to moved to same layer  "blue layer".

thanks for your help!!!!.

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

Hi rajinikanth,

I found how to move the objects. It'll move all the shaped and unshaped objects excludes graphic frames.

Here it is,

var mydoc=app.documents.item(0)

var myobjects=mydoc.splineItems.everyItem().getElements();

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

    var myobject=myobjects;

if (myobject.fillColor.name=="swatch") {

   

    myobject.itemLayer=mydoc.layers.item("test")

    }

}

Feedback expected!

Sundar

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 09, 2012 Nov 09, 2012

Copy link to clipboard

Copied

sundhar jee!

really thanks, also i need to move the strokes to be moved to same layers, as that of you did for object.

thanks really, i help well!

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 09, 2012 Nov 09, 2012

Copy link to clipboard

Copied

LATEST

I checked strokes too. It also get moving!. Try it and let me know Super star.

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

Good one. But it's working if remove the "=" symbol in the "for loop".

I edited like this ...."for (i=0; i<mytexts.length; i++) {" ......

Thanks for your help.

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