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

Layer Set Mask Feather Value

Engaged ,
Apr 06, 2020 Apr 06, 2020

Is a layer set mask feather value scriptable? 

If so visit possible to see a sample code?

 

PSCC 2020

OSX Catalina

TOPICS
Actions and scripting
2.2K
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 , Apr 06, 2020 Apr 06, 2020

In it's simplest form:

 

 

 

app.activeDocument.activeLayer.layerMaskFeather = 25;

 

 

 

However, in practice, you would probably wish to set up a test to see if the active layer actually had a layer mask applied beforehand:

 

if (hasLayerMask() == true) { // Only if it has a layer mask
    app.activeDocument.activeLayer.layerMaskFeather = 25;
}

//github.com/ES-Collection/Photoshop-Scripts/blob/master/Link%20All%20Masks.jsx

//////////////////////////////////////////////////////////////////////
...
Translate
Adobe
Community Expert ,
Apr 06, 2020 Apr 06, 2020

Have you tried recording the operation with ScriptingListener.plugin? 

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
Engaged ,
Apr 06, 2020 Apr 06, 2020

I thought about it but have not been able to make the script listener plugin work with PSCC 2020 and OSX Catalina.

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 ,
Apr 06, 2020 Apr 06, 2020
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
Engaged ,
Apr 06, 2020 Apr 06, 2020

Thank you for sending the links. The ScriptingListenre is working in OSX Catalina now.

After restarting Photoshop the ScriptingListernerJS.log did not show up on the desktop. The plugin had to be activated via the Adobe scriptListenerOff/On scripts.  Here is the recorded code in function:

function setMskFeather(value) {
// =======================================================
var idset = stringIDToTypeID( "set" );
    var desc7 = new ActionDescriptor();
    var idnull = stringIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idlayer = stringIDToTypeID( "layer" );
        var idordinal = stringIDToTypeID( "ordinal" );
        var idtargetEnum = stringIDToTypeID( "targetEnum" );
        ref2.putEnumerated( idlayer, idordinal, idtargetEnum );
    desc7.putReference( idnull, ref2 );
    var idto = stringIDToTypeID( "to" );
        var desc8 = new ActionDescriptor();
        var iduserMaskFeather = stringIDToTypeID( "userMaskFeather" );
        var idpixelsUnit = stringIDToTypeID( "pixelsUnit" );
        desc8.putUnitDouble( iduserMaskFeather, idpixelsUnit, value );
    var idlayer = stringIDToTypeID( "layer" );
    desc7.putObject( idto, idlayer, desc8 );
executeAction( idset, desc7, DialogModes.NO );
}
setMskFeather(25);
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 ,
Apr 06, 2020 Apr 06, 2020

Here is your code run through Clean SL:

 

function setMskFeather(userMaskFeather) {
    var s2t = function (s) {
        return app.stringIDToTypeID(s);
    };

    var descriptor = new ActionDescriptor();
    var descriptor2 = new ActionDescriptor();
    var reference = new ActionReference();

    reference.putEnumerated(s2t("layer"), s2t("ordinal"), s2t("targetEnum"));
    descriptor.putReference(s2t("null"), reference);
    descriptor2.putUnitDouble(s2t("userMaskFeather"), s2t("pixelsUnit"), userMaskFeather);
    descriptor.putObject(s2t("to"), s2t("layer"), descriptor2);
    executeAction(s2t("set"), descriptor, DialogModes.NO);
}
setMskFeather(25);
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
People's Champ ,
Apr 06, 2020 Apr 06, 2020

Untitled-2.png

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
Engaged ,
Apr 06, 2020 Apr 06, 2020

I looked at the specification for layerMaskFetehr before but was not able to make it work. How exactly would you use this property? 

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 ,
Apr 06, 2020 Apr 06, 2020
LATEST

In it's simplest form:

 

 

 

app.activeDocument.activeLayer.layerMaskFeather = 25;

 

 

 

However, in practice, you would probably wish to set up a test to see if the active layer actually had a layer mask applied beforehand:

 

if (hasLayerMask() == true) { // Only if it has a layer mask
    app.activeDocument.activeLayer.layerMaskFeather = 25;
}

//github.com/ES-Collection/Photoshop-Scripts/blob/master/Link%20All%20Masks.jsx

///////////////////////////////////////////////////////////////////////////////
// Function: hasLayerMask
// Usage: see if there is a raster layer mask
// Input: <none> Must have an open document
// Return: true if there is a vector mask
///////////////////////////////////////////////////////////////////////////////
function hasLayerMask() {
    var hasLayerMask = false;
    try {
        var ref = new ActionReference();
        var keyUserMaskEnabled = app.charIDToTypeID('UsrM');
        ref.putProperty(app.charIDToTypeID('Prpr'), keyUserMaskEnabled);
        ref.putEnumerated(app.charIDToTypeID('Lyr '), app.charIDToTypeID('Ordn'), app.charIDToTypeID('Trgt'));
        var desc = executeActionGet(ref);
        if (desc.hasKey(keyUserMaskEnabled)) {
            hasLayerMask = true;
        }
    } catch (e) {
        hasLayerMask = false;
    }
    return hasLayerMask;
}
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