Hi Jack, try another one, though not tested enough,
but I think you need to use custom polyline jig in this case
Public Function RadiansToDegrees(ByVal radians As Double) As Double
Return (180 / Math.PI) * radians
End Function
<CommandMethod("ord")> _
Public Sub PickMultiplePoints()
Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim db As Database = HostApplicationServices.WorkingDatabase
Dim ed As Editor = doc.Editor
Dim pts As Point3dCollection = New Point3dCollection()
Dim osm As Int16 = Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("osmode")
Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("osmode", 0)
Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("orthomode", 0)
Try
Using tr As Transaction = db.TransactionManager.StartTransaction()
Dim btr As BlockTableRecord = TryCast(tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)
Dim n As Integer = 0
Dim strang As String = ""
Dim ang As Double = 0
Dim fstPnt As Point3d = ed.GetPoint(vbLf & "Pick first point: ").Value
Dim plan As New Plane(fstPnt, Vector3d.ZAxis)
pts.Add(fstPnt)
While True
Dim ppo As New PromptPointOptions(vbLf & "Pick Next Point (or hit ""Enter"" to Exit): ")
ppo.AllowNone = True
Dim ppr As PromptPointResult
ppo.UseDashedLine = True
ppo.UseBasePoint = True
ppo.BasePoint = fstPnt
ppr = ed.GetPoint(ppo)
If (Not (ppr.Status = PromptStatus.OK)) Or (ppr.Status = PromptStatus.None) Then
Exit While
End If
Dim endPnt As Point3d = ppr.Value
pts.Add(endPnt)
ed.DrawVector(fstPnt, endPnt, 1, True)
If n = 0 Then
ang = RadiansToDegrees((fstPnt - endPnt).AngleOnPlane(plan)) + 90
Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("orthomode", 1)
strang = String.Format("<{0} ", ang)
doc.SendStringToExecute(strang, False, False, True)
Else
ang = RadiansToDegrees((fstPnt - endPnt).AngleOnPlane(plan)) + 90
strang = String.Format("<{0} ", ang)
doc.SendStringToExecute(strang, False, False, True)
End If
n += 1
fstPnt = endPnt
tr.TransactionManager.QueueForGraphicsFlush()
End While
Dim poly As New Polyline
Dim i As Integer = 0
For i = 0 To pts.Count - 1
poly.AddVertexAt(i, New Point2d(pts(i).X, pts(i).Y), 0, 0, 0)
Next
btr.AppendEntity(poly)
tr.AddNewlyCreatedDBObject(poly, True)
doc.TransactionManager.FlushGraphics()
ed.Regen()
tr.Commit()
End Using
Catch ex As System.Exception
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(vbLf & ex.Message & vbLf + ex.StackTrace)
Finally
Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("orthomode", 0)
Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("osmode", osm)
End Try
End Sub
~'J'~
_____________________________________
C6309D9E0751D165D0934D0621DFF27919