FAQ FAQ      Search Search      Memberlist Memberlist      Usergroups Usergroups      Register Register      Profile Profile      Check private messages Check private messages      Log in Log in     

Structure python code of Operator type.

 
Post new topic   Reply to topic    Houdini Forum Index -> Technical Discussion
View previous topic :: View next topic  
Author Message
dulo
Houdini Adept


Joined: 10 Jun 2010
Posts: 244
Location: vienna

austria.gif
PostPosted: Thu Mar 29, 2012 8:59 am GMT    Post subject: Structure python code of Operator type. Reply with quote

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
View user's profile Send private message Visit poster's website
dulo
Houdini Adept


Joined: 10 Jun 2010
Posts: 244
Location: vienna

austria.gif
PostPosted: Mon Apr 16, 2012 6:21 am GMT    Post subject: Reply with quote

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 Shocked



StructureCode.jpg
 Description:
Structure Code
 Filesize:  252.72 KB
 Viewed:  804 Time(s)

StructureCode.jpg



_________________
www.woogieworks.at
Back to top
View user's profile Send private message Visit poster's website
graham
Houdini Guru


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

canada.gif
PostPosted: Mon Apr 16, 2012 9:22 am GMT    Post subject: Reply with quote

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.



module_from_section_test.hip
 Description:

Download
 Filename:  module_from_section_test.hip
 Filesize:  51.29 KB
 Downloaded:  85 Time(s)

Back to top
View user's profile Send private message Send e-mail Visit poster's website
dulo
Houdini Adept


Joined: 10 Jun 2010
Posts: 244
Location: vienna

austria.gif
PostPosted: Mon Apr 16, 2012 9:39 am GMT    Post subject: Reply with quote

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 Very Happy
_________________
www.woogieworks.at
Back to top
View user's profile Send private message Visit poster's website
dulo
Houdini Adept


Joined: 10 Jun 2010
Posts: 244
Location: vienna

austria.gif
PostPosted: Mon Apr 16, 2012 10:41 am GMT    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
graham
Houdini Guru


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

canada.gif
PostPosted: Mon Apr 16, 2012 11:16 am GMT    Post subject: Reply with quote

Sigh, it was supposed to be embedded. Here's it recreated. Sorry about that.


module_from_section_test_755.hip
 Description:

Download
 Filename:  module_from_section_test_755.hip
 Filesize:  55.63 KB
 Downloaded:  74 Time(s)

Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Houdini Forum Index -> Technical Discussion All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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


phpBB component v1.2.4 RC3 by Adam van Dongen. Based on phpBB © 2001, 2002 phpBB Group