Photoshop: Scripting - is there way hot to delete concrete subPathItem?

  • 1
  • Question
  • Updated 3 years ago
  • (Edited)
Script listner shows this on any subPathItem remove
var idDlt = charIDToTypeID( "Dlt " );
executeAction( idDlt, undefined, DialogModes.NO );
 
Selection of concrete subPathItem is imposible record with script listener.

I can read easy a lot of data like this, 

var myVectorMask = app.activeDocument.pathItems[0];
var myFirstShapeInVectorMask = myVectorMask.subPathItems[0];
var myFirstPointInShape = myFirstShapeInVectorMask.pathPoints[0];
but edit this data is harder.
Photo of Jaroslav Bereza

Jaroslav Bereza

  • 809 Posts
  • 187 Reply Likes

Posted 3 years ago

  • 1
Photo of christoph pfaffenbichler

christoph pfaffenbichler, Champion

  • 1232 Posts
  • 178 Reply Likes
For what you seem to want collecting and editing the path data, then creating a new path and replacing the old one is the way in Photoshop to the best of my knowledge. 
(Edited)
Photo of Jaroslav Bereza

Jaroslav Bereza

  • 809 Posts
  • 187 Reply Likes
Hmm not much effective. Btw replacing(recreating) mask will break position of shape in layer comps if position option is enabled.
Photo of christoph pfaffenbichler

christoph pfaffenbichler, Champion

  • 1232 Posts
  • 178 Reply Likes
»not much effective«
It usually seems efficient enough to me, JavaScript can do the calculations/processing and Photoshop can create Paths quite fast in my experience. 

What exactly do you want to achieve? Could you give an example? 

»Btw replacing(recreating) mask will break position of shape in layer comps if position option is enabled.«
Hadn’t thought of that, that could indeed be disruptive. 
Photo of Jaroslav Bereza

Jaroslav Bereza

  • 809 Posts
  • 187 Reply Likes
I wrote script which can covert rectangles with rouded corners into live-shapes, so you can change radius dynamicaly. But it work now only with one closed path. Right now my script is recreating mask, because I can't delete only one path.
Photo of christoph pfaffenbichler

christoph pfaffenbichler, Champion

  • 1232 Posts
  • 178 Reply Likes
I don’t quite follow. 
I guess I understand 
Right now my script is recreating mask, because I can't delete only one path.
but why 
 But it work now only with one closed path.
? Can’t you create several Shape Layers and merge them for example? 
Photo of Jaroslav Bereza

Jaroslav Bereza

  • 809 Posts
  • 187 Reply Likes
but why 
I can't delete only one from paths in vector mask so I am deleting vector mask completly.

? Can’t you create several Shape Layers and merge them for example? 
Since merging with Ctrl + E merges shapes and preserves vector mask... I probably could. I can also copy vector mask from one layer to another. But I assume that these extra steps will have performance impact. What I don't know yet is how to create completly custom shape. Now I can't create only predefined shapes. Eg. rectangle, circle, line, ...

My script is working like this:
1) find closed path which looks like rectangle (only one first closed path in this moment)
2) gues size and corner radius
3) remove this path (vector mask in this moment)
4) create vector mask 
5) add live rectangle shape in vector mask