<?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 to draw polyline from collection of 3d points? in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-draw-polyline-from-collection-of-3d-points/m-p/8568893#M23655</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Polyline.AddVertexAt() method requires Point2d as argument, so you have to iterate through the Point3dCollection and convert each Point3d to a Point2d, this can be done using the Point3d.Convert2d() method passing it the plane you want to draw the polyline on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a little example to draw the polyline on the XY plane.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;            using (doc.LockDocument())
            using (var tr = doc.TransactionManager.StartTransaction())
            using (var pline = new Polyline())
            {
                var plane = new Plane(Point3d.Origin, Vector3d.ZAxis);
                for (int i = 0; i &amp;lt; points.Count; i++)
                {
                    pline.AddVertexAt(i, points[i].Convert2d(plane), 0.0, 0.0, 0.0);
                }
                var ms = (BlockTableRecord)tr.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForWrite);
                ms.AppendEntity(pline);
                tr.AddNewlyCreatedDBObject(pline, true);
                tr.Commit();
            }&lt;/PRE&gt;</description>
    <pubDate>Sat, 02 Feb 2019 17:47:22 GMT</pubDate>
    <dc:creator>_gile</dc:creator>
    <dc:date>2019-02-02T17:47:22Z</dc:date>
    <item>
      <title>How to draw polyline from collection of 3d points?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-draw-polyline-from-collection-of-3d-points/m-p/8568804#M23654</link>
      <description>&lt;P&gt;Hi. How can I draw a polyline from a previously defined collection of 3d points?&lt;/P&gt;
&lt;P&gt;I create a collection by:&lt;/P&gt;
&lt;PRE&gt;Dim Linia = New Point3dCollection&lt;/PRE&gt;
&lt;P&gt;Then I add points to this collection through:&lt;/P&gt;
&lt;PRE&gt;Linia.Add(New Point3d((Val(Py)), (Val(Px)), 0))&lt;/PRE&gt;
&lt;P&gt;And I want to draw Polyline from this collection. I use this code:&lt;/P&gt;
&lt;PRE&gt;            Using acLckDoc As DocumentLock = acDoc.LockDocument
                Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
                    acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead)
                    acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace),
                OpenMode.ForWrite)
                    Using acPLine As Polyline = New Polyline()
                        acPLine.AddVertexAt(0, Linia, 0, 0, 0)
                        acBlkTblRec.AppendEntity(acPLine)
                        acTrans.AddNewlyCreatedDBObject(acPLine, True)
                        acPLine.ColorIndex = 1
                    End Using
                    acTrans.Commit()
                End Using
            End Using&lt;/PRE&gt;
&lt;P&gt;But this code causes the following error:&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Error BC30311 Value of type 'Point3dCollection' cannot be converted to 'Point2d'.&lt;/U&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 02 Feb 2019 15:58:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-draw-polyline-from-collection-of-3d-points/m-p/8568804#M23654</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-02-02T15:58:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to draw polyline from collection of 3d points?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-draw-polyline-from-collection-of-3d-points/m-p/8568893#M23655</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Polyline.AddVertexAt() method requires Point2d as argument, so you have to iterate through the Point3dCollection and convert each Point3d to a Point2d, this can be done using the Point3d.Convert2d() method passing it the plane you want to draw the polyline on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a little example to draw the polyline on the XY plane.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;            using (doc.LockDocument())
            using (var tr = doc.TransactionManager.StartTransaction())
            using (var pline = new Polyline())
            {
                var plane = new Plane(Point3d.Origin, Vector3d.ZAxis);
                for (int i = 0; i &amp;lt; points.Count; i++)
                {
                    pline.AddVertexAt(i, points[i].Convert2d(plane), 0.0, 0.0, 0.0);
                }
                var ms = (BlockTableRecord)tr.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForWrite);
                ms.AppendEntity(pline);
                tr.AddNewlyCreatedDBObject(pline, true);
                tr.Commit();
            }&lt;/PRE&gt;</description>
      <pubDate>Sat, 02 Feb 2019 17:47:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-draw-polyline-from-collection-of-3d-points/m-p/8568893#M23655</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2019-02-02T17:47:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to draw polyline from collection of 3d points?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-draw-polyline-from-collection-of-3d-points/m-p/8568909#M23656</link>
      <description>&lt;P&gt;Thank you very much.&lt;/P&gt;</description>
      <pubDate>Sat, 02 Feb 2019 18:07:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-draw-polyline-from-collection-of-3d-points/m-p/8568909#M23656</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-02-02T18:07:59Z</dc:date>
    </item>
  </channel>
</rss>

