Hello,
There are a lot of ways to do it.
1)I have created another version for you. You can look at the attached file.
I think that these pages from the documentation will be useful for you:
http://www.sidefx.com/docs/houdini11.0/hom/assetscripts [
sidefx.com] (
This method is described at the end of that page!)
http://www.sidefx.com/docs/houdini11.0/ref/windows/optype [
sidefx.com]
2)Also, you can use a simple script for adding your contents from a file into the section called “PythonModule”:
import hou
def addSectionFromFile(hda_definition, section_name, file_name):
sections = definition.sections()
if sections.has_key(section_name):
# Save contents
contents = section.contents()
# Read the new contents
section_file = open(file_name, “r”)
# Add contents
data = ‘%s\n\n’%contents
data += section_file.read()
hda_definition.addSection(section_name, data)
section_file.close()
file_name = ‘%s/myModule.py’%hou.expandString('$HIP')
nodes = hou.selectedNodes()
for node in nodes:
definition = node.type().definition()
#
if node.type().definition() is None or node.isLocked():
continue
#
addSectionFromFile(definition, ‘PythonModule’, file_name)
3)Of course, if you would like to have your script as an external file then you should put it into “$HOUDINI_PATH/python<version>libs”. Then you can call it from “callback script”, for example:
import myModule;myModule.applyButton()