Ah yes, the good old
Geometry node in Houdini. What would we do without it? By default, when we place down a Geometry node, our little friend creates a
File operator at the Geometry level. At first it’s cute. Sort of like when your cats knock crap off the shelves. So funny!
However, after a while it gets quite annoying. Drop a geo node, dive inside, delete File operator. Rinse and repeat. I appreciate the gesture but I can drop my own File node when I need it, thank you very much! Fortunately, in typical Houdini fashion, we are able to configure this behavior. One way we can accomplish this is by configuring operators in Houdini with
Houdini can run scripts in response to certain events. For example, when Houdini first launches, it runs the 123.cmd script to configure the environment. It can also run the 456.cmd script for when you create or open a scene file. You can also have scripts that perform an action when an object is selected in the viewport. As you can imagine, event scripts are called when creating operators. This is very useful for customizing the behavior of built-in operators.
When you create certain operators, Houdini runs a corresponding script that performs various tasks. This may include preserving compatibility with older versions of Houdini, setting up some default parameters, or in our case, creating other operators i.e File operator.
The trick to getting this to work is setting up the correct directory structure and including the appropriately named script file that corresponds to the operator we are configuring. These script files are typically written in
HScript and end with a
.cmd extension. I like to think of them as
Oh brother, do we need to know how to script? Not necessarily, but it does help. Otherwise you are going to have to test through trial and error. Which is a great way to learn by the way #protip.
Houdini already has all these operator scripts setup for its own customization. All you have to do is make a copy of the operator script in your user scripts directory.
Houdini will search through the list of directories defined in the
HOUDINI_SCRIPT_PATH environment variable. By default, it includes
$HFS/houdini/scripts (for factory-installed scripts),
$HSITE/scripts (for site-specific scripts),
$JOB/scripts (for job-specific scripts), and
$HOME/houdniversion/scripts (for each user’s scripts). If you have a modified
HOUDINI_SCRIPT_PATH environment variable, you may need to make the necessary adjustments.
We are interested in the last path, that is,
$HOME/houdniversion/scripts. Scripts in this directory will override scripts in
$HFS. This is great because you can use this feature to replace factory-installed scripts—such as 123.cmd—with your own scripts and leave the factory-installed scripts intact. If you ever want to revert, all you have to do is delete the script in your user directory.
Since we want to modify the Geometry operator, what we need to do first is check that we have a scripts folder in our Houdini preferences directory, a.k.a
HOUDINI_USER_PREF_DIR . If you don’t, you need to create it.
Next thing you want to do is navigate to
$HFS. I’m showing you OS X paths since I work on a Mac but if you’re on a PC, you will need to do some hunting around. Easiest way is to echo out the value of
$HFS or just type
hconfig in your shell to get a list of the environment variables and corresponding paths. Even easier, on OS X, open
If you go inside the scripts directory, you will see various operator directories in addition to the
123.cmd scripts I mentioned. You also have some scripts such as
pickandcenter.cmd. These are callable by the way. The exact path is:
You need to duplicate the same directory structure for the operators inside your user scripts directory. So it will be like the following:
You can grab the internal operator name by just looking at the files within the scripts directory or by using the
Operator Type Manager window.
Once you copy the
geo.cmd script file over to your user directory and place it in its properly named operator type directory (obj), it should look like this:
Now for the final part to make it all work. Open the
geo.cmd in your favorite text editor. I’m using Sublime here. I’m not going to go into the specifics of the language. I leave that up to the reader to research. All we’re going to do is delete some lines. Make sure you are working on the copy of the script. Once you open the file, you will see the following:
We are going to delete lines 10 through 16. Your file should look life the following now:
That’s it! Save your file and restart Houdini. Now if you place down a Geometry node and dive inside, the File operator is nowhere to be found. If you want the default behavior back, just remove the script. If its not working for you, make sure you have the directory structure and naming correct.
The question that may be circling in your mind right now is “Why not just save the Geometry node without the File node as a preset?” and you can certainly do that. The way presented is great if you wanted to do more advanced setups with your nodes.
Until next time Houdini friends!