Skip to main content
Silly-V
Legend
August 4, 2018
Answered

Convert to Smart Object

  • August 4, 2018
  • 2 replies
  • 1555 views

I am trying to get the active layer to convert to a smart object via script.

After using the script listener to get the text from clicking the context menu on the active layer to "convert to smart object", I got these lines:

// =======================================================

var idinvokeCommand = stringIDToTypeID( "invokeCommand" );

    var desc20 = new ActionDescriptor();

    var idcommandID = stringIDToTypeID( "commandID" );

    desc20.putInteger( idcommandID, 2980 );

    var idkcanDispatchWhileModal = stringIDToTypeID( "kcanDispatchWhileModal" );

    desc20.putBoolean( idkcanDispatchWhileModal, true );

executeAction( idinvokeCommand, desc20, DialogModes.NO );

// =======================================================

var idnewPlacedLayer = stringIDToTypeID( "newPlacedLayer" );

executeAction( idnewPlacedLayer, undefined, DialogModes.NO );

But when I try to run the same lines from ESTK, it says "Genral Error" this operation may not be supported in this version of Photoshop...

What am I doing wrong? Thank you for any wisdom.

This topic has been closed for replies.
Correct answer Kukurykus

runMenuItem(stringIDToTypeID('newPlacedLayer'))

2 replies

tokuredit
Inspiring
August 4, 2018

One thing I can assure you; these lines of code are of no use at all. Always ignore them:

// =======================================================

var idinvokeCommand = stringIDToTypeID( "invokeCommand" );

    var desc20 = new ActionDescriptor();

    var idcommandID = stringIDToTypeID( "commandID" );

    desc20.putInteger( idcommandID, 2980 );

    var idkcanDispatchWhileModal = stringIDToTypeID( "kcanDispatchWhileModal" );

    desc20.putBoolean( idkcanDispatchWhileModal, true );

executeAction( idinvokeCommand, desc20, DialogModes.NO );

// =======================================================

The command you need comes down to the last two lines.

var idnewPlacedLayer = stringIDToTypeID( "newPlacedLayer" );

executeAction( idnewPlacedLayer, undefined, DialogModes.NO );

Here it worked for me:

Silly-V
Silly-VAuthor
Legend
August 4, 2018

Good information to know, thank you!

Yes, it appears those lines prevented the real important lines above from running. When removed, it works!

JJMack
Community Expert
Community Expert
August 5, 2018

Tomas Sinkunas posted a script here and update it with an option to remove junk like that in scriptlistner action manager code for me.  Make sure you download his latest version.  I find it very helpful processing Scriptlistener code. Clean SL

JJMack
Kukurykus
KukurykusCorrect answer
Legend
August 4, 2018

runMenuItem(stringIDToTypeID('newPlacedLayer'))