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

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

   (mai_start nil)
   (mai_last_com "mini_vportlock")
   (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)
)
