Skip to main content
Chuck Uebele
Community Expert
Community Expert
August 26, 2017
Question

Moving/editing a path point

  • August 26, 2017
  • 1 reply
  • 833 views

Is there a way to edit an existing path point without having to create a new path?

This topic has been closed for replies.

1 reply

c.pfaffenbichler
Community Expert
Community Expert
August 27, 2017

As far as I can tell: Not in Photoshop Scripting.

Even determining the selected PathPoint/s would necessitate a less than elegant work-around as far as I know.

But creating a new Path and removing the old one may hardly be noticable speed-wise, so it usually seems to be no big deal.

What exactly do you have in mind, if I may ask?

Chuck Uebele
Community Expert
Community Expert
August 27, 2017

It had to do with that post in the general forums about changing the width of the line tool. I thought it might be fun to try and write a script that takes an existing shape layer created with the line tool and change the width. However, as I mentioned, I can't edit points. I did find a script by Mike Hale that will read the existing path and create a new path, which is nice, but then I can't seem to replace the old path for the shape layer without deleting the entire layer, which would lose all the setting to that layer. Seems you can't remove only one subPathItem, even when there are two of them.

c.pfaffenbichler
Community Expert
Community Expert
August 27, 2017

This would use the last Path in the list, so better include a check that there are indeed Paths apart from the Vector Mask:

// 2017, use it at your own risk;

#target photoshop

try {

// =======================================================

var idDlt = charIDToTypeID( "Dlt " );

    var desc2 = new ActionDescriptor();

    var idnull = charIDToTypeID( "null" );

        var ref1 = new ActionReference();

        var idPath = charIDToTypeID( "Path" );

        var idvectorMask = stringIDToTypeID( "vectorMask" );

        ref1.putEnumerated( idPath, idPath, idvectorMask );

        var idLyr = charIDToTypeID( "Lyr " );

        var idOrdn = charIDToTypeID( "Ordn" );

        var idTrgt = charIDToTypeID( "Trgt" );

        ref1.putEnumerated( idLyr, idOrdn, idTrgt );

    desc2.putReference( idnull, ref1 );

executeAction( idDlt, desc2, DialogModes.NO );

// =======================================================

var idslct = charIDToTypeID( "slct" );

    var desc5 = new ActionDescriptor();

        var ref2 = new ActionReference();

        ref2.putIndex( idPath, activeDocument.pathItems.length );

    desc5.putReference( idnull, ref2 );

executeAction( idslct, desc5, DialogModes.NO );

// =======================================================

var idMk = charIDToTypeID( "Mk  " );

    var desc6 = new ActionDescriptor();

        var ref3 = new ActionReference();

        ref3.putClass( idPath );

    desc6.putReference( idnull, ref3 );

    var idAt = charIDToTypeID( "At  " );

        var ref4 = new ActionReference();

        ref4.putEnumerated( idPath, idPath, idvectorMask );

    desc6.putReference( idAt, ref4 );

    var idUsng = charIDToTypeID( "Usng" );

        var ref5 = new ActionReference();

        ref5.putEnumerated( idPath, idOrdn, idTrgt );

    desc6.putReference( idUsng, ref5 );

executeAction( idMk, desc6, DialogModes.NO );

} catch (e) {};

Edit: I’ve tried to remove all double-definitions but the code might be cleaned up some more.