I´ve just using Python for creating a Random Matrix, but no results.Width and Height are defined in outside in Grasshopper. Any suggestions?
#imports
import rhinoscriptsyntax as rs
import math
import random as rnd
#for accesing GH classes - JUST IN CASE
import clr
clr.AddReference("Grasshopper")
from Grasshopper.Kernel.Data import *
from Grasshopper import DataTree
#create a Matrix
def initMatrix(rndSeed):
global A0
global B0
tempVals=[]
rnd.seed(rndSeed)
for i in range (height):
thisA = [] # empty list
thisB = [] # empty list
for j in range (width):
thisA.append(rnd.random()*12+ rnd.random()*2)
thisB.append(rnd.random()*12+ rnd.random()*2)
tempVals.append(thisA)
# A0.append(thisA)
# B0.append(thisB)
return tempVals
# Call the initMatrix function
a=initMatrix(0.1)

"RESOLUTION" bar will give visible results in the lower yellow panel connected to "A".
It looks like you just have invalid indentations in your script. The comments above the
return tempValswill cause it to be interpreted outside your function. The indentation ofa=initMatrix(0.1)also looks incorrect and should not be indented. Additionally, if you are creating a multi-dimensional array, your output will not be interpretable by Grasshopper, it will read asIronPython.Runtime.List. I suggest formatting your matrix as a native grasshopper tree like the example below.