Quantcast
Channel: Adobe Community: Message List
Viewing all articles
Browse latest Browse all 152999

Re: show mask action/script

$
0
0

Trying to take the code one step further by creating a script to toggle the layer mask visibility.

I am able to call the showMask hideMask functions individually but not toggle the mask visibility yet.

 

Is the if statement the right way to proceed to create the toggle effect?

I am unclear how to target the mask element in a layer with javascript.

 

if the mask is not visible

showMask();

 

else if the mask is visible

maskHide();

 

 

 

////////////////////////////////////////////////////////////////////

 

#target photoshop

 

//Make Photoshop the formost Appplication

app.bringToFront();

 

//Test for open document

if(app.documents.length > 0){

       

        //Select mask layer

        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 visbility            

    }

 

else {

    alert("No documents are open");

    }

 

 

// FUNCTIONS

       

function showMask () {

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

    }


Viewing all articles
Browse latest Browse all 152999

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>