New document from layer
Hello, not sure if it's correct group but maybe someone know how exactly Photoshop 4-chars commands work.
I'm trying to find correct script to create new document from specific layer by id. But it always uses active layer. Is there any way to change the script to fit my requirements?
var mkId = charIDToTypeID("Mk "),
action = new ActionDescriptor(),
nullId = charIDToTypeID("null"),
actionRef = new ActionReference(),
docId = charIDToTypeID("Dcmn");
actionRef.putClass(docId),
action.putReference(nullId, actionRef);
var nmId = charIDToTypeID("Nm ");
action.putString(nmId, "My new document");
var usingId = charIDToTypeID("Usng"),
// trying to set target layer, but it doesn't work
c = new ActionReference();
c.putIndex( charIDToTypeID( "Lyr " ), 2);
action.putReference(usingId, c);
var versionId = charIDToTypeID("Vrsn");
action.putInteger(versionId, 5),
executeAction(mkId, action, DialogModes.NO);
