- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to create a tool that looks similar to Line in Autocad. I got the solution for dynamic multiple insertion points but the issue is the line is only visible after the end point is selected. But i want the line to be visible before selecting the end point, this should be as same as the line we use in autocad. Following is the code i used to create a line with multiple insertion points.
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim acCurEd As Editor = acDoc.Editor
Using lock As DocumentLock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument
Dim ppo As PromptPointOptions = New PromptPointOptions(vbCrLf & "Select Insertion Point:")
Dim ppr As PromptPointResult = acCurEd.GetPoint(ppo)
Dim _startpoint, _endpoint As Point3d
If ppr.Status = PromptStatus.OK Then
_startpoint = ppr.Value
End If
Dim i As Integer = 0
While i = 0
Dim acCurDb As Database = acDoc.Database
Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
Dim _newentLine As New Line
ppo = New PromptPointOptions(vbCrLf & "Select Next Point")
ppr = acCurEd.GetPoint(ppo)
If ppr.Status = PromptStatus.OK Then
_endpoint = ppr.Value
Else
i = 1
Continue While
End If
_newentLine.StartPoint = _startpoint
_newentLine.EndPoint = _endpoint
Dim acBlkTbl As BlockTable = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForWrite)
Dim acBlkTblRec As BlockTableRecord = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
acBlkTblRec.AppendEntity(_newentLine)
acTrans.AddNewlyCreatedDBObject(_newentLine, True)
acTrans.Commit()
acBlkTblRec.Dispose()
acBlkTbl.Dispose()
_startpoint = _endpoint
_newentLine.Dispose()
End Using
acCurDb.Dispose()
End While
End Using
Solved! Go to Solution.