magneto Posted February 24, 2012 Share Posted February 24, 2012 I am trying to make a digital asset using a subnet that takes a curve input. I wanna make it so that if there is no curve provided then it will use the curve inside my subnet, else it will use the provided input curve. I thought I might be able to do this using a switch operator but when there is no input, it errors out. Is there a way to do this? Perhaps with an expression? Quote Link to comment Share on other sites More sharing options...
hopbin9 Posted February 24, 2012 Share Posted February 24, 2012 Switch SOP with two connected inputs. First input is from a Null SOP connected to a subnet input, and the second is a default curve SOP. For the switch value, set the expression as npoints("../null1") == 0 If the null1 has no points, then it'll set the switch to use the second switch input. 2 Quote Link to comment Share on other sites More sharing options...
magneto Posted February 24, 2012 Author Share Posted February 24, 2012 Thanks Hopbin, it works great Would this work for any kind of input? Like if the input has no points? Not sure if that's a valid case. I am basically wondering if there is a function like: isNull(operator) Quote Link to comment Share on other sites More sharing options...
graham Posted February 24, 2012 Share Posted February 24, 2012 I'd personally use comparison of the input path string for a given input to see if it is connected or not: strcmp(opinputpath("..", 0), "") == 0 5 Quote Link to comment Share on other sites More sharing options...
magneto Posted February 24, 2012 Author Share Posted February 24, 2012 Thanks Graham, amazing trick. So if nothing is connected, then the input path is ""? Also you don't use a null for this then, right? Quote Link to comment Share on other sites More sharing options...
graham Posted February 24, 2012 Share Posted February 24, 2012 (edited) Yes, if nothing is connected at a specific input index it will return an empty string. The null is not necessary since it is just asking the parent asset what it's Nth input is and doesn't care about the input connected to the switch. The indirect input can be plugged directly into the switch's first input, or you can put other things between since it doesn't really matter. Edited February 24, 2012 by graham 1 Quote Link to comment Share on other sites More sharing options...
anim Posted February 24, 2012 Share Posted February 24, 2012 ... I am basically wondering if there is a function like: isNull(operator) then you probably need opexist() like opexist(opinputpath('.',0)) 3 Quote Link to comment Share on other sites More sharing options...
magneto Posted February 24, 2012 Author Share Posted February 24, 2012 (edited) Thanks a lot guys, getting better with every post EDIT: @anim: Just tried it, but it says, not enough sources specified, so errors out. Should I use null for this one? Edited February 24, 2012 by magneto Quote Link to comment Share on other sites More sharing options...
rdg Posted February 24, 2012 Share Posted February 24, 2012 Thanks a lot guys, getting better with every post EDIT: @anim: Just tried it, but it says, not enough sources specified, so errors out. Should I use null for this one? Slightly off topic, but a gem I often forget about: From the help card for the switch sop: Often, you can use a Switch in a network that could potentially have errors to bypass the failing nodes. One way to do this is to use the following expression in the Select input parameter: if (strmatch("*Error:*", run("opinfo " + opfullpath("../" + opinput(".", 1)))), 0, 1) With this expression, the switch will use the second input, unless it has an error, in which case it will switch to the first input. 1 Quote Link to comment Share on other sites More sharing options...
anim Posted February 24, 2012 Share Posted February 24, 2012 ... EDIT: @anim: Just tried it, but it says, not enough sources specified, so errors out. ... in your case it should be: !opexist(opinputpath('.',0)) since you want to switch to 1 if it doesn't exist 2 Quote Link to comment Share on other sites More sharing options...
magneto Posted February 24, 2012 Author Share Posted February 24, 2012 Thanks a lot guys Quote Link to comment Share on other sites More sharing options...
hopbin9 Posted February 24, 2012 Share Posted February 24, 2012 Great thread guys! Another trick, if you're going to make the subnet an asset. Create a integer parameter called "connected" and assign the !opexist(opinputpath('.',0)) as it's default expression, then make the parameter visible. Now, when you create parameters you can disable them based upon the "connected" value. So when you connect an input it becomes enabled or disabled. 1 Quote Link to comment Share on other sites More sharing options...
Matt_K Posted February 24, 2012 Share Posted February 24, 2012 Now, when you create parameters you can disable them based upon the "connected" value. So when you connect an input it becomes enabled or disabled. Now that is a neat trick! Many thanks! Matt. Quote Link to comment Share on other sites More sharing options...
hopbin9 Posted February 24, 2012 Share Posted February 24, 2012 It's one of my top 10 tricks in Houdini. That's the theme for my next tutorial. Quote Link to comment Share on other sites More sharing options...
magneto Posted February 24, 2012 Author Share Posted February 24, 2012 It's one of my top 10 tricks in Houdini. That's the theme for my next tutorial. Thanks Hopbin, I didn't get it though. Can you please post a hip file? Quote Link to comment Share on other sites More sharing options...
slamfunk Posted December 2, 2013 Share Posted December 2, 2013 Thanks Hopbin, I didn't get it though. Can you please post a hip file? Same here. Any chance we could shine some light on this tip guys? Quote Link to comment Share on other sites More sharing options...
csp Posted December 3, 2013 Share Posted December 3, 2013 (edited) Billy and Magneto, I think what Hopbin meant two years ago was that if you have an digital asset with inputs, and you want some of your parameters to be enabled or disabled based on the existence of connection on, let's say first input... You can use: opexist(opinputpath('.',0))[/CODE] (documentation) [/font][/color][color=#282828][font=helvetica, arial, sans-serif]as default value on a integer or toggle parameter which will gives you a boolean value where 1 means the first input has a connection and 0 means no connections. [/font][/color][color=#282828][font=helvetica, arial, sans-serif]Then you can hide this parameter but you can use it as reference for the other parameters in [b]Disable When[/b] and [b]Hide When[/b] fields using [/font][/color][color=#282828][font=helvetica, arial, sans-serif] [CODE]{toggle == 0}[/CODE][/font][/color] Edited December 3, 2013 by cparliaros 1 Quote Link to comment Share on other sites More sharing options...
magneto Posted December 3, 2013 Author Share Posted December 3, 2013 lol I figured it out 2 years ago, but thanks Reading back brought memories though Too bad hopbin isn't here anymore 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.