Skip to main content
martink15467522
Inspiring
January 21, 2022
Question

Update all linked smart objects CC2019 script not working in CC2020 and 2021

  • January 21, 2022
  • 2 replies
  • 6091 views

Hello!

 

I am trying to use the following script to update all linked smart objects.  https://stackoverflow.com/questions/62280806/photoshop-cc2019-auto-update-all-linked-smart-objects-including-nested-ones/

 

But the script does not seem to be working in 2020 and 2021. It just closes the file. 

Either something is wrong with my layer structure, or is the script doing something wrong. Maybe anyone can give some advice on solving this?

 

 

 

This topic has been closed for replies.

2 replies

Legend
January 22, 2022

I didn't go into the script and didn't check,

but try replacing the line

app.runMenuItem(stringIDToTypeID('placedLayerEditContents'));

with this code

var doc0 = app.activeDocument;
app.runMenuItem(stringIDToTypeID('placedLayerEditContents'));
if (doc0 != app.activeDocument) { alert("can't open smart object"); throw("error"); }

 

And also in the same function replace the line 

app.activeDocument.close(SaveOptions.SAVECHANGES);

with this

app.activeDocument.close(SaveOptions.SAVECHANGES);
app.activeDocument = doc0;

 

martink15467522
Inspiring
January 24, 2022

Tried this. Now the script opens the first smart object and immediately throws the error 

can't open smart object

 

Kukurykus
Legend
January 27, 2022

Yes, even with the btw part done.

Tried some other options and found a workaround. It works, but it's not the best.

I split the opening and closing of smart objects to two different scripts. Also added a script event listener for file open to also update linked smart objects, because just the script was not fast enough. 

 

I use 2 different actions to activate these scripts. Tried putting 2 scripts under the same action, but the same error occurs: photoshop is not able to open all smart objects before the second script starts. Even if I set playback to pause.

 


Upload your .psd.

martink15467522
Inspiring
January 21, 2022

From extendscript i get an error at line 69

 

autoupdateAllSmartObjects(app.activeDocument, stackNr);  -- no such element