Nice way to make a introduction. Most just request/demand something to be written.
A little food for thought...
Code:
(defun c:RBK (/ ent name new)
;; conditional variable to make sure object selected
(if (and (setq ent (car (entsel "\nSelect block to rename: ")))
;; check to make sure object is a block
(or (eq "INSERT" (cdr (assoc 0 (entget ent))))
(alert "Invalid object!")
)
;; print block name to command line
(princ (strcat "\n->>> "
(setq name (cdr (assoc 2 (entget ent))))
" <<<-"
)
)
;; prompt for new block name and make sure result not equal to ""
(/= "" (setq new (getstring T "\nspecify new block name: ")))
)
(cond
;; check if new name already exists
((tblsearch "block" new) (alert (strcat "Block: " new " already exists.")))
;; check if new name is valid
((not (snvalid new)) (alert (strcat "Invalid block name: " new)))
;; valid name, rename block
((snvalid new)
(command "_.rename" "_block" name new)
(alert (strcat "\nBlock \"" name "\" renamed to \"" new "\""))
)
)
)
(princ)
)
I did my best to comment everything.