<?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: polyline inside closed polyline? in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/polyline-inside-closed-polyline/m-p/1691938#M33139</link>
    <description>Problem with that is even though the vertices may be inside the polyline and edge may still cross. See attached image.&lt;BR /&gt;
&lt;BR /&gt;
Regards - Nathan</description>
    <pubDate>Sun, 02 Jul 2006 23:08:31 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2006-07-02T23:08:31Z</dc:date>
    <item>
      <title>polyline inside closed polyline?</title>
      <link>https://forums.autodesk.com/t5/vba-forum/polyline-inside-closed-polyline/m-p/1691934#M33135</link>
      <description>Im trying to write a function that determines whether a given polyline is inside of another given closed polyline.  I use the standard method of drawing a ray and checking how many intersections it has with the second object.  I also take into account if the polyline starts on top of the other. here is the code&lt;BR /&gt;
&lt;BR /&gt;
Private Function fncIsInside(ByVal obj1stEnt As AcadEntity, ByVal obj2ndEnt As AcadEntity) As Boolean&lt;BR /&gt;
    Dim var1stEntPnts As Variant&lt;BR /&gt;
    Dim var2ndEntPnts As Variant&lt;BR /&gt;
    Dim varNoIntersect As Variant&lt;BR /&gt;
    Dim intNoIntersect As Integer&lt;BR /&gt;
    &lt;BR /&gt;
    Dim intI As Integer&lt;BR /&gt;
    Dim intJ As Integer&lt;BR /&gt;
    Dim intK As Integer&lt;BR /&gt;
    &lt;BR /&gt;
    Dim testRay As AcadRay&lt;BR /&gt;
    Dim firstPt(0 To 2) As Double&lt;BR /&gt;
    Dim secondPt(0 To 2) As Double&lt;BR /&gt;
    &lt;BR /&gt;
    var1stEntPnts = obj1stEnt.Coordinates&lt;BR /&gt;
    For intI = 0 To UBound(var1stEntPnts)&lt;BR /&gt;
        intNoIntersect = 0&lt;BR /&gt;
        firstPt(0) = var1stEntPnts(intI)&lt;BR /&gt;
        firstPt(1) = var1stEntPnts(intI + 1)&lt;BR /&gt;
        firstPt(2) = 0&lt;BR /&gt;
        secondPt(0) = var1stEntPnts(intI) + 1&lt;BR /&gt;
        secondPt(1) = var1stEntPnts(intI + 1)&lt;BR /&gt;
        secondPt(2) = 0&lt;BR /&gt;
        Set testRay = ThisDrawing.ModelSpace.AddRay(firstPt, secondPt)&lt;BR /&gt;
        var2ndEntPnts = testRay.IntersectWith(obj2ndEnt, acExtendNone)&lt;BR /&gt;
        If UBound(var2ndEntPnts) &amp;gt; 0 Then&lt;BR /&gt;
            For intJ = 0 To UBound(var2ndEntPnts)&lt;BR /&gt;
                If var1stEntPnts(intI) &amp;lt;&amp;gt; var2ndEntPnts(intJ) And var1stEntPnts(intI + 1) &amp;lt;&amp;gt; var2ndEntPnts(intJ + 1) Then&lt;BR /&gt;
                    intNoIntersect = intNoIntersect + 1&lt;BR /&gt;
                End If&lt;BR /&gt;
                intJ = intJ + 3&lt;BR /&gt;
            Next intJ&lt;BR /&gt;
            intNoIntersect = (intNoIntersect + 1) / 3&lt;BR /&gt;
            intNoIntersect = intNoIntersect Mod 2&lt;BR /&gt;
&lt;BR /&gt;
        End If&lt;BR /&gt;
        If intNoIntersect = 0 Then&lt;BR /&gt;
            fncIsInside = False&lt;BR /&gt;
        Else&lt;BR /&gt;
            fncIsInside = True&lt;BR /&gt;
        End If&lt;BR /&gt;
        intI = intI + 3&lt;BR /&gt;
        &lt;BR /&gt;
    Next intI&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
my problem is that for some polylines it registers it as being outside when it clearly isnt, what am I doing wrong here?</description>
      <pubDate>Thu, 29 Jun 2006 23:01:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/polyline-inside-closed-polyline/m-p/1691934#M33135</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-29T23:01:09Z</dc:date>
    </item>
    <item>
      <title>Re: polyline inside closed polyline?</title>
      <link>https://forums.autodesk.com/t5/vba-forum/polyline-inside-closed-polyline/m-p/1691935#M33136</link>
      <description>Could you use the SelectByPolygon selection set method and then check if the polyline is in the selection set.&lt;BR /&gt;
&lt;BR /&gt;
Regards - Nathan</description>
      <pubDate>Fri, 30 Jun 2006 02:11:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/polyline-inside-closed-polyline/m-p/1691935#M33136</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-30T02:11:34Z</dc:date>
    </item>
    <item>
      <title>Re: polyline inside closed polyline?</title>
      <link>https://forums.autodesk.com/t5/vba-forum/polyline-inside-closed-polyline/m-p/1691936#M33137</link>
      <description>I agree Nathan, that's what I've done to check overlaps&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
Regards&lt;BR /&gt;
Dave Preston&lt;BR /&gt;
&amp;lt;-&lt;BR /&gt;
&lt;NATHAN taylor=""&gt; wrote in message news:5223722@discussion.autodesk.com...&lt;BR /&gt;
Could you use the SelectByPolygon selection set method and then check if the &lt;BR /&gt;
polyline is in the selection set.&lt;BR /&gt;
&lt;BR /&gt;
Regards - Nathan&lt;/NATHAN&gt;</description>
      <pubDate>Fri, 30 Jun 2006 06:16:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/polyline-inside-closed-polyline/m-p/1691936#M33137</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-30T06:16:53Z</dc:date>
    </item>
    <item>
      <title>Re: polyline inside closed polyline?</title>
      <link>https://forums.autodesk.com/t5/vba-forum/polyline-inside-closed-polyline/m-p/1691937#M33138</link>
      <description>this will check a 2d point is inside a 2d polyline(word wrap!)&lt;BR /&gt;
&lt;BR /&gt;
Public Type A2DPoint&lt;BR /&gt;
    x As Integer&lt;BR /&gt;
    y As Integer&lt;BR /&gt;
End Type&lt;BR /&gt;
&lt;BR /&gt;
Public Type Poly2DCoordinates&lt;BR /&gt;
    CoordsList() As A2DPoint&lt;BR /&gt;
End Type&lt;BR /&gt;
&lt;BR /&gt;
Function ItsInside(AnyPoint As A2DPoint, AnyPoly As Poly2DCoordinates) As &lt;BR /&gt;
Boolean&lt;BR /&gt;
Dim i As Integer, j As Integer, npol As Integer&lt;BR /&gt;
&lt;BR /&gt;
 ItsInside = False&lt;BR /&gt;
  npol = UBound(AnyPoly.CoordsList) + 1&lt;BR /&gt;
  For i = 0 To (npol - 1)&lt;BR /&gt;
    j = (i + 1) Mod npol&lt;BR /&gt;
    If ((((AnyPoly.CoordsList(i).y &amp;lt;= AnyPoint.y) And (AnyPoint.y &amp;lt; &lt;BR /&gt;
AnyPoly.CoordsList(j).y)) Or _&lt;BR /&gt;
         ((AnyPoly.CoordsList(j).y &amp;lt;= AnyPoint.y) And (AnyPoint.y &amp;lt; &lt;BR /&gt;
AnyPoly.CoordsList(i).y))) And _&lt;BR /&gt;
        (AnyPoint.x &amp;lt; (AnyPoly.CoordsList(j).x - AnyPoly.CoordsList(i).x) * &lt;BR /&gt;
(AnyPoint.y - AnyPoly.CoordsList(i).y) _&lt;BR /&gt;
                  / (AnyPoly.CoordsList(j).y - AnyPoly.CoordsList(i).y) + &lt;BR /&gt;
AnyPoly.CoordsList(i).x)) Then _&lt;BR /&gt;
      ItsInside = Not ItsInside&lt;BR /&gt;
  Next i&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
&lt;SRYABININ&gt; wrote in message news:5223643@discussion.autodesk.com...&lt;BR /&gt;
Im trying to write a function that determines whether a given polyline is &lt;BR /&gt;
inside of another given closed polyline.  I use the standard method of &lt;BR /&gt;
drawing a ray and checking how many intersections it has with the second &lt;BR /&gt;
object.  I also take into account if the polyline starts on top of the &lt;BR /&gt;
other. here is the code&lt;BR /&gt;
&lt;BR /&gt;
Private Function fncIsInside(ByVal obj1stEnt As AcadEntity, ByVal obj2ndEnt &lt;BR /&gt;
As AcadEntity) As Boolean&lt;BR /&gt;
    Dim var1stEntPnts As Variant&lt;BR /&gt;
    Dim var2ndEntPnts As Variant&lt;BR /&gt;
    Dim varNoIntersect As Variant&lt;BR /&gt;
    Dim intNoIntersect As Integer&lt;BR /&gt;
&lt;BR /&gt;
    Dim intI As Integer&lt;BR /&gt;
    Dim intJ As Integer&lt;BR /&gt;
    Dim intK As Integer&lt;BR /&gt;
&lt;BR /&gt;
    Dim testRay As AcadRay&lt;BR /&gt;
    Dim firstPt(0 To 2) As Double&lt;BR /&gt;
    Dim secondPt(0 To 2) As Double&lt;BR /&gt;
&lt;BR /&gt;
    var1stEntPnts = obj1stEnt.Coordinates&lt;BR /&gt;
    For intI = 0 To UBound(var1stEntPnts)&lt;BR /&gt;
        intNoIntersect = 0&lt;BR /&gt;
        firstPt(0) = var1stEntPnts(intI)&lt;BR /&gt;
        firstPt(1) = var1stEntPnts(intI + 1)&lt;BR /&gt;
        firstPt(2) = 0&lt;BR /&gt;
        secondPt(0) = var1stEntPnts(intI) + 1&lt;BR /&gt;
        secondPt(1) = var1stEntPnts(intI + 1)&lt;BR /&gt;
        secondPt(2) = 0&lt;BR /&gt;
        Set testRay = ThisDrawing.ModelSpace.AddRay(firstPt, secondPt)&lt;BR /&gt;
        var2ndEntPnts = testRay.IntersectWith(obj2ndEnt, acExtendNone)&lt;BR /&gt;
        If UBound(var2ndEntPnts) &amp;gt; 0 Then&lt;BR /&gt;
            For intJ = 0 To UBound(var2ndEntPnts)&lt;BR /&gt;
                If var1stEntPnts(intI) &amp;lt;&amp;gt; var2ndEntPnts(intJ) And &lt;BR /&gt;
var1stEntPnts(intI + 1) &amp;lt;&amp;gt; var2ndEntPnts(intJ + 1) Then&lt;BR /&gt;
                    intNoIntersect = intNoIntersect + 1&lt;BR /&gt;
                End If&lt;BR /&gt;
                intJ = intJ + 3&lt;BR /&gt;
            Next intJ&lt;BR /&gt;
            intNoIntersect = (intNoIntersect + 1) / 3&lt;BR /&gt;
            intNoIntersect = intNoIntersect Mod 2&lt;BR /&gt;
&lt;BR /&gt;
        End If&lt;BR /&gt;
        If intNoIntersect = 0 Then&lt;BR /&gt;
            fncIsInside = False&lt;BR /&gt;
        Else&lt;BR /&gt;
            fncIsInside = True&lt;BR /&gt;
        End If&lt;BR /&gt;
        intI = intI + 3&lt;BR /&gt;
&lt;BR /&gt;
    Next intI&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
my problem is that for some polylines it registers it as being outside when &lt;BR /&gt;
it clearly isnt, what am I doing wrong here?&lt;/SRYABININ&gt;</description>
      <pubDate>Fri, 30 Jun 2006 14:42:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/polyline-inside-closed-polyline/m-p/1691937#M33138</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-30T14:42:18Z</dc:date>
    </item>
    <item>
      <title>Re: polyline inside closed polyline?</title>
      <link>https://forums.autodesk.com/t5/vba-forum/polyline-inside-closed-polyline/m-p/1691938#M33139</link>
      <description>Problem with that is even though the vertices may be inside the polyline and edge may still cross. See attached image.&lt;BR /&gt;
&lt;BR /&gt;
Regards - Nathan</description>
      <pubDate>Sun, 02 Jul 2006 23:08:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/polyline-inside-closed-polyline/m-p/1691938#M33139</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-07-02T23:08:31Z</dc:date>
    </item>
    <item>
      <title>Re: polyline inside closed polyline?</title>
      <link>https://forums.autodesk.com/t5/vba-forum/polyline-inside-closed-polyline/m-p/1691939#M33140</link>
      <description>In that instance, you could also check the reverse:&lt;BR /&gt;
&lt;BR /&gt;
check that all of poly1 vertices are inside poly2, and also check that all of poly2 vertices are NOT inside poly1.</description>
      <pubDate>Thu, 05 Apr 2007 14:04:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/polyline-inside-closed-polyline/m-p/1691939#M33140</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-04-05T14:04:46Z</dc:date>
    </item>
    <item>
      <title>Re: polyline inside closed polyline?</title>
      <link>https://forums.autodesk.com/t5/vba-forum/polyline-inside-closed-polyline/m-p/1691940#M33141</link>
      <description>He is not speaking generally. He is looking for the borders of rooms and will only be doing 1 at a time. So if a room is inside another room, such as a bathroom in a bedroom, then each will be handled seperatly. It should not be an issue.</description>
      <pubDate>Thu, 05 Apr 2007 17:46:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/polyline-inside-closed-polyline/m-p/1691940#M33141</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-04-05T17:46:49Z</dc:date>
    </item>
    <item>
      <title>Re: polyline inside closed polyline?</title>
      <link>https://forums.autodesk.com/t5/vba-forum/polyline-inside-closed-polyline/m-p/1691941#M33142</link>
      <description>Oh, I think this is a croos post from one on the swamp, so you would know that here. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Thu, 05 Apr 2007 17:47:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/polyline-inside-closed-polyline/m-p/1691941#M33142</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-04-05T17:47:47Z</dc:date>
    </item>
    <item>
      <title>Re: polyline inside closed polyline?</title>
      <link>https://forums.autodesk.com/t5/vba-forum/polyline-inside-closed-polyline/m-p/1691942#M33143</link>
      <description>Then again, maybe I posted on the wrong thread....&lt;BR /&gt;
&lt;BR /&gt;
I am lost.</description>
      <pubDate>Thu, 05 Apr 2007 17:48:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/polyline-inside-closed-polyline/m-p/1691942#M33143</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-04-05T17:48:27Z</dc:date>
    </item>
  </channel>
</rss>

