dulo
March 29, 2012 09:59:28
I created a new operator type. Then i wrote my python code in the “Code” Tab.
Now i would like to split the big code file into several modules.
I switched to the Scripts Tab and created some python modules.
How can I “import” or access those modules from the “Code” Tab ?
All my experiments with createModuleFromSection and hdaModule failed.
Even if it would work how can I import definitions like “Red, Green, Blue, Alpha = range (4)” which serve me as enums but which are not encapsuled in methods ( I guess hdaModule would not work in this case .. )
I really missed some examples on this topic in the hou docs. Maybe I didnt find them or I didnt understand them, but I really hope someone can point me in the right direction.
dulo
April 16, 2012 07:21:20
To make my Question a little bit clearer I added a little Screenshot to show what I want to achive.
How could I reference Methods defined in the extra files Tab from the Code Tab ?
Or what is the way to go to give the code tab more structure ??
I think it would be a little awkward to code all the logic of an otl in one big page/file ..
Excuse the shaky red arrow .. I had too much coffee in the morning :shock:
graham
April 16, 2012 10:22:45
This all works fine for me. See the attached file:
Along with a normal PythonModule I've created 2 additional Python sections OtherModule and TestModule. Then in the PythonModule I use toolutils.createModuleFromSection to create modules from these sections and then call them from the Code tab.
I'm not sure what you're going with for your enumerated like values but I added that line of code in the PythonModule and those are now accessible without having to call a function per se, other than accessing the PythonModule.
dulo
April 16, 2012 10:39:38
Thanks. Thats what I was looking for. Those enumerations where a try to get some used to structures from c/c++ to python. I still have to get used to the pythonic way
dulo
April 16, 2012 11:41:14
graham
This all works fine for me. See the attached file:
Along with a normal PythonModule I've created 2 additional Python sections OtherModule and TestModule. Then in the PythonModule I use toolutils.createModuleFromSection to create modules from these sections and then call them from the Code tab.
I'm not sure what you're going with for your enumerated like values but I added that line of code in the PythonModule and those are now accessible without having to call a function per se, other than accessing the PythonModule.
I think you forgot to attach your python files to your .hip file. This would be my next step to place the python code files outside of the asset for better version control with svn ..
thanks for your effort
graham
April 16, 2012 12:16:20
Sigh, it was supposed to be embedded. Here's it recreated. Sorry about that.