Jump to content
MostHated

Conditional output switch?

Recommended Posts

Hello all,

    I was wondering if there exists any sort of conditional output switch. A switch with more than one output which decides which output to use based on a condition. An example would be I wanted to see if I could output from a solver to one file cache if a switch higher up in the network was set to one input, but then output to a different file cache from the same solver if the switch above was set to a different input.

GGLKGbD.png

 

If anyone knows of a way in which I might be able to go about this, I would greatly appreciate your suggestions.

Thanks,

-MH

 

Share this post


Link to post
Share on other sites

You can achieve the same result in the reverse if the switch is not being driven by an expression and you are just setting the value.  

A Geometry ROP can activate the switch for you before rendering to disk using prerender scripts and a global variable.

Edit/Aliases & Variables - > click the second tab at the top for global variables. There's boxes at the bottom for creating a new one so do something like
"SWITCH"   |     0

Then in your network you can use $SWITCH to call that variable in your switch node.

On the geometry Rop you can add a prerender script.

set -g "SWITCH" = 0

You can add this to a second geometry rop as 

set -g "SWITCH" = 1

And output the result to a different location while switch is set to 1.

Keep in mind, if you're using an expression to drive the switch, a prerender script may not able to evaluate the expression to determine the answer.

 

Share this post


Link to post
Share on other sites

I definitely appreciate the reply. Because I was a new member, my posts got hung in limbo for a day or two. I was able to figure it out by the time this actually showed up but the information you gave is quite useful and it will be nice to have it for reference.

I was able to get what I was after using an attribute wrangle plugged into the spare input nodes of two switches as seen below:

 

lXfwErT.png

 

It worked out how I was wanting for now, which was just a quick switch for testing to swap between two different types of fracturing. That, and I am just trying to learn as much about Houdini as I can, so I am trying to automate little tasks which probably have no need to be automated, just so I can learn how to do it, as well as making little useless tools with python, etc.

Share this post


Link to post
Share on other sites

No worries, that little buffer of "needs to be approved by admin" right?

Just a heads up, your current solution may set you up with a rather frustrating workflow in the future. In that way the switch functioning properly is entirely dependent on whether or not the detail attribute exists. The switch, while usually correctly set to 1, on a weird frame that geometry disappears or changes defaults to 0 rather than stays on its correct value if set globally at render time. 

Share this post


Link to post
Share on other sites

Yeah, luckily that post delay has been removed now, lol. I have the switches value being set from the null at the end, which has a slider I control to switch the things between the two. I can see what you are saying and will keep it in mind. With this particular thing I am making, and most things I will be making, I am just creating some RBD animation to export out as FBX to use in Unity. Not sure if this would come into play in that situation, but luckily things worked out well for me exporting it the few times I have done it so far. Going forward I probably won't need to use this, I was just using it to quickly jump back and forth between voronoi and material fracture to see which I wanted to use since I am new to Houdini, I wanted to see the difference between the changes I was making in both situations.

Share this post


Link to post
Share on other sites

I have been trying to do something similar the whole week. thanks

  • Like 1

Share this post


Link to post
Share on other sites

You can also use and expression with ifs and create the filepath based on the switch

$HIP/geo/`ifs(ch("../switch1/input"),"A","B")`.$F4.bgeo.sc

returns A.0001.bgeo.sc or B.0001.bgeo.sc

conditional_output.hiplc

  • Like 1

Share this post


Link to post
Share on other sites
On 2/15/2020 at 2:02 AM, bunker said:

You can also use and expression with ifs and create the filepath based on the switch


$HIP/geo/`ifs(ch("../switch1/input"),"A","B")`.$F4.bgeo.sc

returns A.0001.bgeo.sc or B.0001.bgeo.sc

conditional_output.hiplc

that is really great thanks.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×