Update and save Smart object via batchPlay

Hi there, this is my first rodeo with UXP so I’m sorry in advance if I’m doing something terribly wrong.

I’m converting a layer to smart object and then open it and make some modifications. What I’m unable to do is after those modifications is saving the .psb which is usually saved in a temp folder so the original document updates the smart object. This is a snippet of what I have so far:

const result = batchPlay([
        // DUPLICATE LAYER
        {
            _obj: "duplicate",
            _target: [{
                _ref: "layer",
                _enum: "ordinal",
                _value: "targetEnum"
            }],
            version: 5,
            ID: [
                25
            ],
            _options: {
                dialogOptions: "dontDisplay"
            }
        },

        // CONVERT TO SMART OBJECT
        {
            _obj: "newPlacedLayer",
        },

        // EDIT SMART OBJECT
        {
            _obj: "placedLayerEditContents",
            _options: {
                dialogOptions: "dontDisplay"
            }
        },

        // DO STUFF


        // SAVE TBD


        //CLOSE
        {
            _obj: "close",
            _options: {
                dialogOptions: "dontDisplay"
            }
        },

    ], {
        synchronousExecution: true,
        modalBehavior: "fail"
    });

I’ve been checking what’s going on when I save using Alchemist but none of the listened events when saving seem to work.

Okay, I found a way that seems to work, I used Occultist to check what happened when I saved a smart object via photoshop action and it was simply

{
    _obj: 'save'
},

That’s it, that’s all needed to make a simple save action to the temp directory

3 Likes