algorithmic modeling for Rhino
Any ideas what am I doing wrong?
Thanks,
Gustavo
Tags:
Format("{0:?}", x)
Format("{0:0.00}", x)
Format("{0:0.00##}", x)
Format("{0:R}", x)
Format("{0:E}", x)
Format("{0:P}", x)
Format("{0:X}", x)
You sure you need the double quotes and the comma x to be included in the result? Sounds like you're only after {0:R}.
Or is the question about the orange number parameter?
The Format() function in the expression language takes a string (ie. text) and then a collection of values. The string describes where to insert the values, and how to insert them. For example, let's assume we want to format two numbers, one integer and a floating point value. The integer represents an index and it should appear inside square brackets, then we want the floating point number rounded to a maximum of 4 decimal places (but always using at least one decimal place, even if it's zero), and then, in parentheses a scientific notation representation using 8 decimal digits of the number.
So, assuming the index is 16 and the value is 47.280006208, what we are after is:
[16] 47.28 (4.72800062E+001)
To make this work, we need a formatting pattern that looks like:
[{0}] {1:0.0###} ({1:E8})
The square brackets, spaces and parenthesis are just part of the output, they have no meaning whilst formatting. Everything inside the curly brackets though will be replaced with a specific formatting of one of the values.
When using the Format component as shown above, the formatting pattern is just text data. The component knows that it is supposed to use the Format() function using the pattern text and whatever additional data is provided.
When you invoke the Format() method in an expression, you do need to make sure that the pattern is actually text:
So here the pattern needs to be encased in double quotes, otherwise it will be treated as code, rather than text.
You cannot use the formatting method in the internal expression of a number parameter, because this method returns text, whereas the number parameter is only capable of storing numbers. Any expression that you put into a number parameter had better return numbers as a result.
Thank You for the detailed answer! I figured out why it wast working.. The information was already string because that is what the karamba component outputs. Is there any solution to transform string scientific notation to "normal" notation?
Also, R doesn't see to work like i understood it should (as in showing the number in normal notation, no matter how long)
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by