Project 6 - Final Projects, Houdini Tools with Python
For my final projects in these last few weeks of VSFX-419, I am going to focus on developing some tools for Houdini, making some GUI interface with an installed Python library wxPython. My starting point for this project is from 3DBuzz, who makes a tutorial on creating a Driven Key tool with a GUI for Houdini.

The python script I developed when we were making the ice shader, was useful. Inside Houdini through a ROPoutput driver, when exporting a RibArchive of points, I have placed my code in the postrender scripts field. This automatically concats the files, strips the headers, and inserts new lines for vectors.
BEFORE RIB
AFTER RIB
This runs and prints status per rib in the python shell of Houdini, when specified in the Post Render Scripts line for the node. Here is a screenshot of said code in the postscript field, with the expression enlarged in its own window to the left.

Here is a list of what I would like to achieve from the GUI.
Name access through GUI to nodes for selected python script insertion
Filename control through GUI to directly impact python script
Frame number control
Status print
New Python updates and milestones
I am able to read in python scripts as modules in Houdini. Take a look at the following screenshot and you can see the difference in code. On the right is simple Houdini Object Code with python to create a sphere. On the left is the code importing a script which lies in the (C:/Houdini9.5.303/houdini/scripts/python) directory. This contains everything needed to create a sphere, utilizing Houdini's Object Model, and wxPython.
The code on the left simply includes the "sys" library, to utilize some basic calls to parse the module before running. This allows for editing and saving externally, without having to close Houdini to re-read the module. The last part of the code...
"stest.AppThread().start():"
is a reference to a channel within my "stest" module, which opens a new thread on the CPU for the window, so that both Houdini and my program can run simultaneously. Otherwise, you would have to minimize the window or close it, to access Houdini again.
Here is the code contained in my wxPython module, named "stest"
import wx, threading
if __name__ != "__main__":
import hou
class TestApp(wx.App):
def OnInit(self):
frame = wx.Frame(None, wx.ID_ANY, "Create Sphere")
button = wx.Button(frame, wx.ID_ANY, "Sphere")
button.Bind(wx.EVT_BUTTON, self.OnButtonClick)
frame.Show(True)
return True
def OnButtonClick(self, event):
hou.cd("/obj")
node = hou.pwd()
ball = node.createNode("geo", "ball", run_init_scripts = False)
ball.createNode("sphere")
class AppThread(threading.Thread):
def run(self):
app = TestApp(False)
app.MainLoop()
if __name__ == "__main__":
AppThread().start()
Renderman Archive node creation, with prebuilt script
My last update for this project is the ability to create a RibArchive node with a button click, which loads in a python module, containing the code I used to strip the headers and footers of the rib file automatically inserted into the post-render scripts field of the RibArchive node.
The functionality of this is if I change the python code for the concatting of the files, the code linked to the button in Houdini will automatically refresh the module. It will also create a brand new ROP node, with the updated code pre-inserted to the post-render scripts field.
With this code I can create a new node, and source whatever python module I have into the postrender parameter.
#node network #node type #parameter #.set command to insert code
hou.node('out').createNode('ribarchive').parm('postrender').set(python)
This screenshot shows my computer, with Houdini and external editor (in my case Boa Constructor, could be Cutter) open. All you have to do is click the button, and a new node is created. If you update your file paths, just click the button again and a new RibArchive node will be created with the updated code.
Ultimately, I did not make an entire GUI for doing the file names and framerange. I did however gain knowledge in Houdini Object Model and wxPython. This system would work fine for my purpose.