skip to Main Content

I have a Photoshop script (Javascript) that copy paste paths from one image to another.
It has worked for a long time, but with PS 2021 (22.1.0) on Windows 10, I get an error in this code where the selected path is copied (3rd line),

1. currentDoc.pathItems[0].select();    
2. var id122 = charIDToTypeID("copy");
3. executeAction( id122, undefined, DialogModes.NO );

"General Photoshop error occurred. This functionality may not be
available in this version of Photoshop"

Everything works fine up to that line of code, image with path (currentDoc – this is the active document) is open in Photoshop and path is selected as intended and the destination image also open. Variable id122 has an int value too.

Any idea how to fix this error?

Thanks

2

Answers


  1. Chosen as BEST ANSWER

    This bug is fixed in the latest Photoshop version 22.3


  2. Scriptlistener code occasionally breaks when Photoshop gets updated 🙁

    However, this is what your after: Two documents in Photoshop, Untitled-1 and Untitled-2.

    Untitled-1 has the path, which is going to get copied.

    Untitled-2 is where you’re going to paste it to.

    // call the source document
    var srcDoc = app.activeDocument;
    var otherDoc = "Untitled-2"; // change this to suit you
    
    // =======================================================
    var idcopy = charIDToTypeID( "copy" );
    executeAction( idcopy, undefined, DialogModes.NO );
    
    // swap to other document
    getDocumentByName(otherDoc)
    
    
    // =======================================================
    var idpast = charIDToTypeID( "past" );
    executeAction( idpast, undefined, DialogModes.NO );
    
    
    
    function getDocumentByName(docname)
    {
      for (var i = 0; i < documents.length; i++)
      {
        if (documents[i].name == docname) app.activeDocument = documents[i];
      }
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search