<?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 automatically create closed polylines from intersections using .NET C# in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-automatically-create-closed-polylines-from-intersections/m-p/13293589#M998</link>
    <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/14570232"&gt;@artillis_prado&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That type of tool has been created many times by various developers, and is a classic GIS problem.&lt;/P&gt;&lt;P&gt;The trick is to handle lines and arcs, and fast as brute force intersection detection is too slow.&lt;/P&gt;&lt;P&gt;I did one for our company, and the approach is likely the same for most that want to handle large scale data sets.&lt;/P&gt;&lt;P&gt;You basically take all the segments and find all intersections with other segments.&lt;/P&gt;&lt;P&gt;That is not trivial, and you optimize checking by first looking for bounding box overlap.&lt;/P&gt;&lt;P&gt;Once you have the ints, you chop up the segments into pieces between them.&lt;/P&gt;&lt;P&gt;Then gather any "chains" which are pieces end to end between intersections.&lt;/P&gt;&lt;P&gt;Then create "hubs" which are points that know what chains end at their location.&lt;/P&gt;&lt;P&gt;Then loop through the segs and hubs, finding the closed shapes by "next" clockwise chain on the hub you end at, until you get back to the starting hub.&lt;/P&gt;&lt;P&gt;Mark the segs as done that direction, and do the next chain on the hub.&lt;/P&gt;&lt;P&gt;I think it must be done that way, as the classic "sweep-line" approaches for intersections computational geometry people use only work on lines.&lt;/P&gt;&lt;P&gt;I'm always looking for "no, use this super fast GIS library instead" answers.&lt;/P&gt;&lt;P&gt;Many are C++ though and I can read the code but can't maintain projects in C++ yet.&lt;/P&gt;&lt;P&gt;Funny thing is I do all the time for arduino, somehow that is easy but in acad its hard? Oh well.&lt;/P&gt;</description>
    <pubDate>Fri, 31 Jan 2025 19:01:17 GMT</pubDate>
    <dc:creator>JamesMaeding</dc:creator>
    <dc:date>2025-01-31T19:01:17Z</dc:date>
    <item>
      <title>How to automatically create closed polylines from intersections using .NET C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-automatically-create-closed-polylines-from-intersections/m-p/13288432#M995</link>
      <description>&lt;P&gt;I have a drawing with a &lt;STRONG&gt;Polyline boundary&lt;/STRONG&gt; and several &lt;STRONG&gt;lines inside that boundary&lt;/STRONG&gt;. In AutoCAD, using the &lt;STRONG&gt;BOUNDARY&lt;/STRONG&gt; command and clicking in the middle of each enclosed region, it automatically creates a &lt;STRONG&gt;closed Polyline&lt;/STRONG&gt; (square, triangle, or any other shape).&lt;/P&gt;&lt;P&gt;I would like to know if it is possible, through the &lt;STRONG&gt;AutoCAD .NET C# API&lt;/STRONG&gt;, to &lt;STRONG&gt;automate this process&lt;/STRONG&gt;, so that all the internal regions formed by the intersections of the lines inside the boundary are automatically converted into closed shapes, without needing to click manually on each one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var hatch = HatchPolyLine(poly2d.Id);
hatch.AddToDocument(btr, act);

DBObjectCollection explodedObjects = new DBObjectCollection();
hatch.Explode(explodedObjects);&lt;/LI-CODE&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="artillis_prado_1-1738162442433.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1460478i299EC71B18853CE3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="artillis_prado_1-1738162442433.png" alt="artillis_prado_1-1738162442433.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Apply Boundary&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="artillis_prado_0-1738162388448.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1460477i41C73D583746A965/image-size/medium?v=v2&amp;amp;px=400" role="button" title="artillis_prado_0-1738162388448.png" alt="artillis_prado_0-1738162388448.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jan 2025 17:05:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-automatically-create-closed-polylines-from-intersections/m-p/13288432#M995</guid>
      <dc:creator>artillis_prado</dc:creator>
      <dc:date>2025-01-29T17:05:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to automatically create closed polylines from intersections?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-automatically-create-closed-polylines-from-intersections/m-p/13288461#M996</link>
      <description>&lt;P&gt;I did a search for LISP file that does Boundaries.&lt;/P&gt;&lt;P&gt;I have created a LISP file called BM.lsp&lt;/P&gt;&lt;P&gt;It works great. Takes some time, but let it run and it will give you what you want.&lt;/P&gt;&lt;P&gt;Original creator link:&amp;nbsp;&lt;A href="https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-boundary-automatically/td-p/10434830" target="_blank"&gt;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-boundary-automatically/td-p/10434830&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Hope this helps! If so please select Solution Solved button.&lt;/P&gt;&lt;P&gt;JRR!&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jan 2025 15:15:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-automatically-create-closed-polylines-from-intersections/m-p/13288461#M996</guid>
      <dc:creator>jreidKVSUZ</dc:creator>
      <dc:date>2025-01-29T15:15:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to automatically create closed polylines from intersections?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-automatically-create-closed-polylines-from-intersections/m-p/13288724#M997</link>
      <description>&lt;P&gt;Very nice! The Lisp solution is interesting, but I'm looking for a .NET C# approach.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jan 2025 17:07:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-automatically-create-closed-polylines-from-intersections/m-p/13288724#M997</guid>
      <dc:creator>artillis_prado</dc:creator>
      <dc:date>2025-01-29T17:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to automatically create closed polylines from intersections using .NET C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-automatically-create-closed-polylines-from-intersections/m-p/13293589#M998</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/14570232"&gt;@artillis_prado&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That type of tool has been created many times by various developers, and is a classic GIS problem.&lt;/P&gt;&lt;P&gt;The trick is to handle lines and arcs, and fast as brute force intersection detection is too slow.&lt;/P&gt;&lt;P&gt;I did one for our company, and the approach is likely the same for most that want to handle large scale data sets.&lt;/P&gt;&lt;P&gt;You basically take all the segments and find all intersections with other segments.&lt;/P&gt;&lt;P&gt;That is not trivial, and you optimize checking by first looking for bounding box overlap.&lt;/P&gt;&lt;P&gt;Once you have the ints, you chop up the segments into pieces between them.&lt;/P&gt;&lt;P&gt;Then gather any "chains" which are pieces end to end between intersections.&lt;/P&gt;&lt;P&gt;Then create "hubs" which are points that know what chains end at their location.&lt;/P&gt;&lt;P&gt;Then loop through the segs and hubs, finding the closed shapes by "next" clockwise chain on the hub you end at, until you get back to the starting hub.&lt;/P&gt;&lt;P&gt;Mark the segs as done that direction, and do the next chain on the hub.&lt;/P&gt;&lt;P&gt;I think it must be done that way, as the classic "sweep-line" approaches for intersections computational geometry people use only work on lines.&lt;/P&gt;&lt;P&gt;I'm always looking for "no, use this super fast GIS library instead" answers.&lt;/P&gt;&lt;P&gt;Many are C++ though and I can read the code but can't maintain projects in C++ yet.&lt;/P&gt;&lt;P&gt;Funny thing is I do all the time for arduino, somehow that is easy but in acad its hard? Oh well.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2025 19:01:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-automatically-create-closed-polylines-from-intersections/m-p/13293589#M998</guid>
      <dc:creator>JamesMaeding</dc:creator>
      <dc:date>2025-01-31T19:01:17Z</dc:date>
    </item>
  </channel>
</rss>

