Below code shows the procedure to use activeX API GetBoundingBox in AutoCAD.NET. As GetBoundingBox returns the points, we need to "InvokeMember" member with "ParameterModifier" parameters.
[CommandMethod("GetBoundingBox")]
static public void GetBoundingBox()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
PromptEntityOptions options =
new PromptEntityOptions("\nSelect an entity");
PromptEntityResult acSSPrompt = ed.GetEntity(options);
if (acSSPrompt.Status != PromptStatus.OK)
return;
// obtain transaction manager
using (Transaction Tx = db.TransactionManager.StartTransaction())
{
Entity text = Tx.GetObject(acSSPrompt.ObjectId,
OpenMode.ForRead) as Entity;
object oAcadObjpl1 = text.AcadObject;
object[] argspl1 = new object[2];
argspl1[0] = new VariantWrapper(0);
argspl1[1] = new VariantWrapper(0);
ParameterModifier pmpl1 = new ParameterModifier(2);
pmpl1[0] = true;
pmpl1[1] = true;
ParameterModifier[] modifierspl1 =
new ParameterModifier[] { pmpl1 };
oAcadObjpl1.GetType().InvokeMember("GetBoundingBox",
BindingFlags.InvokeMethod, null, oAcadObjpl1, argspl1,
modifierspl1, null, null);
Point3d pt1 =
new Point3d((double[])argspl1[0]);
Point3d pt2 =
new Point3d((double[])argspl1[1]);
ed.WriteMessage("\n");
ed.WriteMessage(pt1.X + "," + pt1.Y + "," + pt1.Z + "\n");
ed.WriteMessage(pt2.X + "," + pt2.Y + "," + pt2.Z + "\n");
Tx.Commit();
}
}