chek for correct pick of a polyline

Discussion in 'AutoCAD' started by Henrik, Nov 30, 2004.

  1. Henrik

    Henrik Guest

    How can I check that I pick a polyline when I ask for it. I want a loop to
    reselect if I miss the polyline.



    Dim lineobj1 as object

    ThisDrawing.Utility.GetEntity lineObj1, LinePickPnt, "Select Polyline:"

    Thanks Henrik
     
    Henrik, Nov 30, 2004
    #1
  2. The object's ObjectName property will be "AcadPolyline". Check the help
    file for more info.
     
    John Goodfellow, Nov 30, 2004
    #2
  3. Henrik

    Jeff Mishler Guest

    Generally this can be done like this:
    Code:
    Option Explicit
    
    Function pickPoly() As AcadLWPolyline
    Dim oEnt As AcadEntity
    Dim OPoly As AcadLWPolyline
    Dim vPick As Variant
    
    Do While OPoly Is Nothing
    ThisDrawing.Utility.GetEntity oEnt, vPick, vbCr & "Select polyline: "
    If TypeOf oEnt Is AcadLWPolyline Then
    Set OPoly = oEnt
    Exit Do
    End If
    MsgBox "I said Select a POLYLINE, knucklehead!!!!", , "Invalid
    Selection"
    Loop
    Set pickPoly = OPoly
    End Function
    
    Sub test()
    Dim poly As AcadLWPolyline
    
    Set poly = pickPoly
    End Sub
    
    However, you should include some error checking in case the user presses ESC
    to exit out.
     
    Jeff Mishler, Nov 30, 2004
    #3
  4. Henrik

    Mikko Guest

    There are several ways to approach this, here is one.

    Dim lineobj As Object
    Retry:
    acadUtl.GetEntity(ReturnBall, BasePt, "Select a PLine")
    If lineobj.EntityName <> "AcDbPolyline" Then
    GoTo Retry
    Else
    'do your thing here
    End If
     
    Mikko, Nov 30, 2004
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.