<?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: Check block overlapping in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/check-block-overlapping/m-p/8812153#M22332</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems to me the problem is due to the way you iterate the collection.&lt;/P&gt;
&lt;P&gt;As is, your code only checks for intersection between each block and the the follwong one in the collection: (1, 2) (2, 3) (3, 4).&lt;/P&gt;
&lt;P&gt;If you want to check any possible combination: (1, 2) (1, 3) (1, 4) (2, 3) (2, 4) (3, 4), you have to do something laike this:&lt;/P&gt;
&lt;PRE&gt;            for (int i = 0; i &amp;lt; connectorElements.Count - 1; i++)
            {
                for (int j = i + 1; j &amp;lt; connectorElements.Count; j++)
                {
                    Entity blk = (Entity)tr.GetObject(db.GetObjectId(false, new Handle(Convert.ToInt64(connectorElements[i].HandleValue)), 0), OpenMode.ForRead);
                    Entity blk2 = (Entity)tr.GetObject(db.GetObjectId(false, new Handle(Convert.ToInt64(connectorElements[j].HandleValue)), 0), OpenMode.ForRead);
                    Point3dCollection points = new Point3dCollection();
                    blk.BoundingBoxIntersectWith(blk2, Intersect.OnBothOperands, points, new IntPtr(0), new IntPtr(0));
                    if (points.Count &amp;gt; 0)
                    {
                        Debug.Print("Found");
                    }
                }
            }&lt;/PRE&gt;</description>
    <pubDate>Fri, 24 May 2019 06:40:18 GMT</pubDate>
    <dc:creator>_gile</dc:creator>
    <dc:date>2019-05-24T06:40:18Z</dc:date>
    <item>
      <title>Check block overlapping</title>
      <link>https://forums.autodesk.com/t5/net-forum/check-block-overlapping/m-p/8809585#M22331</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;is there easy way how to check if some block are overlapping? I have test DWG like on the picture. All blocks are on top level.... i mean they aren't nested. i tryed use BoundingBoxIntersectWith but it doesn't works. It is possible to use this command in 3D like that?&lt;/P&gt;&lt;PRE&gt;    //test sample
                    for (int i = 0; i &amp;lt; connectorElements.Count-1; i++)
                    {
                        Entity blk = (Entity)tr.GetObject(db.GetObjectId(false, new Handle(Convert.ToInt64(connectorElements[i].HandleValue)), 0), OpenMode.ForRead);
                        Entity blk2 = (Entity)tr.GetObject(db.GetObjectId(false, new Handle(Convert.ToInt64(connectorElements[i + 1].HandleValue)), 0), OpenMode.ForRead);
                        Point3dCollection points = new Point3dCollection();
                        blk.BoundingBoxIntersectWith(blk2, Intersect.OnBothOperands, points, new IntPtr(0), new IntPtr(0));                   
                        if (points.Count &amp;gt; 0)
                        {
                            Debug.Print("Found");
                        }                     
                   }&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="info.png" style="width: 760px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/639812i9BC8BA6F6F707896/image-size/large?v=v2&amp;amp;px=999" role="button" title="info.png" alt="info.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2019 08:15:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/check-block-overlapping/m-p/8809585#M22331</guid>
      <dc:creator>BestFriendCZ</dc:creator>
      <dc:date>2019-05-23T08:15:09Z</dc:date>
    </item>
    <item>
      <title>Re: Check block overlapping</title>
      <link>https://forums.autodesk.com/t5/net-forum/check-block-overlapping/m-p/8812153#M22332</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems to me the problem is due to the way you iterate the collection.&lt;/P&gt;
&lt;P&gt;As is, your code only checks for intersection between each block and the the follwong one in the collection: (1, 2) (2, 3) (3, 4).&lt;/P&gt;
&lt;P&gt;If you want to check any possible combination: (1, 2) (1, 3) (1, 4) (2, 3) (2, 4) (3, 4), you have to do something laike this:&lt;/P&gt;
&lt;PRE&gt;            for (int i = 0; i &amp;lt; connectorElements.Count - 1; i++)
            {
                for (int j = i + 1; j &amp;lt; connectorElements.Count; j++)
                {
                    Entity blk = (Entity)tr.GetObject(db.GetObjectId(false, new Handle(Convert.ToInt64(connectorElements[i].HandleValue)), 0), OpenMode.ForRead);
                    Entity blk2 = (Entity)tr.GetObject(db.GetObjectId(false, new Handle(Convert.ToInt64(connectorElements[j].HandleValue)), 0), OpenMode.ForRead);
                    Point3dCollection points = new Point3dCollection();
                    blk.BoundingBoxIntersectWith(blk2, Intersect.OnBothOperands, points, new IntPtr(0), new IntPtr(0));
                    if (points.Count &amp;gt; 0)
                    {
                        Debug.Print("Found");
                    }
                }
            }&lt;/PRE&gt;</description>
      <pubDate>Fri, 24 May 2019 06:40:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/check-block-overlapping/m-p/8812153#M22332</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2019-05-24T06:40:18Z</dc:date>
    </item>
    <item>
      <title>Re: Check block overlapping</title>
      <link>https://forums.autodesk.com/t5/net-forum/check-block-overlapping/m-p/8816092#M22333</link>
      <description>&lt;P&gt;Hi _gile,&lt;/P&gt;&lt;P&gt;thank you for the information. This loop is just a sample. In fact i only have two blocks in the list and i would like to know if they intersect in 3D and these two block should be intersect for sure&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;  //connectorElements list contains only two block
                    for (int i = 0; i &amp;lt; connectorElements.Count - 1; i++)
                    {
                        BlockReference blkRefFirst = (BlockReference)tr.GetObject(db.GetObjectId(false, new Handle(Convert.ToInt64(connectorElements[i].HandleValue)), 0), OpenMode.ForRead);
                        BlockReference blkRefSecond = (BlockReference)tr.GetObject(db.GetObjectId(false, new Handle(Convert.ToInt64(connectorElements[i+1].HandleValue)), 0), OpenMode.ForRead);
                        Debug.Print($"X1min: {blkRefFirst.GeometricExtents.MinPoint.X} Y1min: {blkRefFirst.GeometricExtents.MinPoint.Y} Z1min: { blkRefFirst.GeometricExtents.MinPoint.Z}");
                        Debug.Print($"X1min: {blkRefFirst.GeometricExtents.MaxPoint.X} Y1min: {blkRefFirst.GeometricExtents.MaxPoint.Y} Z1min: { blkRefFirst.GeometricExtents.MaxPoint.Z}");
                        Debug.Print($"-------------------------------------------------");
                        Debug.Print($"X2min: {blkRefSecond.GeometricExtents.MinPoint.X} Y2min: {blkRefSecond.GeometricExtents.MinPoint.Y} Z2min: { blkRefSecond.GeometricExtents.MinPoint.Z}");
                        Debug.Print($"X2min: {blkRefSecond.GeometricExtents.MaxPoint.X} Y2min: {blkRefSecond.GeometricExtents.MaxPoint.Y} Z2min: { blkRefSecond.GeometricExtents.MaxPoint.Z}");
                        Point3dCollection points = new Point3dCollection();
                        blkRefFirst.BoundingBoxIntersectWith(blkRefSecond, Intersect.OnBothOperands, points, new IntPtr(0), new IntPtr(0));
                        if (points.Count &amp;gt; 0)
                        {
                            Debug.Print("Found");
                        }
                        blkRefFirst.IntersectWith(blkRefSecond, Intersect.OnBothOperands, points, new IntPtr(0), new IntPtr(0));
                        if (points.Count &amp;gt; 0)
                        {
                            Debug.Print("Found");
                        }
                    }&lt;/PRE&gt;&lt;P&gt;X1min: 2256.xxx-xxxxxxxx Y1min: 2963.xxx-xxxxxxxx Z1min: 1874.xxx-xxxxxxxx&lt;BR /&gt;X1min: 2440.xxx-xxxxxxxx Y1min: 3140.5918479847 Z1min: 1925.0000697987&lt;/P&gt;&lt;P&gt;X2min: 2264.xxx-xxxxxxxx Y2min: 2983.xxx-xxxxxxxx Z2min: 1874.9999302013&lt;BR /&gt;X2min: 2419.xxx-xxxxxxxx Y2min: 3085.xxx-xxxxxxxx Z2min: 1925.xxx-xxxxxxxx&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 559px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/640986i2496CD38488A3040/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.png" alt="1.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2.png" style="width: 506px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/640987iE9C5A7899E7139BC/image-size/large?v=v2&amp;amp;px=999" role="button" title="2.png" alt="2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;link to my test file, was created ACAD2017&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.edisk.cz/stahni/36355/testdwg.dwg_567.85KB.html/" target="_blank"&gt;https://www.edisk.cz/stahni/36355/testdwg.dwg_567.85KB.html/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 27 May 2019 09:07:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/check-block-overlapping/m-p/8816092#M22333</guid>
      <dc:creator>BestFriendCZ</dc:creator>
      <dc:date>2019-05-27T09:07:43Z</dc:date>
    </item>
    <item>
      <title>Re: Check block overlapping</title>
      <link>https://forums.autodesk.com/t5/net-forum/check-block-overlapping/m-p/8816202#M22334</link>
      <description>&lt;P&gt;Hi _gile,&lt;/P&gt;&lt;P&gt;I found reason why my BF does not contains any intersect points. Is there any solution for it... maybe use something different like BB?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="3.png" style="width: 734px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/641005i027C347C61C06FF6/image-size/large?v=v2&amp;amp;px=999" role="button" title="3.png" alt="3.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 27 May 2019 10:04:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/check-block-overlapping/m-p/8816202#M22334</guid>
      <dc:creator>BestFriendCZ</dc:creator>
      <dc:date>2019-05-27T10:04:26Z</dc:date>
    </item>
    <item>
      <title>Re: Check block overlapping</title>
      <link>https://forums.autodesk.com/t5/net-forum/check-block-overlapping/m-p/8816275#M22335</link>
      <description>&lt;P&gt;The box are not intersecting.&lt;/P&gt;
&lt;P&gt;Look at the X coordinates: blkRefFirst is between 2240 and 2256, blkRefSecond is between 2264 and 2419.&lt;/P&gt;</description>
      <pubDate>Mon, 27 May 2019 10:46:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/check-block-overlapping/m-p/8816275#M22335</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2019-05-27T10:46:21Z</dc:date>
    </item>
    <item>
      <title>Re: Check block overlapping</title>
      <link>https://forums.autodesk.com/t5/net-forum/check-block-overlapping/m-p/8816385#M22336</link>
      <description>&lt;P&gt;Hi _gile,&lt;/P&gt;&lt;P&gt;you are correct.&amp;nbsp; My problem is that my blocks have different rotation. If i set rotation for both block to 0 and change only their coordinates for example Z,Y so this function works exactly how i need. I need somehow transform BB by their rotations before compare.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="6.png" style="width: 942px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/641038iB6EC2D9CE7D4CE1B/image-size/large?v=v2&amp;amp;px=999" role="button" title="6.png" alt="6.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[ACAD] ScanBlocks(PCM1242)...&lt;BR /&gt;X1min: 2317.xxx-xxxxxxxx Y1min: 2983.xxx-xxxxxxxx Z1min: 1834.xxx-xxxxxxxx&lt;BR /&gt;X1max: 2472.xxx-xxxxxxxx Y1max: 3085.xxx-xxxxxxxx Z1max: 1885.0000697987&lt;BR /&gt;-------------------------------------------------&lt;BR /&gt;X2min: 2317.xxx-xxxxxxxx Y2min: 2983.xxx-xxxxxxxx Z2min: 1874.9999302013&lt;BR /&gt;X2max: 2472.xxx-xxxxxxxx Y2max: 3085.xxx-xxxxxxxx Z2max: 1925.xxx-xxxxxxxx&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;found point&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="7.png" style="width: 574px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/641042i5CEFBD11D17565CE/image-size/large?v=v2&amp;amp;px=999" role="button" title="7.png" alt="7.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;[ACAD] ScanBlocks(PCM1242)...&lt;BR /&gt;X1min: 2317.xxx-xxxxxxxx Y1min: 2983.xxx-xxxxxxxx Z1min: 1814.xxx-xxxxxxxx&lt;BR /&gt;X1max: 2472.xxx-xxxxxxxx Y1max: 3085.xxx-xxxxxxxx Z1max: 1865.0000697987&lt;BR /&gt;-------------------------------------------------&lt;BR /&gt;X2min: 2317.xxx-xxxxxxxx Y2min: 2983.xxx-xxxxxxxx Z2min: 1874.9999302013&lt;BR /&gt;X2max: 2472.xxx-xxxxxxxx Y2max: 3085.xxx-xxxxxxxx Z2max: 1925.xxx-xxxxxxxx&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;didn't find point&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Thanks for your help&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 27 May 2019 11:54:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/check-block-overlapping/m-p/8816385#M22336</guid>
      <dc:creator>BestFriendCZ</dc:creator>
      <dc:date>2019-05-27T11:54:59Z</dc:date>
    </item>
    <item>
      <title>Re: Check block overlapping</title>
      <link>https://forums.autodesk.com/t5/net-forum/check-block-overlapping/m-p/8816412#M22337</link>
      <description>&lt;P&gt;Sorry but I do not understand what you're trying to achieve.&lt;/P&gt;</description>
      <pubDate>Mon, 27 May 2019 12:10:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/check-block-overlapping/m-p/8816412#M22337</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2019-05-27T12:10:18Z</dc:date>
    </item>
    <item>
      <title>Re: Check block overlapping</title>
      <link>https://forums.autodesk.com/t5/net-forum/check-block-overlapping/m-p/8816428#M22338</link>
      <description>&lt;P&gt;I try to find if some types of blocks are overlapping in space.&lt;BR /&gt;This function works correct "IntersectWith".... but only if these blocks have zero rotation. In another case i have to transform these BB somehow&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="8.png" style="width: 721px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/641049i7BD85B1C30D6C4A2/image-size/large?v=v2&amp;amp;px=999" role="button" title="8.png" alt="8.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 27 May 2019 12:20:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/check-block-overlapping/m-p/8816428#M22338</guid>
      <dc:creator>BestFriendCZ</dc:creator>
      <dc:date>2019-05-27T12:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: Check block overlapping</title>
      <link>https://forums.autodesk.com/t5/net-forum/check-block-overlapping/m-p/8816540#M22339</link>
      <description>&lt;P&gt;i changed function ... and it looks like it works for my purposes&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;                        Double AX1 = blkRefFirst.GeometricExtents.MinPoint.X;
                        Double AX2 = blkRefFirst.GeometricExtents.MaxPoint.X;
                        Double AY1 = blkRefFirst.GeometricExtents.MinPoint.Y;
                        Double AY2 = blkRefFirst.GeometricExtents.MaxPoint.Y;
                        Double AZ1 = blkRefFirst.GeometricExtents.MinPoint.Z;
                        Double AZ2 = blkRefFirst.GeometricExtents.MaxPoint.Z;

                        Double BX1 = blkRefSecond.GeometricExtents.MinPoint.X;
                        Double BX2 = blkRefSecond.GeometricExtents.MaxPoint.X;
                        Double BY1 = blkRefSecond.GeometricExtents.MinPoint.Y;
                        Double BY2 = blkRefSecond.GeometricExtents.MaxPoint.Y;
                        Double BZ1 = blkRefSecond.GeometricExtents.MinPoint.Z;
                        Double BZ2 = blkRefSecond.GeometricExtents.MaxPoint.Z;

                        //it works with rotation
                        if  (AX2 &amp;lt; BX1 || BX2 &amp;lt; AX1 || AZ2 &amp;lt; BZ1 || BZ2 &amp;lt; AZ1 || AY2 &amp;lt; BY1|| BY2 &amp;lt; AY1)
                        {
                          
                            Debug.Print(" no intersect");
                        }
                        else
                        {
                            Debug.Print("Found");
                        }

                        //doesn't work with rotation
                        //blkRefFirst.BoundingBoxIntersectWith(blkRefSecond, Intersect.ExtendArgument, points, new IntPtr(0), new IntPtr(0));
                        //if (points.Count &amp;gt; 0)
                        //{
                        //    Debug.Print("Found");
                        //}
                        //blkRefFirst.IntersectWith(blkRefSecond, Intersect.OnBothOperands, points, new IntPtr(0), new IntPtr(0));
                        //if (points.Count &amp;gt; 0)
                        //{
                        //    Debug.Print("Found");
                        //}&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 May 2019 13:38:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/check-block-overlapping/m-p/8816540#M22339</guid>
      <dc:creator>BestFriendCZ</dc:creator>
      <dc:date>2019-05-27T13:38:30Z</dc:date>
    </item>
  </channel>
</rss>

