Change HDAsection 'onCreate' scriptLanguage via python

   1807   2   0
User Avatar
Member
2 posts
Joined: Aug. 2021
Offline
Anybody help? I'm new to hython.
I want to write a python shelf tool, which add 'onCreate' section a python snippet to selected HDA node.
But the default scriptLanguage of 'onCreate' is HScript. And I can't find the API that relate to the 'Edit as' menu.



Here's my tool script:
____________________________________________________________________________________________________
import hou
select_node = hou.selectedNodes()

definition = select_node.type().definition()

#add 'on create' Section
definition.addSection("OnCreated", "some python snippet", hou.compressionType.NoCompression)
____________________________________________________________________________________________________
User Avatar
Member
1926 posts
Joined: Nov. 2006
Offline
You can view/modify the script language via the "extra file options": hou.HDADefinition.extraFileOptions() and hou.HDADefinition.setExtraOption(). The help for setExtraOption() has a specific example of setting a section as Python:
def markSectionAsPython(definition, section_name):
    definition.setExtraFileOption(section_name + \"/IsPython\", True)
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
2 posts
Joined: Aug. 2021
Offline
graham
The help for setExtraOption() has a specific example of setting a section as Python:
It works!Thank you very much!
  • Quick Links