Find and Replace Help

Hello All,

I’m very new to Dynamo and i don’t have any experience in coding, I hope my question is simple!! Thanks for taking the time.

Under properties in Revit I have something called Data (Vico 01) it’s part of the Project Parameters

so what I’m trying to do each time I write the number (30.04) under Data (Vico 01), i want to run Dynamo and automatically change it from (30.04) to (30.04 - Grade Beam), as you can see here i tried do this

but i don’t know how to link it to Revit or even if i have the coding right ?!

Thank you for the help again

You need to use SetParameterByName to push the data to Revit:

2 Likes

It may be best to use an if statement like x == "30.04" ? "30.04 Grade Beam" : x; instead of a String.Replace function, as sequential runs will iterate the result, potentially resulting in something like this:

Run 0 = 30.04
Run 1 = 30.04 Grade Beam
Run 2 = 30.04 Grade Beam Grade Beam
Run 3 = 30.04 Grade Beam Grade Beam Grade Beam…

Note that there are some speed implications to this, so be wary before proceeding with this route. String replace being a single function is almost always going to be faster than an equality test followed by the replacement (even if run in line). However, in my testing (using the text from 5 of Shakespeare’s plays) with Dynamo Sandbox 2.0.2 I didn’t see any significant difference (1/2 a second) until around 40,000 words (multiple plays).

2 Likes

Well, you haven´t connected all the wires. Something like this will do (but strongly recommend that you look what Jacob has said in the previous post)

image

It works thank you for the help again

You’re going to want to do some research on Dynamo Dictionaries
A Dynamo Dictionary is basically a table where you can have your number(30.04) in one column and your matching text (Grade Beam) in the second column.
Then you call the dictionary with the code and it returns the text.
Here’s screen shot of one that I made and how it’s used

Hello Jacob,

Thank you for the reply, I’m very very new to Dynamo and honestly did not understand ( x == "30.04" ? "30.04 Grade Beam" : x; instead of a String.Replace function), if you could please show me an example ?!

Thank you

As you can see, String.Replace replaces 30.04 with 30.04 Grade Beam. This can create the names Jacob already mentioned.

If you put the code he wrote into a code block, this no longer happens.

The code block basically tells the following:

  • If the input is equal to “30.04” then output “30.04 Grade Beam”.
  • If it’s not equal then output the original string.

Hope this makes it a bit more clear for you.

1 Like

Hello Danos,

Thank you for the help, it does, let me try it and see

Thank you again

Hello,
I think this topic is the right place to put my question.

as you can see I’ve made two different modules with the same input.
I like JacobSmall smart solution, but it seems it doesn’t work as it should.
What am I doing wrong?

And yes I would like to replace text “Family Type: Standard, Family: Coude - Générique” with text " Coude".
PS

Thanks a lot!

What is the x input in your code block?

I’ve found the solution in Revit.
I renamed the Element Name and therefore simplified the code in dynamo for exporting data to excel.