Generating HDAs from Python - adding a Python Module

   1565   2   0
User Avatar
Member
6 posts
Joined: 9月 2014
Offline
Hi

I'm creating HDAs from subnets using Python. I need to add a Python Module to the hda which I can do manually on the ‘scripts’ tab of the ‘Edit Operator Type Properties’ window.

Is there any way of doing this via python, either on creation of the hda or by editing an existing hda?

Thanks in advance
User Avatar
Member
46 posts
Joined: 1月 2018
Offline
check out addSection() on
https://www.sidefx.com/docs/houdini/hom/hou/HDADefinition.html [www.sidefx.com]

and then
https://www.sidefx.com/docs/houdini/hom/hou/HDASection.html [www.sidefx.com]

You want to do something like
pm_section = node.type().definition().addSection("PythonModule")
pm_section.setContents(your_python_module_contents)
User Avatar
Member
6 posts
Joined: 9月 2014
Offline
ben.andersen
check out addSection() on
https://www.sidefx.com/docs/houdini/hom/hou/HDADefinition.html [www.sidefx.com]

and then
https://www.sidefx.com/docs/houdini/hom/hou/HDASection.html [www.sidefx.com]

You want to do something like
pm_section = node.type().definition().addSection("PythonModule")
pm_section.setContents(your_python_module_contents)


Hi Ben

That's brilliant, thank you. I've got that working now.
This is probably more of a general Python question but if I wan to add multiple lines of code in there how would I go about that.

Very new to Python!

thanks again

Llyr


******EDIT

Just worked it out with the help of a colleague by defining a function with the code in triple quotes
Edited by Llyr Williams - 2019年2月7日 10:01:23
  • Quick Links