| View previous topic :: View next topic |
| Author |
Message |
dulo Houdini Adept

Joined: 10 Jun 2010 Posts: 244 Location: vienna

|
Posted: Thu Mar 29, 2012 8:59 am GMT Post subject: Structure python code of Operator type. |
|
|
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.
_________________ www.woogieworks.at |
|
| Back to top |
|
 |
dulo Houdini Adept

Joined: 10 Jun 2010 Posts: 244 Location: vienna

|
|
| Back to top |
|
 |
graham Houdini Guru

Joined: 29 Nov 2006 Posts: 1135 Location: Santa Monica, CA

|
Posted: Mon Apr 16, 2012 9:22 am GMT Post subject: |
|
|
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.
| Description: |
|
 Download |
| Filename: |
module_from_section_test.hip |
| Filesize: |
51.29 KB |
| Downloaded: |
84 Time(s) |
|
|
| Back to top |
|
 |
dulo Houdini Adept

Joined: 10 Jun 2010 Posts: 244 Location: vienna

|
Posted: Mon Apr 16, 2012 9:39 am GMT Post subject: |
|
|
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
_________________ www.woogieworks.at |
|
| Back to top |
|
 |
dulo Houdini Adept

Joined: 10 Jun 2010 Posts: 244 Location: vienna

|
Posted: Mon Apr 16, 2012 10:41 am GMT Post subject: |
|
|
| graham wrote: | 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
_________________ www.woogieworks.at |
|
| Back to top |
|
 |
graham Houdini Guru

Joined: 29 Nov 2006 Posts: 1135 Location: Santa Monica, CA

|
Posted: Mon Apr 16, 2012 11:16 am GMT Post subject: |
|
|
Sigh, it was supposed to be embedded. Here's it recreated. Sorry about that.
| Description: |
|
 Download |
| Filename: |
module_from_section_test_755.hip |
| Filesize: |
55.63 KB |
| Downloaded: |
74 Time(s) |
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|
|