<?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: Iterating through entities multiple times and performance in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/iterating-through-entities-multiple-times-and-performance/m-p/7277223#M30305</link>
    <description>&lt;P&gt;My guess is that spatial indexing is most-likely the best approach to solving your problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A &lt;A href="https://en.wikipedia.org/wiki/Quadtree" target="_blank"&gt;quadtree&lt;/A&gt; can be used to spatially-index the bounding boxes of entities so that other entities that intersect with it can be found quickly. Most CAD software use quadtrees or its 3D analog, &lt;A href="https://en.wikipedia.org/wiki/Octree" target="_blank"&gt;octrees&lt;/A&gt;, to search for objects when you&amp;nbsp;select one by picking a point.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can implement the quadtree in such a way that it can reference nested entities as well, although you will need to use something like a FullSubentityPath, or store the non-database resident entities produced by Explode() themselves in quadtree nodes in order to reference them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Searching the internet for C# implementations might bear some fruit.&lt;/P&gt;</description>
    <pubDate>Fri, 04 Aug 2017 15:12:12 GMT</pubDate>
    <dc:creator>ActivistInvestor</dc:creator>
    <dc:date>2017-08-04T15:12:12Z</dc:date>
    <item>
      <title>Iterating through entities multiple times and performance</title>
      <link>https://forums.autodesk.com/t5/net-forum/iterating-through-entities-multiple-times-and-performance/m-p/7276182#M30304</link>
      <description>&lt;P&gt;I have a situation where I need to check a DBText position vs other entities (check if DBText is clashing) then move the text position if required then do the same iteration check again. The way I check for text clash is similar to this&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="http://through-the-interface.typepad.com/through_the_interface/2011/02/gathering-points-defining-2d-autocad-geometry-using-net.html" target="_blank"&gt;article&lt;/A&gt;&amp;nbsp;which involves exploding entities in memory sometimes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Doing this in a drawing that has xrefs, Block references and other objects is very time consuming. And I typically have to do this for like 2000+ DBTexts.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So my question is, "what is the best way or ways to speed up the process?". I was thinking of iterating first time only and storing most results. But i'm not sure if this will speed things up or not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for your help&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2017 07:07:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/iterating-through-entities-multiple-times-and-performance/m-p/7276182#M30304</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-08-04T07:07:18Z</dc:date>
    </item>
    <item>
      <title>Re: Iterating through entities multiple times and performance</title>
      <link>https://forums.autodesk.com/t5/net-forum/iterating-through-entities-multiple-times-and-performance/m-p/7277223#M30305</link>
      <description>&lt;P&gt;My guess is that spatial indexing is most-likely the best approach to solving your problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A &lt;A href="https://en.wikipedia.org/wiki/Quadtree" target="_blank"&gt;quadtree&lt;/A&gt; can be used to spatially-index the bounding boxes of entities so that other entities that intersect with it can be found quickly. Most CAD software use quadtrees or its 3D analog, &lt;A href="https://en.wikipedia.org/wiki/Octree" target="_blank"&gt;octrees&lt;/A&gt;, to search for objects when you&amp;nbsp;select one by picking a point.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can implement the quadtree in such a way that it can reference nested entities as well, although you will need to use something like a FullSubentityPath, or store the non-database resident entities produced by Explode() themselves in quadtree nodes in order to reference them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Searching the internet for C# implementations might bear some fruit.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2017 15:12:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/iterating-through-entities-multiple-times-and-performance/m-p/7277223#M30305</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2017-08-04T15:12:12Z</dc:date>
    </item>
    <item>
      <title>Re: Iterating through entities multiple times and performance</title>
      <link>https://forums.autodesk.com/t5/net-forum/iterating-through-entities-multiple-times-and-performance/m-p/7284452#M30306</link>
      <description>&lt;P&gt;There's some similarity in processing points for Delaunay triangulation; sort based on execution method prior to evaluation&amp;nbsp;so when they will logically generate a known result they can be skipped in all future loops.&amp;nbsp; Whatever method is chosen consider this: adding an additional item to consider results in an exponential increase in processing time, so removing items has the inverse effect, so reduce the number of items being cross-checked as soon as possible.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Don't forget about hybrid systems either: humans can be better at drawing layout than computers.&amp;nbsp; Let the computer do some of the heavy lifting with repetitive tasks but consider letting the user find the optimum locations.&amp;nbsp; While a completely automated system may be faster, the drawings can be rather ugly and end up needing manual clean-up anyways.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might also want to delve into genetic algorithms.&amp;nbsp; It's a little daunting at first but well-constructed ones perform well where you have large numbers of objects of indeterminate nature.&amp;nbsp; They also perform better when a "good enough" solution is more acceptable than a potentially exhaustive search for multiple equally viable solutions (or no ideal solution is possible).&amp;nbsp; Due to the nature of how it works&amp;nbsp;the results are usually not repeatable (run it on the same problem several times and you'll end up with several variations on the same solution but with few exact matches) but with very large sets that's not a primary concern.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 15:16:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/iterating-through-entities-multiple-times-and-performance/m-p/7284452#M30306</guid>
      <dc:creator>dgorsman</dc:creator>
      <dc:date>2017-08-08T15:16:45Z</dc:date>
    </item>
  </channel>
</rss>

