fonseca Posted October 20, 2009 Share Posted October 20, 2009 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...) Quote Link to comment Share on other sites More sharing options...
CarlB Posted October 20, 2009 Share Posted October 20, 2009 In Lisp, it's the "grread" function. Quote Link to comment Share on other sites More sharing options...
alanjt Posted October 20, 2009 Share Posted October 20, 2009 (cadr (grread t 15 0)) Quote Link to comment Share on other sites More sharing options...
fonseca Posted October 21, 2009 Author Share Posted October 21, 2009 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...) Quote Link to comment Share on other sites More sharing options...
codered8x Posted June 10, 2011 Share Posted June 10, 2011 why must use (grread t 15 0), use (grread t) return same value. (grread [track] [allkeys [curtype]]) allkeys only have effect when track=nil. Quote Link to comment Share on other sites More sharing options...
spiker7221 Posted April 1, 2014 Share Posted April 1, 2014 (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 Quote Link to comment Share on other sites More sharing options...
Bhull1985 Posted April 1, 2014 Share Posted April 1, 2014 I'd take a look at the DynDraw program, may provide insights. Quote Link to comment Share on other sites More sharing options...
jdiala Posted April 1, 2014 Share Posted April 1, 2014 (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) "") ) Quote Link to comment Share on other sites More sharing options...
spiker7221 Posted April 2, 2014 Share Posted April 2, 2014 Good morning Jdiala, That, my friend, is a thing of beauty. Works like a charm! Thank you for your help. Mike Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.