... something simple in c#:
[CommandMethod("SHOLON")]
public void cmd_shortestLongestLines()
{
var e = AcadApp.DocumentManager.MdiActiveDocument.Editor;
TypedValue[] tv = { new TypedValue((int)DxfCode.Start, "LINE") };
var filter = new SelectionFilter(tv);
var options = new PromptSelectionOptions
{
MessageForAdding = "\nAdd lines to selection",
MessageForRemoval = "\nRemove lines from selection",
AllowDuplicates = false,
RejectObjectsFromNonCurrentSpace = true
};
var psr = e.GetSelection(options, filter);
if (psr.Status != PromptStatus.OK) return;
var sw = new Stopwatch();
var pairs = new SortedList<double, ObjectId>();
using (var tr = e.Document.Database.TransactionManager.StartTransaction())
{
sw.Start();
foreach (var id in psr.Value.GetObjectIds())
{
var line = tr.GetObject(id, OpenMode.ForRead) as Line;
if (line != null)
{
pairs.Add(line.Length, id);
}
}
pairs.RemoveAt(0);
pairs.RemoveAt(pairs.Count - 1);
foreach (var pair in pairs)
{
tr.GetObject(pair.Value, OpenMode.ForWrite).Erase();
}
sw.Stop();
tr.Commit();
}
e.WriteMessage("\nElapsed.TotalMilliseconds={0} \n", sw.Elapsed.TotalMilliseconds);
}
Elapsed.TotalMilliseconds=1320.1172