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

Select and move to new layer

Explorer ,
Mar 08, 2019 Mar 08, 2019

Hi - i was wondering if anyone can help? A while back someone kindly supplied me this script which will move all my text which has been coloured up in a specific colour to a new layer. Along with the text we also use leader lines for diagrams which are also coloured up in the same colour. Is there a way of also selecting lines that have been produced either with the pen tool or the line tool and move those to the same layer. The only thing they have in common is they are coloured up in the same colour.

Many thanks

var myDoc = app.activeDocument;

try{

    var myLayer = myDoc.layers.add({name:"Text Black"}); 

}catch(e){myLayer = myDoc.layers.item('Text Black')};

myDoc.textFrames.everyItem().itemLayer = myLayer;

TOPICS
Scripting
774
Translate
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

Advocate , Mar 11, 2019 Mar 11, 2019

Hi There,

Try This code...

var myDoc = app.activeDocument;

try{

    var myLayer = myDoc.layers.add({name:"Text Black"});

    }

catch(e){

    myLayer = myDoc.layers.item('Text Black');

    }

myDoc.textFrames.everyItem().itemLayer = myLayer;

myDoc.graphicLines.everyItem().itemLayer = myLayer;

myDoc.polygons.everyItem().itemLayer = myLayer;

Best

Sunil

Translate
Contributor ,
Mar 08, 2019 Mar 08, 2019

Hi,

    

    Try using pageItem's constructor name to identify the items with color and then move into layer.

     line drawn by line line tool - Constructor name return as GraphicLine

     line drawn by pen tool - Constructor name return as Polygon

     var pgItm = app.selection[0]

     if(pgItm.constructor.name == "GraphicLine" || pgItm.constructor.name == "Polygon")

     {

          // code here

     }

Translate
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 ,
Mar 11, 2019 Mar 11, 2019

Hi - thank you for your reply but unfortunately it's not working. Pretty sure it's going to be something i'm doing wrong as I'm new to scripting.

Screenshot 2019-03-11 at 11.48.14.png

Translate
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
Advocate ,
Mar 11, 2019 Mar 11, 2019

Hi There,

Try This code...

var myDoc = app.activeDocument;

try{

    var myLayer = myDoc.layers.add({name:"Text Black"});

    }

catch(e){

    myLayer = myDoc.layers.item('Text Black');

    }

myDoc.textFrames.everyItem().itemLayer = myLayer;

myDoc.graphicLines.everyItem().itemLayer = myLayer;

myDoc.polygons.everyItem().itemLayer = myLayer;

Best

Sunil

Translate
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 ,
Mar 11, 2019 Mar 11, 2019
LATEST

Great - worked a treat once I'd ungrouped the elements. Out of interest would there be a way of setting the text black stroke to overprint?

Thanks again!!!!

Translate
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