How to connect a number to Element.SetParameterByName

Hi guys

I am going to update my Revit parameter using " Element.SetParameterByName" node. I read and extracted the value from an external database through Dynamo, but as you say in the attached image, it was string. Therefore, I used “String to Number” to convert the string to a number. But as you see when I connect “String to Number” 's output (number) to " Element.SetParameterByName" node, it gives me error. It doesn’t work. Could anyone help me please? Since for establishing some conditions in my Revit model by Dynamo in the later steps, all string type values need to be converted into the number, otherwise the condition statements will not work. Your help is kindly appreciated in advance. Thanx

Regards
Mojtaba

Can you show the error you’re getting? Are you sure the parameter value isn’t supposed to be a string?

Thanks for your response.
The conditions stated in the following script written by @jacob.small do not work. It seems that since the values are string here, Revit cannot recognize them.

Regards

Correct. The values need to be numbers for the check. But are they numbers or strings when you get them from GetParameterValueByName? You’re getting the value of Humidity and setting it again right?

I got these values from MySQL database, assign them to an object in revit, then got these values using “Element.GetParameterValueByName” and assign it to its corresponding room.

Your very first image shows SetParameterByName with a warning. Can you show us what the warning is?
Also, put an Object.Type node after one of the GetParameterValueByName nodes and show us what the output is.

This is the error I got: The parameter’s storage type is not a number

So it’s most likely a string. You’ll have to convert the string to a number to run the check but convert it back to a string when you set the parameter again.

Yes it is string. See the attached image. Could you please show me a simple example in Dynamo? Thanks a lot

You already have the correct nodes, String from Object and String.ToNumber. Just don’t convert it to a number. Leave it as a string.

1 Like

Or better yet, delete the parameter and recreate it as a number based parameter. Storing numbers as strings is bad practice in general as you can’t use them natively in Revit, nor effectively in Dynamo.

2 Likes

I didn’t exactly understand what you said. If I used string.ToNumber that you said it is correct, it doesn’t work when I connect it to Element.SetParameterByName. Could you please show me an example in Dynamo? Thanx

Your Humidity parameter takes a string input. You have to convert it to a number in order to run your checks. When you set the humidity parameter again it needs to be a string. I don’t know where you’re getting the parameter value from but I assume it’s an output from the humidity checks. You need to convert that value to a string before setting your parameter again.

Thanks again @jacob.small for your response. How can we create a number-based parameter in Dynamo? As seen in the attached image, everything started from reading a list of values from MySQL database table. Then get the maximum the value of the list and … You mean that I have to delete all these nodes?

The room parameter Humidity in your project is set up as a string, not a number. You need to recreate the project parameter to take a number.

1 Like

Exactly what nick said. This is a Revit issue, not a dynamo issue.

1 Like

Thank u so much dear @Nick_Boyts & @jacob.small

Finally It worked. I recreated my parameters and it was solved as you see in the attached image.

I have the same problem, different graph, of course. I get the yellow error message “The parameter’s storage type is not a string.” The family is expecting a number and the upstream nodes are providing a set of numbers. How do I feed numbers to the family parameter?
,

String.ToNumber node as indicated above. If that doesn’t solve the problem for you please start a new post providing the .dyn and a small sample rvt file to reproduce the error.