onkel_eilert Posted August 10, 2015 Share Posted August 10, 2015 Hi I'm trying to import an external python script into the source editor. I have gotten it to work before but have forgotten what I did . Any tips? Guessing it is the hou.setSessionModuleSource, but not much help from the docs. So any help would be appreciated. Thanks. Quote Link to comment Share on other sites More sharing options...
lukeiamyourfather Posted August 10, 2015 Share Posted August 10, 2015 If you want to straight up replace the contents of the hou.session module with the contents of an external file then hou.setSessionModuleSource() is the way to do it. The more likely scenario is needing to use an external Python script or library within the hou.session module which can be done by appending search paths. An example is below. import sys sys.path.append('/scripts/houdini') After doing that you'll be able to import libraries in /scripts/houdini directory, or whatever directory you choose. There's an environment variable to set this too but I'm not sure how that works with the Python environment in Houdini. Quote Link to comment Share on other sites More sharing options...
onkel_eilert Posted August 12, 2015 Author Share Posted August 12, 2015 Do you know how to use the hou.setSessionModuleSource(). Replacing the hou.session is what I looked for. I use it to sometimes set enviroment variables, and this way I don't need to add themeach time I quit and reopen Houdini Quote Link to comment Share on other sites More sharing options...
lukeiamyourfather Posted August 12, 2015 Share Posted August 12, 2015 That's not really what the hou.session module is for. If you need access to something every time you open Houdini it should be in the toolbar or in the 123.py or 456.py file. If you want to set it with hou.setSessionModuleSource() you literally put the source code you want for the argument. If that's an external file then it needs to be read in first. f = open('/home/luke/scripts/test.py', 'r') source = f.read() hou.setSessionModuleSource(source) f.close() 1 Quote Link to comment Share on other sites More sharing options...
onkel_eilert Posted August 13, 2015 Author Share Posted August 13, 2015 Thanks. Just what I was looking for. But will try to get it all into the 123.py instead. Quote Link to comment Share on other sites More sharing options...
NSDesign Posted August 16, 2015 Share Posted August 16, 2015 There is also the pythonrc.py file http://odforce.net/wiki/doku.php?id=sceneinitscripts Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.