<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to use GetBoundingBox ? in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-use-getboundingbox/m-p/5911227#M37912</link>
    <description>&lt;P&gt;I have a C# Navisworks 2016 plugin that uses Autocad 2016 automation. I read a handle string of an entity from Navisworks and get the corresponding object in autocad with&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Autodesk.AutoCAD.Interop.Common.AcadObject ThePart = TheDoc.HandleToObject(HandleToZoom);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;then I try to get the bounding box of the entity with&lt;/P&gt;&lt;P&gt;Autodesk.AutoCAD.Interop.Common.AcadEntity TheEnt = (Autodesk.AutoCAD.Interop.Common.AcadEntity)ThePart;&lt;/P&gt;&lt;P&gt;object a;&lt;/P&gt;&lt;P&gt;object b;&lt;/P&gt;&lt;P&gt;TheEnt.GetBoundingBox(out a, out b);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but the GetBoundinBox throws an exception 8020001C&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Late binding doesn’t work either,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;double[] aMinPoint = new double[3], aMaxPoint = new double[3];&lt;/P&gt;&lt;P&gt;object[] Params = new object[] { aMinPoint, aMaxPoint };&lt;/P&gt;&lt;P&gt;TheEnt.GetType().InvokeMember("GetBoundingBox", System.Reflection.BindingFlags.InvokeMethod, null, TheEnt, Params);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;throws an exception too.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to use the GetBoundingBox correctly?&lt;/P&gt;</description>
    <pubDate>Tue, 17 Nov 2015 07:00:15 GMT</pubDate>
    <dc:creator>JanneTS</dc:creator>
    <dc:date>2015-11-17T07:00:15Z</dc:date>
    <item>
      <title>How to use GetBoundingBox ?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-use-getboundingbox/m-p/5911227#M37912</link>
      <description>&lt;P&gt;I have a C# Navisworks 2016 plugin that uses Autocad 2016 automation. I read a handle string of an entity from Navisworks and get the corresponding object in autocad with&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Autodesk.AutoCAD.Interop.Common.AcadObject ThePart = TheDoc.HandleToObject(HandleToZoom);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;then I try to get the bounding box of the entity with&lt;/P&gt;&lt;P&gt;Autodesk.AutoCAD.Interop.Common.AcadEntity TheEnt = (Autodesk.AutoCAD.Interop.Common.AcadEntity)ThePart;&lt;/P&gt;&lt;P&gt;object a;&lt;/P&gt;&lt;P&gt;object b;&lt;/P&gt;&lt;P&gt;TheEnt.GetBoundingBox(out a, out b);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but the GetBoundinBox throws an exception 8020001C&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Late binding doesn’t work either,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;double[] aMinPoint = new double[3], aMaxPoint = new double[3];&lt;/P&gt;&lt;P&gt;object[] Params = new object[] { aMinPoint, aMaxPoint };&lt;/P&gt;&lt;P&gt;TheEnt.GetType().InvokeMember("GetBoundingBox", System.Reflection.BindingFlags.InvokeMethod, null, TheEnt, Params);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;throws an exception too.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to use the GetBoundingBox correctly?&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2015 07:00:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-use-getboundingbox/m-p/5911227#M37912</guid>
      <dc:creator>JanneTS</dc:creator>
      <dc:date>2015-11-17T07:00:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to use GetBoundingBox ?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-use-getboundingbox/m-p/5911961#M37913</link>
      <description>&lt;P&gt;Following code, using COM API in a .NET add-in command method, works OK with my AutoCAD2015/2016:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;public class Commands
    {

        [CommandMethod("BBox")]
        public static void DoDocumentCommand()
        {
            Document dwg = CadApp.DocumentManager.MdiActiveDocument;
            Editor ed = dwg.Editor;

            try
            {
                //Get COM object: AcadDocument
                AcadDocument doc = (AcadDocument)Autodesk.AutoCAD.ApplicationServices.DocumentExtension.GetAcadDocument(dwg);

                //Select an entity
                object ent;
                object point;
                doc.Utility.GetEntity(out ent, out point, "\nSelect an entity:");
                ed.WriteMessage("\nSelected entity is: {0}", (ent as AcadEntity).EntityName);

                //Get AcadEntity's bounding box
                object minPt;
                object maxPt;
                (ent as AcadEntity).GetBoundingBox(out minPt, out maxPt);
                ed.WriteMessage("\nMin point: {0}, {1}", (minPt as double[])[0], (minPt as double[])[1]);
                ed.WriteMessage("\nMax point: {0}, {1}", (maxPt as double[])[0], (maxPt as double[])[1]);
            }
            catch (Autodesk.AutoCAD.Runtime.Exception aex)
            {
                ed.WriteMessage("\nError: {0}", aex.Message);
                ed.WriteMessage("\n*Cancel*");
            }
            catch (System.Exception ex)
            {
                ed.WriteMessage("\nError: {0}", ex.Message);
                ed.WriteMessage("\n*Cancel*");
            }
            finally
            {
                Autodesk.AutoCAD.Internal.Utils.PostCommandPrompt();
            }
        }
    }&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Nov 2015 15:31:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-use-getboundingbox/m-p/5911961#M37913</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2015-11-17T15:31:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to use GetBoundingBox ?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-use-getboundingbox/m-p/5913446#M37914</link>
      <description>&lt;P&gt;Thanks. My problem still remains though. Now I have noticed that the exception happens only in case of 3rd party custom objects. I wonder if it's a bug or a feature that GetBoundingBox fails with custom objects?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I don't really need the bounding box after all, I need the part location in WCS. How to get the location of an entity via COM API, if I know it's handle?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2015 12:00:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-use-getboundingbox/m-p/5913446#M37914</guid>
      <dc:creator>JanneTS</dc:creator>
      <dc:date>2015-11-18T12:00:23Z</dc:date>
    </item>
  </channel>
</rss>

