Thursday, October 11, 2018

Zoom to Extents of All Objects On a Layer

I recently had someone ask me if there was a way to quickly zoom to all objects on a specific layer. I couldn't find any written LISP code as a whole, but found some small pieces here and here that I was able to utilize and make a command to do this.

Load up this lisp, and then run ZOLAYER to pick an object and zoom to the extents of all objects on that layer. Enjoy!

LISP CODE
====================================================================
(defun SALL ()
(setq TargEnt (car (entsel "\nSelect object on layer to select: ")))
(setq TargLayer (assoc 8 (entget TargEnt)))
(sssetfirst nil (ssget "_X" (list TargLayer)))
(princ)
);defun

(defun ZOE ()
(if (setq ss1 (ssget "_I"))
(command "ZOOM" "OBject" ss1 "")
(command "ZOOM" "Extents")
);if
);defun

(defun c:ZOlayer ()
(SALL)
(command)
(command)
(ZOE)
);defun
=======================================================================