Drawing multiple polylines

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to draw multiple LWPOLYLINES and I can't seem to figure out how. I can draw one shape OK but when I try to draw another one it fails. I can do a similar thing with lines but can't make it work with polylines. The first little routine is lifted from Jerry Winters' book as is the 'AddToModelSpace' code.
Thanks for any help.
Mark
Public Class DrawPoly
<CommandMethod("DrawPoly2")> _
Public Sub DrawPoly()
'This little routine draws several lines by changing the points and
'calling the add routine. This works OK.
Dim myStartPoint As Point3d = DocumentManager.MdiActiveDocument.Editor.GetPoint("pick point").Value
For x As Double = myStartPoint.X - 4 To myStartPoint.X + 4
Dim myline As New Line(myStartPoint, New Point3d(x, myStartPoint.Y + 2, 0))
Util.AddToModelSpace(HostApplicationServices.WorkingDatabase, myline)
Next x
Dim PL As New Polyline
PL.AddVertexAt(0, New Point2d(0, 0), 0, 0, 0)
PL.AddVertexAt(1, New Point2d(1, 0), 0, 0, 0)
PL.AddVertexAt(2, New Point2d(1, 1), 0, 0, 0)
PL.AddVertexAt(3, New Point2d(0, 1), 0, 0, 0)
PL.AddVertexAt(3, New Point2d(0, 0), 0, 0, 0)
Util.AddToModelSpace(HostApplicationServices.WorkingDatabase, PL)
'This works and draws a little box
'Now change the vertices and draw another one.
'Uncomment these lines and it fails
'PL.AddVertexAt(0, New Point2d(5, 5), 0, 0, 0)
'PL.AddVertexAt(1, New Point2d(5, 6), 0, 0, 0)
'PL.AddVertexAt(2, New Point2d(6, 6), 0, 0, 0)
'PL.AddVertexAt(3, New Point2d(5, 6), 0, 0, 0)
'PL.AddVertexAt(4 New Point2d(5, 5), 0, 0, 0)
'Util.AddToModelSpace(HostApplicationServices.WorkingDatabase, PL)
End Sub