Skip to content

Commit 12c8efc

Browse files
committed
envelope and formdiagram from point
1 parent b99b8a4 commit 12c8efc

File tree

2 files changed

+133
-57
lines changed

2 files changed

+133
-57
lines changed

commands/TNA_envelope.py

Lines changed: 64 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,36 @@
1515
from compas_tna.envelope import PointedVaultEnvelope
1616

1717

18+
def get_location():
19+
option = rs.GetString("Location", strings=["Origin", "Coordinates", "Point"])
20+
if not option:
21+
return
22+
23+
if option == "Origin":
24+
point = (0, 0)
25+
26+
elif option == "Coordinates":
27+
x = rs.GetReal("X", 0.0, -1000.0, 1000.0)
28+
if x is None:
29+
return
30+
31+
y = rs.GetReal("Y", 0.0, -1000.0, 1000.0)
32+
if y is None:
33+
return
34+
35+
point = (x, y)
36+
37+
elif option == "Point":
38+
point = rs.GetPoint("Point")
39+
if not point:
40+
return
41+
42+
else:
43+
raise NotImplementedError
44+
45+
return point[0], point[1]
46+
47+
1848
def RunCommand():
1949
session = Session()
2050

@@ -56,18 +86,25 @@ def RunCommand():
5686
# =============================================================================
5787

5888
if option == "CrossVault":
59-
x_span = rs.GetReal("X Span", 10, 0.0, 1000)
60-
if not x_span:
89+
point = get_location()
90+
if not point:
6191
return
6292

63-
y_span = rs.GetReal("Y Span", 10, 0.0, 1000)
64-
if not y_span:
93+
x_size = rs.GetReal("X Size", 10, 0.0, 1000)
94+
if not x_size:
95+
return
96+
97+
y_size = rs.GetReal("Y Size", 10, 0.0, 1000)
98+
if not y_size:
6599
return
66100

67101
thickness = rs.GetReal("Thickness", 0.5, 0.0, 100)
68102
if not thickness:
69103
return
70104

105+
x_span = (point[0], point[0] + x_size)
106+
y_span = (point[1], point[1] + y_size)
107+
71108
envelope = CrossVaultEnvelope(
72109
x_span=x_span,
73110
y_span=y_span,
@@ -79,12 +116,16 @@ def RunCommand():
79116
# =============================================================================
80117

81118
elif option == "PointedVault":
82-
x_span = rs.GetReal("X Span", 10, 0.0, 1000)
83-
if not x_span:
119+
point = get_location()
120+
if not point:
84121
return
85122

86-
y_span = rs.GetReal("Y Span", 10, 0.0, 1000)
87-
if not y_span:
123+
x_size = rs.GetReal("X Size", 10, 0.0, 1000)
124+
if not x_size:
125+
return
126+
127+
y_size = rs.GetReal("Y Size", 10, 0.0, 1000)
128+
if not y_size:
88129
return
89130

90131
rise = rs.GetReal("Rise", 3, 0.0, 1000)
@@ -95,6 +136,9 @@ def RunCommand():
95136
if not thickness:
96137
return
97138

139+
x_span = (point[0], point[0] + x_size)
140+
y_span = (point[1], point[1] + y_size)
141+
98142
envelope = PointedVaultEnvelope(
99143
x_span=x_span,
100144
y_span=y_span,
@@ -107,12 +151,16 @@ def RunCommand():
107151
# =============================================================================
108152

109153
elif option == "PavilionVault":
110-
x_span = rs.GetReal("X Span", 10, 0.0, 1000)
111-
if not x_span:
154+
point = get_location()
155+
if not point:
112156
return
113157

114-
y_span = rs.GetReal("Y Span", 10, 0.0, 1000)
115-
if not y_span:
158+
x_size = rs.GetReal("X Size", 10, 0.0, 1000)
159+
if not x_size:
160+
return
161+
162+
y_size = rs.GetReal("Y Size", 10, 0.0, 1000)
163+
if not y_size:
116164
return
117165

118166
thickness = rs.GetReal("Thickness", 0.5, 0.0, 100)
@@ -123,6 +171,9 @@ def RunCommand():
123171
angle = angle or 0
124172
angle = angle / 180.0 * 3.14159
125173

174+
x_span = (point[0], point[0] + x_size)
175+
y_span = (point[1], point[1] + y_size)
176+
126177
envelope = PavillionVaultEnvelope(
127178
x_span=x_span,
128179
y_span=y_span,
@@ -135,7 +186,7 @@ def RunCommand():
135186
# =============================================================================
136187

137188
elif option == "Dome":
138-
center = rs.GetPoint("Center")
189+
center = get_location()
139190
if not center:
140191
return
141192

commands/TNA_formdiagram.py

Lines changed: 69 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,36 @@
2020
# This allows the diagram to be moved afterwards without having to redefine the parameters.
2121

2222

23+
def get_location():
24+
option = rs.GetString("Location", strings=["Origin", "Coordinates", "Point"])
25+
if not option:
26+
return
27+
28+
if option == "Origin":
29+
point = (0, 0)
30+
31+
elif option == "Coordinates":
32+
x = rs.GetReal("X", 0.0, -1000.0, 1000.0)
33+
if x is None:
34+
return
35+
36+
y = rs.GetReal("Y", 0.0, -1000.0, 1000.0)
37+
if y is None:
38+
return
39+
40+
point = (x, y)
41+
42+
elif option == "Point":
43+
point = rs.GetPoint("Point")
44+
if not point:
45+
return
46+
47+
else:
48+
raise NotImplementedError
49+
50+
return point[0], point[1]
51+
52+
2353
def RunCommand():
2454
session = Session()
2555

@@ -80,6 +110,10 @@ def RunCommand():
80110
# =============================================================================
81111

82112
if option == "Circular":
113+
center = get_location()
114+
if not center:
115+
return
116+
83117
radius = rs.GetReal("Radius", number=1.0, minimum=0.0)
84118
if not radius:
85119
return
@@ -97,65 +131,60 @@ def RunCommand():
97131
return
98132

99133
formdiagram = FormDiagram.create_circular_radial(
100-
center=(0, 0),
134+
center=center,
101135
radius=radius,
102136
n_hoops=rings,
103137
n_parallels=radials,
104138
r_oculus=oculus,
105139
)
106140

107-
session["params"]["formdiagram"] = "circular"
108-
session["params"]["center"] = (0, 0)
109-
session["params"]["radius"] = radius
110-
session["params"]["n_hoops"] = rings
111-
session["params"]["n_parallels"] = radials
112-
session["params"]["r_oculus"] = oculus
113-
114141
# =============================================================================
115142
# From a cross vault pattern
116143
# =============================================================================
117144

118145
elif option == "Cross":
119-
xsize = rs.GetReal("XSize", number=10, minimum=0)
120-
if not xsize:
146+
point = get_location()
147+
if not point:
148+
return
149+
150+
x_size = rs.GetReal("X Size", 10, 0.0, 1000)
151+
if not x_size:
121152
return
122-
x_span = (0, xsize)
123153

124-
ysize = rs.GetReal("YSize", number=xsize, minimum=0)
125-
if not ysize:
154+
y_size = rs.GetReal("Y Size", 10, 0.0, 1000)
155+
if not y_size:
126156
return
127-
y_span = (0, ysize)
128157

129-
n = rs.GetInteger("Resolution", 10, 2)
158+
n = rs.GetInteger("Resolution", 10, 0)
130159
if not n:
131160
return
132161

162+
x_span = (point[0], point[0] + x_size)
163+
y_span = (point[1], point[1] + y_size)
164+
133165
formdiagram = FormDiagram.create_cross(
134166
x_span=x_span,
135167
y_span=y_span,
136168
n=n,
137169
supports=None, # type: ignore
138170
)
139171

140-
session["params"]["formdiagram"] = "cross"
141-
session["params"]["x_span"] = x_span
142-
session["params"]["y_span"] = y_span
143-
session["params"]["n"] = n
144-
145172
# =============================================================================
146173
# From a fan vault pattern
147174
# =============================================================================
148175

149176
elif option == "Fan":
150-
xsize = rs.GetReal("XSize", number=10, minimum=0)
151-
if not xsize:
177+
point = get_location()
178+
if not point:
152179
return
153-
x_span = (0, xsize)
154180

155-
ysize = rs.GetReal("YSize", number=xsize, minimum=0)
156-
if not ysize:
181+
x_size = rs.GetReal("X Size", 10, 0.0, 1000)
182+
if not x_size:
183+
return
184+
185+
y_size = rs.GetReal("Y Size", 10, 0.0, 1000)
186+
if not y_size:
157187
return
158-
y_span = (0, ysize)
159188

160189
n_fans = rs.GetInteger("Number of Fans", 10, 2)
161190
if not n_fans:
@@ -165,6 +194,9 @@ def RunCommand():
165194
if not n_hoops:
166195
return
167196

197+
x_span = (point[0], point[0] + x_size)
198+
y_span = (point[1], point[1] + y_size)
199+
168200
formdiagram = FormDiagram.create_fan(
169201
x_span=x_span,
170202
y_span=y_span,
@@ -173,26 +205,22 @@ def RunCommand():
173205
supports=None, # type: ignore
174206
)
175207

176-
session["params"]["formdiagram"] = "fan"
177-
session["params"]["x_span"] = x_span
178-
session["params"]["y_span"] = y_span
179-
session["params"]["n_fans"] = n_fans
180-
session["params"]["n_hoops"] = n_hoops
181-
182208
# =============================================================================
183209
# From an orthogonal pattern
184210
# =============================================================================
185211

186212
elif option == "Ortho":
187-
xsize = rs.GetReal("XSize", number=10, minimum=0)
188-
if not xsize:
213+
point = get_location()
214+
if not point:
189215
return
190-
x_span = (0, xsize)
191216

192-
ysize = rs.GetReal("YSize", number=xsize, minimum=0)
193-
if not ysize:
217+
x_size = rs.GetReal("X Size", 10, 0.0, 1000)
218+
if not x_size:
219+
return
220+
221+
y_size = rs.GetReal("Y Size", 10, 0.0, 1000)
222+
if not y_size:
194223
return
195-
y_span = (0, ysize)
196224

197225
nx = rs.GetInteger("Number of X Faces", 10, 2)
198226
if not nx:
@@ -202,6 +230,9 @@ def RunCommand():
202230
if not ny:
203231
return
204232

233+
x_span = (point[0], point[0] + x_size)
234+
y_span = (point[1], point[1] + y_size)
235+
205236
formdiagram = FormDiagram.create_ortho(
206237
x_span=x_span,
207238
y_span=y_span,
@@ -210,12 +241,6 @@ def RunCommand():
210241
supports=None, # type: ignore
211242
)
212243

213-
session["params"]["formdiagram"] = "ortho"
214-
session["params"]["x_span"] = x_span
215-
session["params"]["y_span"] = y_span
216-
session["params"]["nx"] = nx
217-
session["params"]["ny"] = ny
218-
219244
# =============================================================================
220245
# Not supported
221246
# =============================================================================

0 commit comments

Comments
 (0)