I have heard good comments about indesign scripting community.
It occurred to ask a Photoshop scripting question here given the good reputation of this community.
The photoshop document has a layer with a layer mask.
Using the extended script or javascript,
How would I test if the layer mask is visible or hidden?
Trying to create a script that toggles the visibility of a layer mask.
So far the script can call the showMask or hideMask functions independently.
The next step is to test for the mask visibility and call the corresponding function.
I believe this can be achieved with an if statement.
// if mask visible
call hideMask()
// if mask not visible
call showMask()
////////////////////////////////////////////////////////////////////
#target photoshop
//Make Photoshop the formost Application
app.bringToFront();
//Test for open document
if(app.documents.length > 0){
//Select mask layer 255 fill
var docRef = app.activeDocument;
var layerRef=docRef.layers.getByName("255 fill"); //"Layer Name"
docRef.activeLayer=layerRef;
// call showMask function
//showMask ();
// call hideMask function
//hideMask ();
//toggle mask visibility
}
else {
alert("No documents are open");
}
// FUNCTIONS
function showHideMask () {
// showMask
// =======================================================
var idslct = charIDToTypeID( "slct" );
var desc21 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref21 = new ActionReference();
var idChnl = charIDToTypeID( "Chnl" );
var idChnl = charIDToTypeID( "Chnl" );
var idMsk = charIDToTypeID( "Msk " );
ref21.putEnumerated( idChnl, idChnl, idMsk );
desc21.putReference( idnull, ref21 );
var idMkVs = charIDToTypeID( "MkVs" );
desc21.putBoolean( idMkVs, true );
executeAction( idslct, desc21, DialogModes.NO );
}
function hideMask () {
// hideMask
// =======================================================
var idslct = charIDToTypeID( "slct" );
var desc22 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref22 = new ActionReference();
var idChnl = charIDToTypeID( "Chnl" );
var idChnl = charIDToTypeID( "Chnl" );
var idRGB = charIDToTypeID( "RGB " );
ref22.putEnumerated( idChnl, idChnl, idRGB );
desc22.putReference( idnull, ref22 );
var idMkVs = charIDToTypeID( "MkVs" );
desc22.putBoolean( idMkVs, false );
executeAction( idslct, desc22, DialogModes.NO );
}