Skip to main content
Known Participant
December 26, 2020

P: Script not working after updating

  • December 26, 2020
  • 15 replies
  • 2136 views

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

executeAction( id122, undefined, DialogModes.ERROR );

 

Stripped down version of the script to copy clipping path from one image to another as follows (have to provide file paths to sourceFile and destinationFile variables in the first two lines), and it works with previous versions of Photoshop, 

 

var sourceFile = new File("File path to source file"); // file path to image that has the clipping pathvar destinationFile = new File("File path to destination file"); // file path to image to which we want to copy the clipping path from source fileopen(sourceFile);open(destinationFile);var sourceDoc = documents[0];var destinationDoc = documents[1];activeDocument = sourceDoc;sourceDoc.pathItems[0].select(); //get the top most path from source filevar id122 = charIDToTypeID("copy");executeAction( id122, undefined, DialogModes.ERROR ); // copy the selected pathactiveDocument = destinationDoc;var id126 = charIDToTypeID( "past" );executeAction( id126, undefined, DialogModes.NO ); // paste the copied path to destination filesourceDoc.close(SaveOptions.DONOTSAVECHANGES); //close without any changesdestinationDoc.close(SaveOptions.SAVECHANGES); //save with changesalert("Done");sourceFile.close();destinationFile.close();

 

Inside Photoshop I get error pop up "The command 'copy' is not currently available"
In the ExtendScript toolkit debugger I get the error message "General Photoshop error occurred. This functionality may not be available in this version of Photoshop"

 

Everything works fine up to this line of code,

executeAction( id122, undefined, DialogModes.ERROR );

image with path is open in Photoshop and clipping path is selected as intended and the destination image also open. Variable id122 has an int value too.

 

Can you please check why this happens after updating to Photoshop 2021? It works fine with previous versions.

 

Thanks

This topic has been closed for replies.

15 replies

Known Participant
January 7, 2021

@sam_gannaway_9nz72lhc7me2u 

Hi Sam,

Thanks for looking into this.

Your code did activate the path tool but the script still crashes with the same error message, "The command 'copy' is not currently available"

Highly appreciate it if I could have a solution for this problem soon.

Thanks

Participating Frequently
January 6, 2021

I can't speak to why it's happening, but I did notice something while trying to reproduce the situation.  The "copy" command is a quite situational for what it will take as the target of the copy.  I couldn't it to take the path unless I had a path tool active at the time.  I wonder if adding the following to your script might alleviate the issue for you.

function switchToPathTool() {
    var desc = new ActionDescriptor();
    var ref = new ActionReference();
    var idpathComponentSelectTool = stringIDToTypeID( "pathComponentSelectTool" );
    ref.putClass( idpathComponentSelectTool );
    desc.putReference( stringIDToTypeID( "null" ), ref );
    var iddontRecord = stringIDToTypeID( "dontRecord" );
    desc.putBoolean( iddontRecord, true );
    var idforceNotify = stringIDToTypeID( "forceNotify" );
    desc.putBoolean( idforceNotify, true );
    executeAction( stringIDToTypeID( "select" ), desc, DialogModes.NO );
}
switchToPathTool();

That said, we wouldn't be in this mess if path had the option to duplicate to a different document like layer.

Legend
January 4, 2021

No new info. Most of the engineering team returned from holiday today.

Known Participant
January 4, 2021

@JeffreyTranberry 

Hi Jeffrey,

Are there any updates on this?

Thanks

Legend
December 28, 2020

Thanks. I've asked engineering to take a look.