Copy link to clipboard
Copied
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
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
};
Copy link to clipboard
Copied
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
};
Copy link to clipboard
Copied
Thanks !!!
Where you can read the documentation about the DOM model of Photoshop?
Copy link to clipboard
Copied
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).
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
I do not understand indeed.
What is the problem? Did the Script work or not?
Copy link to clipboard
Copied
Do you mean something like this?

Copy link to clipboard
Copied
yes ! Thanks !
Find more inspiration, events, and resources on the new Adobe Community
Explore Now