Skip to main content
Known Participant
December 8, 2012
Answered

Is it possible to copy and duplicate (only) text to multiple layers?

  • December 8, 2012
  • 1 reply
  • 1270 views

Hallo.

Explanation of my question:

I have an Illustrator document with one layer (named Layer 1).

In that layer are lines, rectangles and text.

Is it possible (in script) to:

  1. make 3 additional layers named NL, EN and GE
  2. select and cut all the text in Layer 1
  3. paste that text in the same place in the layers NL, EN and GE

(Step 2: select all text items and Ctrl-X)

(Step 3: select proper layer and Paste in Place in that layer)

I know this can be done with an action (I did that allready) but the reason I want to script this is because I have to combine this with another script which takes care of colorizing stuff.

Hope someone can help me with this...

Wim

This topic has been closed for replies.
Correct answer Muppet Mark

Well I made a simple-ish test file and this appears to work here…

#target illustrator

languageLayers();

function languageLayers() {

 

          var i, doc, txt, count, nl, en, ge;

 

          doc = app.activeDocument;

 

          txt = doc.textFrames;

 

          count = txt.length;

 

          nl = doc.layers.add(); nl.name = 'NL';

 

          nl.move( doc, ElementPlacement.PLACEATEND );

 

          en = doc.layers.add(); en.name = 'EN';

 

          en.move( doc, ElementPlacement.PLACEATEND );

 

          ge = doc.layers.add(); ge.name = 'GE';

 

          ge.move( doc, ElementPlacement.PLACEATEND );

          for ( i = count-1; i >= 0; i-- ) {

 

                    txt.duplicate( nl, ElementPlacement.PLACEATBEGINNING );

 

                    txt.duplicate( en, ElementPlacement.PLACEATBEGINNING );

 

                    txt.duplicate( ge, ElementPlacement.PLACEATBEGINNING );

          };

 

};

1 reply

Inspiring
December 8, 2012

Yes script can easily do this for you… You have no need for selection in this process… Script would loop all your layer text frames dupicating them and moving dupe to new layer… In script you would not use copy and paste methods for this… You say you have one layer but are all the text frames in this or are there sub-layers and groups to deal with…?

Known Participant
December 8, 2012

Since the original placed file in Layer 1 is a SVG file: yes the text is in groups / in groups / in groups (can be deeply nested). There are no sublayers.

After pasting in the new layers this structure is not important to keep intact...

Did manage to script the layers: for (var i = 0; i<3;i++) { app.activeDocument.layers.add(); } activeDocument.layers[0].name = "GE"; activeDocument.layers[1].name = "EN"; activeDocument.layers[2].name = "NL"; Message was edited by: wimkees

Muppet MarkCorrect answer
Inspiring
December 8, 2012

Well I made a simple-ish test file and this appears to work here…

#target illustrator

languageLayers();

function languageLayers() {

 

          var i, doc, txt, count, nl, en, ge;

 

          doc = app.activeDocument;

 

          txt = doc.textFrames;

 

          count = txt.length;

 

          nl = doc.layers.add(); nl.name = 'NL';

 

          nl.move( doc, ElementPlacement.PLACEATEND );

 

          en = doc.layers.add(); en.name = 'EN';

 

          en.move( doc, ElementPlacement.PLACEATEND );

 

          ge = doc.layers.add(); ge.name = 'GE';

 

          ge.move( doc, ElementPlacement.PLACEATEND );

          for ( i = count-1; i >= 0; i-- ) {

 

                    txt.duplicate( nl, ElementPlacement.PLACEATBEGINNING );

 

                    txt.duplicate( en, ElementPlacement.PLACEATBEGINNING );

 

                    txt.duplicate( ge, ElementPlacement.PLACEATBEGINNING );

          };

 

};