Here's a couple that affect ALL PS viewports without switching Tabs while doing it. Much faster, especially with lots of tabs.
(defun c:lockallVP ()
(vl-load-com)
(ssget "x" '((0 . "VIEWPORT")))
(vlax-for item (vla-get-activeselectionset
(vla-get-activedocument
(vlax-get-acad-object)))
(vla-put-displaylocked item :vlax-true)
)
)
(defun c:unlockallVP ()
(vl-load-com)
(ssget "x" '((0 . "VIEWPORT")))
(vlax-for item (vla-get-activeselectionset
(vla-get-activedocument
(vlax-get-acad-object)))
(vla-put-displaylocked item :vlax-false)
)
)
Jeff