Copy link to clipboard
Copied
[Using PS 2019 on Windows 10]
What I am trying to achieve is to rasterize the current path when it is confirmed.
if(app.currentTool == "penTool") {
//when path is "confirmed", through hitting ENTER or pressing ctrl+LMB
app.activeDocument.activeLayer.rasterize(RasterizeType.ENTIRELAYER);
}
This could also be achieved by checking:
if(/*amount of pathPoints>0 && no pathPoint selected*/) {
app.activeDocument.activeLayer.rasterize(RasterizeType.ENTIRELAYER);
}
Unfortunately, I haven't been successful with either method. Any pointers? I am very new to PS scripting.
Hope this makes sense!
Use notifications to activate the script at the right moment (the code must be saved to disk before running, since the path to the script file is used when adding a notification).
So I understand that we are not talking about paths, but about the shape layer. This imposes certain quirks, since the shape layer is a layer, not a path.
The example rasterizes the unfinished shape layer path by pressing enter. When deselecting a layer, the common for layers notification "selectNoLayers" is used, howeve
if (name.split('Photoshop').length - 1 && !$.getenv('not')) $.setenv('not', 1), notifiers.add('slct', File($.fileName), 'Path')
else if(arguments && currentTool == 'penTool') arguments = runMenuItem(stringIDToTypeID('rasterizeShape'))
Save above script (without targeting it) in:
\c\Program Files (x86)\Common Files\Adobe\Startup Scripts CC\Adobe Photoshop
Then launch Ps, so it will be taken to notifiers memory automatically. It will work on layer when Pen Tool is chosen, and shape closed, l
...Copy link to clipboard
Copied
To clarify:
I have a path as seen above. As soon as I confirm it through Enter or deselection I want the path to be rasterized.
Copy link to clipboard
Copied
Use notifications to activate the script at the right moment (the code must be saved to disk before running, since the path to the script file is used when adding a notification).
So I understand that we are not talking about paths, but about the shape layer. This imposes certain quirks, since the shape layer is a layer, not a path.
The example rasterizes the unfinished shape layer path by pressing enter. When deselecting a layer, the common for layers notification "selectNoLayers" is used, however, additional logic is required to track which layer was deselected from (try to do it yourself - at the moment I don't have enough free time).
#target photoshop
try { var evt = arguments[0] } catch (e) { }
if (evt) {
if (app.currentTool == "penTool") {
app.activeDocument.activeLayer.rasterize(RasterizeType.ENTIRELAYER);
}
} else {
app.notifiersEnabled = true
var f = File($.fileName)
app.notifiers.add('slct', f, 'Path')
}
Copy link to clipboard
Copied
if (name.split('Photoshop').length - 1 && !$.getenv('not')) $.setenv('not', 1), notifiers.add('slct', File($.fileName), 'Path')
else if(arguments && currentTool == 'penTool') arguments = runMenuItem(stringIDToTypeID('rasterizeShape'))
Save above script (without targeting it) in:
\c\Program Files (x86)\Common Files\Adobe\Startup Scripts CC\Adobe Photoshop
Then launch Ps, so it will be taken to notifiers memory automatically. It will work on layer when Pen Tool is chosen, and shape closed, lastly an enter hit. You may also save the script at end of other location, to which (or folder it's in) you'll link from said path, or include the path to your script(s), or else use $.evalFile() instead with that other path.