Jump to content

hou.setSessionModuleSource from variable


underscoreus

Recommended Posts

Hey guys,

I am trying to store some variables into the session source so I can easily get at it at any time. So far the tests I've been running have been working great, but I am not quiet sure how I can expand on the syntax to allow for variables to control the values set into the source.

This is the syntax I've used so far:

hou.setSessionModuleSource("variablename = 0")

However, as far as I've been able to figure out this will only allow for hard coded values, I am looking to insert the value from a variable instead of a hard coded value, like this:

mynum = 3

hou.setSessionModuleSource("variablename = mynum")

When I try this in the python shell I get the error back that "name 'mynum' is not defined" (along with some more text, most notably of which I guess is that it says the operation failed).

 

Do you guys have any tips on how I could make this work?

Sorry if this is very basic, I've been trying to look around for specific syntax examples but I am having kinda a hard time finding examples of actual syntax for the Houdini specific python commands.

 

Thanks for the read!

Link to comment
Share on other sites

And having slept on it I just found a solution to my own problem. I don't know if its the most elegant solution, feel free to add other solutions if you guys have any because mine feels like a cheat.
 

myvarname = 'variablename'

mynum = 3

mystring = myvarname + ' = ' + str(mynum)

hou.setSessionModuleSource(mystring)

Essentially boils down to just creating the entire string before passing it into the setModuleSource command.

Thanks for the read!

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...