;; RenameBlock.lsp (c) 2003, John F. Uhden, Cadlantic/CADvantage ;; Fixed up to validate (01-09-03) ;; Arguments: ;; old - old block name as a string (case-insensitive) ;; new - new block name as a string (case-sensitive in pre-R15 only) ;; Returns: ;; T - if successful ;; nil - if it failed for any reason (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)) ) )