未测试,但请尝试:
- (defun C:Clean ( / bl ss i ent name h s )
- (vl-load-com)
- (setq bl (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))))
- (while (not ss)
- (if (setq ss (ssget "_:L" '((0 . "INSERT"))))
- (progn
- (setq i -1)
- (while (setq ent (ssname ss (setq i (1+ i))))
- (setq name (vla-get-effectivename (vlax-ename->vla-object ent)))
- (if (eq (vla-get-isxref (vla-item bl name)) :vlax-false)
- (progn
- (command "_.bedit" name)
- (setq h (ssget "all" '((0 . "HATCH"))))
- (command "_.erase" h "")
- (setq s (ssget "all" '((0 . "SOLID"))))
- (command "_.erase" s "")
- (command "_.chprop" "all" "" "Color" "ByLayer" "")
- (command "_.bclose" "S")
- )
- )
- )
- )
- (prompt "\nEmpty sel.set... Select again...")
- )
- )
- (princ)
- )
|