layer.smartObject.editContents();
By @valera_9213
Assuming that you have a variable defining layer as the app.activeDocument.activeLayer, where did you get the following from:
.smartObject
and
.editContents();
Would this have come from a generative LLM AI tool (ChatGPT or similar)?
For the active smart object layer, you can:
app.runMenuItem(stringIDToTypeID('placedLayerEditContents'));
This assumes that the file can be edited in Photoshop. Otherwise, the associated app will open instead, such as Illustrator if the smart object is an .ai file. Otherwise, more complex code would be required to assess the type of smart object and handle it accordingly.
So you would need to loop over all layers, check if the layer or a smart object layer and perform the required edits. A text layer only goes one level deep, however, a smart object can contain another smart object etc. So you would need more robust code to look at the edited smart object, detect layer groups and text layers, drill down into further smart objects, and repeat as needed. It depends on how bulletproof the script needs to be, which depends on your data or the expected data being processed.
... View more