(defun c:mini_vportlock ( / old_cmd vlock ss lock )

(defun vlock ( en / en ss )
    (setq obj (vlax-ename->vla-object en))
    (vla-put-DisplayLocked
         obj
        (cond ((= lock "Q") :vlax-false)
              ((= lock "S") :vlax-true)
              ((= (vla-get-DisplayLocked obj) :vlax-true) :vlax-false)
              (:vlax-true)
        )
    )      
    (princ)
)

   (mai_start nil)
   (setvar "tilemode" 0)
   (or (= (getvar "cvport") 1)
       (command "_.pspace")
   )      
   (setq ss (mai_select_first '((0 . "VIEWPORT")) "选择要锁定或解锁的视口:" "没有找到视口."))
   (initget "S Q")
   (setq lock (getint "\n[取消锁定(Q)/锁定(S)]:<回车自动切换>"))
   (foreach ss (mai_ssget_2_list ss) (vlock ss))
   (mai_end)
)
