Skip to main content
Participating Frequently
August 21, 2013
Question

Enable disable layermask of current layer

  • August 21, 2013
  • 2 replies
  • 1099 views

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

Or is it possible with javascript?

This topic has been closed for replies.

2 replies

Inspiring
August 21, 2013

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

};

Participating Frequently
August 23, 2013

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.

timuric
Participating Frequently
August 21, 2013

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