Ok, first: Just to be clear, this seems to be a script written in the script editor, not python code in makehuman as such.
The scripts piped via the 7_scripting plugin are somewhat limited in that they are executed via an "exec" (see line 824 in 7_scripting.py). This has certain effects on scope. In particular, you cannot assume that a global variable is immediately available in a local contex without using the "global" keyword. For a longer discussion, see:
http://stackoverflow.com/questions/1250 ... ction-workExecutive summary, your code should probably be written like this instead (not tested) :
- Code: Select all
def foo():
import random
print(random.uniform(0.0, 1.0))
foo()
Or possibly
- Code: Select all
import random
def foo():
global random
print(random.uniform(0.0, 1.0))
foo()
However, the scripting plugin is mostly intended for short, simplistic things. If you want more complex program logic, you'd benefit from implementing it as a plugin instead.
As a side-note, MHAPI (see
https://github.com/makehumancommunity/c ... /README.md) is intended to replace 7_scripting in the longer run, by making it easier to write plugins. But some things from 7_scripting aren't yet implemented in MHAPI.