Jump to content
faxingberlin

Write(Modify) Extra File in HDAs

Recommended Posts

 

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 by faxingberlin

Share this post


Link to post
Share on other sites

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 by f1480187

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×