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

PS Script, add layer mask to current layer

Contributor ,
Nov 24, 2016 Nov 24, 2016

I'm trying to keep this as simple as possible, so far this is how my script works. At the end I want to add a black layer mask to the document?

Whats the simplist way to make this happen?

#target photoshop

var docRef = activeDocument

var newdLayer = docRef.activeLayer.duplicate();

newdLayer;

var doc = app.activeDocument;

doc.activeLayer = doc.artLayers.getByName("Main Image copy");

doc.activeLayer.applyMedianNoise(12);

doc.activeLayer.applyAddNoise(3, NoiseDistribution.UNIFORM, true)

doc.activeLayer.applyDespeckle()  

TOPICS
Actions and scripting
1.8K
Translate
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

Community Expert , Nov 24, 2016 Nov 24, 2016

A simple way would be to use action manager code to add a hide all layer mask.  The code would not be readable but you could hit the code in a function to make you mainline code readable.

AddHideAllMask();

function AddHideAllMask(); {

  // =======================================================

var idMk = charIDToTypeID( "Mk  " );

    var desc7 = new ActionDescriptor();

    var idNw = charIDToTypeID( "Nw  " );

    var idChnl = charIDToTypeID( "Chnl" );

    desc7.putClass( idNw, idChnl );

    var idAt = c

...
Translate
Adobe
Community Expert ,
Nov 24, 2016 Nov 24, 2016

A simple way would be to use action manager code to add a hide all layer mask.  The code would not be readable but you could hit the code in a function to make you mainline code readable.

AddHideAllMask();

function AddHideAllMask(); {

  // =======================================================

var idMk = charIDToTypeID( "Mk  " );

    var desc7 = new ActionDescriptor();

    var idNw = charIDToTypeID( "Nw  " );

    var idChnl = charIDToTypeID( "Chnl" );

    desc7.putClass( idNw, idChnl );

    var idAt = charIDToTypeID( "At  " );

        var ref3 = new ActionReference();

        var idChnl = charIDToTypeID( "Chnl" );

        var idChnl = charIDToTypeID( "Chnl" );

        var idMsk = charIDToTypeID( "Msk " );

        ref3.putEnumerated( idChnl, idChnl, idMsk );

    desc7.putReference( idAt, ref3 );

    var idUsng = charIDToTypeID( "Usng" );

    var idUsrM = charIDToTypeID( "UsrM" );

    var idHdAl = charIDToTypeID( "HdAl" );

    desc7.putEnumerated( idUsng, idUsrM, idHdAl );

executeAction( idMk, desc7, DialogModes.NO );

}

JJMack
Translate
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
Contributor ,
Nov 24, 2016 Nov 24, 2016

Many Thanks for that, I had to drop the ; from this line function AddHideAllMask(); { for it to work.

I'm trying to re write some of my applescripts to photoshop scripts, so I am trying to learn by doing these simpler things, that said is it common in the scripts to look as they do above as its something I can even begin to understand?

Translate
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
Community Expert ,
Nov 24, 2016 Nov 24, 2016
LATEST

Yes  I can not type I forgot to delet the ; when I did the copy paste.

JJMack
Translate
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