<?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: Help get Point3d within boundary ? in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/help-get-point3d-within-boundary/m-p/5749693#M39117</link>
    <description>&lt;P&gt;Thank SENL, but i want held boundary it. Only gets Point3D within Boundary.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;IMG src="https://forums.autodesk.com/t5/image/serverpage/image-id/181127i83EB227A3A759563/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="1.jpg" title="1.jpg" /&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 30 Jul 2015 12:40:56 GMT</pubDate>
    <dc:creator>anhtrung</dc:creator>
    <dc:date>2015-07-30T12:40:56Z</dc:date>
    <item>
      <title>Help get Point3d within boundary ?</title>
      <link>https://forums.autodesk.com/t5/net-forum/help-get-point3d-within-boundary/m-p/5749323#M39115</link>
      <description>&lt;P&gt;i have a boundary created, &amp;nbsp;i have lots of Point3d but i want know how many Point3d within&amp;nbsp;boundary it. Thank.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2015 06:49:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/help-get-point3d-within-boundary/m-p/5749323#M39115</guid>
      <dc:creator>anhtrung</dc:creator>
      <dc:date>2015-07-30T06:49:43Z</dc:date>
    </item>
    <item>
      <title>Re: Help get Point3d within boundary ?</title>
      <link>https://forums.autodesk.com/t5/net-forum/help-get-point3d-within-boundary/m-p/5749578#M39116</link>
      <description>&lt;P&gt;Simple 2D solution:&lt;/P&gt;&lt;P&gt;Extract the Boundary Point into this polyPoint collection, then test each pnt&amp;nbsp;with Inside2D&lt;/P&gt;&lt;P&gt;There is also a solution from Tony which uses a Region to test inside or even crossing for entities.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;       public static bool IsInside2D(Point3dCollection polyPoint, Point3d pnt)
        {
            if (polyPoint == null)
                return false;

            int i, j = polyPoint.Count - 1;
            bool inside2D = false;

            for (i = 0; i &amp;lt; polyPoint.Count; i++)
            {
                Point3d pi = polyPoint[i];
                Point3d pj = polyPoint[j];

                if ((pi.Y &amp;lt; pnt.Y &amp;amp;&amp;amp; pj.Y &amp;gt;= pnt.Y || pj.Y &amp;lt; pnt.Y &amp;amp;&amp;amp; pi.Y &amp;gt;= pnt.Y) &amp;amp;&amp;amp;
                    (pi.X &amp;lt;= pnt.X || pj.X &amp;lt;= pnt.X))
                    inside2D ^= (pi.X + (pnt.Y - pi.Y) / (pj.Y - pi.Y) * (pj.X - pi.X) &amp;lt; pnt.X);

                j = i;
            }
            return inside2D;
        }&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Jul 2015 11:06:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/help-get-point3d-within-boundary/m-p/5749578#M39116</guid>
      <dc:creator>SENL1362</dc:creator>
      <dc:date>2015-07-30T11:06:46Z</dc:date>
    </item>
    <item>
      <title>Re: Help get Point3d within boundary ?</title>
      <link>https://forums.autodesk.com/t5/net-forum/help-get-point3d-within-boundary/m-p/5749693#M39117</link>
      <description>&lt;P&gt;Thank SENL, but i want held boundary it. Only gets Point3D within Boundary.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;IMG src="https://forums.autodesk.com/t5/image/serverpage/image-id/181127i83EB227A3A759563/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="1.jpg" title="1.jpg" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2015 12:40:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/help-get-point3d-within-boundary/m-p/5749693#M39117</guid>
      <dc:creator>anhtrung</dc:creator>
      <dc:date>2015-07-30T12:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: Help get Point3d within boundary ?</title>
      <link>https://forums.autodesk.com/t5/net-forum/help-get-point3d-within-boundary/m-p/5749836#M39118</link>
      <description>&lt;PRE&gt;        [CommandMethod( "TestInside", CommandFlags.NoPaperSpace)]
        public static void TestInside()
        {

            Document doc = Application.DocumentManager.MdiActiveDocument;&lt;BR /&gt;            if (doc == null)&lt;BR /&gt;               return;
            Database db = doc.Database;
            Editor ed = doc.Editor;

            try
            {
                PromptEntityResult per = ed.GetEntity("Select Polyline");
                if (per.Status != PromptStatus.OK)
                    return;
                var polyId = per.ObjectId;
                if (!Regex.IsMatch(polyId.ObjectClass.DxfName,"POLY",RegexOptions.IgnoreCase))
                    throw new System.Exception("Not a Polyline selected");

                Point3dCollection polyPnts = new Point3dCollection();
                using (Transaction tr=db.TransactionManager.StartTransaction())
                {
                    var poly = (Polyline)tr.GetObject(polyId, OpenMode.ForRead);
                    for (int i = 0; i &amp;lt; poly.NumberOfVertices; i++)
                        polyPnts.Add(poly.GetPoint3dAt(i));
                    tr.Commit();
                }
                ed.WriteMessage("\n PolyPnts: {0}", string.Join("; ", polyPnts.Cast&amp;lt;Point3d&amp;gt;()));&lt;BR /&gt;
                while (true)
                {
                    PromptPointOptions askForPP = new PromptPointOptions("Select Point");
                    askForPP.AllowArbitraryInput = true;
                    PromptPointResult getPP = ed.GetPoint(askForPP);
                    //User escaped?
                    if (getPP.Status != PromptStatus.OK)
                        break;

                    Point3d ucsPP = getPP.Value;
                    Matrix3d ucsWcs = ed.CurrentUserCoordinateSystem;
                    Point3d pickedPointInWcs = ucsPP.TransformBy(ucsWcs);

                    var heIsIn = IsInside2D(polyPnts, pickedPointInWcs);
                    ed.WriteMessage("\n {0}:  ({1}) \n", heIsIn ? "IN" : "OUT", pickedPointInWcs.ToString());
                }
            }
            catch (System.Exception ex)
            {
                if (ed != null)
                    ed.WriteMessage("\n {0}", ex.Message);
            }
        }

        public static bool IsInside2D(Point3dCollection polyPoints, Point3d pnt)
        {
            if (polyPoints == null)
                return false;

            int i, j = polyPoints.Count - 1;
            bool inside2D = false;

            for (i = 0; i &amp;lt; polyPoints.Count; i++)
            {
                Point3d pi = polyPoints[i];
                Point3d pj = polyPoints[j];

                if ((pi.Y &amp;lt; pnt.Y &amp;amp;&amp;amp; pj.Y &amp;gt;= pnt.Y || pj.Y &amp;lt; pnt.Y &amp;amp;&amp;amp; pi.Y &amp;gt;= pnt.Y) &amp;amp;&amp;amp;
                    (pi.X &amp;lt;= pnt.X || pj.X &amp;lt;= pnt.X))
                    inside2D ^= (pi.X + (pnt.Y - pi.Y) / (pj.Y - pi.Y) * (pj.X - pi.X) &amp;lt; pnt.X);

                j = i;
            }
            return inside2D;
        }&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Jul 2015 13:45:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/help-get-point3d-within-boundary/m-p/5749836#M39118</guid>
      <dc:creator>SENL1362</dc:creator>
      <dc:date>2015-07-30T13:45:55Z</dc:date>
    </item>
    <item>
      <title>Re: Help get Point3d within boundary ?</title>
      <link>https://forums.autodesk.com/t5/net-forum/help-get-point3d-within-boundary/m-p/5749849#M39119</link>
      <description>&lt;P&gt;Thank SENL. i can do it.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2015 13:46:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/help-get-point3d-within-boundary/m-p/5749849#M39119</guid>
      <dc:creator>anhtrung</dc:creator>
      <dc:date>2015-07-30T13:46:09Z</dc:date>
    </item>
  </channel>
</rss>

