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

select rgb channel check if selection is empty

Community Beginner ,
Feb 21, 2022 Feb 21, 2022

Copy link to clipboard

Copied

Hello, I have a script I made with javascript some years ago which does multiple things, among other things it runs an action for each layer following a naming pattern.

These layers are black and white images used for making masks, the action does the following things:

* hides all other layers

* selects rgb channel

* deletes the layer

* shows all other layers

* creates a solid color

* adds various options like unlinking the layer mask, linear burn mode, slot color : blue

I want to know if there is a way to know if the selection is empty (so that I can just skip creating and tweaking the solid color layer), also if there is a faster way to select the white part of a layer without doing the layer toggle thing.

I never tried if try and catch works with the command to select (ctrl+click) rgb channel because I don't know what it's named.

TOPICS
Actions and scripting , Windows

Views

244

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

LEGEND , Feb 21, 2022 Feb 21, 2022

 

sTT = stringIDToTypeID
dsc2 = new ActionDescriptor();
(dsc1 = new ActionDescriptor())
.putInteger(sTT('fuzziness'), 0);
mm = ['min', 'max']; while(mm.length)
	dsc2.putDouble(sTT('luminance'), 100),
	dsc2.putDouble(sTT('a'), 0), dsc2.putDouble(sTT('b'), 0),
	dsc1.putObject(sTT(mm.shift() + 'imum'), sTT('labColor'), dsc2)
executeAction(sTT('colorRange'), dsc1);

((ref = new ActionReference()).putProperty(sTT('property'), sTT('selection')),
ref.putEnumerated(sTT('document'), sTT('ordinal'), sTT('
...

Votes

Translate

Translate
Adobe
LEGEND ,
Feb 21, 2022 Feb 21, 2022

Copy link to clipboard

Copied

 

sTT = stringIDToTypeID
dsc2 = new ActionDescriptor();
(dsc1 = new ActionDescriptor())
.putInteger(sTT('fuzziness'), 0);
mm = ['min', 'max']; while(mm.length)
	dsc2.putDouble(sTT('luminance'), 100),
	dsc2.putDouble(sTT('a'), 0), dsc2.putDouble(sTT('b'), 0),
	dsc1.putObject(sTT(mm.shift() + 'imum'), sTT('labColor'), dsc2)
executeAction(sTT('colorRange'), dsc1);

((ref = new ActionReference()).putProperty(sTT('property'), sTT('selection')),
ref.putEnumerated(sTT('document'), sTT('ordinal'), sTT('targetEnum')),
executeActionGet(ref).hasKey(sTT('selection'))) && 'rest of script'

 

Votes

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
Community Beginner ,
Feb 22, 2022 Feb 22, 2022

Copy link to clipboard

Copied

Oh, that's perfect, I've a question though. how do I save the boolean into a variable or something so that I can use it on an if then else format, something like this.

selbool = 
if (selbool == true)
{

}
else
{

}

 

Votes

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
Community Beginner ,
Feb 22, 2022 Feb 22, 2022

Copy link to clipboard

Copied

nevermind, I got it. I added some extra parenthesis before so I couldn't get it to work.

sTT = stringIDToTypeID
dsc2 = new ActionDescriptor();
(dsc1 = new ActionDescriptor())
.putInteger(sTT('fuzziness'), 0);
mm = ['min', 'max']; while(mm.length)
	dsc2.putDouble(sTT('luminance'), 100),
	dsc2.putDouble(sTT('a'), 0), dsc2.putDouble(sTT('b'), 0),
	dsc1.putObject(sTT(mm.shift() + 'imum'), sTT('labColor'), dsc2)
executeAction(sTT('colorRange'), dsc1);

if (((ref = new ActionReference()).putProperty(sTT('property'), sTT('selection')),
ref.putEnumerated(sTT('document'), sTT('ordinal'), sTT('targetEnum')),
executeActionGet(ref).hasKey(sTT('selection'))) == true)
{
	alert("True")
}
else
{
	alert("False")
}

 

Votes

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
LEGEND ,
Feb 22, 2022 Feb 22, 2022

Copy link to clipboard

Copied

LATEST

The last part start from if statement, while "&& 'rest of script'" part change to {/*your code*/}.

Votes

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