Here’s a tool to add filecache and file nodes to your selected node in SOPs geometry context. At Masonry Studios, we base our Houdini geometry caches and its version on the file name (which contains the version number) and the node name, which is the default in Houdini’s file cache node.
However avoid using the file cache’s “Load from Disk” option to load the geometry back in, because:
- It’s convenient for the file cache node’s “Geometry Path” to stay as the default un-evaluated relative path, in order to generate new caches based on the current file version
- If we load in the geometry based on this relative path, and we version up our working file, this relative path will fail.
- Hence, we find it quite an elegant solution to use a file cache and a file node separately. The file node points to the absolute evaluated “Geometry Path” of the file cache node and we’ve since successfully avoided the issue of broken links to caches.
# Author: Ronald Fong # Date: 29 Sep 2021 # Usage: Add this as a shelf tool. With a SOP node selected, use this tool to quickly create a filecache and a cache node. # Feature 1: Names the cache nodes based on your selected node # Feature 2: File node will automatically be the evaluated absolute path of your filecache node selected_node = hou.selectedNodes() geo_node = selected_node.parent() name = str(selected_node) filecache_node = geo_node.createNode("filecache", ("filecache_" + name)) file_node = geo_node.createNode("file", ("file_" + name)) file_node.setInput(0, filecache_node) filecache_node.setInput(0, selected_node) geo_node.layoutChildren() filecache_node.setDisplayFlag(1) filecache_node.setRenderFlag(1) filecache_node.setSelected(1) filename = filecache_node.parm("file").eval() file_node.parm("file").set(filename)