Skip to main content
Alphavader
Participating Frequently
February 17, 2015
Answered

apply selection to layer mask

  • February 17, 2015
  • 1 reply
  • 641 views

Hello,

iam looking for a solution to apply a previeuws

selction to a layer mask of a adjustment layer.

My code mange to select the mask - but when i apply the

selection it creates layer above.

I need to go into the layer mask (alt and click) and then paste.

Then go out.

Scriptlistender isnt helping so much.

app.activeDocument.selection.selectAll(); //selects stuff on the preview layer

app.activeDocument.selection.copy();  //copy that stuff - to paste it into the mask later

var adjLayer = doc.layerSets.getByName("ao").artLayers.getByName("ao");  //searching for a group and specific layer

var mask = ExtendedLayer.selectLayerMask(adjLayer); // extern function wich selects the mask (does not go "into" the mask - just selects it)

pastMask = function()

{

// Selectin recorded by Script listender

var idslct = charIDToTypeID( "slct" );

    var desc321 = new ActionDescriptor();

    var idnull = charIDToTypeID( "null" );

        var ref212 = new ActionReference();

        var idChnl = charIDToTypeID( "Chnl" );

        var idChnl = charIDToTypeID( "Chnl" );

        var idMsk = charIDToTypeID( "Msk " );

        ref212.putEnumerated( idChnl, idChnl, idMsk );

    desc321.putReference( idnull, ref212 );

    var idMkVs = charIDToTypeID( "MkVs" );

    desc321.putBoolean( idMkVs, false );

executeAction( idslct, desc321, DialogModes.NO );

// paste, recorded by script listender

var idpast = charIDToTypeID( "past" );

    var desc322 = new ActionDescriptor();

    var idAntA = charIDToTypeID( "AntA" );

    var idAnnt = charIDToTypeID( "Annt" );

    var idAnno = charIDToTypeID( "Anno" );

    desc322.putEnumerated( idAntA, idAnnt, idAnno );

executeAction( idpast, desc322, DialogModes.NO );

};

pastMask();

Any help would be really nice.!

Thanks alot

Alpha

This topic has been closed for replies.
Correct answer c.pfaffenbichler

app.activeDocument.selection.selectAll(); //selects stuff on the preview layer 

app.activeDocument.selection.copy();  //copy that stuff - to paste it into the mask later 

 

var adjLayer = activeDocument.layerSets.getByName("ao").artLayers.getByName("ao");  //searching for a group and specific layer 

 

activeDocument.activeLayer = adjLayer;

pastMask = function() 

 

// Selectin recorded by Script listender 

var idslct = charIDToTypeID( "slct" ); 

    var desc321 = new ActionDescriptor(); 

    var idnull = charIDToTypeID( "null" ); 

        var ref212 = new ActionReference(); 

        var idChnl = charIDToTypeID( "Chnl" ); 

        var idChnl = charIDToTypeID( "Chnl" ); 

        var idMsk = charIDToTypeID( "Msk " ); 

        ref212.putEnumerated( idChnl, idChnl, idMsk ); 

    desc321.putReference( idnull, ref212 ); 

    var idMkVs = charIDToTypeID( "MkVs" ); 

    desc321.putBoolean( idMkVs, true ); 

executeAction( idslct, desc321, DialogModes.NO ); 

 

// paste, recorded by script listender 

var idpast = charIDToTypeID( "past" ); 

    var desc322 = new ActionDescriptor(); 

    var idAntA = charIDToTypeID( "AntA" ); 

    var idAnnt = charIDToTypeID( "Annt" ); 

    var idAnno = charIDToTypeID( "Anno" ); 

    desc322.putEnumerated( idAntA, idAnnt, idAnno ); 

executeAction( idpast, desc322, DialogModes.NO ); 

 

 

}; 

pastMask();

1 reply

c.pfaffenbichler
Community Expert
c.pfaffenbichlerCommunity ExpertCorrect answer
Community Expert
February 18, 2015

app.activeDocument.selection.selectAll(); //selects stuff on the preview layer 

app.activeDocument.selection.copy();  //copy that stuff - to paste it into the mask later 

 

var adjLayer = activeDocument.layerSets.getByName("ao").artLayers.getByName("ao");  //searching for a group and specific layer 

 

activeDocument.activeLayer = adjLayer;

pastMask = function() 

 

// Selectin recorded by Script listender 

var idslct = charIDToTypeID( "slct" ); 

    var desc321 = new ActionDescriptor(); 

    var idnull = charIDToTypeID( "null" ); 

        var ref212 = new ActionReference(); 

        var idChnl = charIDToTypeID( "Chnl" ); 

        var idChnl = charIDToTypeID( "Chnl" ); 

        var idMsk = charIDToTypeID( "Msk " ); 

        ref212.putEnumerated( idChnl, idChnl, idMsk ); 

    desc321.putReference( idnull, ref212 ); 

    var idMkVs = charIDToTypeID( "MkVs" ); 

    desc321.putBoolean( idMkVs, true ); 

executeAction( idslct, desc321, DialogModes.NO ); 

 

// paste, recorded by script listender 

var idpast = charIDToTypeID( "past" ); 

    var desc322 = new ActionDescriptor(); 

    var idAntA = charIDToTypeID( "AntA" ); 

    var idAnnt = charIDToTypeID( "Annt" ); 

    var idAnno = charIDToTypeID( "Anno" ); 

    desc322.putEnumerated( idAntA, idAnnt, idAnno ); 

executeAction( idpast, desc322, DialogModes.NO ); 

 

 

}; 

pastMask();

Alphavader
Participating Frequently
February 18, 2015

thanks alot man!