Filtering Attributes by Value with Houdini Expressions

Houdini Expressions are variables, shortcuts, or one liner logic code that goes into the parameter values. They help out with small tasks and can turn normal static functionality more dynamic and flexible with the use of logic.

 

In a tutorial video demonstrating a destruction setup in Houdini, I use an assemble node to assign an unique name to each individual 3D geometry. For example, I made 5 boxes and merged them together, but I also required each individual box to be given an unique name, like “piece0”, “piece1”, “piece2”, and so on.

Debugging with the Help of Houdini Expressions

In order to verify the naming, I needed a way to filter out the individual piece by name. This is a perfect example of using Houdini Expressions and when combined with a blast node, it is incredibly easy to do a visual verification.

Filter Geometry by Attribute name Value using blast node

Filter Geometry by Attribute name Value using blast node

@name=piece0
Destruction Glue Constraints___Spreadsheet attribute name.jpg

This one liner code goes into the parameter of the blast node and will filter out the data in the spreadsheet looking for a matching value of “piece0" under the name attribute.

 

Access to Attributes in Houdini Expressions

When you need to access values in a particular attribute in the spreadsheet in Houdini, you can use the @ symbol, followed by the attribute name, which in this case is “@name”.

Houdini Expression Combined with Blast Node

The native functionality of the blast node is to delete things. The blast node can delete groups, point numbers or primitive numbers. By inputting this one liner Houdini Expression into the blast node’s parameter field, it ends up deleting everything BUT “piece0”. And in the 3D viewport, all you see is “piece0” that is being filtered. To verify other geometries, you can change the expression to:

@name=piece1

Or if you want to check out other geometry pieces:

@name=piece2