Hi-
Here is a simple version of what I use in my office. All you need to do to update the routine is to add or delete the layer names from the list. (ex. "Layer1" = "A-ANNO-NOTE") Just keep the layer name in quotes. You can also use an asterisk as a wild card to look for xref layers or general groups of layers. The routine will freeze all layers in a view port and then thaw the layers you have listed in the selection set. You can select one or more view ports and the routine will cycle through all that you pick. Sorry I don't have any error code in there.
Code:
(defun c:vp-layers (/ sset num vprt laylist count)
(setq laylist '(
"0"
"Layer1"
"Layer2"
"Layer3"
)
)
(if (> (getvar "cvport") 1)(command "pspace"))
(princ "\nSelect one or more view ports: ")
(setq sset(ssget '((0 . "viewport"))))
(setq num 0)
(repeat (sslength sset)
(setq vprt(cdr(assoc 69 (entget(ssname sset num)))))
(if (/= vprt 1)
(progn
(command "mspace")
(command "cvport" vprt)
(command "vplayer" "f" "*" "c" "")
(setq count 0)
(foreach lay laylist
(setq count (1+ count))
(setq layers (append layers (list lay ",")))
(if (>= (strlen (apply 'strcat layers)) 2000)
(progn
(command "vplayer" "t" (apply 'strcat layers) "c" "")
(setq layers nil)
)
(if (= count (length laylist))
(progn
(command "vplayer" "t" (apply 'strcat layers) "c" "")
(setq layers nil)
)
)
)
);end foreach
);end progn
);end if
(setq num (1+ num))
);end repeat
(command "pspace")
(command "zoom" "e" )
(princ)
);end defun