3 Replies Latest reply on Aug 23, 2013 4:33 PM by mauritsbrock

    Enable disable layermask of current layer

    mauritsbrock Level 1

      Is it possible to enable or disable a layer mask with Applescript?

      Or is it possible with javascript?

        • 1. Re: Enable disable layermask of current layer
          timuric Level 1

          It should be possible using ActionReference(). You will need to install event listener plugin to track the ID of this action

          • 2. Re: Enable disable layermask of current layer
            Michael L Hale Level 5

            You can use the Applescript do javascript command to run the functions below.

             

            function isChannelMaskEnabled(){
                var ref = new ActionReference(); 
                ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID("UsrM") );
                ref.putEnumerated( charIDToTypeID("Lyr ") , charIDToTypeID("Ordn") , charIDToTypeID("Trgt") );
                return executeActionGet(ref).getBoolean( charIDToTypeID("UsrM") );
            };
            function channelMaskEnabled( enabled ){ // Boolean
                var desc = new ActionDescriptor();
                    var ref = new ActionReference();
                    ref.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
                desc.putReference( charIDToTypeID( "null" ), ref );
                var desc1 = new ActionDescriptor();
                 desc1.putBoolean( charIDToTypeID( "UsrM" ), enabled );
                desc.putObject( charIDToTypeID( "T   " ), charIDToTypeID( "Lyr " ), desc1 );
                executeAction( charIDToTypeID( "setd" ), desc, DialogModes.NO );
            };
            function vectorMaskEnabled( enabled ){ // Boolean
                var desc = new ActionDescriptor();
                    var ref = new ActionReference();
                    ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
                desc.putReference( charIDToTypeID('null'), ref );
                    var desc1 = new ActionDescriptor();
                    desc1.putBoolean( stringIDToTypeID('vectorMaskEnabled'), enabled );
                desc.putObject( charIDToTypeID('T   '), charIDToTypeID('Lyr '), desc1 );
                executeAction( charIDToTypeID('setd'), desc, DialogModes.NO );
            };
            
            1 person found this helpful
            • 3. Re: Enable disable layermask of current layer
              mauritsbrock Level 1

              Michael,

              thanks for your answer, I wil have to search for an example how to use this functions in an Applescript. I let you know if i succeed.