Working with HDAs that contain hou package python code

   3042   2   0
User Avatar
Member
4 posts
Joined: April 2019
Offline
From watching the PDG masterclass I understand its a bad idea to use hou module python code as its not thread-safe

However where does this restriction apply exactly, is it just for writing python processors etc in PDG, or is python in HDAs, python sops etc going to cause problems?


In a specific case I have a custom FBX import HDA that imports FBX files using the hou.hipFile module, creates materials on the fly (in an editable material network inside the HDA), and generally creates and deletes a lot of nodes during processing. Each HDA instance is only really meant to import 1 fbx file/hda, as it requires an actual file>import to generate materials, so until now ive written scripts to run this over a folder of files and generate an HDA per fbx file.


Is there any way to get this sort of setup to work with PDG? Can you physically create nodes with PDG, or is that not going to work? Will the HDA processor work with embedded python code, especially if it is trying to create/destroy geo, or is any hou module in HDAs not going to work at all?


Given that the HDA needs to physically create materials and store them in an HDA instance, I dont see how that could work the the HDA processor, but I'd really like to know what the limitations and options are here for all the above and working with hou python code in general. Thank you!
User Avatar
Member
544 posts
Joined: Sept. 2012
Offline
Hi there,

Basically the restriction is to not use hou to modify the scene. Reading should be ok, but modifying geometry or parameters is not. Also not ok is to try to create nodes with hou (PDG would run this stuff on a background thread). If you want to create nodes with hou, the right way to do it is via the command chain stuff.

These restrictions applies to the Python Script node while it is set to “run in process”, and any of the python callbacks you implement (such as Python processor node's onGenerate, onRegenerate etc. callbacks). It does NOT apply to any SOP node, or any HDA you create. You could do whatever you want with hou in those places.
- Ken Xu
User Avatar
Member
4 posts
Joined: April 2019
Offline
Hey Ken thanks so much for the info, the houdini command chain workflow is exactly what I was looking for, tested and works like a charm
  • Quick Links