Jump to content

Write(Modify) Extra File in HDAs


faxingberlin

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
Link to comment
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
Link to comment
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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...