Paper space View Port Inactive & Zoom Extents All Sheets?

Paper space View Port Inactive & Zoom Extents All Sheets?

jarredmonday
Collaborator Collaborator
750 Views
4 Replies
Message 1 of 5

Paper space View Port Inactive & Zoom Extents All Sheets?

jarredmonday
Collaborator
Collaborator

Hello all,

The attach routine Locks All view ports in all sheets upon startup. In addition to this I would like to have all view ports inactive and possibly zoom extents for each sheet. 

 

Nearly every drawing has all sheets arbitrarily zoomed into an area and a view port is active an often unlocked. 

 

;;;VPLOCK.lsp locks all viewports automatically when opening a drawing
;;;no idea who wrote it

(defun vplock (yesno / ss lock x obj)
  (vl-load-com)
  (if (setq ss (ssget "X" '((0 . "VIEWPORT")(-4 . "/=")(69 . 1))))
    (progn
      (if (= "y" yesno) (setq lock :vlax-true)(setq lock :vlax-false))
      (setq x 0)
      (while (< x (sslength ss))
     (setq obj (vlax-ename->vla-object (ssname ss x)))
     (vla-put-displaylocked obj lock)
     (setq x (1+ x))
     )
      )
    )
  (princ)
  )
(vplock "y")
Please mark Accept as Solution if your question is answered. Kudos gladly accepted. ⇘
0 Likes
751 Views
4 Replies
Replies (4)
Message 2 of 5

CodeDing
Advisor
Advisor

@jarredmonday ,

 

I think this would suit your needs.

(defun VportsAndZoom ( / cTab acObj acDoc ss cnt)
  (setq cTab (getvar 'CTAB))
  (setq acObj (vlax-get-acad-object))
  (setq acDoc (vla-get-activedocument acObj))
  (foreach lay (layoutlist)
    (setvar 'CTAB lay)
    (prompt (strcat "\nPreparing layout: " lay "..."))
    (vla-put-mspace acDoc :vlax-false)
    (vla-ZoomExtents acObj)
    (if (setq ss (ssget "_X" (list '(0 . "VIEWPORT") (cons 410 lay))))
      (repeat (setq cnt (sslength ss))
        (vla-put-displaylocked
          (vlax-ename->vla-object (ssname ss (setq cnt (1- cnt))))
          :vlax-true
        );vla-put-displaylocked
      );repeat
    );if
    (prompt "\nComplete. ")
  );foreach
  (setq ss nil)
  (setvar 'CTAB cTab)
  (princ)
);defun

Best,

~DD

0 Likes
Message 3 of 5

roland.r71
Collaborator
Collaborator

To do the zoom is easy:

(foreach layout (layoutlist)
   (setvar 'ctab layout)
   (command "_zoom" "_a")
)

Note: I prefer "All" instead of "Extents" on layouts, as it zooms to the paper, not its content.

0 Likes
Message 4 of 5

CodeDing
Advisor
Advisor

@roland.r71 ,

 


@roland.r71 wrote:

Note: I prefer "All" instead of "Extents" on layouts, as it zooms to the paper, not its content.


"Ackchyually" Lol

It does zoom to the content also. I was peaked by your comment, so I tried it.

Here's the actual definition for zooming to "All":

Zooms to display all visible objects and visual aids.

 

Which doesn't seem to differ much from my testing.. Zoom ALL & Zoom EXTENTS both ignore frozen layers and both still recognize items on OFF layers. So I'm not sure what they're referring to exactly.

 

Best,

~DD

0 Likes
Message 5 of 5

roland.r71
Collaborator
Collaborator

My 'description' might not be acurate, and if there's anything 'outside' the page, it will zoom to that too, but...

Perhaps the page is a "visual aid"?

As it does work:

Take an empty layout, draw a tiny box on it.

pageandbox.png

Type: zoom e

and it goes like this:

zoome.png

Zoomed in on the box.

Now type: zoom a

and you get this:

zooma.png

Zoomed in the page, instead of just the box