Jump to content

Switch SOP based upon an input


hopbin9

Recommended Posts

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 :)

Link to comment
Share on other sites

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 by graham
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...