Copy link to clipboard
Copied
Is a layer set mask feather value scriptable?
If so visit possible to see a sample code?
PSCC 2020
OSX Catalina
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
//////////////////////////////////////////////////////////////////////
...
Copy link to clipboard
Copied
Have you tried recording the operation with ScriptingListener.plugin?
Copy link to clipboard
Copied
I thought about it but have not been able to make the script listener plugin work with PSCC 2020 and OSX Catalina.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
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);
Copy link to clipboard
Copied
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);
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I looked at the specification for layerMaskFetehr before but was not able to make it work. How exactly would you use this property?
Copy link to clipboard
Copied
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;
}