hopbin9 Posted May 16, 2011 Share Posted May 16, 2011 Hi, I have a Subnet SOP that can take two input connections. I want to have a Switch SOP use the second input only if it's connected, but I can't figure out the HScript expression that tells if an input is selected. Help Quote Link to comment Share on other sites More sharing options...
graham Posted May 16, 2011 Share Posted May 16, 2011 (edited) You could use the opninputs() expression. The following looks at the number of inputs and if there are two, sets the switch input to 1. If there is only one input you just get 0 or the first input. opninputs("..") - 1 Also, you can use opinput() wrapped with strlen(). It gets the name of the input at the specified index. If there is a node then the name will not be an empty string. strlen(opinput("..", 1)) > 0 Edited May 16, 2011 by graham Quote Link to comment Share on other sites More sharing options...
SpencerL Posted May 17, 2011 Share Posted May 17, 2011 You could use the opninputs() expression. The following looks at the number of inputs and if there are two, sets the switch input to 1. If there is only one input you just get 0 or the first input. opninputs("..") - 1 Also, you can use opinput() wrapped with strlen(). It gets the name of the input at the specified index. If there is a node then the name will not be an empty string. strlen(opinput("..", 1)) > 0 you can also use opexist(opinputpath(".", 1)) which returns 1 if the node exists Quote Link to comment Share on other sites More sharing options...
hopbin9 Posted May 17, 2011 Author Share Posted May 17, 2011 you can also use opexist(opinputpath(".", 1)) which returns 1 if the node exists Thanks, I think that will work better. I was reading up on opninputs, but that's not exactly what I need. Cause it can cause mistakes especially if I add another input later in the future. It's not possible to tell which input is connected, just how many. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.