Thursday, 10 July 2014

AutoCAD advanced search replace

A couple of words on Autocad search replace. Autocad has the functionality built in and for simple things is good enough.
For example when I need to change pipe size on a P&I D I can select the labels and use the properties (CTRL+1) to change the attribute text all at once.

If you need to change different types of notes, blocks, texts, multiline-text etc. then you can use the Search/Replace functionality

You can search in Entire drawing / Current space/layout or in selection (pre selected object or on the spot)

On the result list you can select just part of the items before doing replace.

But what if you need to do a complex search replace? This won’t do.
I had to change Cable Schedule in several acad drawings and all I was given was an excel file.  Luckily I had the previous revision of the excel file and I could make a list of old - new name. Lee Mac has created a script that can do that for you. The script is called BFind and here’s how I used it.
                 This is what the Acad looks like.
                 And this is what we will end up with.


Once you load the BFindV2-0.lsp script in you acad session (you can drag drop it on your drawing) run it by typing BFind and you should get the following window.


In here you can search replace in current drawing, all open drawings, folder,  folder with subfolders. You don’t want to type all text changes one at a time but rather use a text document with the values from excel so here’s how to do that.
You need to add something in the search replace fields and save it as a text for reuse late. You can then open the reuse text document and add your texts. Load it back in the BFind window an hit ok.

Let’s add Find: ADS ad Replace with: ADS1 then click Save. Click OK for changes to take effect and then open windows explorer and let’s locate the file.  Do a search on C: drive for a file name that contains LMAC BFind. Mine was located here:
C:\Users\adrian.salariu\AppData\Roaming\Autodesk\AutoCAD Mechanical 2015\R20.0\enu\Support\LMAC_BFind_SavedSearches_V2-0.txt
Open it up and check to make sure it contains our saved Search Items List.



Add your text in and save the document. In Autocad run BFind and click on Load to load your list.
After selecting your search location (drawing, folder , etc.) click OK and go get a coffee till it’s done.

This saved me a couple of hours of boring, mind-numbing work. Hope it helps you as well. Here's the link to Lee's web page.


ADS