Returned Action Descriptor has no keys
Hi everyone and thanks for your support,
I made a Action Descriptor for a perspective cropping tool (Using CS6). It receives the corner points and the middle point. When the action is executed, the user can change the corner points and crop the selection. The return value from executeAction is stored under a new Action Descriptor. Howeever, this Action Descriptor is empty and holds no keys. I would have expected it to hold the keys with the new corner point values.
Code is below.
app.preferences.rulerUnits = Units.PIXELS
var srcDoc = app.activeDocument;
var width = srcDoc.width;
var height = srcDoc.height;
var m1, m2, x1, x2, x3, x4, y1, y2, y3, y4;
var settings_dflt=[m1, m2, x1, y1, x2, y2, x3, y3, x4, y4];
settings_dflt = [width/2,height/2,0,0,width,0,width,height,0,height];
var actionDescriptor=new ActionDescriptor();
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
function defaultActionDesciptor(Fa){
var Ga=new ActionDescriptor();
var Ha=new ActionDescriptor();
var Ia=new ActionDescriptor();
Ia.putUnitDouble(cTID('Hrzn'),cTID('#Pxl'),Fa[0]);
Ia.putUnitDouble(cTID('Vrtc'),cTID('#Pxl'),Fa[1]);
Ha.putObject(cTID('Cntr'),cTID('Pnt '),Ia);
var Ja=new ActionDescriptor();
Ja.putUnitDouble(cTID('Hrzn'),cTID('#Pxl'),Fa[2]);
Ja.putUnitDouble(cTID('Vrtc'),cTID('#Pxl'),Fa[3]);
Ha.putObject(sTID('quadCorner0'),cTID('Ofst'),Ja);
var Ka=new ActionDescriptor();
Ka.putUnitDouble(cTID('Hrzn'),cTID('#Pxl'),Fa[4]);
Ka.putUnitDouble(cTID('Vrtc'),cTID('#Pxl'),Fa[5]);
Ha.putObject(sTID('quadCorner1'),cTID('Ofst'),Ka);
var La=new ActionDescriptor();
La.putUnitDouble(cTID('Hrzn'),cTID('#Pxl'),Fa[6]);
La.putUnitDouble(cTID('Vrtc'),cTID('#Pxl'),Fa[7]);
Ha.putObject(sTID('quadCorner2'),cTID('Ofst'),La);
var Ma=new ActionDescriptor();
Ma.putUnitDouble(cTID('Hrzn'),cTID('#Pxl'),Fa[8]);
Ma.putUnitDouble(cTID('Vrtc'),cTID('#Pxl'),Fa[9]);
Ha.putObject(sTID('quadCorner3'),cTID('Ofst'),Ma);
Ga.putObject(cTID('T '),sTID('quadrilateral'),Ha);
Ga.putUnitDouble(cTID('Wdth'),cTID('#Pxl'),0.000000);
Ga.putUnitDouble(cTID('Hght'),cTID('#Pxl'),0.000000);
Ga.putUnitDouble(cTID('Rslt'),cTID('#Rsl'),0.000000);
return Ga;
}
//
function CallAppropriateAction() {
var fb = new ActionDescriptor();
try{
fb = executeAction(cTID('Crop'),actionDescriptor,DialogModes.ALL);
}
catch(e){
alert("User cancelled operation");
}
if(fb!=null){
srcDoc.selection.selectAll();
alert(fb.count + " = number of keys in fb\n" + fb.typename + " = type of fb")
}}
//
function main()
{
srcDoc.selection.selectAll();
actionDescriptor=defaultActionDesciptor(settings_dflt);
CallAppropriateAction();
}
//
app.activeDocument.suspendHistory("CropTool", "main()")</code>