Newbie question - I want to write Python scripts that generate various networks, using an external editor. Preferably a full-feature ide like eclipse/pydev - that has good code completion, etc.
At the moment I have been trying to setup eclipse/pydev, linking through houxmlrpc, but that is giving some problems. And code completion does not work… I have also tried using hython.exe directly in eclipse (and code completion works), but then Houdini is not visible.
Does anyone have any suggestions?
Python editor
3728 1 0-
- phtj
- Member
- 224 posts
- Joined: June 2009
- Offline
-
- phtj
- Member
- 224 posts
- Joined: June 2009
- Offline
Maybe the way to do it is to write the code with eclipse/pydev, but then run it with Houdini. This seems to work quite smoothly. On the eclipse side I set up hython.exe as the interpreter, and then import hou, so I get nice code completion. Then, for running the code, I go to Houdini, make sure that the file is on the PYTHONPATH, and then run it from there. I can use the reload function to reload the code each time it is edited in eclipse/pydev.
Of course, on the Houdini side, it would be nice to have a button. So I made a shelf button to set the python path, and to reload / import. Here is the code - I have set it up so that it is easy to change the name of the file and the path.
#==============================================
mod_path = “D:\\Documents\\eclipse_workspace_houdini\\test-houdini”
mod_name = ‘test1’
#==============================================
import sys
if mod_path not in sys.path:
sys.path.append(mod_path)
if sys.modules.has_key(mod_name):
print ‘Reloading module’
exec(“import ” + mod_name) #not sure why this is needed?
exec(“reload(” + mod_name + “)”)
else:
print ‘Importing module’
exec(“import ”+mod_name)
This seems to work fine. Are there any pitfalls I have not thought of? Or is there a better way?
One further question: can I access the label of my shelf button from the code. Then I can set my label as ‘test1’ and then automatically read this from the code to set the name of the module.
Of course, on the Houdini side, it would be nice to have a button. So I made a shelf button to set the python path, and to reload / import. Here is the code - I have set it up so that it is easy to change the name of the file and the path.
#==============================================
mod_path = “D:\\Documents\\eclipse_workspace_houdini\\test-houdini”
mod_name = ‘test1’
#==============================================
import sys
if mod_path not in sys.path:
sys.path.append(mod_path)
if sys.modules.has_key(mod_name):
print ‘Reloading module’
exec(“import ” + mod_name) #not sure why this is needed?
exec(“reload(” + mod_name + “)”)
else:
print ‘Importing module’
exec(“import ”+mod_name)
This seems to work fine. Are there any pitfalls I have not thought of? Or is there a better way?
One further question: can I access the label of my shelf button from the code. Then I can set my label as ‘test1’ and then automatically read this from the code to set the name of the module.
Patrick
-
- Quick Links
