Working With Switches
Blog Entry #5, January 26th, 2020
​
Intro
​
Switches are probably one of the most useful tools in Houdini. They can allow you to switch(just as it's name describes) between different geometry, simulation outputs and inputs, and more.
​
However, telling a switch when to switch, or telling it when to do it's job might be a bit difficult. More so if you are either new to VEX, Hscript, or Houdini in general. This article is going to be a reference, or go to sheet for switch commands. Enjoy!
​
Switch Commands
​
-
Current frame,and floating point frame number: $F, $FF.
​
-
Current time: $T or @Time
​
-
Switch input number every 50th frame going between 0 and 1: $F%100<50
​
-
Use the first input for the first four frames, and the second input afterward: $F >= 5
​
-
Switch to the first input at frame 1: $F - 1
​
-
The switch will use the second input if there are no errors, if there is, it will switch to the first input: if (strmatch("*Error:*", run("opinfo " + opfullpath("../" + opinput(".", 1)))), 0, 1)
​
-
To get the switch node affect certain attributes use: point(), prim(), vertex() or detail() expressions.
​
-
Switch to input 0 if there is no other objects in the merge node. If there is, switch to input 1: if(npoints(“../object_merge1/”) != 0, 1, 0)
​
-
Delay a simulation by a frame, and pass the previous frame's input data forward: if($F==1, 0, 1)
​
-
Make things exactly equal to something in a switch: ==
​
-
Make something greater and equal than something: >=
​
-
Make something less than and equal than something else: <=
​
-
Switch if something is not equal to another value: !=
​
References
​
-
[SOLVED] trigger every 10th frame: https://forums.odforce.net/topic/40472-solved-trigger-every-10th-frame/
-
Using Expressions in Parameters: https://www.houdinikitchen.net/2019/05/05/using-expressions-in-parameters/
-
Expression for "every other frame"?: https://www.sidefx.com/forum/topic/27316/?page=1#post-277242
-
Switch SideFX: https://www.sidefx.com/docs/houdini/nodes/sop/switch.html
-
VEX language reference: http://www.sidefx.com/docs/houdini15.0/vex/lang
-
Switch dynamics node: https://www.sidefx.com/docs/houdini/nodes/dop/switch.html
-
Why does Switch not see my attribute?: https://forums.odforce.net/topic/12645-why-does-switch-not-see-my-attribute/
-
How to switch via expression: https://www.sidefx.com/forum/topic/50119/?page=1#post-262279
-
Parameter expressions: https://www.sidefx.com/docs/houdini/network/expressions.html
-
Houdini Hscript tips Common Symbols: http://www.deborahrfowler.com/HoudiniResources/WriteUps/CommonSymbols.pdf
-
Delay Sim on Frame with Houdini Expressions: https://bubblepins.com/blog/delay-sim-on-frame