Message 1 of 37
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Is there lisp routine that will allow you to rename multiple blocks at once?
Thanks,
Anderson51
Solved! Go to Solution.
Is there lisp routine that will allow you to rename multiple blocks at once?
Thanks,
Anderson51
Solved! Go to Solution.
Assuming you want to change all names that begin with "DS-301-145..." to "DS-302-146..." (for example), select one of the names that has that common beginning string, so that its name appears in the upper name field. Now, edit the string to replace everything that follows the characters you want to change with an asterisk ("*"). Now all of the block names that match up to that character will be highlighted in the listing. Now enter what you want that string to read in the lower name field (again using the asterisk) and hit the button.
Of course, it's important to understand that this method works only with names that follow similar patterns. And sometimes the renaming has to be done in logical steps. Your example seemed to be that, so I thought you might benefit from learning about this time-saving technique.
Practice.
Someone in the past bound all the Xrefs together creating unnecessary prefixes to every block and layer.
The RENAME command brings up this dialog box:
Note in the OLD NAME box the prefix I want to get rid of is entered.
The RENAME TO box shows the thing I want to name it to.
Click the RENAME TO button and all block names are changed.
No programming required. It would be helpful if Autodesk made this feature more widely known.
I'm having the same issue. I've exported several cad files from revit, and every block has "-_3D - [my name]_" at the end of the block name. I would like to retain each block's name but without my name on the end. I was able to use the wildcard * along with the text I would like to remove for the block names, but I can't figure out how to remove that portion of the names without going line by line which would take days.
Be sure to include a small portion of the block name that you want to remain after the asterisk, like so:
find: *-_3D - warren_clements_
replace: *-_3D
(Everything that ends with this, I want it to end with this.)
I keep trying that exact text, and it runs through the names like its going to replace/remove the text but it doesn't. Thanks for the quick response.
See attached. It will select all of the matching text as if it plans to replace.
If all of the block names that match the criteria do not become highlighted in the list, then there must be something different in the criteria you've entered.
Try starting smaller and then building up... and hopefully you'll see where the difference is.
That's what I was trying to say. It will select all of the text, and when I click rename all of the text is re-selected.
I understand now.
It appears I've been wrong about how this works, because I just tried something similar in one of my DWGs and it does the same thing you report. I could've sworn I've done this before (but apparently not).
I apologize for misleading you.
I think your only other option may be to use strings of ????... of various lengths as stand-ins for the segments you want to retain in blocknames with similar lengths and suffixes. (This doesn't seem like it will be much of a time-saver, though.)
how does it reference a "Block A"? I get an error saying "Cannot find Block A"
If you're referencing my code in message 2, then you're probably implementing it wrong.
If you do not have a block in your drawing called "Block A" then you should remove that line from the code.
Could probably be written better like:
(defun c:RMB ( / lstBlocks cnt)
;; Rename Multiple Blocks
;; Prep
(setq lstBlocks '(
;("old_name" "new_name")
("Block A" "Block 1")
("BLOCK B" "Block 2")
))
;; Begin work
(setq cnt 0)
(setvar 'CMDECHO 0)
(foreach blk lstBlocks
(if (tblsearch "BLOCK" (car blk))
(progn
(command "-RENAME" "b" (car blk) (cadr blk))
(setq cnt (1+ cnt))
);progn
;else
(prompt (strcat "\nBlock \"" (car blk) "\" not in drawing."))
);if
);foreach
(setvar 'CMDECHO 1)
;; Finish up
(prompt (strcat "\nBlock Re-Naming Complete. " (itoa cnt) " blocks renamed."))
(princ)
);defun
Best,
~DD
You can also mass-rename such blocks with the RRename utility - see
https://www.cadforum.cz/en/rename-on-steroids-complex-renaming-of-autocad-objects-tip9265
the search/replace pair will be something like:
DS-(\\d.+)-(\\d.+)-a(\\d.+)
DS-{$1+1}-$2-a$3
then - similarly:
{$1+1}
then
a{$1+7}
Vladimir Michl, www.arkance.world - www.cadforum.cz
Are we now again allowed by Autodesk to promote our own apps?
I am sorry if this is breaking any rules, it is non-commercial freeware. But still, perhaps blatant advertising. Can be freely deleted.
Vladimir Michl, www.arkance.world - www.cadforum.cz
You can also use Excel to help you rename all the blocks you have since there are so many. This may seem like a lot to do but renaming here is faster than the RENAME inside AutoCAD.
Also, not sure if someone told you but the reason you have the AP-1$0$ is because someone did a XREF BIND BIND vs XREF BIND INSERT. If you have all the Native Files, Redo your XREF BIND INSERT. You can open a drawing, type XREF and select 100 or more files, if you need to. Let them XREF in at 0,0. The go to XREF, select them all and BIND INSERT. Done. No more AP-1$0$.
Start by DATAEXTRATION. Create a new Excel file and choose only Blocks.
Tip for your renaming of this type of block names. Copy Your Existing into Column E.
Select that Column and do a REPLACE and put in FIND WHAT: AP-1$0$
Don’t put anything in REPLACE WHAT and hit OK. Now your renaming is completed.
Seems like a lot, but very easy and fun to watch. Your file should look like my Paste below.
This works for Layer Names as well. Just replace the B with LA. Because I am sure they are messed up as well.
Hope this helps!
JRR!