Thanks to Mootzoid emTools, it’s easy to convert an integer to a string:
Note that you get padding too, so it’s easy to do things like generating replacements for the [Frame] token.
The emTools string compounds are convenience compounds:
For fun, I tried to create my own integer-to-string converter using the stock nodes. I did by dividing by 10 until the quotient (the result) was zero; with each division, I take the remainder and stick it at the front of the string. And by setting Max Repeat to 4, I get padding on my strings (so for integer 45 I get “0045”).
Note the use of Delay Set Data. The integer division compound uses Modulo and Division by Scalar. The 2char compound simply uses a Select Case to map a single digit to a string:
It did occur to me that I could do it all with a single Select Case π
The catch is that the Select Case node has ten thousand cases.
That’s really slow when you create that node in an ICE tree (for example, by importing a compound that uses it). It also takes a long time to create ten thousand cases, even with a script.
case_node = Application.AddICENode("$XSI_DSPRESETS\\ICENodes\\SelectCaseNode.Preset", "pointcloud1.pointcloud.ICETree") string_node = Application.AddICENode("$XSI_DSPRESETS\\ICENodes\\StringNode.Preset", "pointcloud1.pointcloud.ICETree") Application.ConnectICENodes("{0}.case0".format( case_node.FullName ), "{0}.result".format( string_node.FullName ) ) Application.DeleteObj( string_node.FullName ) Application.SetValue("{0}.case{1}_string".format( case_node.FullName, 0), "{0:0>4}".format(0), "") Application.SetValue("{0}.default_string".format( case_node.FullName, "9999", "") for i in range(1,10000): Application.AddPortToICENode("{0}.case{1}".format( case_node.FullName, i-1), "siNodePortDataInsertionLocationAfter") Application.SetValue("{0}.case{1}_string".format( case_node.FullName, i), "{0:0>4}".format(i), "")
I also made one recently with a slightly different approach in order to not require an execute node. I’ll share it here when i get into work.
I didn’t implement padding but I guess it would be a simple thing to add. My approach limits the length to ten or so digits – whatever XSI’s limit is, I can’t remember. This is the key to losing the repeat or while nodes.
Also, once you have the integer to string node made, making scalar to string is easy. π
Nice method π
Here are my attempts. Probably full of redundant nodes, and could be much more compact, but they seem to work!
Integer to String
https://www.dropbox.com/s/9zl2muxwk9z7tsb/Integer%20to%20String.xsicompound?dl=0
Scalar to String
https://www.dropbox.com/s/d1z1elog2zpjajq/Scalar%20to%20String.xsicompound?dl=0
thanks, belatedly…