salman Posted May 10, 2009 Posted May 10, 2009 I want to write code that zooms the objects in the drawing that are below my cursor. And this should happen continueusly as I move my cursor, so that I do not need to use the zoom command repeatedly. Do I need to use some infinite loop for this like below ( while( T ) read the current cursor location zoom the portion below the cursor and surroundings. ) I have not use this technique so far but I think if I perhaps use an infinite loop inside a program and load after loading I will not be able to do other tasks and CAD will become stuck. Please guide. Quote
lpseifert Posted May 10, 2009 Posted May 10, 2009 Have you tried using the scroll wheel on your mouse to zoom in/out? Quote
salman Posted May 10, 2009 Author Posted May 10, 2009 yes I have used the zoom wheel, but it is disturbing when you are quickly moving from one portion to another and you have to zoom in or out the new portion again and again. Quote
Lee Mac Posted May 10, 2009 Posted May 10, 2009 So, how would the program know how much to zoom in? How would it know when to zoom out? Isn't this just a "lazy" lisp request? Quote
stevsmith Posted May 10, 2009 Posted May 10, 2009 do you mean like the old windows magnifier addon that used to kick about. id imagine that this would cause more hastle than its worth. why dont you concider buying a 3dconexxion space navigator, you can buy them from amazon for £40 http://www.3dconnexion.com/3dmouse/spacenavigator.php http://www.amazon.co.uk/3Dconnexion-SpaceNavigator-Personal-Edition-USB/dp/B000LB41BM/ref=sr_1_1?ie=UTF8&s=electronics&qid=1241994390&sr=8-1 Quote
Lee Mac Posted May 10, 2009 Posted May 10, 2009 do you mean like the old windows magnifier addon that used to kick about. id imagine that this would cause more hastle than its worth.why dont you concider buying a 3dconexxion space navigator, you can buy them from amazon for £40 http://www.3dconnexion.com/3dmouse/spacenavigator.php http://www.amazon.co.uk/3Dconnexion-SpaceNavigator-Personal-Edition-USB/dp/B000LB41BM/ref=sr_1_1?ie=UTF8&s=electronics&qid=1241994390&sr=8-1 Never knew those things existed... Quote
stevsmith Posted May 10, 2009 Posted May 10, 2009 I was thinking about buying one for myself, they actually look really handy. Quote
Lee Mac Posted May 10, 2009 Posted May 10, 2009 I was thinking about buying one for myself, they actually look really handy. Yeah, they look pretty quick. I have seen a roller ball thing that acts like a mouse (upside down), so that it stays in the same place, while you move the ball on top... but I have never come across these things before now.. Quote
Lee Mac Posted May 11, 2009 Posted May 11, 2009 (edited) This is the best I could come up with.... left click to zoom out, right click to exit. (defun c:QZoom (/ app grdat iEnt Minp Maxp) (vl-load-com) (setq app (vlax-get-acad-object)) (princ "\nMove Cursor over Objects to Zoom... ") (while (or (= 5 (car (setq grdat (grread t 4 2)))) (eq 3 (car grdat))) (if (setq iEnt (car (nentselp (cadr grdat)))) (progn (vla-getBoundingBox (vlax-ename->vla-object iEnt) 'Minp 'Maxp) (vla-zoomwindow app Minp Maxp))) (if (eq 3 (car grdat)) (vla-zoomextents app))) (princ)) Edited February 13 by Lee Mac Quote
Commandobill Posted May 11, 2009 Posted May 11, 2009 Wow Lee that's crazy... I like it. Seems useful for my laptop. Quote
Lee Mac Posted May 11, 2009 Posted May 11, 2009 Cheers Bill, Its a bit... how to put it... "fragile", but I suppose, if you are careful with the mouse movement, it may work for you Quote
Abrasive Posted February 12 Posted February 12 Good evening @Lee Mac ( well it is here anyway ) I know this is an old post but I'd like to try the zoom routine you posted above, but it has formatting with the brackets. Is there any way to repost it in the new format? Thanks! Quote
Abrasive Posted February 12 Posted February 12 @Lee Mac I copied it and was able to remove the bracketed data... works good. Could you help me modify it to act like a "magnifier" , and when I right or left click it zooms to that view? I'm thinking a predefined square size over an area that defines a zoom window. The drawing could be zoomed all the way out, or any zoom level. The square (grvecs ..?) follows the cursor around until you click. When you move the square over an area and click it defines that as the zoom window? Thanks again! Quote
pkenewell Posted February 13 Posted February 13 (edited) @Abrasive Try this. Not sure if this is what you want. I thought this was an interesting challenge. Use the plus [+] and Minus [-] keys to change the boundary size. (defun C:ZOOMD (/ _rect ac code data h ls pt v) (vl-load-com) ; Sub function for drawing the zoom boundary. (defun _rect () (mapcar '(lambda (a) (grdraw (car a) (cadr a) -1)) (list (list (car ls) (list (car (cadr ls)) (cadr (car ls)))) (list (list (car (cadr ls)) (cadr (car ls))) (cadr ls)) (list (cadr ls) (list (car (car ls)) (cadr (cadr ls)))) (list (list (car (car ls)) (cadr (cadr ls))) (car ls)) ) ) ) (setq ac (vlax-get-acad-object) h (/ (getvar "viewsize") 4.0) v (list (* h (apply '/ (getvar "screensize"))) h) ) (princ "\nUse [+] or [-] keys to Increase or Decrease Zoom Boundary and Pick Center: ") (while (not pt) (setq gr (grread t 15 0) code (car gr) data (cadr gr)) (if ls (_rect)) (cond ((= code 5) (setq ls (list (mapcar '- data v) (mapcar '+ data v))) (_rect) ) ((= code 2) (cond ((or (= data 43)(= data 61)) (setq scl 1.5 v (mapcar '(lambda (x) (* x scl)) v)) (_rect) ) ((= data 45) (setq scl 0.75 v (mapcar '(lambda (x) (* x scl)) v)) (_rect) ) ) ) ((= code 3)(setq pt T)) ) ) (vla-zoomwindow ac (vlax-3d-point (car ls)) (vlax-3d-point (cadr ls))) (princ) ) Edited February 13 by pkenewell Added (vl-load-com) 1 Quote
Abrasive Posted February 13 Posted February 13 2 hours ago, pkenewell said: @Abrasive Try this. Not sure if this is what you want. I thought this was an interesting challenge. Use the plus [+] and Minus [-] keys to change the boundary size. (defun C:ZOOMD (/ _rect ac code data h ls pt v) (vl-load-com) ; Sub function for drawing the zoom boundary. (defun _rect () (mapcar '(lambda (a) (grdraw (car a) (cadr a) -1)) (list (list (car ls) (list (car (cadr ls)) (cadr (car ls)))) (list (list (car (cadr ls)) (cadr (car ls))) (cadr ls)) (list (cadr ls) (list (car (car ls)) (cadr (cadr ls)))) (list (list (car (car ls)) (cadr (cadr ls))) (car ls)) ) ) ) (setq ac (vlax-get-acad-object) h (/ (getvar "viewsize") 4.0) v (list (* h (apply '/ (getvar "screensize"))) h) ) (princ "\nUse [+] or [-] keys to Increase or Decrease Zoom Boundary and Pick Center: ") (while (not pt) (setq gr (grread t 15 0) code (car gr) data (cadr gr)) (if ls (_rect)) (cond ((= code 5) (setq ls (list (mapcar '- data v) (mapcar '+ data v))) (_rect) ) ((= code 2) (cond ((or (= data 43)(= data 61)) (setq scl 1.5 v (mapcar '(lambda (x) (* x scl)) v)) (_rect) ) ((= data 45) (setq scl 0.75 v (mapcar '(lambda (x) (* x scl)) v)) (_rect) ) ) ) ((= code 3)(setq pt T)) ) ) (vla-zoomwindow ac (vlax-3d-point (car ls)) (vlax-3d-point (cadr ls))) (princ) ) PERFECT!!! That's exactly what was thinking. thank you again. 1 Quote
Abrasive Posted February 13 Posted February 13 @pkenewell This works really well, could you get it to update the drawn box as I increase or decrease the size? Right now it updates when I move the cursor. Quote
BIGAL Posted February 14 Posted February 14 My $0.05 Zoom C scale put it in a defun as a command pick a point. Can have various scales. Use maybe numbers for defun name 10, 100. Quote
pkenewell Posted February 14 Posted February 14 15 hours ago, Abrasive said: @pkenewell This works really well, could you get it to update the drawn box as I increase or decrease the size? Right now it updates when I move the cursor. @Abrasive Strange. It works correctly for me without moving the cursor. I did make a couple edits to the code in the hour or 2 after I posted it; check the original post and make sure you copied the latest version. Otherwise - I don't think there is any way I can make it better.This function uses temporary graphics in a (grread) loop, so it is heavily dependant on graphics and processor speed. It may need more mouse movement on slower systems. It could also be less responsive with a lower dpi mouse? Quote
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.