@Anonymous wrote:
So I am kind of understanding, bare with me on this as I am not really good at programming. So I am going to add it to the acad.lsp because I don't want to create a new file. The less files the better, or so that is what I think. ....
If you expect to do more in the way of customization, I would think it will be well worth having an acaddoc.lsp file -- you'll find and make lots of things to put in it. The acad.lsp file is designed for things that need to be fired up once when AutoCAD is started, and that apply across any number of drawings [such as status-line content using MODEMACRO], not in every drawing. But defining custom commands is something that needs to be done in every drawing, which is exactly what acaddoc.lsp is meant for [that's what the "doc" part is about]. You can get acad.lsp to run in every drawing by setting the ACADLSPASDOC System Variable appropriately, without the need for S::Startup stuff, but that can cause drawings to take longer to open if it's doing functions upon opening every drawing that it doesn't really need to do more than once per AutoCAD session.
Personally, I would put the command into acaddoc.lsp followed by a function to invoke it:
(defun C:LAV (/ ss n vp); = Lock All Viewports
(repeat (setq n (sslength (setq ss (ssget "_X" '((0 . "VIEWPORT"))))))
(if (> (cdr (assoc 69 (entget (setq vp (ssname ss (setq n (1- n))))))) 1); not the Paper Space Viewport of its Layout
(vla-put-DisplayLocked (vlax-ename->vla-object vp) -1); lock it
); if
); repeat
); defun
(C:LAV)
Or, if you don't expect to need to use it manually at any time, don't define it as a command, but just put the operative code into acaddoc.lsp:
(repeat (setq n (sslength (setq ss (ssget "_X" '((0 . "VIEWPORT"))))))
(if (> (cdr (assoc 69 (entget (setq vp (ssname ss (setq n (1- n))))))) 1); not the Paper Space Viewport of its Layout
(vla-put-DisplayLocked (vlax-ename->vla-object vp) -1); lock it
); if
); repeat
Kent Cooper, AIA