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
Copy link to clipboard
Copied
give it a loop
...
if (mytext.fillColor.name == "blue") {
var tf = mytext.parentTextFrames;
l = tf.length;
while(l--){tf
}
}
...
Copy link to clipboard
Copied
hi -hans-
now....
the error highlighted on here....
if (mytext.fillColor.name == "blue") {
"undefined is not an object"
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
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
}
}
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
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!!!!.
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
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!
Copy link to clipboard
Copied
I checked strokes too. It also get moving!. Try it and let me know Super star.
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.