Find and Replace Text in Dynamo Civil 3D

Hello everyone! I would like to find all Text objects in a Drawing and replace them with another Text for example for all given “Text 1” to replace to “Text 2”. I found a solution to do that in Revit. But in Civil 3D I only found a way, from a previous Post to change the Style of the Text. Any help would be awesome.

Update: I was able to change a single keyword text object, now I would like to find all Text objects with values given from an Excel column in a Drawing and replace them with names given from another Excel column.

I also upload the Dynamo script that I’ve created to select the desired Text, the point where I am now.

Best regards


There is an MText.SetContents node as shown in the above “Text Content from Lower to Upper” post. If you are only using a text object though, a specific set contents node doesn’t appear to be available.

However you can still set the contents using the ObjectExtensions.SetParameterValueByName node in the Civil3DToolkit. I’ve found this node to be one of the most helpful nodes to adjust or set parameters of all different types of objects, not just text. It’s not the most obvious node but can do quite a bit once you figure out the parameter you are looking for using the ObjectExtensions.GetParameters.

1 Like

Excellent omar.g thank you. I was able to change the text with a single query keyword. Is it possible also to do that with a List of Text names from an Excel column and replace them with Text names from another column in Excel?
Thanks a lot again!

Yes this is possible. You just need to get the data from Excel using the ImportExcel or OpenXMLImportExcel nodes

Thank you for the answer, I have tried to insert the excel texts but I get an error when I try to insert the excel texts, I get a list although my input needs a string. I’m also sending the current situation in a screenshot

When importing Excel make sure to toggle the “read as string” to True. If you get a list, its just a matter of using levels to get the values and not the list : Lists of Lists | The Dynamo Primer

It is also easier to help if you share the data ^^ (dyn/excel/dwg) even if they’re just samples.

I’ve tried to toggle the readAsStrings parameter, I am uploading the current state.

  1. I am missing the nodes to filter the selection of the texts, according to the column given from the excel,
  2. if it is possible to replace the new texts given with the new excel column. Scipt uploaded

text to excel new.dyn (40.7 KB)

It appears the upper part of your script is close to working. I believe all you’ll need is a List.Flatten node between the List.Transpose and the ObjectExtensions.SetParameterValueByName nodes. That should make the list levels match for both the text objects and imported strings.

The bottom part of your script isn’t working because the obj input needs to be an autocad or Civil3D object type so it’ll return null.