faxingberlin Posted January 12, 2017 Share Posted January 12, 2017 (edited) Hi, there. I have some HDAs that use an external python module. I'd like to package the module into the HDAs so that external files are not necessary to use them. Currently I am embedding the python module using the “Custom Script” event handler, and I want to read file from “Extra Files” Tab. I want to write & read files from HDA's Extra Files Tab. Because I don't want to write & read files from External Directory. If I changed computer, I should move not only HDA asset but related External Files. I want to embed all files related to HDA. The Extra File is just txt file or json file. I already ask same question to sidefx forum. But, I receive some useful tips. I try HDADefinition Module but I cannot find to write in HDA. I spend about two weeks.. otl OTL Is there any way to write in the HDA's Extra Files? Link I asked same question Edited January 12, 2017 by faxingberlin Quote Link to comment Share on other sites More sharing options...
f1480187 Posted January 13, 2017 Share Posted January 13, 2017 (edited) Writing something into External Files will override HDA definition every time and it will affect all locked instances for all users. hda = kwargs['type'].definition() old_content = hou.readFile('opdef:/Sop/mytype?MyExternalFile.txt') new_content = 'There was content with length of %d.' % len(old_content) hda.addSection('MyExternalFile.txt', new_content) Using embedded Python module will not modify HDA definition. There is function for it in Houdini's toolutils module: import toolutils mymodule = toolutils.createModuleFromSection('mymodule', kwargs['type'], 'mymodule.py') Edited January 13, 2017 by f1480187 Quote Link to comment Share on other sites More sharing options...
faxingberlin Posted January 13, 2017 Author Share Posted January 13, 2017 7 hours ago, f1480187 said: Writing something into External Files will override HDA definition every time and it will affect all locked instances for all users. hda = kwargs['type'].definition() old_content = hou.readFile('opdef:/Sop/mytype?MyExternalFile.txt') new_content = 'There was content with length of %d.' % len(old_content) hda.addSection('MyExternalFile.txt', new_content) Using embedded Python module will not modify HDA definition. There is function for it in Houdini's toolutils module: import toolutils mymodule = toolutils.createModuleFromSection('mymodule', kwargs['type'], 'mymodule.py') I really appreciate of your answer, Illusionist. Thanks! I will try right now. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.