A little heads-up for everyone using paths in their plugins: In one of the recent updates of Photoshop, a new bug crept in that made my whole plugin malfunction and gave me quite a bit of headaches to find and work around.
If you want to create a new shape using the work path, you’d usually use the following descriptor:
const desc = {
_obj: 'make',
_target:{
_ref: 'contentLayer',
},
using: {
_obj: 'contentLayer',
type: {
_obj: 'solidColorLayer',
color: {
_obj: 'RGBColor',
red: 0,
grain: 0,
blue: 0,
}
},
shape: {
_obj: 'pathClass',
targetPath: {
_enum: 'pathKind',
_value: 'targetPath',
},
},
},
}
This does not work correctly anymore. Instead of using the target path (workpath), it just creates a new shape layer with an empty vector mask. When I built the plugin a few weeks ago, this bug didn’t exist.
(I’m now on version 22.1.0 20201125.r.94 where the bug exists)
Also, this bug is not just related to UXP/scripting. Recording the mentioned event in a Photoshop Action and playing that one back gives the same incorrect result.
For now, I’ve come up with the following workaround:
require(photoshop).action.batchPlay(workPathToShape, {})
function workPathToShape(color: Color): ActionDescriptor[] {
return [
__makeShapeFromPath(color), // usually this would be enough
__deleteActiveVectorMask(),
__selectWorkPath(),
__makeVectorMaskFromActivePath(),
];
}
function __makeShapeFromPath(color: Color): ActionDescriptor {
return {
_obj: "make",
_target: {
_ref: "contentLayer",
},
using: {
_obj: "contentLayer",
type: {
_obj: "solidColorLayer",
color,
},
shape: {
_obj: "pathClass",
targetPath: {
_enum: "pathKind",
_value: "targetPath",
},
},
},
};
}
function __selectWorkPath(): ActionDescriptor {
return {
_obj: "select",
_target: { _ref: "path", _property: "workPath" },
};
}
function __deleteActiveVectorMask(): ActionDescriptor {
return {
_obj: "delete",
_target: { _ref: "path", _enum: "path", _value: "vectorMask" },
};
}
function __makeVectorMaskFromActivePath(): ActionDescriptor {
return {
_obj: "make",
_target: { _ref: "path" },
at: { _ref: "path", _enum: "path", _value: "vectorMask" },
using: { _ref: "path", _enum: "ordinal", _value: "targetEnum" },
};
}
I think this bug is quite critical as it can cause various plugins, actions and scripts from the past to crash in the latest version of Photoshop…