Skip to main content
Participant
November 23, 2020
Answered

Photoshop script. Edit SmartObject

  • November 23, 2020
  • 1 reply
  • 5270 views

Hi everyone!

There is a mockup .psd graphic file.

Inside the file is smart object.

How can I access and edit this smart object? (change layer, delete layer).

I try to access mockup as a normal layer, but it doesn't work.

 

  var mockup    = open(File('mockup.psd'));
  app.activeDocument = mockup

  var layerRef = app.activeDocument.artLayers.getByName("Layer_name");
  layerRef.remove(); //just to delete the Layer for example

I would be glad if there are examples about how is possible edit a smart object.

Thanks.

This topic has been closed for replies.
Correct answer Kukurykus

 

runMenuItem(stringIDToTypeID('placedLayerEditContents'))

 

1 reply

Kukurykus
KukurykusCorrect answer
Legend
November 24, 2020

 

runMenuItem(stringIDToTypeID('placedLayerEditContents'))

 

JJMack
Community Expert
Community Expert
November 24, 2020

Also all Smart object layer objects are not Photoshop object. If you open a Smart Object Layer object that is a vector smart object the temp work file that Photoshop created will open in  AI and Camera RAW work files will open in ACR not Photoshop. Your Photoshop script will not be able to control the edit process.  In my Photoshop Mockup populating scripts, I test what kind of object a smart object  layer contain. If they are not a photoshop object my scripts will inform the user their template layer is not compatible with my script edit option and the smart object layer will not be repopulated.  If a mockup template has a smart object layer the needs to populated has a none Photoshop object  that mockup cans only be populated using my script default method of operation the uses Layer>Smart Objects>Replace Content.  All replacement object need to has the same Aspect Ratio, Size and Print resolution as the objects in the template for proper population. Changing the size of an object does not work when it comes to templates. Template may have several transform and wrappings recorded into the template for objects for other smart object layers can share a single object.  Even if there is only a single smart object layer there is a recorded object transform to generate the layers pixels from the hardened object pixels and that transform cans include warping of the object for the mockup template's use of the of the object and the Layer may also be  mask. Changing an object size populating a template should not be done.

JJMack