<?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: Segment of a Polyline in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/segment-of-a-polyline/m-p/12032036#M8512</link>
    <description>&lt;P&gt;If you looked at the Polyline class (in Object Browser window of Visual Studio), you would have found a bunch of methods: GetXxxxx(int). These methods are the one you can use to find out information on each segment of a Polyline.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 14 Jun 2023 00:49:10 GMT</pubDate>
    <dc:creator>norman.yuan</dc:creator>
    <dc:date>2023-06-14T00:49:10Z</dc:date>
    <item>
      <title>Segment of a Polyline</title>
      <link>https://forums.autodesk.com/t5/net-forum/segment-of-a-polyline/m-p/12031800#M8511</link>
      <description>&lt;P&gt;Can you please let me know how to get the segment of a polyline between the two points i derived.&amp;nbsp; I tried using GetSplitCurves() but couldn't get precise segment.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2023 21:53:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/segment-of-a-polyline/m-p/12031800#M8511</guid>
      <dc:creator>naveenkuma.mukku</dc:creator>
      <dc:date>2023-06-13T21:53:12Z</dc:date>
    </item>
    <item>
      <title>Re: Segment of a Polyline</title>
      <link>https://forums.autodesk.com/t5/net-forum/segment-of-a-polyline/m-p/12032036#M8512</link>
      <description>&lt;P&gt;If you looked at the Polyline class (in Object Browser window of Visual Studio), you would have found a bunch of methods: GetXxxxx(int). These methods are the one you can use to find out information on each segment of a Polyline.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2023 00:49:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/segment-of-a-polyline/m-p/12032036#M8512</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2023-06-14T00:49:10Z</dc:date>
    </item>
    <item>
      <title>Re: Segment of a Polyline</title>
      <link>https://forums.autodesk.com/t5/net-forum/segment-of-a-polyline/m-p/12032172#M8513</link>
      <description>&lt;P&gt;After using&amp;nbsp;&lt;SPAN&gt;GetSplitCurves(), you could test if any segment intersects with both cutting point to get the exact segment.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;[CommandMethod("splitpoly")]
        public void Test()
        {
            Document acDoc = AcadApp.DocumentManager.MdiActiveDocument;
            Database acDb = acDoc.Database;
            Editor ed = acDoc.Editor;

            using(Transaction acTrans = acDoc.TransactionManager.StartTransaction())
            {
                // Get blocktable and blocltablerecord
                BlockTable acBlkTbl = acTrans.GetObject(acDb.BlockTableId,OpenMode.ForRead) as BlockTable;                
                BlockTableRecord acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],OpenMode.ForWrite) as BlockTableRecord;

                // Get polyline
                PromptEntityResult plRet = ed.GetEntity("Please pick a polyline\n");
                if (plRet.Status != PromptStatus.OK)
                {
                    return;
                }
                Polyline pl = acTrans.GetObject(plRet.ObjectId, OpenMode.ForWrite) as Polyline;
                if(pl == null)
                {
                    return;
                }

                // Get cutting point
                PromptPointResult pt1Ret = ed.GetPoint("Please pick the first split point on previous selected polyline.\n");
                if (pt1Ret.Status != PromptStatus.OK)
                {
                    return;
                }
                Point3d pt1 = pt1Ret.Value;

                PromptPointResult pt2Ret = ed.GetPoint("Please pick the second split point on previous selected polyline.\n");
                if (pt2Ret.Status != PromptStatus.OK)
                {
                    return;
                }
                Point3d pt2 = pt2Ret.Value;

                // Get cutting point collection
                Point3dCollection ptColl = new Point3dCollection();
                ptColl.Add(pt1);
                ptColl.Add(pt2);

                // Split the polyline with point collection
                DBObjectCollection dbColl = pl.GetSplitCurves(ptColl);

                // If any segment of the polyline intersects with both two cutting points, add it to database.
                foreach (DBObject obj in dbColl)
                {
                    Polyline subPl = obj as Polyline;
                    Point3d startPt = subPl.StartPoint;
                    Point3d endPt = subPl.EndPoint;
                    
                    if((pt1 == startPt &amp;amp;&amp;amp; pt2 == endPt) || (pt1 == endPt &amp;amp;&amp;amp; pt2 == startPt))
                    {
                        subPl.ConstantWidth = 2;
                        acBlkTblRec.AppendEntity(subPl);
                        acTrans.AddNewlyCreatedDBObject(subPl,true);
                    }                   
                }
                acTrans.Commit();
            }
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2023 02:44:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/segment-of-a-polyline/m-p/12032172#M8513</guid>
      <dc:creator>Miralkong</dc:creator>
      <dc:date>2023-06-14T02:44:33Z</dc:date>
    </item>
  </channel>
</rss>

