<?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 Re: GetBoundingBox by name in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666364#M65885</link>
    <description>BlockReference.BlockName is not the same as BlockReference.Name. The latter is the same as the block definition's name, which the BlockReference is created up on.</description>
    <pubDate>Thu, 15 Apr 2010 19:06:55 GMT</pubDate>
    <dc:creator>norman.yuan</dc:creator>
    <dc:date>2010-04-15T19:06:55Z</dc:date>
    <item>
      <title>GetBoundingBox by name</title>
      <link>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666348#M65869</link>
      <description>I am converting a VB6 out-of-process program to a C# in-process one.  The program looks for a specific block in the drawing called "border" and uses the GetBoundingBox to set the plot window.  I am able to determine if "border" is in the drawing thanks to the post "Is block in drawing" by RolandF.  I still need to work on checking if the block has been erased.  I got the IsItThere code from here too.  Originally I started with the LateBoundComSample.cs by Tony Tanzillo but that kept giving me errors and I found the GeometricExtents somewhere in this group.  I apologize for not giving credit on that one, I cannot remember which post it was.  However, now AutoCAD crashes on the line Point3d btl = e.GeometricExtents.MinPoint; as far as I can tell since debugging does not stop on the line.  I stepped through the code and it seems to crash as soon as I step through that line.  The original code had a PromptEntityResult and it works fine so I just changed that with my object.&lt;BR /&gt;
&lt;BR /&gt;
Any suggestions?&lt;BR /&gt;
&lt;BR /&gt;
            public void IsItThere()&lt;BR /&gt;
            {&lt;BR /&gt;
                Document doc = Application.DocumentManager.MdiActiveDocument;&lt;BR /&gt;
                Editor ed = doc.Editor;&lt;BR /&gt;
                ObjectId objid = new ObjectId();&lt;BR /&gt;
                bool ret = IsBlockInDrawing("border", out objid);&lt;BR /&gt;
                &lt;BR /&gt;
                if (ret)&lt;BR /&gt;
                {&lt;BR /&gt;
                    using (Transaction tr = doc.TransactionManager.StartTransaction())&lt;BR /&gt;
                    {&lt;BR /&gt;
                        ed.WriteMessage("Border is in the drawing");&lt;BR /&gt;
                        Entity e = objid.GetObject(OpenMode.ForRead) as Entity;&lt;BR /&gt;
                        Point3d btl = e.GeometricExtents.MinPoint;&lt;BR /&gt;
                        Point3d tpr = e.GeometricExtents.MaxPoint;&lt;BR /&gt;
                        ed.WriteMessage("\nlowerLeftCorner  = {0}", btl);&lt;BR /&gt;
                        ed.WriteMessage("\nupperRightCorner = {0}", tpr);&lt;BR /&gt;
&lt;BR /&gt;
                        tr.Commit();&lt;BR /&gt;
                    }&lt;BR /&gt;
                }&lt;BR /&gt;
                else&lt;BR /&gt;
                    ed.WriteMessage("Border is NOT in the drawing");&lt;BR /&gt;
            }&lt;BR /&gt;
&lt;BR /&gt;
            public bool IsBlockInDrawing(string BlockName, out ObjectId BlockId)&lt;BR /&gt;
            {&lt;BR /&gt;
                Database db = Application.DocumentManager.MdiActiveDocument.Database;&lt;BR /&gt;
&lt;BR /&gt;
                bool BlockIsInDrawing = false;&lt;BR /&gt;
                BlockId = new ObjectId();&lt;BR /&gt;
                &lt;BR /&gt;
                using (Transaction tr = db.TransactionManager.StartTransaction())&lt;BR /&gt;
                using (BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead, false))&lt;BR /&gt;
                {&lt;BR /&gt;
                    try&lt;BR /&gt;
                    {&lt;BR /&gt;
                        BlockId = bt[BlockName];&lt;BR /&gt;
                        &lt;BR /&gt;
                        using (BlockTableRecord btr = (BlockTableRecord)tr.GetObject(BlockId, OpenMode.ForRead, false))&lt;BR /&gt;
                        {&lt;BR /&gt;
                            if (!btr.IsLayout &amp;amp;&amp;amp; !btr.IsAnonymous &amp;amp;&amp;amp; !BlockId.IsErased)&lt;BR /&gt;
                                BlockIsInDrawing = true;&lt;BR /&gt;
                            &lt;BR /&gt;
                        }&lt;BR /&gt;
                    }&lt;BR /&gt;
                    catch&lt;BR /&gt;
                    {&lt;BR /&gt;
                    }&lt;BR /&gt;
                    tr.Commit();&lt;BR /&gt;
                    return BlockIsInDrawing;&lt;BR /&gt;
                }&lt;BR /&gt;
            }</description>
      <pubDate>Wed, 14 Apr 2010 18:34:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666348#M65869</guid>
      <dc:creator>pjones3</dc:creator>
      <dc:date>2010-04-14T18:34:50Z</dc:date>
    </item>
    <item>
      <title>Re: GetBoundingBox by name</title>
      <link>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666349#M65870</link>
      <description>I think you're confusing blocks and block references.&lt;BR /&gt;
&lt;BR /&gt;
You're trying to get the bounding box of the block, not&lt;BR /&gt;
an insertion of the block.&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD&lt;BR /&gt;
Supporting AutoCAD 2000 through 2011&lt;BR /&gt;
&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");&lt;BR /&gt;
&lt;BR /&gt;
&lt;PJONES&gt; wrote in message &lt;BR /&gt;
news:6372994@discussion.autodesk.com...&lt;BR /&gt;
I am converting a VB6 out-of-process program to a C# in-process one.  The &lt;BR /&gt;
program looks for a specific block in the drawing called "border" and uses the &lt;BR /&gt;
GetBoundingBox to set the plot window.  I am able to determine if "border" is in &lt;BR /&gt;
the drawing thanks to the post "Is block in drawing" by RolandF.  I still need &lt;BR /&gt;
to work on checking if the block has been erased.  I got the IsItThere code from &lt;BR /&gt;
here too.  Originally I started with the LateBoundComSample.cs by Tony Tanzillo &lt;BR /&gt;
but that kept giving me errors and I found the GeometricExtents somewhere in &lt;BR /&gt;
this group.  I apologize for not giving credit on that one, I cannot remember &lt;BR /&gt;
which post it was.  However, now AutoCAD crashes on the line Point3d btl = &lt;BR /&gt;
e.GeometricExtents.MinPoint; as far as I can tell since debugging does not stop &lt;BR /&gt;
on the line.  I stepped through the code and it seems to crash as soon as I step &lt;BR /&gt;
through that line.  The original code had a PromptEntityResult and it works fine &lt;BR /&gt;
so I just changed that with my object.&lt;BR /&gt;
&lt;BR /&gt;
Any suggestions?&lt;BR /&gt;
&lt;BR /&gt;
            public void IsItThere()&lt;BR /&gt;
            {&lt;BR /&gt;
                Document doc = Application.DocumentManager.MdiActiveDocument;&lt;BR /&gt;
                Editor ed = doc.Editor;&lt;BR /&gt;
                ObjectId objid = new ObjectId();&lt;BR /&gt;
                bool ret = IsBlockInDrawing("border", out objid);&lt;BR /&gt;
&lt;BR /&gt;
                if (ret)&lt;BR /&gt;
                {&lt;BR /&gt;
                    using (Transaction tr = &lt;BR /&gt;
doc.TransactionManager.StartTransaction())&lt;BR /&gt;
                    {&lt;BR /&gt;
                        ed.WriteMessage("Border is in the drawing");&lt;BR /&gt;
                        Entity e = objid.GetObject(OpenMode.ForRead) as Entity;&lt;BR /&gt;
                        Point3d btl = e.GeometricExtents.MinPoint;&lt;BR /&gt;
                        Point3d tpr = e.GeometricExtents.MaxPoint;&lt;BR /&gt;
                        ed.WriteMessage("\nlowerLeftCorner  = {0}", btl);&lt;BR /&gt;
                        ed.WriteMessage("\nupperRightCorner = {0}", tpr);&lt;BR /&gt;
&lt;BR /&gt;
                        tr.Commit();&lt;BR /&gt;
                    }&lt;BR /&gt;
                }&lt;BR /&gt;
                else&lt;BR /&gt;
                    ed.WriteMessage("Border is NOT in the drawing");&lt;BR /&gt;
            }&lt;BR /&gt;
&lt;BR /&gt;
            public bool IsBlockInDrawing(string BlockName, out ObjectId BlockId)&lt;BR /&gt;
            {&lt;BR /&gt;
                Database db = &lt;BR /&gt;
Application.DocumentManager.MdiActiveDocument.Database;&lt;BR /&gt;
&lt;BR /&gt;
                bool BlockIsInDrawing = false;&lt;BR /&gt;
                BlockId = new ObjectId();&lt;BR /&gt;
&lt;BR /&gt;
                using (Transaction tr = &lt;BR /&gt;
db.TransactionManager.StartTransaction())&lt;BR /&gt;
                using (BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, &lt;BR /&gt;
OpenMode.ForRead, false))&lt;BR /&gt;
                {&lt;BR /&gt;
                    try&lt;BR /&gt;
                    {&lt;BR /&gt;
                        BlockId = bt[BlockName];&lt;BR /&gt;
&lt;BR /&gt;
                        using (BlockTableRecord btr = &lt;BR /&gt;
(BlockTableRecord)tr.GetObject(BlockId, OpenMode.ForRead, false))&lt;BR /&gt;
                        {&lt;BR /&gt;
                            if (!btr.IsLayout &amp;amp;&amp;amp; !btr.IsAnonymous &amp;amp;&amp;amp; &lt;BR /&gt;
!BlockId.IsErased)&lt;BR /&gt;
                                BlockIsInDrawing = true;&lt;BR /&gt;
&lt;BR /&gt;
                        }&lt;BR /&gt;
                    }&lt;BR /&gt;
                    catch&lt;BR /&gt;
                    {&lt;BR /&gt;
                    }&lt;BR /&gt;
                    tr.Commit();&lt;BR /&gt;
                    return BlockIsInDrawing;&lt;BR /&gt;
                }&lt;BR /&gt;
            }&lt;/PJONES&gt;</description>
      <pubDate>Wed, 14 Apr 2010 18:59:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666349#M65870</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-04-14T18:59:07Z</dc:date>
    </item>
    <item>
      <title>Re: GetBoundingBox by name</title>
      <link>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666350#M65871</link>
      <description>Firstly, you may want to make sure you can distinguish block and block refernece (BlockTableRecord and BlockReference object in .NET API). IN your case, you need to find GeometricExtents of a BlockReference, which is defined by block (BlockTableRecord) named as "Border". The output argument of IsBlockInDrawing() method gives you an OBjectID of a BlockTableRecord, not of a BlockReference, hence the error. &lt;BR /&gt;
&lt;BR /&gt;
Also, when you do something like &lt;BR /&gt;
&lt;BR /&gt;
Entity e = objid.GetObject(OpenMode.ForRead) as Entity;&lt;BR /&gt;
&lt;BR /&gt;
You need to test if the casting by "as" returns wanted object or null. In your case, since you obtained wrong ObjectId from IsBlockInDrawing() method, e will be null. if you coded like this:&lt;BR /&gt;
&lt;BR /&gt;
{code}&lt;BR /&gt;
&lt;BR /&gt;
Entity e = objid.GetObject(OpenMode.ForRead) as Entity;&lt;BR /&gt;
if (e!=null)&lt;BR /&gt;
{&lt;BR /&gt;
  //Go ahead to get GeometricExtents&lt;BR /&gt;
}&lt;BR /&gt;
else&lt;BR /&gt;
{&lt;BR /&gt;
  //You did not get the BlockReference entity, thus, you cannot get GeometricExtents information.&lt;BR /&gt;
}&lt;BR /&gt;
{code}</description>
      <pubDate>Wed, 14 Apr 2010 19:02:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666350#M65871</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2010-04-14T19:02:56Z</dc:date>
    </item>
    <item>
      <title>Re: GetBoundingBox by name</title>
      <link>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666351#M65872</link>
      <description>Firstly, you may want to make sure you can distinguish block and block refernece (BlockTableRecord and BlockReference object in .NET API). IN your case, you need to find GeometricExtents of a BlockReference, which is defined by block (BlockTableRecord) named as "Border". The output argument of IsBlockInDrawing() method gives you an OBjectID of a BlockTableRecord, not of a BlockReference, hence the error. &lt;BR /&gt;
&lt;BR /&gt;
Also, when you do something like &lt;BR /&gt;
&lt;BR /&gt;
Entity e = objid.GetObject(OpenMode.ForRead) as Entity;&lt;BR /&gt;
&lt;BR /&gt;
You need to test if the casting by "as" returns wanted object or null. In your case, since you obtained wrong ObjectId from IsBlockInDrawing() method, e will be null. if you coded like this:&lt;BR /&gt;
&lt;BR /&gt;
{code}&lt;BR /&gt;
&lt;BR /&gt;
Entity e = objid.GetObject(OpenMode.ForRead) as Entity;&lt;BR /&gt;
if (e!=null)&lt;BR /&gt;
{&lt;BR /&gt;
  //Go ahead to get GeometricExtents&lt;BR /&gt;
}&lt;BR /&gt;
else&lt;BR /&gt;
{&lt;BR /&gt;
  //You did not get the BlockReference entity, thus, you cannot get GeometricExtents information.&lt;BR /&gt;
}&lt;BR /&gt;
{code}</description>
      <pubDate>Wed, 14 Apr 2010 19:02:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666351#M65872</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2010-04-14T19:02:57Z</dc:date>
    </item>
    <item>
      <title>Re: GetBoundingBox by name</title>
      <link>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666352#M65873</link>
      <description>Thanks for the reply.  Don't I want to get the insertion of the block to test if the block is actually still in the drawing?  Then I can use the block reference to get the bounding box.  Or am I still confusing this whole thing?  I have tried to find good books to study up on this but my local B&amp;amp;N doesn't seem to have anything.&lt;BR /&gt;
&lt;BR /&gt;
Patrick</description>
      <pubDate>Wed, 14 Apr 2010 19:16:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666352#M65873</guid>
      <dc:creator>pjones3</dc:creator>
      <dc:date>2010-04-14T19:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: GetBoundingBox by name</title>
      <link>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666353#M65874</link>
      <description>Thanks for the reply.  I think I understand what you are saying.  So I should do something like casting the BlockID to a BlockReference? Like&lt;BR /&gt;
using (BlockReference bt = (BlockReference)tr.GetObject(BlockId, OpenMode.ForRead, false))</description>
      <pubDate>Wed, 14 Apr 2010 19:31:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666353#M65874</guid>
      <dc:creator>pjones3</dc:creator>
      <dc:date>2010-04-14T19:31:04Z</dc:date>
    </item>
    <item>
      <title>Re: GetBoundingBox by name</title>
      <link>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666354#M65875</link>
      <description>Thanks for the reply.  I think I understand what you are saying.  So I should do something like casting the BlockID to a BlockReference? Like&lt;BR /&gt;
using (BlockReference bt = (BlockReference)tr.GetObject(BlockId, OpenMode.ForRead, false))</description>
      <pubDate>Wed, 14 Apr 2010 19:31:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666354#M65875</guid>
      <dc:creator>pjones3</dc:creator>
      <dc:date>2010-04-14T19:31:05Z</dc:date>
    </item>
    <item>
      <title>Re: GetBoundingBox by name</title>
      <link>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666355#M65876</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
Read Tony's first post again and again - reinforced by the help files &lt;BR /&gt;
until you understand the difference between a block and a block reference.&lt;BR /&gt;
&lt;BR /&gt;
Until you understand this, no knowledge of programming code will save you.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Regards&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Laurie Comerford&lt;BR /&gt;
&lt;BR /&gt;
pjones@newcomb-boyd.com wrote:&lt;BR /&gt;
&amp;gt; Thanks for the reply.  I think I understand what you are saying.  So I should do something like casting the BlockID to a BlockReference? Like&lt;BR /&gt;
&amp;gt; using (BlockReference bt = (BlockReference)tr.GetObject(BlockId, OpenMode.ForRead, false))</description>
      <pubDate>Wed, 14 Apr 2010 21:29:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666355#M65876</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-04-14T21:29:43Z</dc:date>
    </item>
    <item>
      <title>Re: GetBoundingBox by name</title>
      <link>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666356#M65877</link>
      <description>Unlike most, I like traffic.  It gives me some solitude so I can think about things without someone bothering me every 10 minutes about a computer problem &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
I think I finally understand what you are saying.  The BlockTable is basically all the blocks in the drawing, both definitions and insertions.  The BlockTableRecord is the block definition and the BlockReference is information about each individual block insertion in the drawing.  So it would be something like BlockTable--&amp;gt;BlockTableRecord--&amp;gt;BlockReference.  So BlockId = bt[BlockName]; was just pointing to the location of the block definition in the block table and BlockTableRecord btr = (BlockTableRecord)tr.GetObject(BlockId, OpenMode.ForRead, false)) was returning the actual definition not the insertion.&lt;BR /&gt;
&lt;BR /&gt;
If I had AutoCAD at home I would try tonight.  However, since AutoCAD 2009 will not even install on Windows 2000, when I get to work tomorrow I will try to rewrite things so I get the block reference and not the definition.</description>
      <pubDate>Wed, 14 Apr 2010 21:42:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666356#M65877</guid>
      <dc:creator>pjones3</dc:creator>
      <dc:date>2010-04-14T21:42:50Z</dc:date>
    </item>
    <item>
      <title>Re: GetBoundingBox by name</title>
      <link>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666357#M65878</link>
      <description>Thanks for the reply.  I think I understand it.  I thought about it on my drive home from work.</description>
      <pubDate>Wed, 14 Apr 2010 22:00:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666357#M65878</guid>
      <dc:creator>pjones3</dc:creator>
      <dc:date>2010-04-14T22:00:42Z</dc:date>
    </item>
    <item>
      <title>Re: GetBoundingBox by name</title>
      <link>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666358#M65879</link>
      <description>I think you might want to consider taking the time to become&lt;BR /&gt;
more familiar with the managed API.&lt;BR /&gt;
&lt;BR /&gt;
No, you can't cast the block to a block referenece.&lt;BR /&gt;
&lt;BR /&gt;
You call GetBlockReferenceIds() on the BlockTableRecord&lt;BR /&gt;
to get the ids of all block references for the block.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD&lt;BR /&gt;
Supporting AutoCAD 2000 through 2011&lt;BR /&gt;
&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");&lt;BR /&gt;
&lt;BR /&gt;
&lt;PJONES&gt; wrote in message &lt;BR /&gt;
news:6373073@discussion.autodesk.com...&lt;BR /&gt;
Thanks for the reply.  I think I understand what you are saying.  So I should do &lt;BR /&gt;
something like casting the BlockID to a BlockReference? Like&lt;BR /&gt;
using (BlockReference bt = (BlockReference)tr.GetObject(BlockId, &lt;BR /&gt;
OpenMode.ForRead, false))&lt;/PJONES&gt;</description>
      <pubDate>Wed, 14 Apr 2010 23:22:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666358#M65879</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-04-14T23:22:37Z</dc:date>
    </item>
    <item>
      <title>Re: GetBoundingBox by name</title>
      <link>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666359#M65880</link>
      <description>Thanks.  I didn't really think I could do that cast.  It was just a shot in the dark.  Trying to create this program is part of my learning by doing.&lt;BR /&gt;
&lt;BR /&gt;
I have been looking for some good documentation on the managed API.  Do you have any suggestions?</description>
      <pubDate>Thu, 15 Apr 2010 01:04:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666359#M65880</guid>
      <dc:creator>pjones3</dc:creator>
      <dc:date>2010-04-15T01:04:38Z</dc:date>
    </item>
    <item>
      <title>Re: GetBoundingBox by name</title>
      <link>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666360#M65881</link>
      <description>There's an online reference guide that includes&lt;BR /&gt;
plenty of sample code. No URL handy, but somone&lt;BR /&gt;
should be able to give you the link.&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD&lt;BR /&gt;
Supporting AutoCAD 2000 through 2011&lt;BR /&gt;
&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");&lt;BR /&gt;
&lt;BR /&gt;
&lt;PJONES&gt; wrote in message&lt;BR /&gt;
news:6373270@discussion.autodesk.com...&lt;BR /&gt;
Thanks.  I didn't really think I could do that cast.  It was just a shot in the&lt;BR /&gt;
dark.  Trying to create this program is part of my learning by doing.&lt;BR /&gt;
&lt;BR /&gt;
I have been looking for some good documentation on the managed API.  Do you have&lt;BR /&gt;
any suggestions?&lt;/PJONES&gt;</description>
      <pubDate>Thu, 15 Apr 2010 16:00:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666360#M65881</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-04-15T16:00:25Z</dc:date>
    </item>
    <item>
      <title>Re: GetBoundingBox by name</title>
      <link>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666361#M65882</link>
      <description>Thanks.  I found a few things but I will keep looking.  I did rewrite the code to return a BlockReference.  I found where I needed to get the block table record for the block reference to determine the name of the block reference.  This seems, to me, a little round-about way to do this but it works.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
            public bool IsBlockInDrawing(string BlockName, out BlockReference br)&lt;BR /&gt;
            {&lt;BR /&gt;
                bool BlockIsInDrawing = false;&lt;BR /&gt;
                br = null;&lt;BR /&gt;
&lt;BR /&gt;
                Database db = Application.DocumentManager.MdiActiveDocument.Database;                &lt;BR /&gt;
&amp;nbsp; &amp;nbsp;             &lt;BR /&gt;
&amp;nbsp; &amp;nbsp;             using (Transaction tr = db.TransactionManager.StartTransaction()) {&lt;BR /&gt;
            &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;BR /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;              BlockTableRecord BTR = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead);&lt;BR /&gt;
            &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;BR /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;             foreach (ObjectId id in BTR) {&lt;BR /&gt;
            &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;BR /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;             Entity ent = (Entity)tr.GetObject(id, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead);&lt;BR /&gt;
            &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;BR /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;             if ((ent is BlockReference) &amp;amp;&amp;amp; (!ent.IsErased))&lt;BR /&gt;
                        {&lt;BR /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;             br = (BlockReference)ent;&lt;BR /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;             BlockTableRecord mbtr = (BlockTableRecord)tr.GetObject(br.BlockTableRecord, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead);&lt;BR /&gt;
                            if (mbtr.Name == BlockName)&lt;BR /&gt;
                            {&lt;BR /&gt;
                                return BlockIsInDrawing = true;&lt;BR /&gt;
                            }&lt;BR /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;             }&lt;BR /&gt;
            &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;BR /&gt;
&amp;nbsp; &amp;nbsp;             }&lt;BR /&gt;
                return BlockIsInDrawing;&lt;BR /&gt;
            &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;BR /&gt;
            }</description>
      <pubDate>Thu, 15 Apr 2010 16:37:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666361#M65882</guid>
      <dc:creator>pjones3</dc:creator>
      <dc:date>2010-04-15T16:37:06Z</dc:date>
    </item>
    <item>
      <title>Re: GetBoundingBox by name</title>
      <link>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666362#M65883</link>
      <description>When looping through all entities in the targeting space for BlockReference, once you find a BlockReference, you do not need to trace it back to its block definition to determine block name: a BlockReference object has "Name" property, which is the same as corrsponding BlockTableRecord's name.&lt;BR /&gt;
&lt;BR /&gt;
However, if the block is a dynamic block, the BlockReference you are looking at hand may be a reference to an anonymous block definition created according to the dynamic block definition. You need to go further to to find out the dynamic block definition's name.&lt;BR /&gt;
&lt;BR /&gt;
Since your goal is to find the block reference's GeometricExtents, you may want to loop through the entire targeting space (not just quit the loop at the first found block reference) to make sure there is no more than one block reference of this name found, so that you get reliable GeometricExtents information.</description>
      <pubDate>Thu, 15 Apr 2010 17:52:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666362#M65883</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2010-04-15T17:52:53Z</dc:date>
    </item>
    <item>
      <title>Re: GetBoundingBox by name</title>
      <link>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666363#M65884</link>
      <description>Thanks for the reply.  When I first did the program I did not go back through the block table.  I had used br.BlockName and all it returned was *Model_Space.  Is there something else I should use?&lt;BR /&gt;
&lt;BR /&gt;
I understand what you are saying about looping through all the blocks but then I would not be able to know which one if the "correct" reference.  The way our CAD is setup, if there is more than one block of the same name they should all have the same GeometricExtents.  If not, the border will be very visible and the users would wonder why there is a white block going through the middle of their drawing or why the border block is much bigger than their sheet.</description>
      <pubDate>Thu, 15 Apr 2010 19:02:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666363#M65884</guid>
      <dc:creator>pjones3</dc:creator>
      <dc:date>2010-04-15T19:02:31Z</dc:date>
    </item>
    <item>
      <title>Re: GetBoundingBox by name</title>
      <link>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666364#M65885</link>
      <description>BlockReference.BlockName is not the same as BlockReference.Name. The latter is the same as the block definition's name, which the BlockReference is created up on.</description>
      <pubDate>Thu, 15 Apr 2010 19:06:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666364#M65885</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2010-04-15T19:06:55Z</dc:date>
    </item>
    <item>
      <title>Re: GetBoundingBox by name</title>
      <link>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666365#M65886</link>
      <description>Thanks for the reply.  I was thinking it should be Name but for some reason I chose BlockName.  Either that was a holdover from when I was using the BlockTableRecord or it was the first thing that showed up with name in it after I typed br.  I will try br.Name when I get into work tomorrow.  I am curious to what BlockReference.BlockName refers.  I am guessing, since it said *Model_Space, that it is the block which holds the BlockReference.  I will have to do some research on it.</description>
      <pubDate>Thu, 15 Apr 2010 21:10:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666365#M65886</guid>
      <dc:creator>pjones3</dc:creator>
      <dc:date>2010-04-15T21:10:44Z</dc:date>
    </item>
    <item>
      <title>Re: GetBoundingBox by name</title>
      <link>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666366#M65887</link>
      <description>If you're still interested I think this might be the online documentation Tony is talking about...&lt;BR /&gt;&lt;BR /&gt;
&lt;A href="http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%20.NET%20Developer's%20Guide/index.html" target="_newWindow" class="jive-link-external"&gt;http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%20.NET%20Developer's%20Guide/index.html&lt;/A&gt;</description>
      <pubDate>Mon, 19 Apr 2010 15:05:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666366#M65887</guid>
      <dc:creator>Paulio</dc:creator>
      <dc:date>2010-04-19T15:05:35Z</dc:date>
    </item>
    <item>
      <title>Re: GetBoundingBox by name</title>
      <link>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666367#M65888</link>
      <description>Thanks for the information.  I will give it a read.  I have looked through some of the videos on the Autodesk website.</description>
      <pubDate>Mon, 19 Apr 2010 15:18:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getboundingbox-by-name/m-p/2666367#M65888</guid>
      <dc:creator>pjones3</dc:creator>
      <dc:date>2010-04-19T15:18:54Z</dc:date>
    </item>
  </channel>
</rss>

