Replace AutoCAD Blocks in DWG

I am converting MicroStation DGN’s to AutoCAD DWG’s. During the conversion (using DGNIMPORT), each instance of a MicroStation Cell comes in as an AutoCAD block with a number suffix. An example of this is, a manhole cell called MH comes over as MH1, MH2, MH3… This is resulting in upwards of 90,000 individual blocks in the DWG. I am looking for help on if I can replace each block that was created during the conversion process with an AutoCAD block. So, I would like to replace MH1, MH2, MH3…with one called MH.

Any help is appreciated.

Hi @Michael.McKeon ,

That sounds doable, you would probably just have to retrieve the locations of all your BlockInstances, together with what block they are supposed to be and you could replace them that way.

What have you tried so far?

1 Like

I am a novice at Dynamo so I haven’t gotten far. I was able to get the names of each block in the DWG exported to Excel. I was thinking I could just replace each block with a new one but realize that won’t be easy.

I think I will need to capture the block name, x, y and z coordinate, scale, and rotation of each block. Then I can use that to insert the correct block.

You don’t have to export to excel.
First filter out all block references that Contains “MH” and get their insertionspoint as a coordinatesystem (x, y and z value)
After that you can insert the correct Block reference at the same coordinatesystem.
Finally use the delete node for AutoCAD object to remove the Block references that you filtered out.
In my example I searched for all Blockreferences with a name that contains “BEL” and then I wanted to replace them with a new block reference named “cdh_Buske E”

2 Likes

thank you for the response. The main reason that I wanted to send the list to Excel is that I won’t be replacing one specific block. I will be replacing many. I was going to export the list and then add a column to map the old block to the appropriate one to use. Something like this:
MH123 will be replaced with MH
MH124 will be replaced with MH
WM435 will be replaced with WM
The user will need to fill in the spreadsheet with the new block.

If I could parse the block name to remove the numbers, I might not need to send to Excel and remap the names. Like if I could strip the “123” out of “MH123”, then I wouldn’t need excel.

What I feel I need to do is capture each blocks name, coordinates, scale and rotation so that when I insert the new block, it matches the old one.

Matybe like this then?

1 Like