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

How to duplicate the layer and than rename it ?

Participant ,
Mar 20, 2014 Mar 20, 2014

Greetings to all.

I'm doing a little tool and I need to duplicate the layer, change name and so...

Tell me how to change the layer name ? After all, when duplicating app.activeDocument() layer in the Layers palette cursor remains on the same layer. Can be done through cross-array difficult, but I think that there is a simpler solution.

Thanks

TOPICS
Actions and scripting
2.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

Community Expert , Mar 20, 2014 Mar 20, 2014

Layers have a name-property that can be changed via Script.

// 2014, use it at your own risk;

#target photoshop

if (app.documents.length > 0) {

var theDoc = app.activeDocument;

var theLayer = theDoc.activeLayer.duplicate(theDoc.activeLayer, ElementPlacement.PLACEBEFORE);

theLayer.name = "test";

theDoc.activeLayer = theLayer

};

Translate
Adobe
Community Expert ,
Mar 20, 2014 Mar 20, 2014

Layers have a name-property that can be changed via Script.

// 2014, use it at your own risk;

#target photoshop

if (app.documents.length > 0) {

var theDoc = app.activeDocument;

var theLayer = theDoc.activeLayer.duplicate(theDoc.activeLayer, ElementPlacement.PLACEBEFORE);

theLayer.name = "test";

theDoc.activeLayer = theLayer

};

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
Participant ,
Mar 20, 2014 Mar 20, 2014

Thanks !!!

Where you can read the documentation about the DOM model of Photoshop?

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
Community Expert ,
Mar 20, 2014 Mar 20, 2014

photoshop-cc-scripting-guide.pdf and photoshop-cc-javascript-ref.pdf are available online and ExtendScript Toolkit has an Object Model Viewer (check the Help-menu item).

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
Participant ,
Mar 20, 2014 Mar 20, 2014

Sorry, but I could not find an example for this function "theDoc.activeLayer.duplicate(theDoc.activeLayer, ElementPlacement.PLACEBEFORE);" .Could you give a screenshot for me to understand where to look?

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
Community Expert ,
Mar 20, 2014 Mar 20, 2014

In JavaScripts »function« has a special meaning and this line is not defined as a function.

The line is made up of several parts.

• the variable theDoc has already been set up before

• activeLayer is a property of Document

• duplicate is a method of Layer (though also of Channel, Document, PathItem)

• the stuff in the brackets are the optional arguments the method takes

You can look up the parts individually (except theDoc naturally) in the OMV.

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
Participant ,
Mar 24, 2014 Mar 24, 2014

no No, you do not understand. Principles I know, but could not find how to use this function. To continue to ask stupid questions, show me the screenshot taken from the correct parameters?

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
Community Expert ,
Mar 25, 2014 Mar 25, 2014

I do not understand indeed.

What is the problem? Did the Script work or not?

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
Community Expert ,
Mar 25, 2014 Mar 25, 2014

Do you mean something like this?

OMVLayerDuplicate.jpg

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
Participant ,
Mar 25, 2014 Mar 25, 2014
LATEST

yes ! Thanks !

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