@m_adam thanks !
So I changed xrange to range but there's still some issues I can't seem to figure out
Here's the code I'm using
import c4d, math, random, pip._internal.utils.misc
from c4d.modules import mograph as mo
from c4d import Vector as v, utils as u, Matrix as m
from pip._internal.utils.misc import *
from math import *
TWOPI = pi*2
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 range(cnt):
index = indarr[i]
positions.append(marr[index].off)
for i in range(cnt):
marr[i].off = positions[i]
print (indarr)
md.SetArray(c4d.MODATA_MATRIX, marr, True)
return True
Nothing happens when I execute and hit play, and this is what the console says:
Traceback (most recent call last):
File "<Python>", line 29, in main
File "<Python>", line 11, in my_shuffle
File "C:\Program Files\Maxon Cinema 4D R24\resource\modules\python\libs\python39.win64.framework\lib\random.py", line 362, in shuffle
x[i], x[j] = x[j], x[i]
TypeError: 'range' object does not support item assignment
it also types "range(0, 4)" a whole bunch of times
I know it might be the easiest or most obvious thing but I really feel like I'm so ignorant when it comes to anything code.
Hopefully there's an easy fix I'm missing.
Thanks!