<?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: How to calculate the length and width of a block definition? in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-calculate-the-length-and-width-of-a-block-definition/m-p/12335147#M6786</link>
    <description>&lt;P&gt;maybe you're looking for BlockReference.GeometryExtentsBestFit()&amp;nbsp; ?&lt;/P&gt;&lt;P&gt;that applies a transformation, otherwise you can iterate the block and get the extent of each entity.&lt;/P&gt;</description>
    <pubDate>Fri, 27 Oct 2023 10:14:48 GMT</pubDate>
    <dc:creator>daniel_cadext</dc:creator>
    <dc:date>2023-10-27T10:14:48Z</dc:date>
    <item>
      <title>How to calculate the length and width of a block definition?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-calculate-the-length-and-width-of-a-block-definition/m-p/12335021#M6785</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I am using the following code to calculate the dimensions of a block definition, but 'bounds' is always null. What could be the issue?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The blockReference object is obtained through Editor.GetSelection()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;double width = 0;
double height = 0;
Database db = HostApplicationServices.WorkingDatabase;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
    BlockReference blockRef = blockReference.ObjectId.GetObject(AcDb.OpenMode.ForRead) as BlockReference;
    if (blockRef != null)
    {
        string blockName = blockRef.Name;
        BlockTable blockTable = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
        if (blockTable.Has(blockName))
        {
            ObjectId blockDefId = blockTable[blockName];
            BlockTableRecord blockDef = tr.GetObject(blockDefId, OpenMode.ForRead) as BlockTableRecord;

            if (blockDef != null)
            {
                Extents3d? bounds = blockDef.Bounds;
                if (bounds != null)
                {
                    width = bounds.Value.MaxPoint.X - bounds.Value.MinPoint.X;
                    height = bounds.Value.MaxPoint.Y - bounds.Value.MinPoint.Y;
                }
                else
                {
                     AcAp.ShowAlertDialog("Block Bounds is null.\n");
                }
            }
       }
       tr.Commit();
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2023 08:59:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-calculate-the-length-and-width-of-a-block-definition/m-p/12335021#M6785</guid>
      <dc:creator>zhengyunyang2019</dc:creator>
      <dc:date>2023-10-27T08:59:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the length and width of a block definition?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-calculate-the-length-and-width-of-a-block-definition/m-p/12335147#M6786</link>
      <description>&lt;P&gt;maybe you're looking for BlockReference.GeometryExtentsBestFit()&amp;nbsp; ?&lt;/P&gt;&lt;P&gt;that applies a transformation, otherwise you can iterate the block and get the extent of each entity.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2023 10:14:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-calculate-the-length-and-width-of-a-block-definition/m-p/12335147#M6786</guid>
      <dc:creator>daniel_cadext</dc:creator>
      <dc:date>2023-10-27T10:14:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the length and width of a block definition?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-calculate-the-length-and-width-of-a-block-definition/m-p/12342259#M6787</link>
      <description>&lt;LI-CODE lang="csharp"&gt;var br = new Block reference(blockdefId, Point3d.Origin);
var bound = br.bound.value;&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 31 Oct 2023 03:19:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-calculate-the-length-and-width-of-a-block-definition/m-p/12342259#M6787</guid>
      <dc:creator>cuongtk2</dc:creator>
      <dc:date>2023-10-31T03:19:59Z</dc:date>
    </item>
  </channel>
</rss>

