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

Jan 10, 2021

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 );
}
TOPICS
Actions and scripting, Feature request, How to, Import and export, Problem or error

Views

65

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

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

Jan 10, 2021

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 );
}
TOPICS
Actions and scripting, Feature request, How to, Import and export, Problem or error

Views

66

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jan 10, 2021 0
Jan 10, 2021

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 10, 2021 2
Jan 10, 2021

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 10, 2021 0
Jan 20, 2021

Copy link to clipboard

Copied

Shulipa Bernad~

Great. It works. Perfect

Thank you very much.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 20, 2021 0