I'm just starting to learn python, so I'm sure that this is quite the newbie question.
What magic combination of switches and settings do I need to set so that I can put a python expression in a parameter field and have it evaluate?
I know that I can put `pythonexprs(“hou.blah.blah()”)` in an expression, but that seems like it's more work than it's worth. I can't seem to put `hou.blah.blah()` in and have it work.
And yes, I know that hou.blah.blah() is not a real python function. :roll:
Dave
python expressions in parameters
5981 8 1- davedjohnson
- Member
- 221 posts
- Joined: July 2005
- Offline
- Gerome
- Member
- 85 posts
- Joined: July 2005
- Offline
- kuba
- Member
- 345 posts
- Joined:
- Offline
Hi Dave,
You need to import hou module first.
Here is a quick example what you can do with it…
http://forums.odforce.net/index.php?showtopic=7103&hl= [forums.odforce.net]
hope it helps.
kuba
You need to import hou module first.
Here is a quick example what you can do with it…
http://forums.odforce.net/index.php?showtopic=7103&hl= [forums.odforce.net]
hope it helps.
kuba
- graham
- Member
- 1909 posts
- Joined: Nov. 2006
- Offline
When using Python in parameters, really the only thing required is that the node or parameter have it's language set to Python. You actually don't need to import hou. Parameters automatically do a ‘from hou import *’ This is why you can do a ‘ch()’ in them while set to python and it works alright. The only slightly tricky thing is python in a string parameter.
Graham Thompson, Technical Artist @ Rockstar Games
- davedjohnson
- Member
- 221 posts
- Joined: July 2005
- Offline
- edward
- Member
- 7750 posts
- Joined: July 2005
- Offline
- davedjohnson
- Member
- 221 posts
- Joined: July 2005
- Offline
Ok, so here's what I've tried:
In a mantra ROP, right click on the vm_picture parameter and set a keyframe.
Then I right clicked on the parameter and changed the language to Python. (which you can't do until you set a keyframe).
Then I replaced the expression (ip) with hou.pwd().name()
Then if I MMB on the name of the parameter, it puts a dashed line around it, but doesn't evaluate the python expression, it just shows my expression with a dashed line around it.
Do I need to put it in backticks or something, like in hscript?
Dave
In a mantra ROP, right click on the vm_picture parameter and set a keyframe.
Then I right clicked on the parameter and changed the language to Python. (which you can't do until you set a keyframe).
Then I replaced the expression (ip) with hou.pwd().name()
Then if I MMB on the name of the parameter, it puts a dashed line around it, but doesn't evaluate the python expression, it just shows my expression with a dashed line around it.
Do I need to put it in backticks or something, like in hscript?
Dave
- edward
- Member
- 7750 posts
- Joined: July 2005
- Offline
- davedjohnson
- Member
- 221 posts
- Joined: July 2005
- Offline
-
- Quick Links