Copy link to clipboard
Copied
Hi,
I vaguely recalled to have asked about this in the past (although my memory could fail me), but I can't find the post, maybe it was on ps-scripts.com
I'd need to pack into a single ActionManager step a "merge layer on top" (command + shift + option + E) with the layer name set.
My (unsuccessful) take is:
function s2t (s) { return app.stringIDToTypeID(s) }
var d1 = new ActionDescriptor();
d1.putBoolean(s2t('duplicate'), true);
// trying to set the name =======
var d2 = new ActionDescriptor();
d2.putString( s2t('name'), "some name");
d1.putObject(s2t('using'), s2t('layer'), d2);
// ======
executeAction(s2t('mergeVisible'), d1, DialogModes.NO);
Alas always the default name (which depends on the existing layers) is used.
I know it's not the end of the world to divide into 2 steps but... 😉
Thanks in advance for any suggestion,
Davide
Copy link to clipboard
Copied
Hi Davide,
So far, I've never found a way to achieve a stamp visible operation with a new layer name in one single step only.
Here is how I do it in some of my scripts, by creating first an empty layer:
function stampVisible (name)
{
var desc1 = new ActionDescriptor ();
var ref1 = new ActionReference ();
ref1.putClass (app.stringIDToTypeID ("layer"));
desc1.putReference (app.stringIDToTypeID ("target"), ref1);
if (name)
{
var desc2 = new ActionDescriptor ();
desc2.putString (app.stringIDToTypeID ("name"), name);
desc1.putObject (app.stringIDToTypeID ("using"), app.stringIDToTypeID ("layer"), desc2);
}
app.executeAction (app.stringIDToTypeID ("make"), desc1, DialogModes.NO);
var desc3 = new ActionDescriptor ();
desc3.putBoolean (app.stringIDToTypeID ("duplicate"), true);
app.executeAction (app.stringIDToTypeID ("mergeVisible"), desc3, DialogModes.NO);
}
stampVisible ("New Layer");
HTH,
--Mikaeru
Find more inspiration, events, and resources on the new Adobe Community
Explore Now