• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

P: Script not working after updating

Community Beginner ,
Dec 26, 2020 Dec 26, 2020

Copy link to clipboard

Copied

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

Bug Fixed
TOPICS
Actions and scripting , macOS , Windows

Views

1.6K

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
community guidelines

correct answers 1 Correct answer

New Here , Mar 23, 2021 Mar 23, 2021

I finally got the error by downgrading to 22.1.0.  I could file a bug, but I expect the team would simply close it as fixed in 22.3.

Please try with 22.3.  I did not see the error there.

Votes

Translate

Translate
15 Comments
Adobe Employee ,
Dec 28, 2020 Dec 28, 2020

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community Beginner ,
Jan 03, 2021 Jan 03, 2021

Copy link to clipboard

Copied

@JeffreyTranberry 

Hi Jeffrey,

Are there any updates on this?

Thanks

Votes

Translate

Translate

Report

Report
Adobe Employee ,
Jan 04, 2021 Jan 04, 2021

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
New Here ,
Jan 06, 2021 Jan 06, 2021

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community Beginner ,
Jan 06, 2021 Jan 06, 2021

Copy link to clipboard

Copied

@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

Votes

Translate

Translate

Report

Report
New Here ,
Jan 07, 2021 Jan 07, 2021

Copy link to clipboard

Copied

Hmm, since we're invoking the "copy" command, I still believe the issue is one of the app state.  Until I can replicate, would you try the following to help identify the app state characteristic:

  • Run the script up to the copy command. Try using the keyboard short cut or menu to execute the copy.  
  • Manually execute the steps of the script.

Hopefully, you'll get an error or the path will fail to copy.

"The command 'copy' is not currently available" error should correspond with the menu item Edit > Copy being disabled.

Votes

Translate

Translate

Report

Report
Community Beginner ,
Feb 16, 2021 Feb 16, 2021

Copy link to clipboard

Copied

I tried your suggestion, manual shortcuts and menu copy / paste works fine, without errors.

Thanks

Votes

Translate

Translate

Report

Report
Community Beginner ,
Mar 01, 2021 Mar 01, 2021

Copy link to clipboard

Copied

Any updates / solution for this issue?

Thanks

Votes

Translate

Translate

Report

Report
New Here ,
Mar 12, 2021 Mar 12, 2021

Copy link to clipboard

Copied

@Asela Sandaruwan I have not yet been able to reproduce the issue here.  Would you please describe in detail the structure of the file from which the path is copied or provide a sample file?

 

Votes

Translate

Translate

Report

Report
Community Beginner ,
Mar 15, 2021 Mar 15, 2021

Copy link to clipboard

Copied

@SamGannaway Is there a way to send you sample files without posting here?

Votes

Translate

Translate

Report

Report
Community Beginner ,
Mar 15, 2021 Mar 15, 2021

Copy link to clipboard

Copied

@SamGannaway Also I am not sure it has anything to do with the images, when I run the script on any image with PS 2018, it works fine.

And I tried with many images on PS 2021, script crashes on all of them.

Source files have only Background layer and one path, destination file is the same without a path. Thanks

Votes

Translate

Translate

Report

Report
Community Beginner ,
Mar 22, 2021 Mar 22, 2021

Copy link to clipboard

Copied

Can we please escalate this as it has been almost three months?

Thanks

Votes

Translate

Translate

Report

Report
New Here ,
Mar 23, 2021 Mar 23, 2021

Copy link to clipboard

Copied

I finally got the error by downgrading to 22.1.0.  I could file a bug, but I expect the team would simply close it as fixed in 22.3.

Please try with 22.3.  I did not see the error there.

Votes

Translate

Translate

Report

Report
Community Beginner ,
Mar 24, 2021 Mar 24, 2021

Copy link to clipboard

Copied

I mentioned the version I am using in the question three months ago.

Script works with the latest PS version 22.3

Votes

Translate

Translate

Report

Report
New Here ,
Mar 24, 2021 Mar 24, 2021

Copy link to clipboard

Copied

LATEST

Yes, the delay is frustrating.  I wonder now if it was actually resolved in 22.1.1 or 22.2.  

A safer alternative to cut/paste for paths would be to 

  1. Create a new layer
  2. Create a vector mask from the path
  3. Duplicate that layer to the destination
  4. In the destination doc, duplicate the vector mask to a new path
  5. Delete the new layer
  6. Rename the path if desired

I will also see if duplicating paths to another document (like layers) is in that team's backlog.

Votes

Translate

Translate

Report

Report