Math.RandomList as Python code

49

Hi,
I’ve come across the problem that I can’t seem to use the Math.RandomList node in the PythonScript node. It gives me the error “global name ‘Math’ is not defined”. I have come across that problem with other nodes as well but this one I can’t figure out. I’m just trying to translate the visual programming into a Python script (if possible without importing any extra libraries).

Any advice is appreciated :slight_smile:

You need to add these import lines at the beginning of your python script:

import clr
clr.AddReference('DSCoreNodes')
from DSCore import Math
3 Likes

Thank you! That’s great, I assume there is something similar for other nodes that don’t automatically work as well then. I’ll keep an eye out for them

No problem! Yeah, most probably is because you haven´t imported it. One way to get them all is (usually not good practice because of the conflict between names in the different imported modules):

import clr
clr.AddReference('DSCoreNodes')
from DSCore import *
1 Like