|
;;作者:John Uhden
;;功能:图块重命名
;;参数:old:旧图块名称;new:重命名后的名称
;;返回:重新命名后的图块
(defun renameblock (old new / ent)
(and
(= (type old)(type new) 'STR)
(/= new old)
(snvalid new 0)
(setq ent (tblobjname "block" old))
(or
;; allow changing case of block name
(= (strcase old)(strcase new))
(not (tblobjname "block" new))
)
;; then get the block record...
(setq ent (cdr (assoc 330 (entget ent))))
(setq ent (entget ent))
(entmod (subst (cons 2 new)(assoc 2 ent) ent))
)
)