Skip to main content
dublove
Legend
January 10, 2021
Answered

In Photoshop, is there a script or method to directly convert path to shape layer?

  • January 10, 2021
  • 2 replies
  • 928 views

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~

This topic has been closed for replies.
Correct answer Shulipa Bernad

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 );
}

2 replies

Shulipa Bernad
Shulipa BernadCorrect answer
Inspiring
January 10, 2021

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 );
}
dublove
dubloveAuthor
Legend
January 20, 2021

Shulipa Bernad~

Great. It works. Perfect

Thank you very much.

Chuck Uebele
Community Expert
Community Expert
January 10, 2021

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.