I’m trying to create a Dynamo script where I can select multiple existing blocks in AutoCAD/Civil 3D and replace them with another block type.
For example:
I select several instances of Block A in the drawing.
I want to replace all of them with Block B, keeping the same insertion point, rotation, scale, and layer.
I tried using the BlockReference.ByCoordinateSystem node, but I keep getting type errors because it expects Block definitions instead of BlockReference. I also tried connecting the selected blocks directly, but that didn’t work either.
Has anyone done this before? What’s the best approach — using only nodes, or is it better to handle this with a Python script inside Dynamo?
Here is a super simple approach for what you are looking for. You can accomplish this with the out of the box nodes. If you have additional items like attributes you can read and set those as well.
Instead of making new block references and deleting the old ones, I would recommend using the BlockReference.SetBlock node. So you can just change the block definition of the block reference directly. There’s also a sample graph that you can try out
I’d also like to mention that the functionality that you are looking for already exists with the BLOCKREPLACE command (from Express Tools) which will allow you to do exactly what you want. With a caveat though that it doesn’t work with dynamic blocks, that might be possible with Dynamo.
Hello Devin. Thank you very much for your reply. I’m just getting started with Dynamo and I’m having some difficulties. The node BlockReference.ByPoint doesn’t appear in my Dynamo. Is it part of a specific package?
Hello Zachri. Thank you very much for your reply. I’m just getting started with Dynamo and I’m having some difficulties. The node BlockReference.SetBlock doesn’t appear in my Dynamo. Is it part of a specific package?
Hello HenrikJ. Thank you very much for your reply. This question is part of a routine I am trying to develop, which is why it is necessary for me to use Dynamo.