aloy Posted June 27, 2012 Posted June 27, 2012 Dear All, Is it possible to zoom "w" at a certain area, give a point and zoom "p", go to another area and do the same several times in a lisp routine?. I will be very grateful if someone can give a clue. Regards, Aloy Quote
Lee Mac Posted June 28, 2012 Posted June 28, 2012 Two methods: Zoom Window '(0 0 0) to '(1 1 0): (vla-zoomwindow (vlax-get-acad-object) (vlax-3D-point '(0 0 0)) (vlax-3D-point '(1 1 0))) (command "_.zoom" "_W" "_non" '(0 0 0) "_non" '(1 1 0)) Zoom Previous: (vla-zoomprevious (vlax-get-acad-object)) (command "_.zoom" "_P") Other Visual LISP Zoom methods of the Application Object: vla-zoomall vla-zoomcenter vla-zoomextents vla-zoompickwindow vla-zoomprevious vla-zoomscaled vla-zoomwindow When using these methods repeatedly, I would strongly advise using a local variable to point to an instance of the Application Object, rather than inefficiently retrieving the Application Object many times over. Quote
aloy Posted June 28, 2012 Author Posted June 28, 2012 LeeMac, Thanks a lot. I entered the following lisp modifying your code a bit to serve my purpose: (command "_.zoom" "_W" "_non" (getpoint "\nGive window first point: ") "_non" (getpoint "\nGive window second point: ")) (setq p1 (getpoint "\nGive point p1: ")) (command "_.zoom" "_p") point p1 has been taken to the memory. How ever it also gives a message to say that 'cannot re- enter lisp' though it has actually re-entered. Regards, Aloy Quote
MSasu Posted June 28, 2012 Posted June 28, 2012 Your code works well on my station - please make sure that you are testing it while no command was active. The first line can be tweaked a bit: (command "_.zoom" "_W" "_non" (setq pz (getpoint "\nGive window first point: ")) "_non" (getcorner pz "\nGive window second point: ")) Quote
BlackBox Posted June 28, 2012 Posted June 28, 2012 Unless you are going to use the first and second points again, there is no need for using GETPOINT, or GETCORNER, as simply using the PAUSE function in the Command call will suffice. If storing these points is needed, consider instead using IF & AND to test for these points, then supplying them to the Command call when AND returns T. Quote
aloy Posted June 28, 2012 Author Posted June 28, 2012 MSasu, RenderMan, The code given by MSasu works well showing the actual window and without error message. I think pz is just a value which keeps on changing as we go. Thanks both of you. Regards, Aloy Quote
MSasu Posted June 28, 2012 Posted June 28, 2012 I introduced that variable to use it as argument for next input (GETCORNER). But, as RenderMan well observed, the code can be tweaked further: (command "_.zoom" "_W" "_non" pause "_non" pause) Quote
aloy Posted June 28, 2012 Author Posted June 28, 2012 MSasu, The second code (latest) does not work in my compuyer. It goes on asking for fistpoint and second without getting into ask for p1. I am happy with the previous. Thanks. Aloy Quote
MSasu Posted June 28, 2012 Posted June 28, 2012 That's strange - can you post here the entire code? Quote
aloy Posted June 28, 2012 Author Posted June 28, 2012 ok, here it is: (command "_.zoom" "_W" "_non" pause "_non" pause) (setq p1(getpoint "\n Give point p1: ")) (command "zoom" "p") However what I want to do is this: (command "_.zoom" "_W" "_non" (setq pz (getpoint "\nGive window first point: ")) "_non" (getcorner pz "\nGive window second point: ")) (setq p1(getpoint "\nGive point p1: ")) (command "zoom" "_p") (command "_.zoom" "_W" "_non" (setq pz (getpoint "\nGive window first point: ")) "_non" (getcorner pz "\nGive window second point: ")) (setq p2(getpoint "\nGive point p2: ")) (command "zoom" "_p") (command "_.line" "_non" p1 "_non"p2 "") (command "_.zoom" "_W" "_non" (setq pz (getpoint "\nGive window first point: ")) "_non" (getcorner pz "\nGive window second point: ")) (setq p3(getpoint "\nGive point p3: ")) (command "zoom" "_p") (command "_.zoom" "_W" "_non" (setq pz (getpoint "\nGive window first point: ")) "_non" (getcorner pz "\nGive window second point: ")) (setq p4(getpoint "\nGive point p4: ")) (command "zoom" "_p") (command "line" p3 p4 "") (setq ip(inters p1 p2 p3 p4)) (setq pr(getpoint "\nGive pr: ")) ;pr is just a point, actual pr to be calculated (command "_.line" "_non" ip "_non" pr "") (setq x(getpoint "\nGive nearest point on arc to ip: ")) It works fine with rest of the code to give me a value for optimum radius Quote
Lee Mac Posted June 28, 2012 Posted June 28, 2012 Consider this code: (defun c:test ( / _getpoint _line ip p1 p2 p3 p4 pr x ) (defun _getpoint ( msg bpt / pt ) (vla-zoompickwindow app) (if bpt (setq pt (getpoint msg bpt)) (setq pt (getpoint msg)) ) (vla-zoomprevious app) pt ) (defun _line ( a b ) (entmake (list '(0 . "LINE") (cons 10 a) (cons 11 b))) ) (setq app (vlax-get-acad-object)) (if (and (setq p1 (_getpoint "\nSpecify p1: " nil)) (setq p2 (_getpoint "\nSpecify p2: " p1)) (_line (trans p1 1 0) (trans p2 1 0)) (setq p3 (_getpoint "\nSpecify p3: " nil)) (setq p4 (_getpoint "\nSpecify p4: " p3)) (_line (trans p3 1 0) (trans p4 1 0)) ) (if (setq ip (inters p1 p2 p3 p4)) (if (and (setq pr (getpoint "\nGive pr: ")) (_line (trans ip 1 0) (trans pr 1 0)) (setq x (getpoint "\nGive nearest Point on Arc to ip: ")) ) (princ "\nYou win.") (princ "\nYou lose.") ) (princ "\nLines do not intersect.") ) (princ "\nYou lose.") ) (princ) ) (vl-load-com) (princ) Quote
aloy Posted June 28, 2012 Author Posted June 28, 2012 Thanks Lee Mac. Unlike my crude code, this is an elegant way of doing things. However it does not take the point x. I need to learn Visual Lisp?. Regards, Aloy Quote
Lee Mac Posted June 28, 2012 Posted June 28, 2012 However it does not take the point x. Your original code did not specify what to do with the point 'x' Quote
aloy Posted June 28, 2012 Author Posted June 28, 2012 Here is what I intended to do with x, it goes further with r: (setq x(getpoint "\nGive nearest point on arc to ip: ")) (setq del(+ (angle p1 p2) (- (* pi 2) (angle p3 p4)))) (setq a(/ del 2)) (setq tan(/ (sin a) (cos a))) (setq y(* tan tan)) (setq r(* (/ (distance ip x) y) (+ 1 (sqrt (+ 1 y))))) Regards, Aloy Quote
SLW210 Posted June 29, 2012 Posted June 29, 2012 aloy, Please read the CODE POSTING GUIDELINES and use CODE TAGS for your code, not QUOTE TAGS. Quote
aloy Posted June 30, 2012 Author Posted June 30, 2012 (setq x(getpoint "\nGive nearest point on arc to ip: ")) (setq del(+ (angle p1 p2) (- (* pi 2) (angle p3 p4)))) (setq a(/ del 2)) (setq tan(/ (sin a) (cos a))) (setq y(* tan tan)) (setq w(getreal "\nGiveValue of w: ")) (setq r(* (/ (distance ip x) y) (+ w (sqrt (+ 1 y))))) Quote
aloy Posted June 30, 2012 Author Posted June 30, 2012 LeeMac, Thanks a lot, I have modified your code a bit to give me all the info I need. Actually, AutoCAD can modify the code to apply to all use cases and create an option for drawing arcs which has useful applications. Regards, Aloy 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.