Jump to content

Getting cursor coordinates without picking a point


fonseca

Recommended Posts

Hi to all, I am writing a routine in VBA that will need to frequently monitor present cursor coordinates, without the user having to pick any point. Exactly like the coords display in the lower left corner of the status bar, which I don't seem to be able to access programmatically. I've searched for ACAD functions related to the cursor position, but couldn't find any. I'm sure there will be a solution if I turn to the Windows API, but I need the position in ACAD coordinates, not in pixels... Any idea on how to do this in VBA (or perhaps LISP, which I don't know, but surely would find a way to use...)

Link to comment
Share on other sites

Thanks to you both for the tips.

 

But now there's another problem: how is the return value handled to VBA? If I'm not mistaken, the only way to call a LISP routine from VBA is SendCommand and it seems a one-way only function.

 

Am I stuck with writing the whole routine in LISP? It would be a pitty, since it will take me some time to grasp the workings of this language when I already have the routine all figured out in VBA (except for the cursor coords thing...)

Link to comment
Share on other sites

  • 1 year later...

why must use (grread t 15 0), use (grread t) return same value.

(grread [track] [allkeys [curtype]])

 

allkeys only have effect when track=nil.

Link to comment
Share on other sites

  • 2 years later...
(cadr (grread t 15 0))

 

 

Good afternoon AlanJt

 

I'm learning the GRREAD & GRDRAW command, but am stuck.

Building off your example.....I have this circle (pt1) with lines coming off quad (pt3) & quad (pt4) to a given point (pt2) selected by the user.

 

Is there a way I can display the 2 ghosted lines while the user selects pt2? When I tried your example, it just put the ghost lines from pt3 & pt4 to pt1. Is it even possible to capture pt2 in real-time....I.E. my cursor location? My end result is to show the circle and the two lines dotted while the user is selecting the 2nd point as the destination and the rotation of all three objects. Maybe I draw actual lines from the points. But how do I get the end points of each line to change as I move my cursor?

 

Thanks for any help,

Mike in Dallas

 

(progn
       (setq pt1 (getpoint "\nSelect 1st point"))
       (command "circle" pt1 4.0)
       (setq pt2 (getpoint pt1 "\nSelect 2nd point"))
;        (princ "\nSlect 2nd point")
;        (setq pt2 (cadr (grread t 15 0)))
       (setq ang (angle pt1 pt2))
       
       (setq pt3 (polar pt1 (+ ang (* pi 1.5)) 4.0))
       (grdraw pt3 pt2 255 3)
;        (command "line" pt1 pt3 "");test point
       (command "line" pt3 pt2 "")
       
       (setq pt4 (polar pt1 (- ang (* pi 1.5)) 4.0))
       (grdraw pt4 pt2 255 3)
;        (command "line" pt1 pt4 "");test point
       (command "line" pt4 pt2 "")
   );end progn

Link to comment
Share on other sites

    (progn
   (if  
     (setq pt1 (getpoint "\nSelect 1st point"))
       (progn
         (command "circle" pt1 4.0)
         (while 
           (not (= (car (setq pt2 (grread t 15 0))) 3))
           (redraw) 
           (if
             (listp (setq pt2 (cadr pt2)))
             (progn 
               (setq ang (angle pt1 pt2)
                     pt3 (polar pt1 (+ ang (* pi 1.5)) 4.0)
                     pt4 (polar pt1 (- ang (* pi 1.5)) 4.0))
               (grdraw pt3 pt2 255 3)
               (grdraw pt4 pt2 255 3)
             )
           )
         )
       )
   )
   (redraw)
   (command "line" pt3 (cadr pt2) "")
   (command "line" pt4 (cadr pt2) "")    
   )        
      

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...