Skip to main content
December 24, 2012
Question

"New Smart Object via copy" via JavaScript?

  • December 24, 2012
  • 3 replies
  • 1905 views

I'd like to know how to copy a smart object but, so every smart object is independent.

I know you can copy layers via layer.duplicate() but that function just copies a instance of the object instead of creating a new object. So how would you do it?

This topic has been closed for replies.

3 replies

JJMack
Community Expert
Community Expert
December 24, 2012

Install Scriptlisener Plugin and do menu layer>Smart Objects>New Smart Object via Copy

javascript action manager code looks like this

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

var idplacedLayerMakeCopy = stringIDToTypeID( "placedLayerMakeCopy" );

executeAction( idplacedLayerMakeCopy, undefined, DialogModes.NO );

Look quit a bit like Michael's above append one may execute faster the the other.

JJMack
Inspiring
December 25, 2012

I don't think there would be any speed difference between using the Photoshop Object method and Action Manager in this case.

The Action Manager version does have the advantage of working  in older versions of Photoshop( I think CS3 or lower ) that don't have the app.runMenuItem() method.

Inspiring
December 24, 2012

I am not sure what you are asking so this may be off, but if you want to do the same thing as the menu item "New Smart Object via Copy" you can use:

app.runMenuItem(stringIDToTypeID( "placedLayerMakeCopy" ));

That will create an independent copy of the Smart Object layer. i.e. edits to the layer only effect that layer.

Paul Riggott
Inspiring
December 24, 2012

The only reliable way I can think of is to use use the full path and name as the layer name, then this can be used to place a new smart object.