• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to add layer mask?

Guest
Jul 21, 2014 Jul 21, 2014

Copy link to clipboard

Copied

Must add each layer of the document (except the background) mask blank:

3f0b3bca0b2749368d2d6ed8d23f4e3f.png

There is such a script:

if(app.documents.length>0){

    var docRef = activeDocument;

    var layerNum = docRef.layers.length;

    for(var i=0;i<layerNum;i++){

        docRef.activeLayer = docRef.layers;

        if(!docRef.activeLayer.isBackgroundLayer){

            try{addMask ()}

            catch(e){}

            }

        }

    }

else{alert('There are no open files')};

function addMask(){

    var idMk = charIDToTypeID( "Mk  " );

        var desc2 = new ActionDescriptor();

        var idNw = charIDToTypeID( "Nw  " );

        var idChnl = charIDToTypeID( "Chnl" );

        desc2.putClass( idNw, idChnl );

        var idAt = charIDToTypeID( "At  " );

            var ref1 = new ActionReference();

            var idChnl = charIDToTypeID( "Chnl" );

            var idChnl = charIDToTypeID( "Chnl" );

            var idMsk = charIDToTypeID( "Msk " );

            ref1.putEnumerated( idChnl, idChnl, idMsk );

        desc2.putReference( idAt, ref1 );

        var idUsng = charIDToTypeID( "Usng" );

        var idUsrM = charIDToTypeID( "UsrM" );

        var idHdAl = charIDToTypeID( "HdAl" );

        desc2.putEnumerated( idUsng, idUsrM, idHdAl );

    executeAction( idMk, desc2, DialogModes.NO );

}

It runs and adds a mask, but it is filled with black:

7dcfa4d0ed8f47a39c9cc0f7056514d2.png

How to change the code to create an empty mask (like in the first picture)?

Sorry for my english...

TOPICS
Actions and scripting

Views

638

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guru , Jul 21, 2014 Jul 21, 2014

Line 30 you have the actionmanager "HdAl" hide all… Record again using show all…?

Votes

Translate

Translate
Adobe
Guru ,
Jul 21, 2014 Jul 21, 2014

Copy link to clipboard

Copied

Line 30 you have the actionmanager "HdAl" hide all… Record again using show all…?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 21, 2014 Jul 21, 2014

Copy link to clipboard

Copied

Thank you very much

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jul 21, 2014 Jul 21, 2014

Copy link to clipboard

Copied

LATEST

Personly I would add argument to the function so I could pass the 4 options...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines