Math.RandomList as Python code

python
#1

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:

#2

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
#3

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

#4

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