検索 - User list
Full Version: python - script to edit python module within HDA
Root » Technical Discussion » python - script to edit python module within HDA
wjm
Hiya

I'm looking to have a python script go into my HDA and insert lines of code within the Scripts -> PythonModule section. Is it possible to access this via python? To answer the "why would you even want to do this?" questions, i'm trying to automate a larger more complicated process which requires code within the HDA to be present.
I've been looking at hou.HDADefinition as well as hou.hda which came close as you're able to set callbacks but that's been the closest i've seen thus far.

Thanks
wjm
took a day and a half to find this but here's the answer for others looking


import hou

node = hou.selectedNodes()[0] #get node

nodeTypeData= node.type().definition().sections()#dict of available info from the hda sections.
pycode = node.type().definition().sections()["PythonModule"].contents() #this gets the contents on the python module

node.type().definition().addSection("PythonModule","Test string goes here")#overwrite the python module here. you can use a file read in place of the string. 
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB