The other day I needed to create a bunch of toggles on a master controller. Each toggle was to be connected to a Switch SOP in 25 different copies of an object. Each of these had a number in its name and I thought: “Hey, I can use opdigits()
for this”. What I didn’t know was how to combine the string pointing to the node with the result from opdigits()
. Something I swore I knew how to write ended up being not what I expected.
Originally I thought I needed to use backticks to evaluate opdigits()
first. But it turned out that I didn’t. Also, I was a bit confused about how to convert from integer to string. But it was also something I didn’t need to do!
In the end the correct syntax is the following:
ch("name_of_node_without_number_"+opdigits(".."))
In the parenthesis of opdigits()
I have ".."
because it’s pointing to its parent. Anyway, this is the kind of thing that I’ll forget, so I thought documenting it here was a good idea.