I tryed to go down that path too, then found this.
Worked for me.
Private Function DrawPolyGraphics() As ObjectId
Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("cmdecho", 0)
Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim ed As Editor = doc.Editor
Dim db As Database = doc.Database
Dim RetOID As ObjectId = ObjectId.Null
Dim msg As String = vbLf & "Pick first point: "
Dim ppo As New PromptPointOptions(msg)
ppo.AllowNone = True
Dim usept As Boolean = False
Dim ppr As PromptPointResult = ed.GetPoint(ppo)
Dim pnt As Point3d = ppr.Value
ppo.AllowNone = True
ppo.UseBasePoint = True
ppo.UseDashedLine = True
ppo.Keywords.Add("Undo")
Dim undokKeyword As Keyword = ppo.Keywords(0)
Using DokLock As DocumentLock = doc.LockDocument
Using Trans As Transaction = doc.TransactionManager.StartTransaction()
doc.TransactionManager.EnableGraphicsFlush(True)
Dim btr As BlockTableRecord = DirectCast(Trans.GetObject(db.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)
Dim pl As New Polyline()
Dim plan As Plane = pl.GetPlane()
pl.AddVertexAt(0, pnt.TransformBy(ed.CurrentUserCoordinateSystem).Convert2d(plan), 0, 0, 0)
If MyDialogSettings.LayerName <> String.Empty Then
Dim LayerTab As LayerTable = DirectCast(Trans.GetObject(db.LayerTableId, OpenMode.ForRead), LayerTable)
If LayerTab.Has(MyDialogSettings.LayerName) Then
pl.Layer = MyDialogSettings.LayerName
Else
ed.WriteMessage("Current Drawing is missing " & MyDialogSettings.LayerName & ", Contact CAD Support" & vbCrLf)
End If
End If
btr.AppendEntity(pl)
RetOID = pl.ObjectId
Trans.AddNewlyCreatedDBObject(pl, True)
Trans.TransactionManager.QueueForGraphicsFlush()
Dim strHandle As String = pl.Handle.ToString()
Do
ppo.BasePoint = pnt
undokKeyword.Enabled = pl.NumberOfVertices > 1
msg = vbLf & "Pick next point: "
ppo.Message = msg
ppr = ed.GetPoint(ppo)
If ppr.Status = PromptStatus.Cancel Then
Return ObjectId.Null
End If
If ppr.Status = PromptStatus.Keyword Then
pl.RemoveVertexAt(pl.NumberOfVertices - 1)
If pl.NumberOfVertices > 1 AndAlso pl.GetBulgeAt(pl.NumberOfVertices - 2) <> 0 Then
pl.RemoveVertexAt(pl.NumberOfVertices - 1)
pl.SetBulgeAt(pl.NumberOfVertices - 1, 0)
End If
pnt = pl.GetPoint3dAt(pl.NumberOfVertices - 1)
pl.Draw()
End If
If ppr.Status = PromptStatus.OK Then
pnt = ppr.Value
pl.AddVertexAt(pl.NumberOfVertices, pnt.TransformBy(ed.CurrentUserCoordinateSystem).Convert2d(plan), 0, 0, 0)
Trans.TransactionManager.QueueForGraphicsFlush()
End If
usept = True
ppo.BasePoint = pnt
Loop While ppr.Status = PromptStatus.OK
doc.TransactionManager.FlushGraphics()
Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("CMDECHO", 1)
' pl.MinimizeMemory();// UpdateScreen do it instead
ed.UpdateScreen()
Trans.Commit()
End Using
End Using
Return RetOID
End Function