.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to create a Line with multiple Insertion Points as in Autocad

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
chockalingam
608 Views, 6 Replies

How to create a Line with multiple Insertion Points as in Autocad

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

6 REPLIES 6
Message 2 of 7

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 -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 3 of 7
chockalingam
in reply to: chockalingam

Thanks for your reply, exactly this is what I searched for......

Message 4 of 7
chockalingam
in reply to: chockalingam

Is it possible to show the scale,angle and enable right click in the above code  as same as Autocad Line.

Message 5 of 7

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 -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 6 of 7
chockalingam
in reply to: chockalingam

How to define things in CUIX...... Can i have any reference..................

Message 7 of 7

Hi,

 

>> How to define things in CUIX

that's a lot, starting >>>here<<<, taking some popcorn and read/learn/read/learn.... 😉

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost