Jump to content

hou.setSessionModuleSource


Johannes Saam

Recommended Posts

hou.session.start()

hey!

Can someone help with an example on how to use hou.setSessionModuleSource( source ) ? i am trying to programatically add stuff to the current session i have a .py file with a one line function

def test():

print 'test'

in it only and i am trying hou.setSessionModuleSource( 'path/to/py/file' ) and i get a syntax error in my py file.. i might not be a python god but those 2 lines seam perfect to me :)

Can anyone elaborate on how to use this module?

Thanks

Jo

Link to comment
Share on other sites

Setting the session module source is equivalent to editing it through the dialog, meaning it needs string data that contains your code, not a file path, as the argument. If you are reading from a file then you need to read it all in, then set the source.

f = open("/home/gthompson/tooldev/scripts/python/parmutils.py")
hou.setSessionModuleSource(f.read())
f.close()

Edited by graham
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...