How to set corners (free transform) to smart layer by script?
Hi,
Below is the code that is getting smart object corners coordinates (from free transform). How I can take these corners and apply to another smart object? Can anyone help with the SET function?
You can simply run this code on your side to get complete understanding of what I mean. It's 4 relative coordinates of four corners when you move each corner independently in Free Transform. (Hold Option/Control + drag the corner point).
Example :

function get_smart_object_corners(layer) {
try
{
if(layer.kind == LayerKind.SMARTOBJECT)
{
var layer0 = activeDocument.activeLayer;
activeDocument.activeLayer = layer;
var r = new ActionReference();
r.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
var d;
try { d = executeActionGet(r); } catch (e) { alert(e); return; }
try { d = d.getObjectValue(stringIDToTypeID("smartObjectMore"));} catch (e) { alert(e); return; }
try { d = d.getList(stringIDToTypeID("nonAffineTransform"));} catch (e) { alert(e); return; }
var ret = [ [UnitValue(d.getDouble(0), "px"), UnitValue(d.getDouble(1), "px")],
[UnitValue(d.getDouble(2), "px"), UnitValue(d.getDouble(3), "px")],
[UnitValue(d.getDouble(4), "px"), UnitValue(d.getDouble(5), "px")],
[UnitValue(d.getDouble(6), "px"), UnitValue(d.getDouble(7), "px")] ];
activeDocument.activeLayer = layer0;
return ret;
}
else return layer.boundsNoEffects;
}
catch (e) { alert(e); }
}
