algorithmic modeling for Rhino
Tags:
Hi Adam,
the Format() function is basically a very advanced Find/Replace function. What happens is that all the format blocks in the format pattern (the string that looks like "{0}...") are replaced with the associated data (x, y or z).
So, whenever there's a format block with a zero inside curly brackets ("{0}") the value of the first piece of data (x in this case) is inserted in that location. If the format block contains another number, say {2}, then the third piece of data is inserted there (z in this case).
So, when the function looks like this:
Format("{0}({1}) i{2}", x, y, z)
you can imagine it as three find/replace operations:
replace "{0}" in "{0}({1}) i{2}" with x
replace "{1}" in "{0}({1}) i{2}" with y
replace "{2}" in "{0}({1}) i{2}" with z
thus, giving you
"x(y) iz"
Furthermore you can add additional constraints on how values like x, y and z are pasted into the pattern. For example you can enforce a specific numeric formatting (scientific notation, or hexadecimal notation), or a specific time and date formatting (depending on current culture settings) or even customized formats. However, since you don't seem to need these, I'll skip over them for now.
Does that explain to your liking how Format() behaves?
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Hi Adam,
in addition and for more documentation, you can also refer to .Net's String.Format function, which is the implementing method for Grasshopper's Format function.
- Giulio
______________
giulio@mcneel.com
McNeel Europe
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