Is it possible to hide/show a layer by label using JSX scripting?

Explorer ,
Nov 12, 2021 Nov 12, 2021

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!

TOPICS
Actions and scripting

Views

73

Likes

Translate

Translate

Report

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

Adobe Community Professional , Nov 12, 2021 Nov 12, 2021
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);

Likes

Translate

Translate
Adobe Community Professional ,
Nov 12, 2021 Nov 12, 2021

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); 

 

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Nov 12, 2021 Nov 12, 2021

Copy link to clipboard

Copied

@Gotta Dance 

 

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

 

No Color = "none"
Red = "red"
Orange = "orange"
Yellow = "yellowColor"
Green = "green"
Blue = "blue"
Violet = "violet"
Gray = "gray"
 
I'm also guessing globally on all layers and or layer sets that share the label colour.

Likes

Translate

Translate

Report

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
Explorer ,
Nov 14, 2021 Nov 14, 2021

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!

 

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Nov 14, 2021 Nov 14, 2021

Copy link to clipboard

Copied

Still you didn't say to us whether you meant name or label of layers?

Likes

Translate

Translate

Report

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
Explorer ,
Nov 14, 2021 Nov 14, 2021

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.

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Nov 14, 2021 Nov 14, 2021

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.

 

Photoshop Scripting

Likes

Translate

Translate

Report

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
Explorer ,
Nov 14, 2021 Nov 14, 2021

Copy link to clipboard

Copied

LATEST

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!! 🙂

Likes

Translate

Translate

Report

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