- ;[隐藏物体(反)]
- (defun c:yf (/ AcadObject AcadDocument LayersObj ssObj ss ob n i ent ob ss2 ss3 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 ss2 (ssget "x"))
- (repeat (setq i (sslength ss))
- (ssdel (ssname ss (setq i (1- i))) ss2)
- );end repeat
- (sssetfirst nil ss2)
- (repeat (setq i (sslength ss2))
- (setq ent (ssname ss2 (setq i (1- 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
- );end repeat
- (princ "\n已隐藏非选择物体" )
- ));end if
- (sssetfirst nil nil)
- (princ)
- );end defun
|