Make a general python input window
The python console in Houdini is a live command line, which is great for some things, but doesn't allow you to enter multi-line code easily. Maya's script editor allows this, I wanted a similar thing in Houdini.
The python SOP looks like its the answer, but don't be fooled. Its the python equivalent of a point wrangle, its designed to process geometry, not do general node or UI fiddling (which is really what you'd want python for).
With the help of Luke Gravett, here's a way to make something akin to maya's python script editor. This is version 2 of such a thing, it's just a null with a text editor and a button to execute the code. An earlier version of this used an OTL/HDA, which was more fiddly than necessary.
- Make a null sop, name it 'my_python_code'
- parameter pane, gear menu, 'Edit Parameter Interface...':
- add a string parameter, label 'Code', enable 'multi-line string', language 'Python'
- add a button, label 'Run', python callback is
- Hit Accept
Now you can type in code, click the button, make magic.
Get point attributes from a node
From the node get its geometry, then its point attributes, then the short names of those attributes.
[ x.name() for x in hou.node('/obj/mygeo/mysop').geometry().pointAttribs() ]
To go one further and make a nice list to feed to an attribute delete node, use a join() with a single space, prepend with ^'s, and stick an asterisk on the front:
print '*',' '.join([ '^'+x.name() for x in hou.node('/obj/geo1/mysop').geometry().pointAttribs()])
* ^id ^Cd ^Alpha ^center ^orient ^P ^uniqueId ^materialId
Drag most things into the python window
Do this, and what you drag will be converted into the python text equivalent. This works for nodes, parameters, shelf buttons, most parts of the UI.
Write out mmb error text to file