Author Topic: Rename Blocks:Replace XYZ with ABC in all block names  (Read 8581 times)

0 Members and 1 Guest are viewing this topic.

Remarrk

  • Mosquito
  • Posts: 16
Re: Rename Blocks:Replace XYZ with ABC in all block names
« Reply #15 on: January 19, 2012, 12:54:48 PM »
Hello Swamp,

I'm hoping that posting to this old thread helps with the explanation better than I could by starting a new thread.
I have a situation similar to the OP's.
I have created blocks in several master drawings for tool palettes use.
I want to change the convention of the blocks names.
I have, for example:
ISORED90_L1
ISORED90_L2
ISORED90_L3
etc., etc.

I want to change not only the names, but the case of part of the name,
for example:
iso90RED_L1
iso90RED_L2
iso90RED_L3
etc., etc.

I tried the lisp routines without success. It may be my ignorance of the first user entry "Block name pattern:". I don't know what is required there.

Also, I tried the AutoCAD rename with wild cards and all I was able to accomplish was adding my entry to the block name.

Perhaps someone could clear this up for me.

thanks,

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Rename Blocks:Replace XYZ with ABC in all block names
« Reply #16 on: January 19, 2012, 01:04:41 PM »
Very quickly written and untested, but may help:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ( / name ) (vl-load-com)
  2.         (if (wcmatch (setq name (vla-get-name block)) "ISORED90*")
  3.             (vl-catch-all-apply 'vla-put-name (list block (strcat "iso90RED" (substr name 9))))
  4.         )
  5.     )
  6.     (princ)
  7. )

Remarrk

  • Mosquito
  • Posts: 16
Re: Rename Blocks:Replace XYZ with ABC in all block names
« Reply #17 on: January 19, 2012, 07:48:53 PM »
Lee Mac,
Works great, thanks much.

Remarrk

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Rename Blocks:Replace XYZ with ABC in all block names
« Reply #18 on: January 20, 2012, 07:03:41 AM »
Good stuff, happy to help  :-)