Copy link to clipboard
Copied
Happy Friday everyone.
I've been trying to figure out this JS where the script will create a layer set if there already isn't one of that name.
I've founds lots on how to create a layer set, but not how to do a conditional around it.
Any help would be appreciated.
Thank you.
This will work for a top level layer set:
#target photoshop
var doc=activeDocument;
var setName = 'My Set';
try{doc.activeDocument = doc.layerSets.getByName (setName)}
catch(e){
doc.layerSets.add();
doc.activeLayer.name = setName
}
Copy link to clipboard
Copied
My question is where would you want the layerset created if it doesn't exist? Does your file have nested layersets? Would you need to check the nested layersets if it does have them?
Copy link to clipboard
Copied
It would be a top level layer set if it exists. Will be created there as well. The file may have nested layer sets but what I want to test for would not be nested.
-Tim
Copy link to clipboard
Copied
This will work for a top level layer set:
#target photoshop
var doc=activeDocument;
var setName = 'My Set';
try{doc.activeDocument = doc.layerSets.getByName (setName)}
catch(e){
doc.layerSets.add();
doc.activeLayer.name = setName
}
Copy link to clipboard
Copied
Thank you, Chuck Uebele‌.
As always, a huge help.
Copy link to clipboard
Copied
Glad I could help.
Copy link to clipboard
Copied
I'd buy you a beer if you were local.
Or three...
Copy link to clipboard
Copied
Well, if you're in the Los Angeles area...
Find more inspiration, events, and resources on the new Adobe Community
Explore Now