Copy link to clipboard
Copied
Hi Adobe folks,
The body is pretty much the subject...
Is it possible to hide/show a layer by label using JSX scripting?
Any advice is appreciated, thanks!
var d = new ActionDescriptor();
var r = new ActionReference();
r.putName(stringIDToTypeID("layer"), "label"); // label here
d.putReference(stringIDToTypeID("null"), r);
executeAction(stringIDToTypeID("show"), d, DialogModes.NO);
// or
//executeAction(stringIDToTypeID("hide"), d, DialogModes.NO);
Copy link to clipboard
Copied
var d = new ActionDescriptor();
var r = new ActionReference();
r.putName(stringIDToTypeID("layer"), "label"); // label here
d.putReference(stringIDToTypeID("null"), r);
executeAction(stringIDToTypeID("show"), d, DialogModes.NO);
// or
//executeAction(stringIDToTypeID("hide"), d, DialogModes.NO);
Copy link to clipboard
Copied
Your request is open to interpretation. I'm assumimg that you are referring to the ability to set a layer with a highlight colour:
labelCol
Copy link to clipboard
Copied
Hi guys,
Sorry for the delayed response, I've been really busy. I love both these answers, thanks so much.
Can Photoshop JSX work with conditional logic? Like would it be possible to say...
if (layer == "RED") {
// hide all layers NOT red
}
?
I would then want to Export -- Save to web (at like 40% quality or something). Then rotate to the next color, etc. That's the agenda.
Also is there good reference I can find online to get more exposure to JSX snytax? I know what want to say but I'm not sure how to say it.
Thanks again!
Copy link to clipboard
Copied
Still you didn't say to us whether you meant name or label of layers?
Copy link to clipboard
Copied
Either I imagine would work, but I suppose the name of the layer would be a better approach for differentatation. As there are only 7 color labels, and an infinite count for names.
So for the sake of argument, name would probably best but as long as I could isolate a layer by some form of means that's what's intended.
Copy link to clipboard
Copied
Loll, forgive me, I'm not sure what you asked in your original post for. The latest answer confuses me, that it's a little like you looked for name, but on the other hand you wanted the label 😛 If that's name, then please mark as correct solution the one provided by r-bin. If label then the one by Stephen_A_Marsh.
btw you may make a loop over layers to hide all of those which name / label is not red.
Copy link to clipboard
Copied
No worries, sorry if my question was vague. I don't entirely know what's possible so knowing what to ask was a bit in the dark.
Thanks for the scripting guides too. It looks kind of like After Effects expressions or a similar way of accessing layers for command. I'll take a look at that and search for some examples to mod as well.
Thanks everybody, big help!! 🙂