Populate a table row with randoms values

Hello,
I need to populate a table row with randoms values (between 0 and 1) when I pulse with a Chop, can you help me do this ?
Thank you!

On the Facebook help group you might get a quick answer, cheers, P

Hi @stephanebissieres,

There are a few different possibilities for this.
Just creating random values and convert it to a DAT? You could use a Patter CHOP and generate new random values by driving the Seed parameter. Perhaps use a Count CHOP from the triggering pulse.

You could also use a Hold CHOP with the Timeslice parameter turned off and an animated Seed (I just used absTime.frame)

Another option would be - thinking that you are coming from a Button COMP - to use a PanelExecute DAT and copy the channel values from the Pattern CHOP to a Table DAT:


The panelExecute DAT’s onOffToOn callback would be:

def onOffToOn(panelValue):
	allVals = op('pattern1')[0].vals
	tblDAT = op('table1')
	tblDAT.clear()
	tblDAT.appendRow(allVals)
	return

Another option could be to do everything in python (I’m again assuming the pulse might come from a Button COMP):

import random
def onOffToOn(panelValue):
	allVals = [x/10000 for x in random.sample(range(10000),10)]
	tblDAT = op('table1')
	tblDAT.clear()
	tblDAT.appendRow(allVals)
	return

Hope that helps
Cheers
Markus

@priam We also try to answer quickly here! The FB Group is community run so you won’t find us there and more importantly most answers are not very searchable over there and are lost to time. We hope the community comes here more often for their answers so we can build a stronger support forum with searchable answers for everything and everyone using TouchDesigner in the future.

Since you replied so fast, join in the conversation here and offer an answer to help out! :+1:

2 Likes

Hello Markus,
Thank you very much for that detailed answer, it helped me a lot !!
Cheers,
Stéphane

Hi @ben that makes sense, that was kind of misleading from me and not really useful, I get now that you want people in here :-/, cheers, P

1 Like