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.
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('
...
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'
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
{
}
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")
}
Copy link to clipboard
Copied
The last part start from if statement, while "&& 'rest of script'" part change to {/*your code*/}.