.NET

.NET

Reply
Valued Contributor
chockalingam
Posts: 87
Registered: ‎03-06-2012
Message 1 of 7 (288 Views)
Accepted Solution

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

288 Views, 6 Replies
03-09-2012 12:23 AM

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

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 -

*Expert Elite*
Alfred.NESWADBA
Posts: 9,606
Registered: ‎06-29-2007
Message 2 of 7 (283 Views)

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

03-09-2012 12:28 AM in reply to: chockalingam

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
-------------------------------------------------------------------------
Valued Contributor
chockalingam
Posts: 87
Registered: ‎03-06-2012
Message 3 of 7 (281 Views)

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

03-09-2012 12:35 AM in reply to: chockalingam

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

Valued Contributor
chockalingam
Posts: 87
Registered: ‎03-06-2012
Message 4 of 7 (266 Views)

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

03-09-2012 01:39 AM 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.

*Expert Elite*
Alfred.NESWADBA
Posts: 9,606
Registered: ‎06-29-2007
Message 5 of 7 (250 Views)

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

03-09-2012 02:00 AM in reply to: chockalingam

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
-------------------------------------------------------------------------
Valued Contributor
chockalingam
Posts: 87
Registered: ‎03-06-2012
Message 6 of 7 (240 Views)

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

03-09-2012 02:28 AM in reply to: chockalingam

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

*Expert Elite*
Alfred.NESWADBA
Posts: 9,606
Registered: ‎06-29-2007
Message 7 of 7 (235 Views)

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

03-09-2012 02:30 AM in reply to: chockalingam

Hi,

 

>> How to define things in CUIX

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

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.