Results 1 to 7 of 7

Thread: using grread

  1. #1
    Member
    Join Date
    2009-09
    Posts
    32
    Login to Give a bone
    0

    Default using grread

    Using Autolisp I want to write code which differentiates between the

    still and moving state of mouse. I have written a number of test codes to

    do the task. One of them is given below, I have used the grread function.

    So far I am not able to achieve the goal. In the following program I have

    tried to display state of mouse on command line, i.e. if it is moving or still.

    But even if I continueusly move the mouse the output of the program is like this



    mouse is moving

    mouse is still

    mouse is moving

    mouse is still

    .
    .
    .
    .


    Which I do not understand why, if the mouse is continueusly moving the program

    should only display mouse is moving and not the other message. Please guide.



    Code:
    (defun c:tst()
    
    
       (setq coor nil)   ; To store coordinates returned by grread.
    
       (setq code nil)   ; To store the integer code returned by grread.
    
    
    
       (while(/= code 3)
    
         (setq input(grread t))
    
         (setq code(car input))
    
        
         ; If input is being read for first time.
      
         (if(= nil coor)
    
            (progn
    
               (setq coor(cadr input))
    
            )
    
    
            (progn
    
               (setq newCoor(cadr input))
    
               (if(equal newCoor coor)
    
                  (progn
    
                     (princ "mouse is still\n")
    
                  )
     
                  (progn
    
                      (princ "mouse is moving\n")
    
                      (setq coor newCoor)
    
                  )
    
               )
    
            )
    
         )
        
    
       )
    
    )
    Secondly, according to help of grread we can pass a number of arguments. I want to use grread such that it works only

    when I move the mouse or If I press a keyboard key. is it possible to do that if so what arguments values we need to pass it.

    I think if we use (grread T) it returns the cursor coordinates with return code 5 even if we do not move mouse.
    Last edited by Opie; 2009-10-14 at 03:41 PM. Reason: [code] tags added

  2. #2
    I could stop if I wanted to msretenovic's Avatar
    Join Date
    2002-02
    Location
    Galloway, Oh
    Posts
    305
    Login to Give a bone
    0

    Arrow Re: using grread

    Quote Originally Posted by mdsalman2003 View Post
    I think if we use (grread T) it returns the cursor coordinates with return code 5 even if we do not move mouse.
    Actually, GRREAD will not return anything if the mouse is left completely still. The function itself is waiting to return something. If nothing is happening, there is nothing to return; and so, GRREAD waits.

    The fact that your function is showing the mouse stopping and moving suddenly (I think) has more to do with the speed at which GRREAD is collecting the coordinates. The mouse, in essence, isn't moving fast enough to show a measurable difference. This can be seen by placing a few PRINC statements within your code:
    Code:
    ;;...
            (progn
               (setq newCoor (cadr input))
               (princ (strcat "newCoor x: " (rtos (car newCoor) 2 16) "\n"))
               (princ (strcat "   Coor y: " (rtos (car Coor) 2 16) "\n"))
               (princ (strcat "newCoor x: " (rtos (cadr newCoor) 2 16) "\n"))
               (princ (strcat "   Coor y: " (rtos (cadr Coor) 2 16) "\n"))
               (if (equal newCoor coor)
                  
                  (progn
                     (princ "mouse is still\n")
                  )
    
                  (progn
                      (princ "mouse is moving\n")
                      (setq coor newCoor)
                  )
                  
               )
            )
    ;;...
    The good news is that this should actually help you reach your though, as you state you only want GRREAD to return something if the user moves the mouse or presses a button.

    HTH,

  3. #3
    AUGI Addict
    Join Date
    2008-02
    Posts
    1,141
    Login to Give a bone
    0

    Default Re: using grread

    Give up on The Plague Michael?

  4. #4
    I could stop if I wanted to msretenovic's Avatar
    Join Date
    2002-02
    Location
    Galloway, Oh
    Posts
    305
    Login to Give a bone
    0

    Smile Re: using grread

    Quote Originally Posted by alanjt View Post
    Give up on The Plague Michael?
    Yeah, I thought it was time for a change. I thought I might get something a little more representative of myself - so, I decided that to turn myself into something cartoonish and get a quote that I think of when I'm a little down. You know, just trying to be a little more positive during depressed times

  5. #5
    AUGI Addict
    Join Date
    2008-02
    Posts
    1,141
    Login to Give a bone
    0

    Default Re: using grread

    Quote Originally Posted by msretenovic View Post
    Yeah, I thought it was time for a change. I thought I might get something a little more representative of myself - so, I decided that to turn myself into something cartoonish and get a quote that I think of when I'm a little down. You know, just trying to be a little more positive during depressed times
    Right on. Cool picture, did you Shop it or use something else? Nice quote.

  6. #6
    I could stop if I wanted to msretenovic's Avatar
    Join Date
    2002-02
    Location
    Galloway, Oh
    Posts
    305
    Login to Give a bone
    0

    Default Re: using grread

    Quote Originally Posted by alanjt View Post
    Right on. Cool picture, did you Shop it or use something else? Nice quote.
    Yeah, I found a tutorial online to do it. Glad you like.

  7. #7
    Member
    Join Date
    2014-11
    Posts
    21
    Login to Give a bone
    0

    Default Re: using grread

    in the Line command you can point the mouse in a direction (angle) and type in a number and it will draw the line at that angle and distance how do you get the point where the crosshairs is at so you know the polar angle I was going to create a command so you can put the crosshairs in any direction and type in a number and draw a Polygon in that direction and that distance. on a Polygon it you type in the radius it draws it at 90 degrees. If you want it an angle you have to move the mouse to the angle and distance and click the mouse. I would is hard to get the angle and distance if it wasn't even.


    Quote Originally Posted by mdsalman2003 View Post
    Using Autolisp I want to write code which differentiates between the

    still and moving state of mouse. I have written a number of test codes to

    do the task. One of them is given below, I have used the grread function.

    So far I am not able to achieve the goal. In the following program I have

    tried to display state of mouse on command line, i.e. if it is moving or still.

    But even if I continueusly move the mouse the output of the program is like this



    mouse is moving

    mouse is still

    mouse is moving

    mouse is still

    .
    .
    .
    .


    Which I do not understand why, if the mouse is continueusly moving the program

    should only display mouse is moving and not the other message. Please guide.



    Code:
    (defun c:tst()
    
    
       (setq coor nil)   ; To store coordinates returned by grread.
    
       (setq code nil)   ; To store the integer code returned by grread.
    
    
    
       (while(/= code 3)
    
         (setq input(grread t))
    
         (setq code(car input))
    
        
         ; If input is being read for first time.
      
         (if(= nil coor)
    
            (progn
    
               (setq coor(cadr input))
    
            )
    
    
            (progn
    
               (setq newCoor(cadr input))
    
               (if(equal newCoor coor)
    
                  (progn
    
                     (princ "mouse is still\n")
    
                  )
     
                  (progn
    
                      (princ "mouse is moving\n")
    
                      (setq coor newCoor)
    
                  )
    
               )
    
            )
    
         )
        
    
       )
    
    )
    Secondly, according to help of grread we can pass a number of arguments. I want to use grread such that it works only

    when I move the mouse or If I press a keyboard key. is it possible to do that if so what arguments values we need to pass it.

    I think if we use (grread T) it returns the cursor coordinates with return code 5 even if we do not move mouse.

Similar Threads

  1. OSNAPS IN GRREAD FUNCTION
    By hostetterkl in forum AutoLISP
    Replies: 6
    Last Post: 2005-08-03, 06:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •