i found that you and r-bin already answered me for something else that does the same thing! (thank you again)
select_max_selection();
function select_max_selection()
{
try {
// selection to workpath
var d = new ActionDescriptor();
var r = new ActionReference();
r.putClass(stringIDToTypeID("path"));
d.putReference(stringIDToTypeID("null"), r);
var r1 = new ActionReference();
r1.putProperty(stringIDToTypeID("selectionClass"), stringIDToTypeID("selection"));
d.putReference(stringIDToTypeID("from"), r1);
d.putUnitDouble(stringIDToTypeID("tolerance"), stringIDToTypeID("pixelsUnit"), 0.5);
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
// leave only one subpath with maximum points;
var d = new ActionDescriptor();
var r = new ActionReference();
r.putEnumerated(stringIDToTypeID("path"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var pth = executeActionGet(r).getObjectValue(stringIDToTypeID("pathContents"));
var lst = pth.getList(stringIDToTypeID("pathComponents"));
var list = new ActionList();
var len = lst.count;
var max;
var max_obj;
for (var i = 0; i < len; i++)
{
var obj = lst.getObjectValue(i);
var count = obj.getList(stringIDToTypeID("subpathListKey")).getObjectValue(0).getList(stringIDToTypeID("points")).count;
if (!max || max < count)
{
max = count;
max_obj = obj;
}
}
max_obj.putEnumerated(stringIDToTypeID("shapeOperation"), stringIDToTypeID("shapeOperation"), stringIDToTypeID("add") );
list.putObject(stringIDToTypeID("pathComponent"), max_obj);
var r = new ActionReference();
r.putProperty( charIDToTypeID( "Path" ), charIDToTypeID( "WrPt" ) );
d.putReference( stringIDToTypeID( "null" ), r );
d.putList(charIDToTypeID("T "), list);
executeAction(charIDToTypeID("setd"), d, DialogModes.NO);
// workpath to selection
var d = new ActionDescriptor();
var r = new ActionReference();
r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
d.putReference(stringIDToTypeID("null"), r);
var r1 = new ActionReference();
r1.putProperty(stringIDToTypeID("path"), stringIDToTypeID("workPath"));
d.putReference(stringIDToTypeID("to"), r1);
d.putBoolean(stringIDToTypeID("antiAlias"), true);
d.putUnitDouble(stringIDToTypeID("feather"), stringIDToTypeID("pixelsUnit"), 0);
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
// delete workpath
var doc = app.activeDocument;
for (var i = 0; i < doc.pathItems.length; i++)
{
if (doc.pathItems.kind == PathKind.WORKPATH)
{
doc.pathItems.remove();
break;
}
}
}
catch(e) { alert(e); }
}