<?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 do I know whether the polyline overlap itself? in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-do-i-know-whether-the-polyline-overlap-itself/m-p/3791253#M58987</link>
    <description>&lt;P&gt;I have an idea.&lt;/P&gt;&lt;P&gt;How about getting the start and end points for the line segments and using linear algebra to check if any of those lines intersect O.o? But if you have arcs in the polyline... then I wouldn't know what to do XD&lt;/P&gt;</description>
    <pubDate>Wed, 27 Feb 2013 13:30:03 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2013-02-27T13:30:03Z</dc:date>
    <item>
      <title>How do I know whether the polyline overlap itself?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-know-whether-the-polyline-overlap-itself/m-p/3180744#M58983</link>
      <description>&lt;P&gt;Hi Guys，&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a polyline and need to check whether it overlap itself. What do I need to do in vb.net?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yaqi&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2011 14:41:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-know-whether-the-polyline-overlap-itself/m-p/3180744#M58983</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-10-05T14:41:38Z</dc:date>
    </item>
    <item>
      <title>Re: How do I know whether the polyline overlap itself?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-know-whether-the-polyline-overlap-itself/m-p/3182666#M58984</link>
      <description>&lt;P&gt;There are several IntersectWith methods available from various classes, but I can recall that some or all of those methods have the specific limitation of not discovering self-intersecting polylines.&amp;nbsp; So without spending a bunch of time checking the help for each one of them, I would suggest getting the individual line segments (and/or arc segments) and checking each one of those for intersections with each of the others.&amp;nbsp; I can probably work something up pretty quick, if you need it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2011 18:02:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-know-whether-the-polyline-overlap-itself/m-p/3182666#M58984</guid>
      <dc:creator>chiefbraincloud</dc:creator>
      <dc:date>2011-10-06T18:02:46Z</dc:date>
    </item>
    <item>
      <title>Re: How do I know whether the polyline overlap itself?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-know-whether-the-polyline-overlap-itself/m-p/3790052#M58985</link>
      <description>&lt;P&gt;Please help me to send that code to my mail id if possible.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my mail id id abdulrfaee.gis@gmail.com&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Feb 2013 07:46:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-know-whether-the-polyline-overlap-itself/m-p/3790052#M58985</guid>
      <dc:creator>abdul.rafee</dc:creator>
      <dc:date>2013-02-26T07:46:08Z</dc:date>
    </item>
    <item>
      <title>Re: How do I know whether the polyline overlap itself?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-know-whether-the-polyline-overlap-itself/m-p/3791031#M58986</link>
      <description>&lt;P&gt;To provide code that actually works, we would need to know the version of AutoCAD you are working with, in particular wether you are working with 2010-2012/or 2013 or greater.&amp;nbsp; If you are working with older than 2010, that may make a difference as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, if you could provide the code you have, along with the specific problem you have, we could help you fix it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lastly, regardless of the previous suggestions, I would only post my code to this forum.&amp;nbsp; If I email it to you, then only you can benefit from it, but if I post it here then others can also find it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it is clear that your first language is not English, so I hope you can understand or translate what I am saying properly.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Feb 2013 07:18:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-know-whether-the-polyline-overlap-itself/m-p/3791031#M58986</guid>
      <dc:creator>chiefbraincloud</dc:creator>
      <dc:date>2013-02-27T07:18:59Z</dc:date>
    </item>
    <item>
      <title>Re: How do I know whether the polyline overlap itself?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-know-whether-the-polyline-overlap-itself/m-p/3791253#M58987</link>
      <description>&lt;P&gt;I have an idea.&lt;/P&gt;&lt;P&gt;How about getting the start and end points for the line segments and using linear algebra to check if any of those lines intersect O.o? But if you have arcs in the polyline... then I wouldn't know what to do XD&lt;/P&gt;</description>
      <pubDate>Wed, 27 Feb 2013 13:30:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-know-whether-the-polyline-overlap-itself/m-p/3791253#M58987</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-02-27T13:30:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do I know whether the polyline overlap itself?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-know-whether-the-polyline-overlap-itself/m-p/3792105#M58988</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;&lt;P&gt;I have an idea.&lt;/P&gt;&lt;P&gt;How about getting the start and end points for the line segments and using linear algebra to check if any of those lines intersect O.o? But if you have arcs in the polyline... then I wouldn't know what to do XD&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Or, he could just P/Invoke this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;bool acdbIsRealSelfIntersectEntity(class AcDbEntity *)&lt;/P&gt;</description>
      <pubDate>Thu, 28 Feb 2013 06:28:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-know-whether-the-polyline-overlap-itself/m-p/3792105#M58988</guid>
      <dc:creator>DiningPhilosopher</dc:creator>
      <dc:date>2013-02-28T06:28:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do I know whether the polyline overlap itself?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-know-whether-the-polyline-overlap-itself/m-p/3792302#M58989</link>
      <description>&lt;P&gt;Tony! You dug another undocumented function? &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://forums.autodesk.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Feb 2013 12:22:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-know-whether-the-polyline-overlap-itself/m-p/3792302#M58989</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2013-02-28T12:22:01Z</dc:date>
    </item>
    <item>
      <title>Re: How do I know whether the polyline overlap itself?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-know-whether-the-polyline-overlap-itself/m-p/3792462#M58990</link>
      <description>&lt;P&gt;XD&lt;/P&gt;&lt;P&gt;Now that I think about it, you could create an approximate function for the curve (arc) and with a margin error, check if the polyline intersects itself.&lt;/P&gt;&lt;P&gt;I just wonder how the function tells the polyline intersects itself. I'm sure it would be much easier for that value to be calculated just once everytime the polyline changes and then just be accessed instead of it being calculated everytime a method be called. both scenarios have their prons and cons &amp;gt;.&amp;lt;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Feb 2013 14:45:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-know-whether-the-polyline-overlap-itself/m-p/3792462#M58990</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-02-28T14:45:36Z</dc:date>
    </item>
    <item>
      <title>Re: How do I know whether the polyline overlap itself?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-know-whether-the-polyline-overlap-itself/m-p/3793033#M58991</link>
      <description>&lt;P&gt;There is no need for that.&amp;nbsp; If you simply break the polyline down into its components, using GetSegmentType to tell you whether to call GetArcSegmentAt or GetLineSegmentAt, then you will have a collection of CircularArc3d, and LineSegment3d.&amp;nbsp; then you can loop through that collection calling IntersectWith on all the other objects in the collection, and make sure to ignore any intersections that may appear because of the coincident start and end points of adjacent segments.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You could probably even make it logically simpler, but programmatically messier, by calling explode on the polyline to get a collection of Lines and Arcs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That said, the PInvoke mentioned above is intriguing, but I don't see the function documented in the 2012 Arx SDK, so I'll have to do some digging to see if I can find it, unless Tony would like to elaborate on the signature.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Feb 2013 23:05:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-know-whether-the-polyline-overlap-itself/m-p/3793033#M58991</guid>
      <dc:creator>chiefbraincloud</dc:creator>
      <dc:date>2013-02-28T23:05:21Z</dc:date>
    </item>
    <item>
      <title>Re: How do I know whether the polyline overlap itself?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-know-whether-the-polyline-overlap-itself/m-p/3793101#M58994</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/468374"&gt;@chiefbraincloud&lt;/a&gt; wrote:&lt;BR /&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;That said, the PInvoke mentioned above is intriguing, but I don't see the function documented in the 2012 Arx SDK, so I'll have to do some digging to see if I can find it, unless Tony would like to elaborate on the signature.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;The function isn't documented, meaning the standard caveat applies: Use it at your own risk.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Of course, one can't help but wonder why the public API of a $4K CADD product can't answer a simple question like the one asked by the subject line of this thread.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The entry point signature is platform-dependent, and you can find it acdbxx.dll, by using Depends.exe or dumpbin.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2013 02:20:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-know-whether-the-polyline-overlap-itself/m-p/3793101#M58994</guid>
      <dc:creator>DiningPhilosopher</dc:creator>
      <dc:date>2013-03-01T02:20:57Z</dc:date>
    </item>
    <item>
      <title>Re: How do I know whether the polyline overlap itself?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-know-whether-the-polyline-overlap-itself/m-p/3793109#M58995</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/468374"&gt;@chiefbraincloud&lt;/a&gt; wrote:&lt;BR /&gt;&lt;P&gt;There is no need for that.&amp;nbsp; If you simply break the polyline down into its components, using GetSegmentType to tell you whether to call GetArcSegmentAt or GetLineSegmentAt, then...&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I'm not sure there's any need for that either, at least, in the most common usage cases.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;// Excerpts from CurveExtensionMethods.cs  (C)  2009-2012   Tony Tanzillo&lt;BR /&gt;using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.AutoCAD.Geometry;

namespace Autodesk.AutoCAD.DatabaseServices
{
   public static class PolylineExtensionMethods
   {
      /// &amp;lt;summary&amp;gt;
      /// Returns true if the given Polyline is self-intersecting.
      /// 
      /// This API defines self-intersection as follows:
      /// 
      /// The Polyline is self-intersecting if any of the
      /// following conditions are true:
      /// 
      /// 1.  Any segment intersects any other segment.
      /// 
      /// 2.  Any interior vertex lies directly on any segment.
      ///     or is coincident with any other vertex.
      /// 
      /// 3.  If the polyline is effectively-closed (e.g.,
      ///     the first and last vertices are coincident, but
      ///     the PolyLine's Closed property is false), the
      ///     polyline is considered self-intersecting.
      ///     
      ///  4. A Closed polyline with &amp;lt; 3 vertices
      ///     is considered to be self-intersecting.
      ///     
      /// The definition is intended to be consistent with the 
      /// REGION command's definition of self-intersecting.
      ///     
      /// You may wish to interpret any of the above differently 
      /// depending on your specific functional requirements.
      /// 
      /// &amp;lt;/summary&amp;gt;

      public static bool IsSelfIntersecting( this Polyline pline )
      {
         int numverts = pline.NumberOfVertices;
         if( numverts &amp;lt; 3 )
         {
            return pline.Closed;
         }

         Point3dCollection points = new Point3dCollection();

         pline.IntersectWith( pline, Intersect.OnBothOperands, points, 
            IntPtr.Zero, IntPtr.Zero );

         if( ! pline.Closed )
            numverts -= 2;

         return points.Count != numverts;
      }
   }
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2013 02:36:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-know-whether-the-polyline-overlap-itself/m-p/3793109#M58995</guid>
      <dc:creator>DiningPhilosopher</dc:creator>
      <dc:date>2013-03-01T02:36:11Z</dc:date>
    </item>
    <item>
      <title>Re: How do I know whether the polyline overlap itself?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-know-whether-the-polyline-overlap-itself/m-p/3793137#M58996</link>
      <description>&lt;P&gt;I saw that you had posted that code earlier, and if it works, that's great.&amp;nbsp; I can't test it at the moment, so I don't know.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My previous statements, as I had indicated in my first reply back in Oct 2011, were based on the fact that I thought Entity.IntersectWith did not work with Self Intersecting polylines (my recollection would be that I read it somewhere in the docs, but I looked at a few things earlier today, and I can't seem to find where I read it.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2013 03:35:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-know-whether-the-polyline-overlap-itself/m-p/3793137#M58996</guid>
      <dc:creator>chiefbraincloud</dc:creator>
      <dc:date>2013-03-01T03:35:22Z</dc:date>
    </item>
    <item>
      <title>Re: How do I know whether the polyline overlap itself?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-know-whether-the-polyline-overlap-itself/m-p/3793142#M58997</link>
      <description>&lt;P&gt;The version I posted earler and removed doesn't care about effectively-closed polylines because for my own purposes, the code was only used for checking polylines used to create regions, and the region API accepts effectively-closed polylines. But I can't assume that's what the OP is doing, and decided to revise the code to be more consistent with the more general use case and definition of self-intersecting, where effectively-closed polyines &lt;EM&gt;&lt;STRONG&gt;are&lt;/STRONG&gt; &lt;/EM&gt;considered self-intersecting.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As far as the question of whether it works, that depends on the specific use case, and in-turn on what precisely 'self-intersecting' means. It doesn't necessarily have a consistent definition beyond the most simple case of segments intersecting other segments, which as far as I can tell, was the only thing that the other proposed solutions actually check for.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2013 04:03:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-know-whether-the-polyline-overlap-itself/m-p/3793142#M58997</guid>
      <dc:creator>DiningPhilosopher</dc:creator>
      <dc:date>2013-03-01T04:03:07Z</dc:date>
    </item>
  </channel>
</rss>

