Hi Thomas, I quite don't understand why one of the attached programs is working while the other doesn't. My stupidity or something strange with pyext? Hope you are well, thanks, Michael
try: import pyext except: print "ERROR: This script must be loaded by the PD/Max pyext external" from testclass import *
orchestra = [['x1',['a',1]],['x2',['c',11]]]
for i in orchestra: j = (i[0], i[1][0], i[1][1]) exec str(i[0])+' = Instrument'+str(j)
class Test(pyext._class): _inlets=1 _outlets=1
def float_1(self,f):
global orchestra
if f > 10:
exec str(orchestra[0][0])+'.setVal('+str(f)+')'
else:
exec str(orchestra[1][0])+'.setVal('+str(f)+')'
try: import pyext except: print "ERROR: This script must be loaded by the PD/Max pyext external" from testclass import *
orchestra1 = [['x1',['a',1]],['x2',['c',11]]] orchestra2 = [['y1',['e',2]],['y2',['g',22]]] orchestra = []
class Test(pyext._class): _inlets=1 _outlets=1
def __init__(self, *args):
global orchestra
print str(args[0])
orchestra = eval(str(args[0]))
for i in orchestra:
j = (i[0], i[1][0], i[1][1])
exec str(i[0])+' = Instrument'+str(j)
def float_1(self,f):
global orchestra
if f > 10:
exec str(orchestra[0][0])+'.setVal('+str(f)+')'
else:
exec str(orchestra[1][0])+'.setVal('+str(f)+')'
class Instrument: def __init__(self, name, q1, q2): self.name = name self.quality1 = q1 self.quality2 = q2 self.val = 999 def setVal(self, val): self.val = val print self.name, self.val return self.val
#N canvas 98 517 848 412 10; #X msg 380 35 reload orchestra1; #X msg 410 58 reload orchestra2; #X msg 579 44 9; #X msg 610 70 11; #X obj 389 117 pyext doesnt Test orchestra1; #X msg 204 61 9; #X msg 235 87 11; #X msg 107 77 reload; #X obj 107 115 pyext works Test; #X connect 0 0 4 0; #X connect 1 0 4 0; #X connect 2 0 4 1; #X connect 3 0 4 1; #X connect 5 0 8 1; #X connect 6 0 8 1; #X connect 7 0 8 0;