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.
Solved by Alfred.NESWADBA. Go to Solution.
Hi,
check this, I think that is what you are searching for:
Dim ppo As PromptPointOptions = New PromptPointOptions(vbCrLf & "Select Next Point") ppo.BasePoint = _startpoint 'previous point ppo.UseBasePoint = True 'so it drags the line-segment while you move the cursor ppo.UseDashedLine = True 'optional ppr = acCurEd.GetPoint(ppo)
HTH, - alfred -
Is it possible to show the scale,angle and enable right click in the above code as same as Autocad Line.
Hi,
>> to show the scale,angle
Not really sure waht a scale-angle is. If you need some text displayed on your screen while dragging anything you will have to go through JIG-functionality (look >>>here<<<, but do also your own search for "JIG")
>> enable right click
You can capture your mouse-buttons, you can define/add keywords to your prompt to get options (e.g. look at AppendKeywordsToMessage) or you have to define similar things in your CUIX, depends on what you want to do with the right-click.
- alfred -
How to define things in CUIX...... Can i have any reference..................
Hi,
>> How to define things in CUIX
that's a lot, starting >>>here<<<, taking some popcorn and read/learn/read/learn.... 😉
- alfred -
Can't find what you're looking for? Ask the community or share your knowledge.