Using the UXP code from a Photoshop Action and calling it from an Applescript
Hi all,
Here's the UXP code taken from the Photoshop Action (enabling debug mode allows you to extract it from a recorded action), it's simply adding a drop shadow to the currently selected layer:
async function action() {
let result;
let psAction = require(\"photoshop\").action;
let command = [
// Set Layer Styles of current layer
{'_obj':'set','_target':[{'_property':'layerEffects','_ref':'property'},{'_enum':'ordinal','_ref':'layer','_value':'targetEnum'}],'to':{'_obj':'layerEffects','dropShadow':{'_obj':'dropShadow','antiAlias':false,'blur':{'_unit':'pixelsUnit','_value':35.0},'chokeMatte':{'_unit':'pixelsUnit','_value':0.0},'color':{'_obj':'RGBColor','blue':0.0,'grain':0.0,'red':0.0},'distance':{'_unit':'pixelsUnit','_value':0.0},'enabled':true,'layerConceals':true,'localLightingAngle':{'_unit':'angleUnit','_value':90.0},'mode':{'_enum':'blendMode','_value':'multiply'},'noise':{'_unit':'percentUnit','_value':0.0},'opacity':{'_unit':'percentUnit','_value':100.0},'present':true,'showInDialog':true,'transferSpec':{'_obj':'shapeCurveType','name':'Linear'},'useGlobalAngle':true},'scale':{'_unit':'percentUnit','_value':100.0}}}
];
result = await psAction.batchPlay(command, {});
}
async function runModalFunction() {
await require('photoshop').core.executeAsModal(action, {'commandName': 'Action Commands'});
}
await runModalFunction();
As I haven't jumped into the world of UXP coding yet, I'm not sure how to extract the correct information above and place into an Applescript. I was hoping the above could be wrapped into a Javascript, which in turn could be called from an Applescript.
The aim is to then apply the same rules to other actions when the focus is on the current layer,
Thanks in advance!
