GetPoint with a closed rubber band

Discussion in 'AutoCAD' started by Tom Roberts, Jul 20, 2004.

  1. Tom Roberts

    Tom Roberts Guest

    Hi all

    I would like to prompt my Users to pick a series of points and iteractively
    display a closed loop on the screen as they are being picked.
    In much the same way as the CP or WP selection options work.

    Any suggestions?

    Regards
    Tom Roberts
     
    Tom Roberts, Jul 20, 2004
    #1
  2. Here is an example to draw to the screen using the Visual Lisp ActiveX Module and the GRVECS autolisp function. I came up with this last week with help from this group. The example draws a line from 0,0 to 1,1 that disappears as soon as the drawing is redrawn/zoomed.

    Regards - Nathan

    Code:
    
    Public Sub DrawToScreen()
    Dim strGRVECS As String
    Dim objVL As Object
    Dim objVLF As Object
    Dim objVLO As Object
    Dim varReturned As Variant
    Set objVL = ThisDrawing.Application.GetInterfaceObject("VL.Application.16")
    Set objVLF = objVL.ActiveDocument.Functions
    strGRVECS = "(grvecs '(7 (0 0)(1 1))) "
    Set objVLO = objVLF.Item("read").funcall(strGRVECS)
    varReturned = objVLF.Item("eval").funcall(objVLO)
    End Sub
    
    
     
    Nathan Taylor, Jul 21, 2004
    #2
  3. Tom Roberts

    Tom Roberts Guest

    Hi Nathan

    Thanks for your reply.
    What is the Visual Lisp ActiveX Module. Do I need to make a reference to a
    type library.
    When I try to run your code I get the error:

    Run Time Error '-2147221005 (800401f3)':
    Problem in loading application

    At the line:

    Set objVL =
    ThisDrawing.Application.GetInterfaceObject("VL.Application.16")

    I am running AutoCAD 2002 on WinXP pro.

    --
    Regards
    Tom Roberts
    __________________________
    MechWest Design & Drafting
    Perth, Western Australia



    Module and the GRVECS autolisp function. I came up with this last week with
    help from this group. The example draws a line from 0,0 to 1,1 that
    disappears as soon as the drawing is redrawn/zoomed.
     
    Tom Roberts, Jul 21, 2004
    #3
  4. Tom Roberts

    MP Guest

    does this work?
    Set objVL = ThisDrawing.Application.GetInterfaceObject("VL.Application.15")
    i think 16 is 2004,5
     
    MP, Jul 21, 2004
    #4
  5. Tom Roberts

    Tom Roberts Guest

    No...same error


     
    Tom Roberts, Jul 21, 2004
    #5
  6. The line with the error is where the connection to the VisualLisp ActiveX Module is being made. You can add a reference to the library but I found there is no need.

    I think as you are using 2002 the line should read:
    Set objVL = ThisDrawing.Application.GetInterfaceObject("VL.Application.1")

    Here is an example for looping through GetPoint and knowing whether the user wants to finish or cancel.

    Code:
    
    Option Explicit
    Private Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vKey As Long) As Integer
    
    Public Sub MultiGetPoint()
    Dim blnError As Boolean
    Dim varPickedPoint As Variant
    Dim intKeyState As Integer
    intKeyState = GetAsyncKeyState(&H2)
    intKeyState = GetAsyncKeyState(&H1B)
    intKeyState = GetAsyncKeyState(&HD)
    Do
    blnError = False
    On Error GoTo ErrorHandler
    varPickedPoint = ThisDrawing.Utility.GetPoint(, "Pick point:")
    On Error GoTo 0
    If blnError = True Then
    intKeyState = GetAsyncKeyState(&H2)
    If intKeyState = -32767 Then Exit Do 'Right Button Click
    intKeyState = GetAsyncKeyState(&HD)
    If intKeyState = -32767 Then Exit Do  'Enter Key Press
    intKeyState = GetAsyncKeyState(&H1B)
    If intKeyState = -32767 Then Exit Sub 'Esc Key Press
    Else
    'Do stuff with point
    End If
    Loop
    Exit Sub
    ErrorHandler:
    blnError = True
    Resume Next
    End Sub
    
    
    Regards - Nathan
     
    Nathan Taylor, Jul 21, 2004
    #6
  7. Tom Roberts

    Tom Roberts Guest

    Great...that's got it
    I think I will have some fun experimenting with temporary vectors
    BTW is it possible to change the linetype to say a dashed line

    Thanks very much

    --
    Regards
    Tom Roberts
    __________________________
    MechWest Design & Drafting
    Perth, Western Australia


    Module is being made. You can add a reference to the library but I found
    there is no need.
    user wants to finish or cancel.
     
    Tom Roberts, Jul 21, 2004
    #7
  8. No worries Tom, I don't think you can change the linetype but you can change the colour. For more info look up grvecs in the developer help file.
    Regards - Nathan
     
    Nathan Taylor, Jul 21, 2004
    #8
  9. Tom Roberts

    Tom Roberts Guest

    Great idea, RTFM (read the f#####g manual)

    From the developers guide:
    If the color value is less than zero, the vector is highlighted.
    Highlighting depends on the display device.
    Most display devices indicate highlighting by a dashed line, but some
    indicate it by using a distinctive color.

    Thanks again

    --
    Regards
    Tom Roberts
    __________________________
    MechWest Design & Drafting
    Perth, Western Australia



    change the colour. For more info look up grvecs in the developer help file.
     
    Tom Roberts, Jul 21, 2004
    #9
  10. I'm glad you read the help because I missed the point about negative values which I will probably use now.
    Regards - Nathan
     
    Nathan Taylor, Jul 21, 2004
    #10
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.