Make a general python thing ala maya pymel thing
The python console in houdini is a live command line, which if you're used to maya's script editor, feels a bit limiting. What you want is a sketchpad to write stuff, maybe define a function, all that. This is my best attempt at that. Fiddly, but it works.
In a nutshell, create a OTL with a button to call an internal python script.
Make a digital asset
- Create a null
- Immediately subnet it
- R.click, create digital asset
- save n stuff
- select the node, cog menu, 'edit parameter interface'
- on the right hand panel, shift click on the root node to collapse it
- regular click it again to expand it, but now the subfolders are collapsed
- click each one, make invisible
- create a button, label 'doit'
- set the callback script to python mode, and the command to 'kwargs['node'].hdaModule().click()'
- r.click node, 'save operator type'
- r.click node, 'match current definition' to ensure its all clean and correct.
that odd command there calls the current node, and finds the python module inside, and calls the click function. time to set that up.
define a click function
- r.click the node, 'type properties'
- go to the scripts tab
- make a 'PythonModule' section
- add a basic click function, eg:
def click(): print 'hello world'
Once you hit apply/accept, you should now be able to click the button, and see output to the python prompt. You can now code away, after each change hit 'accept', and it'll do your bidding.
Other less fiddly ways to achieve this are via the python editor for shelf buttons, but this seemed good practice to make a button click interface hda thing.
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
Write out mmb error text to file