<?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: Create rectangle using &amp;quot;AddVertexAt&amp;quot; using Point3d in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/create-rectangle-using-quot-addvertexat-quot-using-point3d/m-p/3459796#M55548</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Polyline has a elevation property, so &lt;FONT color="#0000FF"&gt;pline.Elevation=Z&lt;/FONT&gt; it's what you need.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Gaston Nunez&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 16 May 2012 14:58:51 GMT</pubDate>
    <dc:creator>hgasty1001</dc:creator>
    <dc:date>2012-05-16T14:58:51Z</dc:date>
    <item>
      <title>Create rectangle using "AddVertexAt" using Point3d</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-rectangle-using-quot-addvertexat-quot-using-point3d/m-p/3459664#M55547</link>
      <description>&lt;P&gt;Hey everyone, yet another question...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've got my code to create a rectangle just fine, however i've noticed it doesn't take "Z" coordinates at all. I've got through the code and found my issue to be at these lines;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
                using (Polyline pline = new Polyline())
                {
                    pline.AddVertexAt(0, new Point2d(LowerLeft.X, LowerLeft.Y), 0.0, 0.0, 0.0);
                    pline.AddVertexAt(1, new Point2d(UpperRight.X, LowerLeft.Y), 0.0, 0.0, 0.0);
                    pline.AddVertexAt(2, new Point2d(UpperRight.X, UpperRight.Y), 0.0, 0.0, 0.0);
                    pline.AddVertexAt(3, new Point2d(LowerLeft.X, UpperRight.Y), 0.0, 0.0, 0.0);
                    pline.Closed = true;
                    btr.AppendEntity(pline);
                    tr.AddNewlyCreatedDBObject(pline, true);
                }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I need to use a Point3d in order to add "Z" but apparently the pline.AddVertexAt only allows for a Point2d. Has any come across this or know of a solution?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;Vince&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2012 14:21:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-rectangle-using-quot-addvertexat-quot-using-point3d/m-p/3459664#M55547</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-05-16T14:21:06Z</dc:date>
    </item>
    <item>
      <title>Re: Create rectangle using "AddVertexAt" using Point3d</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-rectangle-using-quot-addvertexat-quot-using-point3d/m-p/3459796#M55548</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Polyline has a elevation property, so &lt;FONT color="#0000FF"&gt;pline.Elevation=Z&lt;/FONT&gt; it's what you need.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Gaston Nunez&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2012 14:58:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-rectangle-using-quot-addvertexat-quot-using-point3d/m-p/3459796#M55548</guid>
      <dc:creator>hgasty1001</dc:creator>
      <dc:date>2012-05-16T14:58:51Z</dc:date>
    </item>
    <item>
      <title>Re: Create rectangle using "AddVertexAt" using Point3d</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-rectangle-using-quot-addvertexat-quot-using-point3d/m-p/3459808#M55549</link>
      <description>&lt;P&gt;Thanks gasty. any chance you have an example of this in action?&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2012 15:04:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-rectangle-using-quot-addvertexat-quot-using-point3d/m-p/3459808#M55549</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-05-16T15:04:28Z</dc:date>
    </item>
    <item>
      <title>Re: Create rectangle using "AddVertexAt" using Point3d</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-rectangle-using-quot-addvertexat-quot-using-point3d/m-p/3459914#M55550</link>
      <description>&lt;P&gt;Actually scratch that, I still need to use a 3dPolyline as I will have differing start and end elevations. Is it possible to modify the above code to use a 3dPolyline?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks Again&lt;/P&gt;&lt;P&gt;Vince&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2012 15:40:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-rectangle-using-quot-addvertexat-quot-using-point3d/m-p/3459914#M55550</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-05-16T15:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: Create rectangle using "AddVertexAt" using Point3d</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-rectangle-using-quot-addvertexat-quot-using-point3d/m-p/3460018#M55551</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will draw a rectangle with a elevation of 400&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    &amp;lt;CommandMethod("DREC")&amp;gt; _
    Public Sub DrawRect()
        Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
        Dim db As Database = HostApplicationServices.WorkingDatabase()
        Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
        Dim p1, p2 As Point3d

        Using acTrans As Transaction = db.TransactionManager.StartTransaction()
            Dim acSSPrompt As PromptPointResult = doc.Editor.GetPoint("Select First Point: ")
            If acSSPrompt.Status = PromptStatus.OK Then
                p1 = acSSPrompt.Value
                acSSPrompt = doc.Editor.GetCorner(vbCrLf + "Select Second Point: ", p1)
                If acSSPrompt.Status = PromptStatus.OK Then
                    p2 = acSSPrompt.Value
                Else
                    MsgBox("Invalid point")
                    Exit Sub
                End If
            Else
                MsgBox("Invalid point")
                Exit Sub
            End If

            Dim v1 As Vector3d
            Dim theta As Double
            Dim p3, p4 As TVertex
            Dim a, b, l, s As Double
            Dim d As Double

            v1 = p1.GetVectorTo(p2)
            theta = v1.GetAngleTo(Vector3d.XAxis, Vector3d.ZAxis.Negate())
            d = p1.DistanceTo(p2)
            a = d * Math.Cos(theta)
            b = d * Math.Sin(theta)
            l = 2 * (Math.Abs(a) + Math.Abs(b))
            s = Math.Abs(a * b)

            If s &amp;lt;= 0.001 Then
                MsgBox("Degenerated Rectangle, try again", vbCritical)
                Exit Sub
            End If

            p3 = New Point3d(p1.X + a, p1.Y, p1.Z)
            p4 = New Point3d(p1.X, p1.Y + b, p1.Z)

            Dim pl As New Polyline

            pl.AddVertexAt(0, New Point2d(p1.X, p1.Y), 0, 0, 0)
            pl.AddVertexAt(1, New Point2d(p3.X, p3.Y), 0, 0, 0)
            pl.AddVertexAt(2, New Point2d(p2.X, p2.Y), 0, 0, 0)
            pl.AddVertexAt(3, New Point2d(p4.X, p4.Y), 0, 0, 0)
            pl.Closed = True
            pl.Elevation = 400 '&amp;lt;---------------------Elevation

            Dim acBlkTbl As BlockTable
            acBlkTbl = acTrans.GetObject(db.BlockTableId, OpenMode.ForRead)
            Dim acBlkTblRec As BlockTableRecord
            acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite)

            acBlkTblRec.AppendEntity(pl)
            acTrans.AddNewlyCreatedDBObject(pl, True)

            ed.WriteMessage(vbCrLf + "Rectangle length:=" + l.ToString + vbCrLf)
            ed.WriteMessage("Rectangle Area:=" + s.ToString + vbCrLf)
            ed.WriteMessage("Width:=" + Math.Abs(a).ToString + vbCrLf)
            ed.WriteMessage("Height:=" + Math.Abs(b).ToString + vbCrLf)

            acTrans.Commit()
        End Using
    End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Gaston Nunez&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2012 16:20:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-rectangle-using-quot-addvertexat-quot-using-point3d/m-p/3460018#M55551</guid>
      <dc:creator>hgasty1001</dc:creator>
      <dc:date>2012-05-16T16:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: Create rectangle using "AddVertexAt" using Point3d</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-rectangle-using-quot-addvertexat-quot-using-point3d/m-p/3460088#M55552</link>
      <description>&lt;P&gt;Ahh that makes much more sense. Is it possible to create the vertexes using Point3D so that each vertex may be given a unique "Z"? I've been playing around with the InsertVertexAt properties of Point3D with no luck.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
                using (Polyline pline = new Polyline())      
               // using (Polyline3d pline3d = new Polyline3d())
              //  using (PolylineVertex3d vertex = new PolylineVertex3d())
                
                {                
                    
                  //  pline3d.InsertVertexAt (0,);

                    pline.AddVertexAt(0, new Point2d(LowerLeft.X, LowerLeft.Y), 0.0, 0.0, 0.0);
                    pline.AddVertexAt(1, new Point2d(UpperRight.X, LowerLeft.Y), 0.0, 0.0, 0.0);
                    pline.AddVertexAt(2, new Point2d(UpperRight.X, UpperRight.Y), 0.0, 0.0, 0.0);
                    pline.AddVertexAt(3, new Point2d(LowerLeft.X, UpperRight.Y), 0.0, 0.0, 0.0);
                    pline.Closed = true;
                    pline.Elevation = LowerLeft.Z;
                    btr.AppendEntity(pline);
                    tr.AddNewlyCreatedDBObject(pline, true);
                }
                tr.Commit();
            }
        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2012 16:48:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-rectangle-using-quot-addvertexat-quot-using-point3d/m-p/3460088#M55552</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-05-16T16:48:04Z</dc:date>
    </item>
    <item>
      <title>Re: Create rectangle using "AddVertexAt" using Point3d</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-rectangle-using-quot-addvertexat-quot-using-point3d/m-p/3460154#M55553</link>
      <description>&lt;P&gt;For a Polyline3d you either pass a Point3dCollection of your vertex coordinates into the constructor, or you call the constructor with no arguments and use&lt;/P&gt;&lt;PRE&gt;PLObj.AppendVertex(&lt;SPAN style="color: blue;"&gt;New&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="color: #2b91af;"&gt;PolylineVertex3d&lt;/SPAN&gt;(LowerLeft))&lt;/PRE&gt;&lt;P&gt;and so on...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Depending on your specific needs, you potentially have two other options.&amp;nbsp; You could still use a Polyline, and use TransformBy to rotate it around the x and/or y axis to get the proper orientation, or you could set the Normal property to accomplish the same thing.&amp;nbsp; A Polyline must be planar, but it does not have to be parallel to the XY plane.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm thinking the easiest route is to use a Polyline3d, and as long as you aren't making thousands of them, the additional overhead shouldn't be a problem.&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2012 17:19:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-rectangle-using-quot-addvertexat-quot-using-point3d/m-p/3460154#M55553</guid>
      <dc:creator>chiefbraincloud</dc:creator>
      <dc:date>2012-05-16T17:19:09Z</dc:date>
    </item>
    <item>
      <title>Re: Create rectangle using "AddVertexAt" using Point3d</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-rectangle-using-quot-addvertexat-quot-using-point3d/m-p/3460158#M55554</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No, you can't add a Point3D as a vertex to a Polyline, &amp;nbsp;i fyou need a "sloped" rectangle, you have to setup the plane (UCS) &amp;nbsp;on that the Polyline will lie on, and that, I think, &amp;nbsp;requires some Matrix3d manipulation. You can read this post on Theswamp:&amp;nbsp;&lt;A href="http://www.theswamp.org/index.php?topic=41571.0" target="_blank"&gt;http://www.theswamp.org/index.php?topic=41571.0&lt;/A&gt;, I have no time now to code but i'll check this topic.&lt;/P&gt;&lt;P&gt;later.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any way, if you need to put the vertex list of a Polyline ina Point3dCollection, it's simple:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim n as integer=Pline.NumberOfVertices-1&lt;/P&gt;&lt;P&gt;Dim i as integer&lt;/P&gt;&lt;P&gt;Dim pc as new Point3dCollection&lt;/P&gt;&lt;P&gt;Dim vertexList as new list (of Point3D)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For i=Pline.StartParameter to n&lt;/P&gt;&lt;P&gt;&amp;nbsp;pc.Add(Pline.GetPointAtparaMeter(i))&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;vertexList .Add(&lt;SPAN&gt;Pline.GetPointAtparaMeter(i))&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Next&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note1:I'd prefer to use a list instead of Point3dCollection in most cases.&lt;/P&gt;&lt;P&gt;Note2: The GetPointAtParameter returns a Point3D with Z=Elevation,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Gaston Nunez&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2012 17:21:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-rectangle-using-quot-addvertexat-quot-using-point3d/m-p/3460158#M55554</guid>
      <dc:creator>hgasty1001</dc:creator>
      <dc:date>2012-05-16T17:21:02Z</dc:date>
    </item>
  </channel>
</rss>

