edward
I assume you actually meant saveIndexDataToFile() here instead. In anycase, opdef: paths not not usually writable. Your best chance is probably to hack around the sections of the hou.HDADefinition [sidefx.com] itself and then save it.
Thanks, edward.
I look around all HDADefinition methods all yesterday.
For example,
...
...
------------------------------------------------------------------------
# HDA's Help Tab
node = hou.node("../HDANAME").type().definition().embeddedHelp()
------------------------------------------------------------------------
""" HDA's ExtraFileOptions -> Cursor of Extra Files, Extra Files's Name,
IsScipt, IsPython, Extra File's Source Path
"""
node = hou.node("../HDANAME").type().definition().extraFileOptions()
------------------------------------------------------------------------
""" HDA's sections -> return dict data type
{
'EXTRA_FILE_NAME' :
<hou.HDASection EXTRA_FILE_NAME in definition of Sop HDA's Name in HDA's Installed Path>
}
"""
node = hou.node(".").type().definition().sections()
------------------------------------------------------------------------
# HDA's Name in HDA's Installed Path
node = hou.node(".").type().definition().libraryFilePath()
------------------------------------------------------------------------
# HDA's Name in HDA's User Info
node = hou.node(".").type().definition().userInfo()
------------------------------------------------------------------------
....
------------------------------------------------------------------------
....
------------------------------------------------------------------------
I look around
HDASection [
sidefx.com], too.
For example,
add SectionFromFile like other Extra Files File
class EXAMPLE():
....
def addSectionFromFile(self, hda_definition, section_name, file_name):
section_file = open(file_name, "r")
hda_definition.addSection(section_name, section_file.read())
section_file.close()
def markSectionAsTxt(self, hda_definition, section_name):
....
hda_definition.setExtraFileOption(section_name + "/IsPython", False)
hda_definition.setExtraFileOption(section_name + "/IsScript", False)
....
def ADD_MARK_SECTION(self):
hda_definition = hou.node(".").type().definition()
self.addSectionFromFile(hda_definition, "a.txt", hda_definition.libraryFilePath())
self.markSectionAsTxt(hda_definition, "a.txt")
....
I run ADD_MARK_SECTION method.
The Section's Created like others. And, Extra File Option is added like others.
In Extra File's Tab “a.txt” is added!!
So, I can make Extra File's. I can see “a.txt” in Extra File's Tab.
But the content of “a.txt” said “Contains binary information”(Section Size always 487 bytes)
I don't know why.. (hou.readFile function cannot read “a.txt”)
And I think
.hda file format is
Oracle HyperData File [docs.oracle.com].(If not, let me know)
I open the
.hda by Oracle's HDA. But HDA just contains definitions of shelves, toolbars, and tools. It should not be hand-edited when it is being used by the application. Note, that two definitions of the same element are not allowed in a single file. (<- This is message of HDA raw file) So, Editing
.hda raw file is not good way.
And,
.otl's raw file can be opened by Python's file open function. But
.hda's raw file cannot.
Next I will try : modify or add the content of “a.txt”
I look around
$HFS/toolkit/include/HOM/HOM_hda.h
/HOM_HDADefinition.h
/HOM_HDASection.h
/...
/...