Copy link to clipboard
Copied
In Photoshop, is there a script or method to directly convert path to shape layer?
My graph has many paths that need to be merged and subtracted from the upper path, but the path in PS doesn't seem to have this function.
But shape layer is OK, so I need to convert my path to shape layer.
Now it's a bit troublesome. You need to convert the path to a custom shape, and then generate the shape layer from the custom shape.
Thanks~
It would be like this?
convertPathtoShape();
function convertPathtoShape() {
var d = new ActionDescriptor();
var d2 = new ActionDescriptor();
var d3 = new ActionDescriptor();
var d4 = new ActionDescriptor();
var r = new ActionReference();
r.putClass( stringIDToTypeID( "contentLayer" ));
d.putReference( charIDToTypeID( "null" ), r );
d4.putDouble( charIDToTypeID( "Rd " ), 255);
d4.putDouble( charIDToTypeID( "Grn " ), 255);
d4.putDouble( charIDToTypeID( "Bl " ), 255);
d3.putObject( charIDToTypeID( "Clr " ), charIDToTypeID( "RGBC" ), d4 );
d2.putObject( charIDToTypeID( "Type" ), stringIDToTypeID( "solidColorLayer" ), d3 );
d.putObject( charIDToTypeID( "Usng" ), stringIDToTypeID( "contentLayer" ), d2 );
executeAction( charIDToTypeID( "Mk " ), d, DialogModes.NO );
}
Copy link to clipboard
Copied
In Photoshop, is there a script or method to directly convert path to shape layer?
My graph has many paths that need to be merged and subtracted from the upper path, but the path in PS doesn't seem to have this function.
But shape layer is OK, so I need to convert my path to shape layer.
Now it's a bit troublesome. You need to convert the path to a custom shape, and then generate the shape layer from the custom shape.
Thanks~
It would be like this?
convertPathtoShape();
function convertPathtoShape() {
var d = new ActionDescriptor();
var d2 = new ActionDescriptor();
var d3 = new ActionDescriptor();
var d4 = new ActionDescriptor();
var r = new ActionReference();
r.putClass( stringIDToTypeID( "contentLayer" ));
d.putReference( charIDToTypeID( "null" ), r );
d4.putDouble( charIDToTypeID( "Rd " ), 255);
d4.putDouble( charIDToTypeID( "Grn " ), 255);
d4.putDouble( charIDToTypeID( "Bl " ), 255);
d3.putObject( charIDToTypeID( "Clr " ), charIDToTypeID( "RGBC" ), d4 );
d2.putObject( charIDToTypeID( "Type" ), stringIDToTypeID( "solidColorLayer" ), d3 );
d.putObject( charIDToTypeID( "Usng" ), stringIDToTypeID( "contentLayer" ), d2 );
executeAction( charIDToTypeID( "Mk " ), d, DialogModes.NO );
}
Copy link to clipboard
Copied
You can use scriptListener to record changing a path to a shape to get the code. Unfortunately, there is a bug with the current version of PS, and this fails. It creates the shape layer, but there is nothing in that shape layer. I have notified Adobe regarding this. PS 2019 still works for doing this.
Copy link to clipboard
Copied
It would be like this?
convertPathtoShape();
function convertPathtoShape() {
var d = new ActionDescriptor();
var d2 = new ActionDescriptor();
var d3 = new ActionDescriptor();
var d4 = new ActionDescriptor();
var r = new ActionReference();
r.putClass( stringIDToTypeID( "contentLayer" ));
d.putReference( charIDToTypeID( "null" ), r );
d4.putDouble( charIDToTypeID( "Rd " ), 255);
d4.putDouble( charIDToTypeID( "Grn " ), 255);
d4.putDouble( charIDToTypeID( "Bl " ), 255);
d3.putObject( charIDToTypeID( "Clr " ), charIDToTypeID( "RGBC" ), d4 );
d2.putObject( charIDToTypeID( "Type" ), stringIDToTypeID( "solidColorLayer" ), d3 );
d.putObject( charIDToTypeID( "Usng" ), stringIDToTypeID( "contentLayer" ), d2 );
executeAction( charIDToTypeID( "Mk " ), d, DialogModes.NO );
}
Copy link to clipboard
Copied
Shulipa Bernad~
Great. It works. Perfect
Thank you very much.