Skip to main content
Inspiring
August 12, 2017
Answered

Make/Release Clipping Mask via Script

  • August 12, 2017
  • 1 reply
  • 5090 views

Hi, y'all

There is a way to reach the command "Make/Release Clipping Mask" in the Layer window via script?

What I'm trying to achieve is to create a rectangle using the size of my artboard, name it "CLIP", put it on the top of my active Layer and set it as my mask.

Example bellow:

Any help will be appreciated.

This topic has been closed for replies.
Correct answer moluapple

Hi, check this:

/* to make sure the desired layer(let's say layers[0]) been selected in the layers panel:

app.selection = null;

activeDocument.layers[0].hasSelectedArtwork = true;

*/

var actionStr =

    '''

    /name [ 1    73]

    /actionCount 1

    /action-1 {

        /name [ 1    61]

        /eventCount 1

        /event-1 {

            /internalName (ai_plugin_Layer)

            /parameterCount 1

            /parameter-1 {

                /key 1836411236

                /type (integer)

                /value 18

            }

        }

    }

    ''';

createAction(actionStr, 's');

app.doScript('a', 's');

app.unloadAction('s', '');

function createAction(str, set) {

    var f = File(set + '.aia');

    f.open('w');

    f.write(str);

    f.close();

    app.loadAction(f);

    f.remove();

}

1 reply

moluappleCorrect answer
Inspiring
August 13, 2017

Hi, check this:

/* to make sure the desired layer(let's say layers[0]) been selected in the layers panel:

app.selection = null;

activeDocument.layers[0].hasSelectedArtwork = true;

*/

var actionStr =

    '''

    /name [ 1    73]

    /actionCount 1

    /action-1 {

        /name [ 1    61]

        /eventCount 1

        /event-1 {

            /internalName (ai_plugin_Layer)

            /parameterCount 1

            /parameter-1 {

                /key 1836411236

                /type (integer)

                /value 18

            }

        }

    }

    ''';

createAction(actionStr, 's');

app.doScript('a', 's');

app.unloadAction('s', '');

function createAction(str, set) {

    var f = File(set + '.aia');

    f.open('w');

    f.write(str);

    f.close();

    app.loadAction(f);

    f.remove();

}

Inspiring
August 13, 2017

thank you very much. that totally solves my problem. <3