Copy link to clipboard
Copied
Hi all. I have a small script that should open all folders and change all text layers. But I need to change text layers in smart objects too and this is the biggest problem. I don't know why but I can only get the name of the smart object and nothing else.
2 Correct answers
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 a
...var theSO = openSmartObject (activeDocument.activeLayer);
////// open smart object //////
function openSmartObject (theLayer) {
try {
activeDocument.activeLayer = theLayer;
var idplacedLayerEditContents = stringIDToTypeID( "placedLayerEditContents" );
var desc2 = new ActionDescriptor();
executeAction( idplacedLayerEditContents, desc2, DialogModes.NO );
return app.activeDocument
} catch (e) {return false}
};
Explore related tutorials & articles
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Hi Stephen. You correctly assumed that I take the data from AI chats because I have no other sources of information on how to open this or that object and what functions I have access to. At the moment, my main task is to open access to a smart object and get all the layers from there as their folders.
Copy link to clipboard
Copied
You correctly assumed that I take the data from AI chats because I have no other sources of information on how to open this or that object and what functions I have access to.
Have you already found
?
As far as Action Manager-code, which offers access to functionality that is beyond the DOM-code, is concerned one can use SciptingListener.plugin to record it and then try to adapt it as necessary.
Copy link to clipboard
Copied
var theSO = openSmartObject (activeDocument.activeLayer);
////// open smart object //////
function openSmartObject (theLayer) {
try {
activeDocument.activeLayer = theLayer;
var idplacedLayerEditContents = stringIDToTypeID( "placedLayerEditContents" );
var desc2 = new ActionDescriptor();
executeAction( idplacedLayerEditContents, desc2, DialogModes.NO );
return app.activeDocument
} catch (e) {return false}
};

