Newer
Older
Paul Marshall
committed
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
# Stairs and railing creator script for blender 2.49
# Author: Nick van Adium
# Date: 2010 08 09
#
# Creates a straight-run staircase with railings and stringer
# All components are optional and can be turned on and off by setting e.g. makeTreads=True or makeTreads=False
# No GUI for the script, all parameters must be defined below
# Current values assume 1 blender unit = 1 metre
#
# Stringer will rest on lower landing and hang from upper landing
# Railings start on the lowest step and end on the upper landing
#
# NOTE: You must have numpy installed for this script to work!
# numpy is used to easily perform the necessary algebra
# numpy can be found at http://www.scipy.org/Download
#
# Note: I'm not sure how to use recalcNormals so not all normals points ouwards.
# Perhaps someone else can contribute this.
#
#-----------------------------------------------------------
#
# Converted to Blender 2.5:
# - Still uses NumPy.
# - Classes are basically copy-paste from the original code
# - New Make_mesh copied from BrikBot's rock generator
# - Implemented standard add mesh GUI.
# @todo:
# - global vs. local needs cleaned up.
# - Join separate stringer objects and then clean up the mesh.
# - Put all objects into a group.
# - Generate left/right posts/railings/retainers separatly with
# option to disable just the left/right.
# - Add wall railing type as an option for left/right
# - Add different rail styles (profiles). Select with enum.
# - Should have a non-NumPy code path for cross-compatability.
# - Could be another file with equivalent classes/functions?
# Then we would just import from there instead of from
# NumPy without having to change the actual code. It
# would instead be a "try-except" block that trys to use
# NumPy.
# - Would like to add additional staircase types.
# - Spiral staircase
# - "L" staircase
# - "T" staircase
#
# Last Modified By: Paul "brikbot" Marshall
# Last Modification: November 20, 2011
Paul Marshall
committed
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
#-----------------------------------------------------------
# BEGIN NEW B2.5/Py3.2 CODE
import bpy
from add_mesh_stairs.general import General
from add_mesh_stairs.post import Posts
from add_mesh_stairs.rail import Rails
from add_mesh_stairs.retainer import Retainers
from add_mesh_stairs.stringer import Stringer
from add_mesh_stairs.tread import Treads
from bpy.props import (BoolProperty,
EnumProperty,
IntProperty,
FloatProperty)
from mathutils import Vector
global G
global typ
global typ_s
global typ_t
global rise
global run
class stairs(bpy.types.Operator):
'''Add stair objects'''
bl_idname = "mesh.stairs"
bl_label = "Add Stairs"
bl_options = {'REGISTER', 'UNDO'}
bl_description = "Add stairs"
# Stair types for enum:
id1 = ("id1", "Freestanding", "Generate a freestanding staircase.")
id2 = ("id2", "Housed-Open", "Generate a housed-open staircase.")
id3 = ("id3", "Box", "Generate a box staircase.")
id4 = ("id4", "Circular", "Generate a circular or spiral staircase.")
# Tread types for enum:
tId1 = ("tId1", "Classic", "Generate wooden style treads")
tId2 = ("tId2", "Basic Steel", "Generate common steel style treads")
tId3 = ("tId3", "Bar 1", "Generate bar/slat steel treads")
tId4 = ("tId4", "Bar 2", "Generate bar-grating steel treads")
tId5 = ("tId5", "Bar 3", "Generate bar-support steel treads")
# Stringer types for enum:
sId1 = ("sId1", "Classic", "Generate a classic style stringer")
sId2 = ("sId2", "I-Beam", "Generate a steel I-beam stringer")
sId3 = ("sId3", "C-Beam", "Generate a C-channel style stringer")
typ = EnumProperty(name = "Type",
description = "Type of staircase to generate",
items = [id1, id2, id3, id4])
rise = FloatProperty(name = "Rise",
description = "Single tread rise",
min = 0.0, max = 1024.0,
default = 0.20)
run = FloatProperty(name = "Run",
description = "Single tread run",
min = 0.0, max = 1024.0,
default = 0.30)
#for circular
rad1 = FloatProperty(name = "Inner Radius",
description = "Inner radius for circular staircase",
min = 0.0, max = 1024.0,
default = 0.2)
rad2 = FloatProperty(name = "Outer Radius",
description = "Outer radius for circular staircase",
min = 0.0001, max = 1024.0001,
default = 0.5)
deg = IntProperty(name = "Degrees",
description = "Degrees per step",
min = 5, max = 45, step = 5,
default = 20)
center = BoolProperty(name = "Center Pillar",
description = "Generate a central pillar",
default = False)
#for treads
make_treads = BoolProperty(name = "Make Treads",
description = "Enable tread generation",
default = True)
tread_w = FloatProperty(name = "Tread Width",
description = "Width of each generated tread",
min = 0.0001, max = 1024.0,
default = 1.2)
tread_h = FloatProperty(name = "Tread Height",
description = "Height of each generated tread",
min = 0.0001, max = 1024.0,
default = 0.04)
tread_t = FloatProperty(name = "Tread Toe",
description = "Toe (aka \"nosing\") of each generated tread",
min = 0.0, max = 10.0,
default = 0.03)
tread_o = FloatProperty(name = "Tread Overhang",
description = "How much tread \"overhangs\" the sides",
min = 0.0, max = 1024.0,
default = 0.025)
tread_n = IntProperty(name = "Number of Treads",
description = "How many treads to generate",
min = 1, max = 1024,
default = 10)
typ_t = EnumProperty(name = "Tread Type",
description = "Type/style of treads to generate",
items = [tId1, tId2, tId3, tId4, tId5])
tread_tk = FloatProperty(name = "Thickness",
description = "Thickness of the treads",
min = 0.0001, max = 10.0,
default = 0.02)
tread_sec = IntProperty(name = "Sections",
description = "Number of sections to use for tread",
min = 1, max = 1024,
default = 5)
tread_sp = IntProperty(name = "Spacing",
description = "Total spacing between tread sections as a percentage of total tread width",
min = 0, max = 80,
default = 5)
tread_sn = IntProperty(name = "Crosses",
description = "Number of cross section supports",
min = 2, max = 1024,
default = 4)
#for posts
make_posts = BoolProperty(name = "Make Posts",
description = "Enable post generation",
default = True)
post_d = FloatProperty(name = "Post Depth",
description = "Depth of generated posts",
min = 0.0001, max = 10.0,
default = 0.04)
post_w = FloatProperty(name = "Post Width",
description = "Width of generated posts",
min = 0.0001, max = 10.0,
default = 0.04)
post_n = IntProperty(name = "Number of Posts",
description = "Number of posts to generated",
min = 1, max = 1024,
default = 5)
#for railings
make_railings = BoolProperty(name = "Make Railings",
description = "Generate railings",
default = True)
rail_w = FloatProperty(name = "Railings Width",
description = "Width of railings to generate",
min = 0.0001, max = 10.0,
default = 0.12)
rail_t = FloatProperty(name = "Railings Thickness",
description = "Thickness of railings to generate",
min = 0.0001, max = 10.0,
default = 0.03)
rail_h = FloatProperty(name = "Railings Height",
description = "Height of railings to generate",
min = 0.0001, max = 10.0,
default = 0.90)
#for retainers
make_retainers = BoolProperty(name = "Make Retainers",
description = "Generate retainers",
default = True)
ret_w = FloatProperty(name = "Retainer Width",
description = "Width of generated retainers",
min = 0.0001, max = 10.0,
default = 0.01)
ret_h = FloatProperty(name = "Retainer Height",
description = "Height of generated retainers",
min = 0.0001, max = 10.0,
default = 0.01)
ret_n = IntProperty(name = "Number of Retainers",
description = "Number of retainers to generated",
min = 1, max = 1024,
default = 3)
#for stringer
make_stringer = BoolProperty(name = "Make Stringer",
description = "Generate stair stringer",
default = True)
typ_s = EnumProperty(name = "Stringer Type",
description = "Type/style of stringer to generate",
items = [sId1, sId2, sId3])
string_n = IntProperty(name = "Number of Stringers",
description = "Number of stringers to generate",
min = 1, max = 10,
default = 1)
string_dis = BoolProperty(name = "Distributed",
description = "Use distributed stringers",
default = False)
Paul Marshall
committed
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
string_w = FloatProperty(name = "Stringer width",
description = "Width of stringer as a percentage of tread width",
min = 0.0001, max = 100.0,
default = 15.0)
string_h = FloatProperty(name = "Stringer Height",
description = "Height of the stringer",
min = 0.0001, max = 100.0,
default = 0.3)
string_tw = FloatProperty(name = "Web Thickness",
description = "Thickness of the beam's web as a percentage of width",
min = 0.0001, max = 100.0,
default = 25.0)
string_tf = FloatProperty(name = "Flange Thickness",
description = "Thickness of the flange",
min = 0.0001, max = 100.0,
default = 0.05)
string_tp = FloatProperty(name = "Flange Taper",
description = "Flange thickness taper as a percentage",
min = 0.0, max = 100.0,
default = 0.0)
string_g = BoolProperty(name = "Floating",
description = "Cut bottom of strigner to be a \"floating\" section",
default = False)
use_original = BoolProperty(name = "Use legacy method",
description = "Use the Blender 2.49 legacy method for stair generation",
default = True)
rEnable = BoolProperty(name = "Right Details",
description = "Generate right side details (posts/rails/retainers)",
default = True)
lEnable = BoolProperty(name = "Left Details",
description = "Generate left side details (posts/rails/retainers)",
default = True)
# Draw the GUI:
def draw(self, context):
layout = self.layout
box = layout.box()
box.prop(self, 'typ')
box = layout.box()
box.prop(self, 'rise')
if self.typ != "id4":
box.prop(self, 'run')
else:
box.prop(self, 'deg')
box.prop(self, 'rad1')
box.prop(self, 'rad2')
box.prop(self, 'center')
if self.typ == "id1":
box.prop(self, 'use_original')
if not self.use_original:
box.prop(self, 'rEnable')
box.prop(self, 'lEnable')
else:
self.use_original = False
Paul Marshall
committed
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
354
355
box.prop(self, 'rEnable')
box.prop(self, 'lEnable')
# Treads
box = layout.box()
box.prop(self, 'make_treads')
if self.make_treads:
if not self.use_original:
box.prop(self, 'typ_t')
else:
self.typ_t = "tId1"
box.prop(self, 'tread_w')
box.prop(self, 'tread_h')
box.prop(self, 'tread_t')
if self.typ != "id2":
box.prop(self, 'tread_o')
else:
self.tread_o = 0.0
box.prop(self, 'tread_n')
if self.typ_t != "tId1":
box.prop(self, 'tread_tk')
box.prop(self, 'tread_sec')
if self.tread_sec > 1 and self.typ_t not in ["tId3", "tId4"]:
box.prop(self, 'tread_sp')
if self.typ_t in ["tId3", "tId4", "tId5"]:
box.prop(self, 'tread_sn')
# Posts
box = layout.box()
box.prop(self, 'make_posts')
if self.make_posts:
box.prop(self, 'post_d')
box.prop(self, 'post_w')
box.prop(self, 'post_n')
# Railings
box = layout.box()
box.prop(self, 'make_railings')
if self.make_railings:
box.prop(self, 'rail_w')
box.prop(self, 'rail_t')
box.prop(self, 'rail_h')
# Retainers
box = layout.box()
box.prop(self, 'make_retainers')
if self.make_retainers:
box.prop(self, 'ret_w')
box.prop(self, 'ret_h')
box.prop(self, 'ret_n')
# Stringers
box = layout.box()
if self.typ != "id2":
box.prop(self, 'make_stringer')
else:
self.make_stringer = True
if self.make_stringer:
if not self.use_original:
box.prop(self, 'typ_s')
else:
self.typ_s = "sId1"
box.prop(self, 'string_w')
if self.typ == "id1":
if self.typ_s == "sId1" and not self.use_original:
box.prop(self, 'string_n')
box.prop(self, 'string_dis')
Paul Marshall
committed
elif self.typ_s in ["sId2", "sId3"]:
box.prop(self, 'string_n')
box.prop(self, 'string_dis')
Paul Marshall
committed
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
box.prop(self, 'string_h')
box.prop(self, 'string_tw')
box.prop(self, 'string_tf')
box.prop(self, 'string_tp')
box.prop(self, 'string_g')
elif self.typ == "id2":
if self.typ_s == "sId2":
box.prop(self, 'string_tw')
box.prop(self, 'string_tf')
# Tread support:
## if self.make_stringer and typ_s in ["sId2", "sId3"]:
def execute(self, context):
global G
global typ
global typ_s
global typ_t
global rise
global run
typ = self.typ
typ_s = self.typ_s
typ_t = self.typ_t
rise = self.rise
run = self.run
G=General(rise,run,self.tread_n)
if self.make_treads:
Treads(G,
typ,
typ_t,
run,
self.tread_w,
self.tread_h,
self.run,
self.rise,
self.tread_t,
self.tread_o,
self.tread_n,
self.tread_tk,
self.tread_sec,
self.tread_sp,
self.tread_sn)
if self.make_posts and (self.rEnable or self.lEnable):
Posts(G,
rise,
run,
self.post_d,
self.post_w,
self.tread_w,
self.post_n,
self.rail_h,
self.rail_t,
self.rEnable,
self.lEnable)
if self.make_railings and (self.rEnable or self.lEnable):
Rails(G,
self.rail_w,
self.rail_t,
self.rail_h,
self.tread_t,
self.post_w,
self.post_d,
self.tread_w,
self.rEnable,
self.lEnable)
if self.make_retainers and (self.rEnable or self.lEnable):
Retainers(G,
self.ret_w,
self.ret_h,
self.post_w,
self.tread_w,
self.rail_h,
self.ret_n,
self.rEnable,
self.lEnable)
if self.make_stringer:
if typ == "id1" and self.use_original:
Stringer(G,
typ,
typ_s,
rise,
run,
self.string_w,
self.string_h,
self.tread_n,
self.tread_h,
self.tread_w,
self.tread_t,
self.tread_o,
self.string_tw,
self.string_tf,
self.string_tp,
not self.string_g)
Paul Marshall
committed
elif typ == "id3":
Stringer(G,
typ,
typ_s,
rise,
run,
100,
self.string_h,
self.tread_n,
self.tread_h,
self.tread_w,
self.tread_t,
self.tread_o,
self.string_tw,
self.string_tf,
self.string_tp,
not self.string_g,
Paul Marshall
committed
else:
Stringer(G,
typ,
typ_s,
rise,
run,
self.string_w,
self.string_h,
self.tread_n,
self.tread_h,
self.tread_w,
self.tread_t,
self.tread_o,
self.string_tw,
self.string_tf,
self.string_tp,
not self.string_g,
self.string_n,
Paul Marshall
committed
self.use_original)
return {'FINISHED'}