Expression for number of connected inputs

   10122   4   0
User Avatar
Member
228 posts
Joined: Dec. 2012
Offline
Is there an expression for getting the number of connected inputs for a given node?

For example, I want to write an expression for a switch statement so that it randomly selects one of the input nodes and I can add or remove connections without having to re-write the expression

select input: rand(seed)*numInputs

I know that opinput() can get a connection to a given input index, but I'm looking for the number of connected inputs.

Thanks!
www.kmcnamara.com
User Avatar
Member
1926 posts
Joined: Nov. 2006
Offline
You should be able to use opninputs() http://www.sidefx.com/docs/houdini12.5/expressions/opninputs [sidefx.com]

There's a caveat dealing with missing inputs but that shouldn't be an issue with a Switch.
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
228 posts
Joined: Dec. 2012
Offline
Hey Graham, I tried using that earlier but got ‘Unknown Function in Expression’. Also, when I begin typing ‘opin…’ there's no auto complete for opinputs, just opinput and opinputpath, which makes me think it isn't accessible. Any idea why?

Thanks for the help
www.kmcnamara.com
User Avatar
Member
1926 posts
Joined: Nov. 2006
Offline
You're missing the ‘n’ in there: op(n)inputs.
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
228 posts
Joined: Dec. 2012
Offline
derp. Thanks!
www.kmcnamara.com
  • Quick Links