Jump to content

Need a Lisp to Zoom fit model space rectangle on layout View.


Recommended Posts

Posted (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 by Saqib_theleo
  • Replies 31
  • Created
  • Last Reply

Top Posters In This Topic

  • hmsilva

    9

  • Saqib_theleo

    7

  • EBROWN

    6

  • janaudie

    3

Posted

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?

Posted

I just want to zoom specific area from model space (where rectangle in placed), on Layout tab in viewport for print purpose.

Posted

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

Posted

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.

Posted

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

Posted

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.

Posted

You're welcome, Saqib_theleo

Glad I could help

 

Henrique

Posted

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

Posted
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"))

Posted
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

Posted

Henrique,

 

 

You are correct. Works great.

Thank you and all the others for your contributions to this forum.

 

 

EBROWN

Posted

You're welcome, EBROWN

 

 

Henrique

Posted
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.

Posted

Henrique,

 

 

Is it possible to lock the viewport after the zoom.

 

 

Thanks

 

 

EBROWN

Posted

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

Posted

very nice Henrique.

 

 

Thank You

 

 

 

 

EBROWN

Posted

You're welcome, EBROWN

Glad i could help

 

 

Henrique

  • 1 month later...
Posted

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)
 )

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...