Saqib_theleo Posted April 13, 2014 Posted April 13, 2014 (edited) Hello everyone, Is there anyone that can provide or create a simple Lisp that can Zoom fit rectangle without selecting its upper left corner and lower right corner, on layout tab where same size viewport is available. It can be done manually as you double click inside viewport on Layout then select zoom command and then pick upper left end point and lower right end point of rectangle. I wanted that this could be done with only selecting rectangle by one click. I hope someone can make it. Thanks. Edited April 15, 2014 by Saqib_theleo Quote
maratovich Posted April 13, 2014 Posted April 13, 2014 Why is it you? You want to move a lot of drawings from the model in paper space? Or do it directly in the viewport? Quote
Saqib_theleo Posted April 13, 2014 Author Posted April 13, 2014 I just want to zoom specific area from model space (where rectangle in placed), on Layout tab in viewport for print purpose. Quote
maratovich Posted April 13, 2014 Posted April 13, 2014 1. If you have a lot of drawings in model space - it is better to print directly from the model. 2. If you need to create separate sections - read this link. You fit options number 1, 2, 4, 6 Here is the link : http://translate.google.ru/translate?hl=ru&sl=ru&tl=en&u=http%3A%2F%2Fforum.dwg.ru%2Fshowthread.php%3Ft%3D104517&sandbox=1 Here is original link : http://forum.dwg.ru/showthread.php?t=104517 Quote
Saqib_theleo Posted April 15, 2014 Author Posted April 15, 2014 It does not work with Zoom > Object command. It does not exactly fit selected rectangle on viewport where it can be fit exactly by manual procedure I described previously. It could be done with custom Lisp if someone can help and try to make it. Thanks. Quote
hmsilva Posted April 15, 2014 Posted April 15, 2014 Activate the viewport, run the demo. Quick and dirty, no error checking... (defun c:demo ( / a b e o) (if (setq e (car (entsel "\nSelect Rectang : "))) (progn (setq o (vlax-ename->vla-object e)) (vlax-invoke-method o 'GetBoundingBox 'a 'b) (setq a (vlax-safearray->list a) b (vlax-safearray->list b) ) (vl-cmdf "_.zoom" a b) ) ) (princ) ) HTH Henrique Quote
Saqib_theleo Posted April 15, 2014 Author Posted April 15, 2014 Hi Henrique, Yes this is exactly what I needed to zoom a box with one click. I tried it and it is working good and nice. It will save my time of zooming manually, because in Cad 2007 when you activate viewport and run zoom command it does not pick the endpoint of any object even if Osnap is activated and Endpoint snap is enabled. Thanks for your time and help. God bless you. Thanks again. Quote
hmsilva Posted April 15, 2014 Posted April 15, 2014 You're welcome, Saqib_theleo Glad I could help Henrique Quote
EBROWN Posted April 16, 2014 Posted April 16, 2014 Henrique, The layer that our rectangle is on is locked. Can you add the ability to select a rectangle that is on a locked layer? Many Thanks Quote
ketxu Posted April 17, 2014 Posted April 17, 2014 Hi Henrique, Yes this is exactly what I needed to zoom a box with one click. I tried it and it is working good and nice. It will save my time of zooming manually, because in Cad 2007 when you activate viewport and run zoom command it does not pick the endpoint of any object even if Osnap is activated and Endpoint snap is enabled. . Just use Shift + Right Mouse here and feel the diff ^^ (defun c:zo()(command "._zoom" "_end" pause "_end")) Quote
hmsilva Posted April 17, 2014 Posted April 17, 2014 Henrique,The layer that our rectangle is on is locked. Can you add the ability to select a rectangle that is on a locked layer? EBROWN, if the rectangle layer is locked, the code should work as expected, you're not trying to modify the rectangle... HTH Henrique Quote
EBROWN Posted April 17, 2014 Posted April 17, 2014 Henrique, You are correct. Works great. Thank you and all the others for your contributions to this forum. EBROWN Quote
Saqib_theleo Posted April 17, 2014 Author Posted April 17, 2014 Just use Shift + Right Mouse here and feel the diff ^^ (defun c:zo()(command "._zoom" "_end" pause "_end")) This is also good for picking end points manually but when you want to do that kind of zoom with one click then first Lisp is advantageous. Thanks. Quote
EBROWN Posted April 18, 2014 Posted April 18, 2014 Henrique, Is it possible to lock the viewport after the zoom. Thanks EBROWN Quote
hmsilva Posted April 18, 2014 Posted April 18, 2014 Hi EBROWN, (defun c:demo (/ a b e o) (vl-load-com) (if (and (= (getvar 'TILEMODE) 0) (/= (getvar 'CVPORT) 1) (setq e (car (entsel "\nSelect Rectang : "))) ) (progn (setq o (vlax-ename->vla-object e)) (vlax-invoke-method o 'GetBoundingBox 'a 'b) (setq a (vlax-safearray->list a) b (vlax-safearray->list b) ) (vl-cmdf "_.zoom" a b) (vlax-put (vla-get-activepviewport (vla-get-activedocument (vlax-get-acad-object)) ) 'DisplayLocked :vlax-true ) ) ) (princ) ) HTH Henrique Quote
hmsilva Posted April 18, 2014 Posted April 18, 2014 You're welcome, EBROWN Glad i could help Henrique Quote
Saqib_theleo Posted May 31, 2014 Author Posted May 31, 2014 This Lisp is working good when UCS is set to Word. But in layout tab inside the viewport when UCS is changed to object or UCS is other than World, so if you select the rectangle then it does not zoom correctly. Can someone or Henrique who made this Lisp can fix it. Thanks. (defun c:demo ( / a b e o) (if (setq e (car (entsel "\nSelect Rectang : "))) (progn (setq o (vlax-ename->vla-object e)) (vlax-invoke-method o 'GetBoundingBox 'a 'b) (setq a (vlax-safearray->list a) b (vlax-safearray->list b) ) (vl-cmdf "_.zoom" a b) ) ) (princ) ) 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.