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 26, 2022

Not sure where should i use this? It seems your function activates refresh only if there is an error? I forgot to add, that these smart objects are nested ( linked smart object inside embedded smart object), could this be an issue?

 

What i want the script to do. 

1. Loop through all layers

2. If a layer is a smart object, open that smart object > update modified content > save and close.

 

What my script currently does:

1. Loops through layers.

2. First 8(for example) smart objects are opened, updated and closed correctly, but since the 9th is a bigger document, Photoshop does not get it open before the loop already tries to save it. this causes the script to save and close the main file. 

 

if i use activeDocument = doc; instead of  app.activeDocument.close(SaveOptions.SAVECHANGES); the script manages to update the first 8 objects and manages to open all the others, but not update them. 

 

 

 

 


Inside of commented part you may activate document that perhaps is not set yet. Check how your script works in slower mode: Step by Step Playback options of dropdown Action menu.

martink15467522
Inspiring
January 21, 2022

From extendscript i get an error at line 69

 

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