Hello All,
Wondering if I can get some help. Below is part of a bigger routine (I posted about before) that I am working on where I was replacing our title block with an updated version. That worked well, but I ran into a scenario that it doesn't work on, hence, adding this new part. The routine searches for the block named "title_block" and will pull the attributes and enter them into the new one. Based off the "size" attribute will determine which title block will be inserted. Once inserted, the block name will be renamed to "title_block".
The scenario I ran into I have a title_block that was put into a drawing via a copy/paste I would guess. It still has the original block name, D Size. What I am looking for is a test to see if title_block exists and if not, rename it from one of the possible three sizes. There may be others, but these are the most probable ones. Once it gets renamed, then the rest of the routine should work as normal.
Below is what I was able to get together. Not very good with lisp, but trying to get better. I'm sure what I have is wrong or could be done better. I have the "C:" in there because I was using this portion to test this out. Any thoughts?
Code:
(defun c:blkrnm (/ blknewnme)
(setq blknewnme
(ssget "X" '((0 . "INSERT") (2. "TITLE_BLOCK"))))
(if (null (tblsearch "block" "TITLE_BLOCK"))
(cond
((= blknewnme "C Size") (command "-rename" "b" "C Size" "TITLE_BLOCK"))
((= blknewnme "D Size") (command "-rename" "b" "D Size" "TITLE_BLOCK"))
((= blknewnme "E Size") (command "-rename" "b" "E Size" "TITLE_BLOCK"))
)
(princ "Nothing Changed")
)
)
Thanks,
Paul