Houdini Tip of the Day - Python pressButton() and set() Commands

I've been using the Python pressButton() and set() commands to make one-click rendering/caching systems. 

It's a one-line command and looks like this:
hou.parm('/obj/sphere_object1/rop_alembic1/execute').pressButton()

Using the "Post-render Script" field you can tell Houdini what to do after the rendering is finished. Make sure to set it from "Hscript" to "Python".
In this case, I wanted Houdini to export another ROP Alembic node that I had setup elsewhere.

So rather than export each of these manually I can just click on button and go relax while they render! Another command I've been using allows us to control Checkboxes on other nodes. It is the set() command and looks like this:

hou.parm('/obj/AutoDopNetwork/isplayer').set(1)

Again, this is certainly not limited to ROP Alembic nodes. That's just what I like to use. You can do the same thing on any node that has the "Post-Render Script" parameter.

Using a ROP Output Driver node instead

You can even type multiple commands and it will work

Open the expression editor with Ctrl + E

If you do type in multiple commands, you may see a strange looking symbol that separates each command. This is called a 'Paragraph Mark'.

It's a bit of a hassle to type that character manually but if you need to, use the shortcut 'Alt + 0182'

I also found out that inside the DOP Network there is a "Post-Render Script" parameter hidden inside the Output node. To access it you need to right click on the Output node and choose 'Allow Editing of Contents'. Once inside you will see that there is a ROP Output Driver node and you could use this to export Alembic's or BGEO's after you simulation is cached.
Pretty awesome functionality if you ask me!

Well that's it!
With one line of code you could be saving yourself hours of time having to wait for something to export then having to press another button manually. With this setup it's all automatic!

Until next time, happy sims!

Follow me on Twitter: @renderyourworld
And also on Facebook

Houdini Tip of the Day - Deleting Glue Constraints with Color

So last time I was talking about  activating RBD objects with the Active Value DOP and also with Glue Contraint Networks. I recently figured out how to delete glue constraints based on the distance a particular object is away from them.
It's fairly straightforward and by no means an advanced-level technique.

So basically what we are going to be doing is taking an object you have and scattering points on it and then assigning a particular color to those points. Then that color will be transferred to the glue network, and then we will promote that color value to the primitive level and then throw down a Delete SOP and delete what is colored.

Here's what your Network will look like at the end. Very simple but very effective.

By default, when you make a Glue Constraint Network it will look like this (inside the DOP Network)

Also, when you make a Glue Constraint Network, Houdini will make a separate Geometry node that will house a few nodes like "Connect Adjacent Pieces" and an "Attribute Create" that is making a few attributes for the Glue Constraint Network. 

Here's what you should have so far

Now what you need to do is make an object (in my case I made a sphere) that will be used to delete the Glue Constraints. Animate this object so that is encompasses the part of your object that you want to delete the constraints on. 
In my case, I wanted it to animate from being small to encompassing the whole wall.

My sphere starts off small

Over a few frames it grows to fully encompass the whole Glue Constraint Network

Now that I have that, after my sphere object I dropped down an "ISO Offset SOP" followed by a "Scatter SOP". I left the settings for these nodes at their defaults because we don't need an incredibly dense amount of points on our sphere. Just enough to evenly cover the surface.
 Okay now we need to apply color to the Glue Constraints and to the sphere. On the stream that has the Glue Constraints, drop down a Color SOP and set the color to pure black (0,0,0). And on the stream with the sphere, drop down a Color SOP and set the color to pure red (1,0,0).

Now I need to transfer the attributes from my red colored points onto my black colored Glue Constraints. To do this, I need an "Attribute Transfer SOP".
Drop one down and connect the output of the black Color SOP to the first input and output of the red Color SOP to the second input. 

If I play through the animation of my sphere I can see that as it gets closer to my Glue Constraints it slowly changes their color from black to red

It's important to point out here that if you are working at a much larger scene scale than the Houdini defaults (like I am) then you will need to increase the "Distance Threshold" value on the "Conditions" tab in the "Attribute Transfer" node. For instance, because I'm working in such a large scene scale I had to increase that value to 200.

Okay so far so good. Almost there!

Now after the Attribute Transfer SOP, drop down an "Attribute Promote SOP" and set the Original Name value to "Cd" (because we want to promote the color). Also make sure to change the "New Class" value to "Primitive" because we want to promote the red color that was on the Points from the Scatter SOP onto the Glue Constraints (which are technically a piece of geometry with polygons).

If you are interested in what this is actually doing, you can middle mouse click on the Attribute Transfer SOP and then on the Attribute Promote SOP and you will notice that it is taking the "Cd" Attribute that exists on the Point level and moving it to the Primitive level.

So really you can think of the Attribute Promote SOP as the Attribute Move SOP (at least that's what I call it)

Middle mouse on the Attribute Transfer SOP

Middle mouse on the Attribute Promote SOP

Finally, I need to delete any color that is not black (so in this case, delete everything that's red).
After the Attribute Promote SOP, drop down a Delete SOP and in the "Group" field, put "@Cd.x>0".
What this simple expression is saying is "take the attribute called 'Cd' " (@Cd), look for color value in the X (so in this case it would be looking for R because XYZ = RGB), and if that color value is above 0, delete it.

Now when you do that your constraints should look something like this

And that's it! Pretty simple but very effective because now you can animate any object and control how it breaks apart. You could even fracture your object more based on where your animated object is (I'll have to go through that in further detail at another time).

And again, just for clarity, your full node graph should look similar to this:

That's it!
Hoped this helped!