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

Duplicate Layer

New Here ,
Sep 14, 2010 Sep 14, 2010

I have been scripting in Photoshop and need to convert my script to Illustrator.

I use VBScript/Javascript and also program in .Net with VB and C# to create programs for Photoshop / Illustrator

In Photoshop you have layer.duplicate to duplicate a layer with all its contents, but I cant seem to find the corresponding one for Illustrator.

In the layers window in Illustrator you can select a layer and then from the drop down in the layer window select Dupliate "layername" I have looked at the scripting reference and cant seem to find a solution.

Thanks in advance.

TOPICS
Scripting
3.3K
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

Guide , Sep 14, 2010 Sep 14, 2010

Sorry the example is expecting you to have a top level layer called 'Layer 1' present in you document it should duplicate all the pageItems from that. As is, it does NOT deal with nested sub layers you would need to recurse through those if needed.

Translate
Adobe
Guide ,
Sep 14, 2010 Sep 14, 2010

I think you will find that 'layers' do NOT have a duplicate method. You can however create your own layer then duplicate all the relative 'pageItems' over to the new layer. pageItems does NOT have a duplicate method but it is a more general collection of elements but if you reference each pageItem in turn then you can duplicate to given location. So you could do like so…

#target illustrator var docRef = app.activeDocument; with(docRef) {      var ln = 'Layer 1'      var ol = layers.getByName(ln);      var nl = layers.add();      nl.name = ln+' Copy';      for (var a = ol.pageItems.length-1; a >= 0; a--) {           ol.pageItems.duplicate(nl, ElementPlacement.PLACEATBEGINNING);      } }

Its a little more work than in PS but thats Illustrator for you…

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
New Here ,
Sep 14, 2010 Sep 14, 2010

I ran it and all it did was create a new Layer and name it.

It does not create any layers inside that layer or the groupitems and textFrames.

I idea is that is should duplicate the selected layer regardless of what is in it.

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
Guide ,
Sep 14, 2010 Sep 14, 2010

Sorry the example is expecting you to have a top level layer called 'Layer 1' present in you document it should duplicate all the pageItems from that. As is, it does NOT deal with nested sub layers you would need to recurse through those if needed.

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
New Here ,
Sep 14, 2010 Sep 14, 2010
LATEST

So just to clarify all i need to do is take care of the Layers that could appear below the first layer and it should "duplicate" anything else that is possible below it (eg TextFrames, PathItems, GroupItems etc) ?

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