Hi,
From the tests I did calling the UNION comand (directly or from code) is not faster than calling the Region.BooleanOperation.
[CommandMethod("TEST1")]
public void Test1()
{
var doc = Application.DocumentManager.MdiActiveDocument;
var db = doc.Database;
var ed = doc.Editor;
var filter = new SelectionFilter(new[] { new TypedValue(0, "REGION") });
var selection = ed.GetSelection(filter);
if (selection.Status == PromptStatus.OK)
{
var stopwatch = new Stopwatch();
stopwatch.Start();
using (var tr = db.TransactionManager.StartTransaction())
{
selection.Value.GetObjectIds()
.Select (id => (Region)tr.GetObject(id, OpenMode.ForWrite))
.Aggregate((r1, r2) =>
{
r1.BooleanOperation(BooleanOperationType.BoolUnite, r2);
return r1;
});
tr.Commit();
}
stopwatch.Stop();
ed.WriteMessage($"\nElapsed millisecond: {stopwatch.ElapsedMilliseconds} to union {selection.Value.Count} regions.");
}
}
[CommandMethod("TEST2")]
public void Test2()
{
var doc = Application.DocumentManager.MdiActiveDocument;
var db = doc.Database;
var ed = doc.Editor;
var filter = new SelectionFilter(new[] { new TypedValue(0, "REGION") });
var selection = ed.GetSelection(filter);
if (selection.Status == PromptStatus.OK)
{
var stopwatch = new Stopwatch();
stopwatch.Start();
ed.Command("_.UNION", selection.Value, "");
stopwatch.Stop();
ed.WriteMessage($"\nElapsed millisecond: {stopwatch.ElapsedMilliseconds} to union {selection.Value.Count} regions.");
}
}