-
Notifications
You must be signed in to change notification settings - Fork 338
/
Copy pathSteel.rvb
353 lines (261 loc) · 9.98 KB
/
Steel.rvb
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Steel.rvb -- September 2008
' If this code works, it was written by Dale Fugier.
' If not, I don't know who wrote it.
' Works with Rhino 4.0.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Draws Steel Wide Flanges
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub SteelWideFlange
Dim cmdname, configfile, section
Dim filename, entries, entry, value, data, bname
Dim ip, d, b, tf, tw, c
Dim p0, p1, p2, p3
Dim e0, e1, e2, e3, a0
cmdname = "Steel Wide Flange"
configfile = "STEEL.INI"
section = "STEEL_WIDE_FLANGE"
filename = Rhino.FindFile(configfile)
If IsNull(filename) Then
Call MsgBox("Unable to locate " & configfile & ".", 17, cmdname)
Exit Sub
End If
entries = Rhino.GetSettings(filename, section)
If IsNull(entries) Then Exit Sub
entry = Rhino.ListBox(entries, "Select a wide flange", cmdname)
If IsNull(entry) Then Exit Sub
bname = Replace(entry, ".", "_")
If Rhino.IsBlock(bname) = False Then
value = Rhino.GetSettings(filename, section, entry)
If IsNull(value) Then Exit Sub
data = Rhino.Strtok(value, ", ;")
If IsNull(data) Or (UBound(data) <> 3) Then Exit Sub
' Hide the dirty work
Call Rhino.EnableRedraw(False)
ip = Array(0,0,0)
d = CDbl(data(0))
b = CDbl(data(1))
tf = CDbl(data(2))
tw = CDbl(data(3))
' Top
p0 = Rhino.Polar(Rhino.Polar(ip, 0, b/2), 270, tf)
p1 = Rhino.Polar(ip, 0, b/2)
p2 = Rhino.Polar(ip, 180, b/2)
p3 = Rhino.Polar(p0, 180, b)
e0 = Rhino.AddPolyline(Array(p0, p1, p2, p3))
' Bottom
c = Rhino.Polar(ip, 270, d/2)
e1 = Rhino.MirrorObject(e0, c, Rhino.Polar(c, 0, 1), True)
' Right side
p1 = Rhino.Polar(p0, 180, (b-tw)/2)
p2 = Rhino.Polar(p1, 270, (d-(tf*2)))
p3 = Rhino.Polar(p2, 0, (b-tw)/2)
e2 = Rhino.AddPolyline(Array(p0, p1, p2, p3))
Call Rhino.Command("_-FilletCorners _SelID " & e2 & " _Enter " & CStr(0.9*tf), 0)
' Left side
e3 = Rhino.MirrorObject(e2, c, ip, True)
' Join
a0 = Rhino.JoinCurves(Array(e0, e1, e2, e3), True)
' Create the block
Call Rhino.SelectObjects(a0)
Call Rhino.Command("_-Block 0 " & Chr(34) & bname & Chr(34) & " _Enter _Enter _Enter", 0)
' Delete the block inserted by the Block command
Call Rhino.DeleteObjects(Rhino.LastCreatedObjects)
' Enable redrawing
Call Rhino.EnableRedraw(True)
End If
' Insert the block
Call Rhino.Command("_-Insert " & Chr(34) & bname & Chr(34) & " _Block", 0)
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Draws Steel Channels
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub SteelChannel
Dim cmdname, configfile, section
Dim filename, entries, entry, value, data, bname
Dim ip, d, b, tf, tw, tip
Dim p0, p1, p2, p3, p4, p5
Dim e0, e1, a0
cmdname = "Steel Channel"
configfile = "STEEL.INI"
section = "STEEL_CHANNEL"
filename = Rhino.FindFile(configfile)
If IsNull(filename) Then
Call MsgBox("Unable to locate " & configfile & ".", 17, cmdname)
Exit Sub
End If
entries = Rhino.GetSettings(filename, section)
If IsNull(entries) Then Exit Sub
entry = Rhino.ListBox(entries, "Select a channel", cmdname)
If IsNull(entry) Then Exit Sub
bname = Replace(entry, ".", "_")
If Rhino.IsBlock(bname) = False Then
value = Rhino.GetSettings(filename, section, entry)
If IsNull(value) Then Exit Sub
data = Rhino.Strtok(value, ", ;")
If IsNull(data) Or (UBound(data) <> 3) Then Exit Sub
' Hide the dirty work
Call Rhino.EnableRedraw(False)
ip = Array(0,0,0)
d = CDbl(data(0))
b = CDbl(data(1))
tf = CDbl(data(2))
tw = CDbl(data(3))
tip = tf * 0.7
' Top
p0 = Rhino.Polar(Rhino.Polar(ip, 90, d/2), 0, b)
p1 = Rhino.Polar(ip, 90, d/2)
p2 = Rhino.Polar(ip, 270, d/2)
p3 = Rhino.Polar(p0, 270, d)
e0 = Rhino.AddPolyline(Array(p0, p1, p2, p3))
' Right
p1 = Rhino.Polar(p0, 270, tip)
p2 = Rhino.Polar(Rhino.Polar(p0, 180, b-tw), 270, tf)
p3 = Rhino.Polar(p2, 270, d-(tf*2))
p4 = Rhino.Polar(Rhino.Polar(p0, 270, d), 90, tip)
p5 = Rhino.Polar(p0, 270, d)
e1 = Rhino.AddPolyline(Array(p0, p1, p2, p3, p4, p5))
Call Rhino.Command("_-FilletCorners _SelID " & e1 & " _Enter " & CStr(0.9*tip), 0)
' Join
a0 = Rhino.JoinCurves(Array(e0, e1), True)
' Create the block
Call Rhino.SelectObjects(a0)
Call Rhino.Command("_-Block 0 " & Chr(34) & bname & Chr(34) & " _Enter _Enter _Enter", 0)
' Delete the block inserted by the Block command
Call Rhino.DeleteObjects(Rhino.LastCreatedObjects)
' Enable redrawing
Call Rhino.EnableRedraw(True)
End If
' Insert the block
Call Rhino.Command("_-Insert " & Chr(34) & bname & Chr(34) & " _Block", 0 )
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Draws Steel Angles
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub SteelAngle
Dim cmdname, configfile, section, tsection
Dim filename, entries, entry, value, data, bname
Dim tentries, tentry, tvalue
Dim ip, xl, yl, thk
Dim p0, p1, p2, p3, p4
Dim e0, e1, a0
cmdname = "Steel Angle"
configfile = "STEEL.INI"
section = "STEEL_ANGLE"
tsection = "STEEL_ANGLE_THICKNESS"
filename = Rhino.FindFile(configfile)
If IsNull(filename) Then
Call MsgBox("Unable to locate " & configfile & ".", 17, cmdname)
Exit Sub
End If
entries = Rhino.GetSettings(filename, section)
If IsNull(entries) Then Exit Sub
entry = Rhino.ListBox(entries, "Select an angle", cmdname)
If IsNull(entry) Then Exit Sub
tentries = Rhino.GetSettings(filename, tsection)
If IsNull(tentries) Then Exit Sub
tentry = Rhino.ListBox(tentries, "Select an angle thickness", cmdname)
If IsNull(tentry) Then Exit Sub
tvalue = Rhino.GetSettings(filename, tsection, tentry)
If IsNull(value) Then Exit Sub
bname = Replace(entry, ".", "_") & Replace(tvalue, ".", "_")
If Rhino.IsBlock(bname) = False Then
value = Rhino.GetSettings(filename, section, entry)
If IsNull(value) Then Exit Sub
data = Rhino.Strtok(value, ", ;")
If IsNull(data) Or (UBound(data) <> 1) Then Exit Sub
' Hide the dirty work
Call Rhino.EnableRedraw(False)
ip = Array(0,0,0)
xl = CDbl(data(0))
yl = CDbl(data(1))
thk = CDbl(tvalue)
' Top
p0 = Rhino.Polar(ip, 90, yl)
p1 = Rhino.Polar(ip, 0, xl)
e0 = Rhino.AddPolyline(Array(ip, p0, ip, p1))
' Right
p1 = Rhino.Polar(p0, 0, thk)
p2 = Rhino.Polar(p1, 270, yl - thk)
p3 = Rhino.Polar(p2, 0, xl - thk)
p4 = Rhino.Polar(p3, 270, thk)
e1 = Rhino.AddPolyline(Array(p0, p1, p2, p3, p4))
Call Rhino.Command("_-FilletCorners _SelID " & e1 & " _Enter " & CStr(0.9*thk), 0 )
' Join
a0 = Rhino.JoinCurves(Array(e0, e1), True)
' Create the block
Call Rhino.SelectObjects(a0)
Call Rhino.Command("_-Block 0 " & Chr(34) & bname & Chr(34) & " _Enter _Enter _Enter", 0)
' Delete the block inserted by the Block command
Call Rhino.DeleteObjects(Rhino.LastCreatedObjects)
' Enable redrawing
Call Rhino.EnableRedraw(True)
End If
' Insert the block
Call Rhino.Command("_-Insert " & Chr(34) & bname & Chr(34) & " _Block", 0 )
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Draws Steel T-Sections
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub SteelTSection
Dim cmdname, configfile, section
Dim filename, entries, entry, value, data, bname
Dim ip, d, b, tf, tw, tip
Dim p0, p1, p2, p3, p4, p5
Dim e0, e1, e2, e3, a0
cmdname = "Steel T-Sections"
configfile = "STEEL.INI"
section = "STEEL_TSECTION"
filename = Rhino.FindFile(configfile)
If IsNull(filename) Then
Call MsgBox("Unable to locate " & configfile & ".", 17, cmdname)
Exit Sub
End If
entries = Rhino.GetSettings(filename, section)
If IsNull(entries) Then Exit Sub
entry = Rhino.ListBox(entries, "Select a channel", cmdname)
If IsNull(entry) Then Exit Sub
bname = Replace(entry, ".", "_")
If Rhino.IsBlock(bname) = False Then
value = Rhino.GetSettings(filename, section, entry)
If IsNull(value) Then Exit Sub
data = Rhino.Strtok(value, ", ;")
If IsNull(data) Or (UBound(data) <> 3) Then Exit Sub
' Hide the dirty work
Call Rhino.EnableRedraw(False)
ip = Array(0,0,0)
d = CDbl(data(0))
b = CDbl(data(1))
tf = CDbl(data(2))
tw = CDbl(data(3))
' Top
p0 = Rhino.Polar(Rhino.Polar(ip, 0, b/2), 270, tf)
p1 = Rhino.Polar(ip, 0, b/2)
p2 = Rhino.Polar(ip, 180, b/2)
p3 = Rhino.Polar(p0, 180, b)
e0 = Rhino.AddPolyline(Array(p0, p1, p2, p3))
' Right
p1 = Rhino.Polar(p0, 180, (b-tw)/2)
p2 = Rhino.Polar(p1, 270, d-tf)
p3 = Rhino.Polar(p2, 270, d-(tf*2))
e1 = Rhino.AddPolyline(Array(p0, p1, p2, p3))
Call Rhino.Command("_-FilletCorners _SelID " & e1 & " _Enter " & CStr(0.9*tf), 0)
' Mirror left
e2 = Rhino.MirrorObject(e1, ip, Rhino.Polar(ip, 270, 1), True)
' Bottom
e3 = Rhino.AddPolyline(Array(p3, Rhino.Polar(p3, 180, tw)))
' Join
a0 = Rhino.JoinCurves(Array(e0, e1, e2, e3), True)
' Create the block
Call Rhino.SelectObjects(a0)
Call Rhino.Command("_-Block 0 " & Chr(34) & bname & Chr(34) & " _Enter _Enter _Enter", 0)
' Delete the block inserted by the Block command
Call Rhino.DeleteObjects(Rhino.LastCreatedObjects)
' Enable redrawing
Call Rhino.EnableRedraw(True)
End If
' Insert the block
Call Rhino.Command("_-Insert " & Chr(34) & bname & Chr(34) & " _Block", 0 )
End Sub