• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    .NET

    Reply
    Active Contributor
    Posts: 43
    Registered: ‎03-06-2012
    Accepted Solution

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

    172 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

    Please use plain text.
    *Expert Elite*
    Posts: 6,460
    Registered: ‎06-29-2007

    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
    -------------------------------------------------------------------------
    Please use plain text.
    Active Contributor
    Posts: 43
    Registered: ‎03-06-2012

    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......

    Please use plain text.
    Active Contributor
    Posts: 43
    Registered: ‎03-06-2012

    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.

    Please use plain text.
    *Expert Elite*
    Posts: 6,460
    Registered: ‎06-29-2007

    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
    -------------------------------------------------------------------------
    Please use plain text.
    Active Contributor
    Posts: 43
    Registered: ‎03-06-2012

    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..................

    Please use plain text.
    *Expert Elite*
    Posts: 6,460
    Registered: ‎06-29-2007

    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
    -------------------------------------------------------------------------
    Please use plain text.