forked from miladrogha/ARCH7210F21
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIllustration.py
136 lines (117 loc) · 4.42 KB
/
Illustration.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import rabbit
import random
import rhinoscriptsyntax as rs
import math
r=rabbit
# test forward method
def illustration1():
r.Drawing.speed = 1
pts = r.Drawing().ptCluster()
for pt in pts:
r.Drawing.rabbit_id = pt
for j in range (10):
for i in range (10):
color = (255 * math.cos(j*9 * math.pi / 180), 255 * math.sin(j*9* math.pi / 180),255 *math.cos(j*9* math.pi / 180)* math.sin(j*9* math.pi / 180))
lineWeight = 0
lineWeight += ((i+1) * 0.01) + ((j+1) * 0.1)
r.visualization().lineWeight(lineWeight, color)
r.Drawing().forward(i+2)
r.Drawing.anglexy += i
r.Drawing.anglez += 60
rs.DeleteObjects(pt)
# illustration1()
# test forward method
def illustration2():
r.Drawing.speed = 1
pts = r.Drawing().ptCluster()
for pt in pts:
r.Drawing.rabbit_id = pt
for j in range (10):
for i in range (10):
color = (255 * math.cos(j*3 * math.pi / 180), 255 * math.sin(j*3* math.pi / 180),255 * math.sin(j*3* math.pi / 180))
lineWeight = 0
lineWeight += ((i+1) * 0.01) + ((j+1) * 0.1)
r.visualization().lineWeight(lineWeight, color)
r.Drawing().forward(i+2)
r.Drawing.anglexy += i
r.Drawing.anglez += 45
rs.DeleteObjects(pt)
# illustration2()
# test forward method
def illustration3():
r.Drawing.speed = 1
pts = r.Drawing().ptCluster()
for pt in pts:
r.Drawing.rabbit_id = pt
for j in range (10):
for i in range (20):
color = ((255), 255 * math.sin(j*9* math.pi / 180),255 * math.cos(j*9* math.pi / 180))
lineWeight = 0
lineWeight += ((i+1) * 0.01) + ((j+1) * 0.1)
r.visualization().lineWeight(lineWeight, color)
r.Drawing().forward(i+2)
r.Drawing.anglexy += i * 5
r.Drawing.anglez += 90
rs.DeleteObjects(pt)
# illustration3()
def illustration4():
points = r.Drawing().XYZgrid()
r.Drawing().irregShape(points)
illustration4()
#Test illustration, will need to modify function
def illustration6():
location = [0,0,0]
points=[]
for i in range(500):
x=random.uniform(-1,1)
y=random.uniform(-1,1)
z=random.uniform(-1,1)
point=rs.AddPoint(location[0]+x,location[1]+y,location[2]+z)
location=(location[0]+x,location[1]+y,location[2]+z)
points.append(point)
rs.AddCurve(points)
rs.AddPolyline(points)
# illustration5()
#Test illustration_2, will need to modify function
def myFunc():
curve = rs.GetObject("please select a curve",rs.filter.curve)
line = rs.GetObject("Select a mirror line")
pt = rs.GetObject("please select a point", rs.filter.point)
limitscale = rs.GetReal("please input a limit scale factor", 0.3)
angle = rs.GetReal("please input a rotate angle", 10)
len = rs.CurveLength(curve)
list = []
lenlimit=limitscale*len
while (len>lenlimit):
if len<=lenlimit: break
curve = rs.ScaleObject(curve,pt,[0.9,0.9,0.9], True)
curve = rs.RotateObject(curve,pt,angle)
len = rs.CurveLength(curve)
list.append(curve)
view = rs.CurrentView()
rs.ViewCPlane( view, rs.WorldZXPlane() )
colors = [(193, 0, 0),(5, 46, 192),(146, 75, 96)]
color = random.choice(colors)
rs.ObjectColor (curve, color=color)
r.Drawing().Mirror1(line,list)
# myFunc()
####################### Random 3D ####################
####################### Random 3D ####################
####################### Random 3D ####################
def myFunc():
intLength = rs.GetInteger("how many in x",30)
intWidth = rs.GetInteger("how many in y",30)
intGen = rs.GetInteger("how many generations",50)
strStack = rs.GetString ("should I stack the generations", "yes", ["yes", "no"])
arrValues = r.Drawing().randomizeArray01(intLength,intWidth)
arrMeshes = r.Drawing().render(arrValues,-1, strStack)
for i in range(intGen):
arrValues = r.Drawing().applyGOL(arrValues)
if strStack == "no" :
r.Drawing().update(arrMeshes, arrValues)
else :
r.Drawing().render(arrValues,i, strStack)
#myFunc()
####################### Random 3D ####################
####################### Random 3D ####################
####################### Random 3D ####################