试试这个。
- (defun c:Test (/ l ss doc )
- ;;----------------------------;;
- ;; Tharwat 20.09.2015 ;;
- ;; Move object in Normal ;;
- ;; Blocks to a specific Layer ;;
- ;;----------------------------;;
- (if (and (/= "" (setq l (getstring t "\nSpecify the Layer name to move objects in blocks to :")))
- (if (not (tblsearch "LAYER" l))
- (progn
- (alert (strcat "Layer name < " l " > is not found !!")) nil)
- t
- )
- (princ "\nSelect Normal blocks to proceed :")
- (setq ss (ssget "_:L" '((0 . "INSERT"))))
- )
- (progn
- (vla-startundomark (setq doc (vla-get-activedocument (vlax-get-acad-object))))
- ((lambda ( r / sn nm lst obj)
- (while (setq sn (ssname ss (setq r (1+ r))))
- (if (not (member (setq nm (cdr (assoc 2 (entget sn)))) lst))
- (progn
- (setq lst (cons nm lst)
- obj (tblobjname "BLOCK" nm)
- )
- (while (setq obj (entnext obj))
- (entmod (subst (cons 8 l) (assoc 8 (entget obj)) (entget obj)))
- )
- )
- )
- )
- )
- -1
- )
- (vla-endundomark doc)
- (vla-regen doc acAllViewports)
- )
- )
- (princ)
- )(vl-load-com)
|