On 21/03/2017 at 07:42, xxxxxxxx wrote:
Hey, just having a look at another way of doing this without global variables. I smashed this together really quickly so needs error handling, tightening up, optimising, minimising etc:
import c4d, random
from c4d.modules import mograph as mo
from c4d import Vector as v, utils as u, Matrix as m
def my_shuffle(array) :
random.shuffle(array)
return array
def main() :
md = mo.GeGetMoData(op)
if md is None: return False
cnt = md.GetCount()
indarr = md.GetArray(c4d.MODATA_ALT_INDEX)
marr = md.GetArray(c4d.MODATA_MATRIX)
fall = md.GetFalloffs()
frame = doc.GetTime().GetFrame(doc.GetFps())
if frame == 0 or -1 in indarr : indarr = range(cnt)
if frame % 30 == 0:
my_shuffle(indarr)
md.SetArray(c4d.MODATA_ALT_INDEX, indarr, True)
positions = []
for i in xrange(cnt) :
index = indarr[i]
positions.append(marr[index].off)
for i in xrange(cnt) :
marr[i].off = positions[i]
md.SetArray(c4d.MODATA_MATRIX, marr, True)
return True
So it looks like the MODATA_ALT_INDEX array does not get reset each frame so you can use it for all kinds of stuff 
Hope this helps,
Adam