- ;[隐藏物体]
- (defun c:yc ( / AcadObject AcadDocument LayersObj ss n n-yc i ent ob lay vlay ) ;lay-tn
- (setq AcadObject (vlax-get-acad-object)
- AcadDocument (vla-get-ActiveDocument AcadObject)
- LayersObj (vla-get-layers AcadDocument)
- );end setq
- (princ "\n请选择需要隐藏的物体" )
- (if (setq ss (ssget))
- (progn
- (setq n (sslength ss)
- n-yc 0 )
- (setq i (- n 1))
- (repeat n
- (setq ent (ssname ss i)
- ob (vlax-ename->vla-object ent)
- lay (vla-get-layer ob)
- vlay (vla-item LayersObj lay)
- );end setq
-
-
- ; (if (= (setq lay-tn (vla-get-lock vlay)) :vlax-true);如果图层锁定
- ; (vla-put-lock vlay :vlax-false);先解锁图层
- ; );end if
- ; (vla-put-visible ob :vlax-false)
- ; (if (= lay-tn :vlax-true)
- ; (vla-put-lock vlay :vlax-true);再锁定图层,恢复图层状态
- ; );end if
- ;当图层未锁定时,执行隐藏操作
- (if (= (vla-get-lock vlay) :vlax-false)
- (progn
- (vla-put-visible ob :vlax-false)
- (setq n-yc (+ n-yc 1))
- )
- )
- (setq i (1- i))
- );end repeat
- (princ (strcat "\n已隐藏" (itoa n-yc) "物体" ))
- ));end if
- (princ)
- );end defun
|