-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsplines_script.py
85 lines (54 loc) · 2.42 KB
/
splines_script.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import c4d, random
import c4d.utils
from c4d import Vector as v
""" ---------------------------- Basics --------------------------- """
basetime = doc.GetTime()
Fps = doc.GetFps()
cF = doc.GetTime() .GetFrame(doc.GetFps())
""" ---------------------------- Vars --------------------------- """
global tV
tV = [0,0,0] # Temp null vector
vX = tV[0] #Vector X
vY = tV[1] #Vector Y
vZ = tV[2] #Vector Z
rM = range(1, 100) #Range of movement
nTimes = 50 # Number of times to run the loop/generate points on splines/generate vectors
def main():
a = doc.SearchObject("Null")
if cF == 0: # only runs on frame 0
l = [] # loop iteration store list
for x in xrange(nTimes):
randindextv = random.randint(0,(len(tV)-1)) # Generates a random [i] for rM
randrM = random.randint(0,(len(rM)-1)) # a random value is returned from rM list
global X, Y, Z
X = rM[randrM] # X vector is generated
Y = rM[randrM] # Y vector is generated
Z = rM[randrM] # Z vector is generated
spline = c4d.SplineObject((nTimes),c4d.SPLINETYPE_LINEAR) # A spline with nTimes divisions is created
if randindextv == 0:
tV[0] += X # should these be globals? working in console though
tV[1] += 0
tV[2] += 0
#print x, tV
if randindextv == 1: #Y
tV[0] += 0
tV[1] += Y
tV[2] += 0
#print x, tV
if randindextv == 2:
tV[0] += 0
tV[1] += 0
tV[2] += Z
#print x, tV
l2 = [tV[0], tV[1], tV[2]]
l.append(l2)
for y in xrange(nTimes):
spline.SetPoint( y, v(l[y][0], l[y][1], l[y][2]))
spline[c4d.SPLINEOBJECT_CLOSED] = False
if op:
spline.InsertUnder(a)
else:
doc.InsertObject(spline)
random.shuffle(l)
else:
return