String numbers to Numbers with Dynamo

Hello,

Question of concept of numbers in Revit.

I am a bit curious what happens with the numbers when you get them initially in string format and you convert them into a number, because for small numbers, they appear displayed as 2*E^-10 for example and if I introduce this number into a Revit parameter which is a number it is displayed in same way, so not sure if that number is a number or just a text, not sure if I could sort a schedule as ascendent or descendent with those small numbers.

All of Revit parameter have “Type of Parameter” option so it can’t confusing…
If the Type of the Parameter is ‘Text’, the value can’t be ‘Number’, and vice versa.

1 Like

I know that for sure, but even being a number parameter, not sure if how the numbers displayed are an issue when you read in screen a number ending in E-12 for example. I am expecting that for example a number displayed as E-12 is lower than 1 in a schedule, so if I export to Excel for example I cannot sort by number I think, I would have to export a number like 0,000000000000001 instead of 1E-12.

In resume, by default all is a string, but if I want a number in Revit, the input needs to be a number, although it is displayed as scientific number when converted into a number, but if I want the number in a schedule not inside Revit, I think I have to make it work with full decimal numbers displayed instead, but maybe I am wrong, it is just a perception of behaviours with numbers

Excel should sort the number without issue, as it too should know it’s a number. That said this is a general Revit question in regulars to how your units are displayed. Check the project units settings and if that doesn’t work you may get better answers over on a Revit forum.

1 Like

My ideal is use some code python scripts, multiply it to a large number and sort it, like this, or give it and convert again.

from decimal import Decimal
import math
lst = IN[0]
nums = []
for i in range(len(lst)):
    nums.append(Decimal(lst[i])*100000000)
    
#example if you want convert 
value = float('9.81E7')
OUT = sorted(nums, key=float),value

2 Likes

Hello. Can I ensure that the entered value is automatically recognized and entered whether it is a number or text? or is there another method?

If the input is required to be a number then just use a number input. Using a string input also allows for non-numerical values which would immediately cause problems.

1 Like

Thanks for the info. Can I write Python Script for this that If the input is number, then string is changed to number, if the input is string, it is used.

If you’re writing to a parameter it won’t matter. The input has to match the parameter type.

It’s also typically poor practice to maintain a parameter as multiple types. Why do you need a number in some situations and a string in others?

2 Likes

You are right. I wanted to write an Dynamo for parameter, whether it’s a text or a number.

maybe this could be the solution

The parameter will only accept a number if the parameter’s type is set as a number and it will only accept a string if the type is a string. You need to format your value to match the parameter every time, not under certain conditions. Look at the parameter definition and match it.
image

Thanks for all information