"Escaping" from point selection

Discussion in 'AutoCAD' started by Chris Cox, Apr 21, 2004.

  1. Chris Cox

    Chris Cox Guest

    I would like to allow the user to select several points that will be used in
    my program. I want the user to be able to select a point, and then be able
    to hit the "escape" key when they are finished selected their points.

    I am using the "GetPoint" method, which will accept the points fine. The
    problem is that I cannot loop this as many times as the user selectes a
    point, and then stop the loop once the users "escapes". The user needs to
    be in full control so that they can enter as many points as they need to.

    Any suggestions?

    Thanks,
    Chris Cox
     
    Chris Cox, Apr 21, 2004
    #1
  2. Nathan Taylor, Apr 21, 2004
    #2
  3. Standard behavior for the ESC key is to cancel
    a command. If you want to play nice, then allow
    the user to press SPACE/ENTER to exit the point
    entry loop.

    In general, deviating from standard ESC behavor
    is ill advised.
     
    Tony Tanzillo, Apr 21, 2004
    #3
  4. Chris Cox

    A Seidel Guest


    This seems to work:

    Put this under the Thisdrawing code:

    Public Function GetPoint(Optional pt As Variant, Optional Prompt As
    String) As Variant
    On Error Resume Next
    Do
    GetPoint = ThisDrawing.Utility.GetPoint(pt, Prompt)
    If err Then
    If StrComp(err.Description, "User input is a keyword", 1)
    = 0 Then
    err.Clear
    Exit Do
    ElseIf GetAsyncKeyState(&H1B) And &H8000 Then
    err.Clear
    Exit Do
    End If
    Else
    Exit Do
    End If
    err.Clear
    Loop
    End Function

    The use something like this in your operating code:

    Private Sub GetAllColDistByPnts()
    Dim ptnew As Variant
    Dim ptlast As Variant
    Dim Dist As Double
    Dim col As Integer
    On Error GoTo UserCAN
    ReDim ColDataArray(0)
    col = 1
    ptlast = ThisDrawing.GetPoint(, vbCr & "Select left side of column
    " + CStr(col) + ". (Esc to escape):")
    Do While Not err
    ptnew = ThisDrawing.GetPoint(, vbCr & "Select right side of
    column " + CStr(col) + ". (Esc to finish):")
    Dist = FlatDist(ptlast, ptnew)
    ptlast = ptnew
    Add2StrArray str(Dist), ColDataArray
    col = col + 1
    Loop
    Exit Sub
    UserCAN:
    If err Then err.Clear
    End Sub
     
    A Seidel, Apr 21, 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.