Using Python to write expressions

   2523   2   1
User Avatar
Member
25 posts
Joined: 7月 2012
Offline
The main purpose for me wanting to do this is because 1: I know python already and 2: I have been hearing that Hscript is going out of date.

So I have been digging around in the help docs and through old posts on the forums and I have found some things about using hou.Points and hou.expandString.

Now I have been working on trying to get this expression to go through using Python.
Hscript version:
rand($PT*1400)*0.5 +0.5
My python version:
rand(hou.Points*1400)*0.5+0.5
I changed the expression language to python, but when I try to evaluate the expression I get the error:
Error: Unable to evaluate expression (
Traceback (most recent call last):
File “<stdin>”, line 1, in <module>
NameError: name ‘rand’ is not defined
(/obj/curve_object1/copy1/val2)).
So I get that “rand” is not evaluating correctly. Overall i'm just hoping someone can push me in the right direction on this.

Thank you.
User Avatar
Member
184 posts
Joined: 6月 2010
Offline
Hi Jason,

Check out hou.hmath - in this case you're after hou.hmath.rand()


Cheers
User Avatar
Member
25 posts
Joined: 7月 2012
Offline
Thank you, got me on the right track.
  • Quick Links