Update for changes in Blender's API
[blender-addons.git] / archimesh / achm_window_maker.py
blob5095f47ef3450d4ac596410dae2a7c20b2c27d26
1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
19 # <pep8 compliant>
21 # ----------------------------------------------------------
22 # Author: Antonio Vazquez (antonioya)
24 # ----------------------------------------------------------
25 # noinspection PyUnresolvedReferences
26 import bpy
27 from math import pi, radians
28 from bpy.types import Operator, PropertyGroup, Object, Panel
29 from bpy.props import StringProperty, FloatProperty, BoolProperty, IntProperty, FloatVectorProperty, \
30 CollectionProperty, EnumProperty
31 from .achm_tools import *
34 # ------------------------------------------------------------------
35 # Define operator class to create object
36 # ------------------------------------------------------------------
37 class AchmWindows(Operator):
38 bl_idname = "mesh.archimesh_window"
39 bl_label = "Rail Windows"
40 bl_description = "Rail Windows Generator"
41 bl_category = 'Archimesh'
42 bl_options = {'REGISTER', 'UNDO'}
44 # -----------------------------------------------------
45 # Draw (create UI interface)
46 # -----------------------------------------------------
47 # noinspection PyUnusedLocal
48 def draw(self, context):
49 layout = self.layout
50 row = layout.row()
51 row.label("Use Properties panel (N) to define parms", icon='INFO')
53 # -----------------------------------------------------
54 # Execute
55 # -----------------------------------------------------
56 def execute(self, context):
57 if bpy.context.mode == "OBJECT":
58 create_object(self, context)
59 return {'FINISHED'}
60 else:
61 self.report({'WARNING'}, "Archimesh: Option only valid in Object mode")
62 return {'CANCELLED'}
65 # ------------------------------------------------------------------------------
67 # Create main object. The other objects will be children of this.
69 # ------------------------------------------------------------------------------
70 # noinspection PyUnusedLocal
71 def create_object(self, context):
72 # deselect all objects
73 for o in bpy.data.objects:
74 o.select = False
76 # we create main object and mesh
77 mainmesh = bpy.data.meshes.new("WindowFrane")
78 mainobject = bpy.data.objects.new("WindowFrame", mainmesh)
79 mainobject.location = bpy.context.scene.cursor_location
80 bpy.context.scene.objects.link(mainobject)
81 mainobject.WindowObjectGenerator.add()
83 # we shape the main object and create other objects as children
84 shape_mesh_and_create_children(mainobject, mainmesh)
86 # we select, and activate, main object
87 mainobject.select = True
88 bpy.context.scene.objects.active = mainobject
91 # ------------------------------------------------------------------------------
93 # Update main mesh and children objects
95 # ------------------------------------------------------------------------------
96 # noinspection PyUnusedLocal
97 def update_object(self, context):
98 # When we update, the active object is the main object
99 o = bpy.context.active_object
100 oldmesh = o.data
101 oldname = o.data.name
102 # Now we deselect that object to not delete it.
103 o.select = False
104 # and we create a new mesh
105 tmp_mesh = bpy.data.meshes.new("temp")
106 # deselect all objects
107 for obj in bpy.data.objects:
108 obj.select = False
110 # ---------------------------------
111 # Clear Parent objects (autohole)
112 # ---------------------------------
113 myparent = o.parent
114 ploc = myparent.location
115 if myparent is not None:
116 o.parent = None
117 o.location = ploc
118 # remove_children(parent)
119 for child in myparent.children:
120 # noinspection PyBroadException
121 try:
122 # clear child data
123 child.hide = False # must be visible to avoid bug
124 child.hide_render = False # must be visible to avoid bug
125 old = child.data
126 child.select = True
127 bpy.ops.object.delete()
128 bpy.data.meshes.remove(old)
129 except:
130 dummy = -1
132 myparent.select = True
133 bpy.ops.object.delete()
135 # -----------------------
136 # remove all children
137 # -----------------------
138 # first granchild
139 for child in o.children:
140 remove_children(child)
141 # now children of main object
142 remove_children(o)
144 # Finally we create all that again (except main object),
145 shape_mesh_and_create_children(o, tmp_mesh, True)
146 o.data = tmp_mesh
147 # Remove data (mesh of active object),
148 bpy.data.meshes.remove(oldmesh)
149 tmp_mesh.name = oldname
150 # and select, and activate, the main object
151 o.select = True
152 bpy.context.scene.objects.active = o
155 # ------------------------------------------------------------------------------
156 # Generate all objects
157 # For main, it only shapes mesh and creates modifiers (the modifier, only the first time).
158 # And, for the others, it creates object and mesh.
159 # ------------------------------------------------------------------------------
160 # noinspection PyUnusedLocal
161 def shape_mesh_and_create_children(mainobject, tmp_mesh, update=False):
162 mp = mainobject.WindowObjectGenerator[0]
163 # Create only mesh, because the object is created before
164 if mp.opentype == "1":
165 generate_rail_window(mainobject, mp, tmp_mesh)
166 else:
167 generate_leaf_window(mainobject, mp, tmp_mesh)
169 remove_doubles(mainobject)
170 set_normals(mainobject)
172 # saves OpenGL data
173 if mp.blind is True:
174 plus = mp.blind_height
175 else:
176 plus = 0
178 mp.glpoint_a = (-mp.width / 2, 0, 0)
179 mp.glpoint_b = (-mp.width / 2, 0, mp.height + plus)
180 mp.glpoint_c = (mp.width / 2, 0, mp.height + plus)
182 # Lock
183 mainobject.lock_location = (True, True, True)
184 mainobject.lock_rotation = (True, True, True)
186 # -------------------------
187 # Create empty and parent
188 # -------------------------
189 bpy.ops.object.empty_add(type='PLAIN_AXES')
190 myempty = bpy.data.objects[bpy.context.active_object.name]
191 myempty.location = mainobject.location
193 myempty.name = "Window_Group"
194 parentobject(myempty, mainobject)
195 mainobject["archimesh.hole_enable"] = True
196 # Rotate Empty
197 myempty.rotation_euler.z = radians(mp.r)
198 # Create control box to open wall holes
199 gap = 0.002
200 y = 0
201 z = 0
202 if mp.blind is True:
203 y = mp.blind_rail
204 if mp.blind is True and mp.blind_box is True:
205 z = mp.blind_height
207 myctrl = create_control_box("CTRL_Hole",
208 mp.width - gap,
209 mp.depth * 3, # + y,
210 mp.height + z - gap)
211 # Add custom property to detect Controller
212 myctrl["archimesh.ctrl_hole"] = True
214 set_normals(myctrl)
215 myctrl.parent = myempty
216 myctrl.location.x = 0
217 myctrl.location.y = -mp.depth * 3 / 2
218 myctrl.location.z = 0
219 myctrl.draw_type = 'BOUNDS'
220 myctrl.hide = False
221 myctrl.hide_render = True
222 if bpy.context.scene.render.engine == 'CYCLES':
223 myctrl.cycles_visibility.camera = False
224 myctrl.cycles_visibility.diffuse = False
225 myctrl.cycles_visibility.glossy = False
226 myctrl.cycles_visibility.transmission = False
227 myctrl.cycles_visibility.scatter = False
228 myctrl.cycles_visibility.shadow = False
230 mat = create_transparent_material("hidden_material", False)
231 set_material(myctrl, mat)
233 # deactivate others
234 for o in bpy.data.objects:
235 if o.select is True and o.name != mainobject.name:
236 o.select = False
238 return
241 # ------------------------------------------------------------------
242 # Define property group class to create or modify
243 # ------------------------------------------------------------------
244 class ObjectProperties(PropertyGroup):
245 width = FloatProperty(
246 name='Width',
247 min=0.20, max=50,
248 default=1.20, precision=3,
249 description='window width',
250 update=update_object,
252 depth = FloatProperty(
253 name='Depth',
254 min=0.07, max=1,
255 default=0.10, precision=3,
256 description='window depth',
257 update=update_object,
259 height = FloatProperty(
260 name='Height',
261 min=0.20, max=50,
262 default=1, precision=3,
263 description='window height',
264 update=update_object,
266 r = FloatProperty(
267 name='Rotation', min=0, max=360, default=0, precision=1,
268 description='Window rotation',
269 update=update_object,
272 external = BoolProperty(
273 name="External frame",
274 description="Create an external front frame",
275 default=True,
276 update=update_object,
278 frame = FloatProperty(
279 name='External Frame',
280 min=0.001, max=1,
281 default=0.01, precision=3,
282 description='External Frame size',
283 update=update_object,
286 frame_L = FloatProperty(
287 name='Frame',
288 min=0.02, max=1,
289 default=0.06, precision=3,
290 description='Frame size',
291 update=update_object,
293 wf = FloatProperty(
294 name='WinFrame',
295 min=0.001, max=1,
296 default=0.05, precision=3,
297 description='Window Frame size',
298 update=update_object,
300 leafratio = FloatProperty(
301 name='Leaf ratio',
302 min=0.001, max=0.999,
303 default=0.50,
304 precision=3,
305 description='Leaf thickness ratio',
306 update=update_object,
308 opentype = EnumProperty(
309 items=(
310 ('1', "Rail window", ""),
311 ('2', "Two leaf", ""),
312 ('3', "Right leaf", ""),
313 ('4', "Left leaf", "")),
314 name="Type",
315 description="Defines type of window",
316 update=update_object,
318 handle = BoolProperty(
319 name="Create handles",
320 description="Create default handle to the leaf",
321 default=True,
322 update=update_object,
325 sill = BoolProperty(
326 name="Sill",
327 description="Add sill to window",
328 default=True,
329 update=update_object,
331 sill_thickness = FloatProperty(
332 name='Thickness',
333 min=0, max=50,
334 default=0.01, precision=3,
335 description='Sill thickness',
336 update=update_object,
338 sill_back = FloatProperty(
339 name='Back',
340 min=0, max=10,
341 default=0.0, precision=3,
342 description='Extrusion in back side',
343 update=update_object,
345 sill_front = FloatProperty(
346 name='Front',
347 min=0, max=10,
348 default=0.12, precision=3,
349 description='Extrusion in front side',
350 update=update_object,
353 blind = BoolProperty(
354 name="Blind",
355 description="Create an external blind",
356 default=False,
357 update=update_object,
359 blind_box = BoolProperty(
360 name="Blind box", description="Create a box over frame for blind",
361 default=True,
362 update=update_object,
364 blind_height = FloatProperty(
365 name='Height',
366 min=0.001, max=10,
367 default=0.12, precision=3,
368 description='Blind box height',
369 update=update_object,
371 blind_back = FloatProperty(
372 name='Back',
373 min=0.001, max=10,
374 default=0.002, precision=3,
375 description='Extrusion in back side',
376 update=update_object,
378 blind_rail = FloatProperty(
379 name='Separation',
380 min=0.001, max=10,
381 default=0.10, precision=3,
382 description='Separation from frame',
383 update=update_object,
385 blind_ratio = IntProperty(
386 name='Extend',
387 min=0, max=100,
388 default=20,
389 description='% of extension (100 full extend)',
390 update=update_object,
393 # Materials
394 crt_mat = BoolProperty(
395 name="Create default Cycles materials",
396 description="Create default materials for Cycles render",
397 default=True,
398 update=update_object,
400 # opengl internal data
401 glpoint_a = FloatVectorProperty(
402 name="glpointa",
403 description="Hidden property for opengl",
404 default=(0, 0, 0),
406 glpoint_b = FloatVectorProperty(
407 name="glpointb",
408 description="Hidden property for opengl",
409 default=(0, 0, 0),
411 glpoint_c = FloatVectorProperty(
412 name="glpointc",
413 description="Hidden property for opengl",
414 default=(0, 0, 0),
417 # Register
418 bpy.utils.register_class(ObjectProperties)
419 Object.WindowObjectGenerator = CollectionProperty(type=ObjectProperties)
422 # ------------------------------------------------------------------
423 # Define panel class to modify object
424 # ------------------------------------------------------------------
425 class AchmWindowObjectgeneratorpanel(Panel):
426 bl_idname = "OBJECT_PT_window_generator"
427 bl_label = "Window Rail"
428 bl_space_type = 'VIEW_3D'
429 bl_region_type = 'UI'
430 bl_category = 'Archimesh'
432 # -----------------------------------------------------
433 # Verify if visible
434 # -----------------------------------------------------
435 @classmethod
436 def poll(cls, context):
437 o = context.object
438 if o is None:
439 return False
440 if 'WindowObjectGenerator' not in o:
441 return False
442 else:
443 return True
445 # -----------------------------------------------------
446 # Draw (create UI interface)
447 # -----------------------------------------------------
448 def draw(self, context):
449 o = context.object
450 # noinspection PyBroadException
451 try:
452 if 'WindowObjectGenerator' not in o:
453 return
454 except:
455 return
457 layout = self.layout
458 if bpy.context.mode == 'EDIT_MESH':
459 layout.label('Warning: Operator does not work in edit mode.', icon='ERROR')
460 else:
461 myobjdat = o.WindowObjectGenerator[0]
462 space = bpy.context.space_data
463 if not space.local_view:
464 # Imperial units warning
465 if bpy.context.scene.unit_settings.system == "IMPERIAL":
466 row = layout.row()
467 row.label("Warning: Imperial units not supported", icon='COLOR_RED')
469 box = layout.box()
470 row = box.row()
471 row.prop(myobjdat, 'opentype')
472 row = box.row()
473 row.label("Window size")
474 row = box.row()
475 row.prop(myobjdat, 'width')
476 row.prop(myobjdat, 'depth')
477 row.prop(myobjdat, 'height')
478 row = box.row()
479 row.prop(myobjdat, 'wf')
480 row = box.row()
481 row.prop(myobjdat, 'r')
483 row = box.row()
484 row.prop(myobjdat, 'external')
485 row.prop(myobjdat, 'handle')
486 if myobjdat.external:
487 row.prop(myobjdat, 'frame')
489 if myobjdat.opentype != "1":
490 row = box.row()
491 row.prop(myobjdat, 'frame_L')
492 row.prop(myobjdat, 'leafratio', slider=True)
494 box = layout.box()
495 row = box.row()
496 row.prop(myobjdat, 'sill')
497 if myobjdat.sill:
498 row = box.row()
499 row.prop(myobjdat, 'sill_thickness')
500 row.prop(myobjdat, 'sill_back')
501 row.prop(myobjdat, 'sill_front')
503 box = layout.box()
504 row = box.row()
505 row.prop(myobjdat, 'blind')
506 if myobjdat.blind:
507 row = box.row()
508 row.prop(myobjdat, 'blind_rail')
509 row.prop(myobjdat, 'blind_ratio', slider=True)
510 row = box.row()
511 row.prop(myobjdat, 'blind_box')
512 if myobjdat.blind_box:
513 row.prop(myobjdat, 'blind_height')
514 row.prop(myobjdat, 'blind_back')
516 box = layout.box()
517 if not context.scene.render.engine == 'CYCLES':
518 box.enabled = False
519 box.prop(myobjdat, 'crt_mat')
520 else:
521 row = layout.row()
522 row.label("Warning: Operator does not work in local view mode", icon='ERROR')
525 # ------------------------------------------------------------------------------
526 # Generate rail windows
527 # ------------------------------------------------------------------------------
528 def generate_rail_window(myframe, mp, mymesh):
529 myloc = bpy.context.scene.cursor_location
531 alummat = None
532 if mp.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
533 alummat = create_diffuse_material("Window_material", False, 0.8, 0.8, 0.8, 0.6, 0.6, 0.6, 0.15)
535 # Frame
536 win_size, p1, p2 = create_rail_window_frame(myframe, mymesh,
537 mp.width, mp.depth, mp.height,
538 mp.frame,
539 mp.crt_mat, alummat, mp.external,
540 mp.blind and mp.blind_box,
541 mp.blind_height,
542 mp.blind_back,
543 mp.blind_rail)
545 remove_doubles(myframe)
546 set_normals(myframe)
548 # Window L
549 width = (mp.width / 2) + 0.01
550 mywin_l = create_rail_window_leaf("Window.L", "L",
551 width, win_size, mp.height - 0.05,
552 mp.wf,
553 myloc.x, myloc.y, myloc.z,
554 mp.crt_mat, alummat, mp.handle)
556 remove_doubles(mywin_l)
557 set_normals(mywin_l)
559 mywin_l.parent = myframe
560 mywin_l.location.x = (-mp.width / 2) + 0.01
561 mywin_l.location.y = p1 - 0.001
562 mywin_l.location.z = 0.025
563 # Window R
564 mywin_r = create_rail_window_leaf("Window.R", "R",
565 width, win_size, mp.height - 0.05,
566 mp.wf,
567 myloc.x, myloc.y, myloc.z,
568 mp.crt_mat, alummat, mp.handle)
570 remove_doubles(mywin_r)
571 set_normals(mywin_r)
573 mywin_r.parent = myframe
574 mywin_r.location.x = (mp.width / 2) - 0.01
575 mywin_r.location.y = p2 - 0.001
576 mywin_r.location.z = 0.025
577 # Sill
578 if mp.sill:
579 mysill = create_sill("Windows_Sill", mp.width,
580 mp.depth + mp.sill_back + mp.sill_front,
581 mp.sill_thickness, mp.crt_mat)
582 mysill.parent = myframe
583 mysill.location.x = 0
584 mysill.location.y = -mp.depth - mp.sill_back
585 mysill.location.z = 0
587 # Blind
588 if mp.blind:
589 myblindrail = create_blind_rail("Blind_rails", mp.width, mp.height,
590 myloc.x, myloc.y, myloc.z,
591 mp.crt_mat, alummat, mp.blind_rail)
592 set_normals(myblindrail)
594 myblindrail.parent = myframe
595 myblindrail.location.x = 0
596 myblindrail.location.y = 0
597 myblindrail.location.z = 0
598 # Lock
599 myblindrail.lock_location = (True, True, True)
600 myblindrail.lock_rotation = (True, True, True)
602 myblind = create_blind("Blind", mp.width - 0.006, mp.height,
603 myloc.x, myloc.y, myloc.z,
604 mp.crt_mat, mp.blind_ratio)
605 set_normals(myblind)
607 myblind.parent = myframe
608 myblind.location.x = 0
609 myblind.location.y = mp.blind_rail - 0.014
610 myblind.location.z = mp.height - 0.098
611 # Lock
612 myblind.lock_location = (True, True, True)
613 myblind.lock_rotation = (True, True, True)
616 # ------------------------------------------------------------------------------
617 # Generate leaf windows
618 # ------------------------------------------------------------------------------
619 def generate_leaf_window(myframe, mp, mymesh):
620 myloc = bpy.context.scene.cursor_location
622 alummat = None
623 if mp.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
624 alummat = create_diffuse_material("Window_material", False, 0.8, 0.8, 0.8, 0.6, 0.6, 0.6, 0.15)
626 # Frame
627 win_size = create_leaf_window_frame(myframe, mymesh,
628 mp.width, mp.depth, mp.height,
629 mp.frame, mp.frame_L, mp.leafratio,
630 mp.crt_mat, alummat, mp.external,
631 mp.blind and mp.blind_box, mp.blind_height, mp.blind_back,
632 mp.blind_rail)
634 remove_doubles(myframe)
635 set_normals(myframe)
637 stepsize = 0.01
638 # -----------------------------
639 # Window L
640 # -----------------------------
641 if mp.opentype == "2" or mp.opentype == "4":
642 handle = mp.handle
643 if mp.opentype == "2":
644 width = ((mp.width - (mp.frame_L * 2) + stepsize) / 2) + 0.004
645 handle = False # two windows only one handle
646 else:
647 width = mp.width - (mp.frame_L * 2) + stepsize + 0.008
649 mywin_l = create_leaf_window_leaf("Window.L", "L",
650 width, win_size, mp.height - (mp.frame_L * 2) + (stepsize * 2) - 0.004,
651 mp.wf,
652 myloc.x, myloc.y, myloc.z,
653 mp.crt_mat, alummat, handle)
655 remove_doubles(mywin_l)
656 set_normals(mywin_l)
658 mywin_l.parent = myframe
659 mywin_l.location.x = -mp.width / 2 + mp.frame_L - stepsize + 0.001
660 mywin_l.location.y = -mp.depth
661 mywin_l.location.z = mp.frame_L - (stepsize / 2) - 0.003
662 # -----------------------------
663 # Window R
664 # -----------------------------
665 if mp.opentype == "2" or mp.opentype == "3":
666 if mp.opentype == "2":
667 width = ((mp.width - (mp.frame_L * 2) + stepsize) / 2) + 0.003
668 else:
669 width = mp.width - (mp.frame_L * 2) + stepsize + 0.008
671 mywin_r = create_leaf_window_leaf("Window.R", "R",
672 width, win_size, mp.height - (mp.frame_L * 2) + (stepsize * 2) - 0.004,
673 mp.wf,
674 myloc.x, myloc.y, myloc.z,
675 mp.crt_mat, alummat, mp.handle)
677 remove_doubles(mywin_r)
678 set_normals(mywin_r)
680 mywin_r.parent = myframe
681 mywin_r.location.x = mp.width / 2 - mp.frame_L + stepsize - 0.001
682 mywin_r.location.y = -mp.depth
683 mywin_r.location.z = mp.frame_L - (stepsize / 2) - 0.003
685 # Sill
686 if mp.sill:
687 mysill = create_sill("Windows_Sill", mp.width,
688 mp.depth + mp.sill_back + mp.sill_front,
689 mp.sill_thickness, mp.crt_mat)
690 mysill.parent = myframe
691 mysill.location.x = 0
692 mysill.location.y = -mp.depth - mp.sill_back
693 mysill.location.z = 0
695 # Blind
696 if mp.blind:
697 myblindrail = create_blind_rail("Blind_rails", mp.width, mp.height,
698 myloc.x, myloc.y, myloc.z,
699 mp.crt_mat, alummat, mp.blind_rail)
700 myblindrail.parent = myframe
701 myblindrail.location.x = 0
702 myblindrail.location.y = 0
703 myblindrail.location.z = 0
704 # Lock
705 myblindrail.lock_location = (True, True, True)
706 myblindrail.lock_rotation = (True, True, True)
708 myblind = create_blind("Blind", mp.width - 0.006, mp.height,
709 myloc.x, myloc.y, myloc.z,
710 mp.crt_mat, mp.blind_ratio)
711 myblind.parent = myframe
712 myblind.location.x = 0
713 myblind.location.y = mp.blind_rail - 0.014
714 myblind.location.z = mp.height - 0.098
716 # Lock
717 myblind.lock_location = (True, True, True)
718 myblind.lock_rotation = (True, True, True)
720 # deactivate others
721 for o in bpy.data.objects:
722 if o.select is True:
723 o.select = False
725 myframe.select = True
726 bpy.context.scene.objects.active = myframe
728 return myframe
731 # ------------------------------------------------------------------------------
732 # Create windows frame
734 # sX: Size in X axis
735 # sY: Size in Y axis
736 # sZ: Size in Z axis
737 # frame: size of external frame
738 # mat: Flag for creating materials
739 # matdata: Aluminum material
740 # external: create external frame flag
741 # blind: blind flag
742 # blind_height: height of blind box
743 # blind_back: front extension
744 # blind_rail: distance of the rail
745 # ------------------------------------------------------------------------------
746 def create_rail_window_frame(mywindow, mymesh, sx, sy, sz, frame, mat, matdata, external,
747 blind, blind_height, blind_back, blind_rail):
748 myvertex = []
749 myfaces = []
750 v = 0
751 # ===========================================================================
752 # Horizontal pieces
753 # ===========================================================================
754 m = 0.02 # gap in front
755 gap = 0.001 # gap between leafs
756 rail = 0.007 # rail width
757 thick = 0.002 # aluminum thickness
758 w = (sy - m - gap - thick - thick - thick) / 2 # width of each leaf
759 p = (w - rail) / 2 # space of each side
760 side = 0.02 # vertical
761 for z in (0, sz):
762 for x in (-sx / 2, sx / 2):
763 myvertex.extend([(x, 0, z), (x, 0, z + side),
764 (x, -m - p, z + side),
765 (x, -m - p, z + (side * 2)), # rail 1
766 (x, -m - p - rail, z + (side * 2)),
767 (x, -m - p - rail, z + side),
768 (x, -m - p - rail - thick - p - gap - p, z + side),
769 (x, -m - p - rail - thick - p - gap - p, z + (side * 2)), # rail 2
770 (x, -m - p - rail - thick - p - gap - p - rail, z + (side * 2)),
771 (x, -m - p - rail - thick - p - gap - p - rail, z + side),
772 (x, -m - p - rail - thick - p - gap - p - rail - p - thick, z + side)])
773 # Faces
774 myfaces.extend([(v + 12, v + 1, v + 0, v + 11), (v + 13, v + 2, v + 1, v + 12), (v + 14, v + 3, v + 2, v + 13),
775 (v + 15, v + 4, v + 3, v + 14), (v + 16, v + 5, v + 4, v + 15), (v + 17, v + 6, v + 5, v + 16),
776 (v + 18, v + 7, v + 6, v + 17), (v + 19, v + 8, v + 7, v + 18), (v + 20, v + 9, v + 8, v + 19),
777 (v + 20, v + 21, v + 10, v + 9)])
779 side *= -1 # reveser direction
780 v = len(myvertex)
781 # ===========================================================================
782 # Vertical pieces
783 # ===========================================================================
784 y = 0
785 sideb = 0.03
786 sides = 0.02
787 thickb = 0.002 # aluminum thickness
788 win_size = p + rail + p
789 p1 = y - m - thick
790 p2 = y - m - thick - gap - p - rail - p - thick
792 # Left
793 for x in (-sx / 2, sx / 2):
794 for z in (0, sz):
795 myvertex.extend([(x, y, z),
796 (x + thickb, y, z),
797 (x + thickb, y - m, z),
798 (x + thickb + sides, y - m, z),
799 (x + thickb + sides, y - m - thick, z),
800 (x + thickb, y - m - thick, z),
801 (x + thickb, y - m - thick - gap - p - rail - p, z),
802 (x + thickb + sides, y - m - thick - gap - p - rail - p, z),
803 (x + thickb + sides, y - m - thick - gap - p - rail - p - thick, z),
804 (x + thickb, y - m - thick - gap - p - rail - p - thick, z),
805 (x + thickb, y - m - thick - gap - p - rail - p - thick - p - rail - p, z),
806 (x + thickb + sideb, y - m - thick - gap - p - rail - p - thick - p - rail - p, z),
807 (x + thickb + sideb, y - m - thick - gap - p - rail - p - thick - p - rail - p - thick, z),
808 (x, y - m - thick - gap - p - rail - p - thick - p - rail - p - thick, z)])
809 # Faces
810 myfaces.extend([(v + 13, v + 27, v + 14, v + 0), (v + 13, v + 12, v + 26, v + 27),
811 (v + 11, v + 10, v + 24, v + 25),
812 (v + 6, v + 5, v + 19, v + 20), (v + 10, v + 9, v + 23, v + 24),
813 (v + 25, v + 24, v + 27, v + 26), (v + 24, v + 23, v + 15, v + 16),
814 (v + 22, v + 21, v + 20, v + 23),
815 (v + 17, v + 16, v + 19, v + 18), (v + 9, v + 8, v + 22, v + 23),
816 (v + 7, v + 6, v + 20, v + 21), (v + 3, v + 2, v + 16, v + 17),
817 (v + 5, v + 4, v + 18, v + 19),
818 (v + 4, v + 3, v + 17, v + 18), (v + 7, v + 8, v + 9, v + 6),
819 (v + 3, v + 4, v + 5, v + 2), (v + 11, v + 12, v + 13, v + 10),
820 (v + 6, v + 5, v + 9, v + 10),
821 (v + 1, v + 0, v + 14, v + 15),
822 (v + 19, v + 16, v + 15, v + 14, v + 27, v + 24, v + 23, v + 20),
823 (v + 8, v + 7, v + 21, v + 22), (v + 12, v + 11, v + 25, v + 26),
824 (v + 2, v + 1, v + 15, v + 16),
825 (v + 5, v + 6, v + 9, v + 10, v + 13, v + 0, v + 1, v + 2)])
827 v = len(myvertex)
828 # reverse
829 thickb *= -1
830 sideb *= -1
831 sides *= -1
832 # ===========================================================================
833 # Front covers
834 # ===========================================================================
835 x = sx - 0.005 - (sideb * 2) # sideB + small gap
836 y = y - m - thick - gap - p - rail - p - thick - p - rail - p
837 z = sideb
838 # Bottom
839 myvertex.extend([(-x / 2, y - thick, 0.0),
840 (-x / 2, y, 0.0),
841 (x / 2, y, 0.0),
842 (x / 2, y - thick, 0.0),
843 (-x / 2, y - thick, z),
844 (-x / 2, y, z),
845 (x / 2, y, z),
846 (x / 2, y - thick, z)])
848 myfaces.extend([(v + 0, v + 1, v + 2, v + 3), (v + 0, v + 1, v + 5, v + 4), (v + 1, v + 2, v + 6, v + 5),
849 (v + 2, v + 6, v + 7, v + 3), (v + 5, v + 6, v + 7, v + 4), (v + 0, v + 4, v + 7, v + 3)])
850 v = len(myvertex)
851 # Top
852 myvertex.extend([(-x / 2, y - thick, sz - sideb),
853 (-x / 2, y, sz - sideb),
854 (x / 2, y, sz - sideb),
855 (x / 2, y - thick, sz - sideb),
856 (-x / 2, y - thick, sz - sideb + z),
857 (-x / 2, y, sz - sideb + z),
858 (x / 2, y, sz - sideb + z),
859 (x / 2, y - thick, sz - sideb + z)])
861 myfaces.extend([(v + 0, v + 1, v + 2, v + 3), (v + 0, v + 1, v + 5, v + 4), (v + 1, v + 2, v + 6, v + 5),
862 (v + 2, v + 6, v + 7, v + 3), (v + 5, v + 6, v + 7, v + 4), (v + 0, v + 4, v + 7, v + 3)])
863 v = len(myvertex)
864 # ===========================================================================
865 # External front covers
866 # ===========================================================================
867 if external:
868 x = sx
869 gap = -0.001
870 sidem = frame
871 box = 0
872 if blind:
873 box = blind_height
875 myvertex.extend([((-x / 2) - sidem, y - thick, sz + sidem + box),
876 ((x / 2) + sidem, y - thick, sz + sidem + box),
877 ((-x / 2) - sidem, y - thick, -sidem),
878 ((x / 2) + sidem, y - thick, -sidem),
879 ((-x / 2) - gap, y - thick, sz + gap + box),
880 ((x / 2) + gap, y - thick, sz + gap + box),
881 ((-x / 2) - gap, y - thick, -gap),
882 ((x / 2) + gap, y - thick, -gap)])
883 myvertex.extend([((-x / 2) - sidem, y - thick * 2, sz + sidem + box),
884 ((x / 2) + sidem, y - thick * 2, sz + sidem + box),
885 ((-x / 2) - sidem, y - thick * 2, -sidem),
886 ((x / 2) + sidem, y - thick * 2, -sidem),
887 ((-x / 2) - gap, y - thick * 2, sz + gap + box),
888 ((x / 2) + gap, y - thick * 2, sz + gap + box),
889 ((-x / 2) - gap, y - thick * 2, -gap),
890 ((x / 2) + gap, y - thick * 2, -gap)])
892 myfaces.extend([(v + 3, v + 1, v + 9, v + 11), (v + 9, v + 8, v + 0, v + 1),
893 (v + 1, v + 5, v + 4, v + 0),
894 (v + 3, v + 7, v + 5, v + 1),
895 (v + 7, v + 3, v + 2, v + 6),
896 (v + 0, v + 4, v + 6, v + 2),
897 (v + 9, v + 13, v + 12, v + 8), (v + 11, v + 15, v + 13, v + 9),
898 (v + 15, v + 11, v + 10, v + 14),
899 (v + 8, v + 12, v + 14, v + 10),
900 (v + 11, v + 3, v + 2, v + 10),
901 (v + 2, v + 10, v + 8, v + 0), (v + 14, v + 12, v + 4, v + 6),
902 (v + 7, v + 6, v + 14, v + 15),
903 (v + 5, v + 13, v + 12, v + 4),
904 (v + 15, v + 7, v + 5, v + 13)])
906 mymesh.from_pydata(myvertex, [], myfaces)
907 mymesh.update(calc_edges=True)
909 if mat and bpy.context.scene.render.engine == 'CYCLES':
910 set_material(mywindow, matdata)
911 # --------------
912 # Blind Box
913 # --------------
914 if blind:
915 mybox = create_blind_box("Blind_box", sx, sy + blind_back + blind_rail, blind_height)
916 set_normals(mybox)
918 mybox.parent = mywindow
919 mybox.location.x = 0
920 mybox.location.y = -blind_back - sy
921 mybox.location.z = sz
922 if mat and bpy.context.scene.render.engine == 'CYCLES':
923 set_material(mybox, matdata)
924 # Lock
925 mybox.lock_location = (True, True, True)
926 mybox.lock_rotation = (True, True, True)
928 return win_size, p1, p2
931 # ------------------------------------------------------------------------------
932 # Create leafs windows frame
934 # sX: Size in X axis
935 # sY: Size in Y axis
936 # sZ: Size in Z axis
937 # frame: size of external frame
938 # frame_L: size of main frame
939 # leafratio: ratio of leaf depth
940 # mat: Flag for creating materials
941 # matdata: Aluminum material
942 # external: create external frame flag
943 # blind: blind flag
944 # blind_height: height of blind box
945 # blind_back: front extension
946 # blind_rail: distance of the rail
947 # ------------------------------------------------------------------------------
948 def create_leaf_window_frame(mywindow, mymesh, sx, sy, sz, frame, frame_l, leafratio, mat, matdata, external,
949 blind, blind_height, blind_back, blind_rail):
950 myvertex = []
951 myfaces = []
952 # ===========================================================================
953 # Main frame_L
954 # ===========================================================================
955 x = sx / 2
956 z = sz
957 y = sy * leafratio
958 gap = 0.01
959 size = sy - y - 0.001 # thickness of the leaf
961 myvertex.extend([(-x, 0, 0),
962 (-x, 0, z),
963 (x, 0, z),
964 (x, 0, 0),
965 (-x + frame_l, 0, frame_l),
966 (-x + frame_l, 0, z - frame_l),
967 (x - frame_l, 0, z - frame_l),
968 (x - frame_l, 0, frame_l),
969 (-x + frame_l, -y, frame_l),
970 (-x + frame_l, -y, z - frame_l),
971 (x - frame_l, -y, z - frame_l),
972 (x - frame_l, -y, frame_l),
973 (-x + frame_l - gap, -y, frame_l - gap),
974 (-x + frame_l - gap, -y, z - frame_l + gap),
975 (x - frame_l + gap, -y, z - frame_l + gap),
976 (x - frame_l + gap, -y, frame_l - gap),
977 (-x + frame_l - gap, -sy, frame_l - gap),
978 (-x + frame_l - gap, -sy, z - frame_l + gap),
979 (x - frame_l + gap, -sy, z - frame_l + gap),
980 (x - frame_l + gap, -sy, frame_l - gap),
981 (-x, -sy, 0),
982 (-x, -sy, z),
983 (x, -sy, z),
984 (x, -sy, 0)])
985 # Faces
986 myfaces.extend([(1, 5, 4, 0), (21, 1, 0, 20), (17, 21, 20, 16), (16, 12, 13, 17), (12, 8, 9, 13),
987 (5, 9, 8, 4), (3, 7, 6, 2), (23, 3, 2, 22), (19, 23, 22, 18), (15, 19, 18, 14),
988 (11, 15, 14, 10), (6, 7, 11, 10), (0, 3, 23, 20), (21, 22, 2, 1), (17, 13, 14, 18),
989 (21, 17, 18, 22), (13, 9, 10, 14), (8, 11, 7, 4), (8, 12, 15, 11), (4, 7, 3, 0),
990 (12, 16, 19, 15), (16, 20, 23, 19), (9, 5, 6, 10), (1, 2, 6, 5)])
992 v = len(myvertex)
993 # ===========================================================================
994 # External front covers
995 # ===========================================================================
996 if external:
997 thick = 0.002 # aluminum thickness
998 x = sx
999 gap = -0.001
1000 sidem = frame
1001 box = 0
1002 if blind:
1003 box = blind_height
1005 myvertex.extend([((-x / 2) - sidem, -sy, sz + sidem + box),
1006 ((x / 2) + sidem, -sy, sz + sidem + box),
1007 ((-x / 2) - sidem, -sy, -sidem),
1008 ((x / 2) + sidem, -sy, -sidem),
1009 ((-x / 2) - gap, -sy, sz + gap + box),
1010 ((x / 2) + gap, -sy, sz + gap + box),
1011 ((-x / 2) - gap, -sy, -gap),
1012 ((x / 2) + gap, -sy, -gap)])
1013 myvertex.extend([((-x / 2) - sidem, -sy - thick, sz + sidem + box),
1014 ((x / 2) + sidem, -sy - thick, sz + sidem + box),
1015 ((-x / 2) - sidem, -sy - thick, -sidem),
1016 ((x / 2) + sidem, -sy - thick, -sidem),
1017 ((-x / 2) - gap, -sy - thick, sz + gap + box),
1018 ((x / 2) + gap, -sy - thick, sz + gap + box),
1019 ((-x / 2) - gap, -sy - thick, -gap),
1020 ((x / 2) + gap, -sy - thick, -gap)])
1022 myfaces.extend([(v + 3, v + 1, v + 9, v + 11), (v + 9, v + 8, v + 0, v + 1), (v + 1, v + 5, v + 4, v + 0),
1023 (v + 3, v + 7, v + 5, v + 1), (v + 7, v + 3, v + 2, v + 6),
1024 (v + 0, v + 4, v + 6, v + 2), (v + 9, v + 13, v + 12, v + 8), (v + 11, v + 15, v + 13, v + 9),
1025 (v + 15, v + 11, v + 10, v + 14), (v + 8, v + 12, v + 14, v + 10),
1026 (v + 11, v + 3, v + 2, v + 10), (v + 2, v + 10, v + 8, v + 0), (v + 14, v + 12, v + 4, v + 6),
1027 (v + 7, v + 6, v + 14, v + 15), (v + 5, v + 13, v + 12, v + 4),
1028 (v + 15, v + 7, v + 5, v + 13)])
1030 mymesh.from_pydata(myvertex, [], myfaces)
1031 mymesh.update(calc_edges=True)
1033 if mat and bpy.context.scene.render.engine == 'CYCLES':
1034 set_material(mywindow, matdata)
1036 # --------------
1037 # Blind Box
1038 # --------------
1039 if blind:
1040 mybox = create_blind_box("Blind_box", sx, sy + blind_back + blind_rail, blind_height)
1041 set_normals(mybox)
1043 mybox.parent = mywindow
1044 mybox.location.x = 0
1045 mybox.location.y = -blind_back - sy
1046 mybox.location.z = sz
1047 if mat and bpy.context.scene.render.engine == 'CYCLES':
1048 set_material(mybox, matdata)
1049 # Lock
1050 mybox.lock_location = (True, True, True)
1051 mybox.lock_rotation = (True, True, True)
1053 return size
1056 # ------------------------------------------------------------------------------
1057 # Create rail windows leaf
1059 # objName: Name for the new object
1060 # hand: Left or Right
1061 # sX: Size in X axis
1062 # sY: Size in Y axis
1063 # sZ: Size in Z axis
1064 # f: size of the frame_L
1065 # pX: position X axis
1066 # pY: position Y axis
1067 # pZ: position Z axis
1068 # mat: Flag for creating materials
1069 # matdata: default material
1070 # handle: create handle flag
1071 # ------------------------------------------------------------------------------
1072 def create_rail_window_leaf(objname, hand, sx, sy, sz, f, px, py, pz, mat, matdata, handle):
1073 myvertex = []
1074 myfaces = []
1075 v = 0
1076 # ===========================================================================
1077 # Horizontal pieces
1078 # ===========================================================================
1079 rail = 0.010 # rail width
1080 t = sy - 0.002
1081 p = ((t - rail) / 2) - 0.002
1082 side = 0.02 # vertical rail
1084 x = sx
1085 z = sz
1086 fz = f
1087 if hand == "R":
1088 x *= -1
1089 f *= -1
1090 # ------------------------
1091 # frame
1092 # ------------------------
1093 myvertex.extend([(0, 0, 0),
1094 (0, 0, z),
1095 (x, 0, z),
1096 (x, 0, 0),
1097 (f, 0, fz),
1098 (f, 0, z - fz),
1099 (x - f, 0, z - fz),
1100 (x - f, 0, fz),
1101 (f, -t / 2, fz),
1102 (f, -t / 2, z - fz),
1103 (x - f, -t / 2, z - fz),
1104 (x - f, -t / 2, fz),
1105 (f, -t, fz),
1106 (f, -t, z - fz),
1107 (x - f, -t, z - fz),
1108 (x - f, -t, fz),
1109 (0, -t, 0),
1110 (0, -t, z),
1111 (x, -t, z),
1112 (x, -t, 0)])
1113 # ------------------------
1114 # Side rails
1115 # ------------------------
1116 for z in (0, sz):
1117 myvertex.extend([(0, -p, z),
1118 (x, -p, z),
1119 (0, -p, z + side),
1120 (x, -p, z + side),
1121 (0, -p - rail, z + side),
1122 (x, -p - rail, z + side),
1123 (0, -p - rail, z),
1124 (x, -p - rail, z)])
1125 side *= -1 # reverse
1126 # Faces
1127 myfaces.extend([(v + 10, v + 6, v + 7, v + 11), (v + 9, v + 8, v + 4, v + 5),
1128 (v + 13, v + 12, v + 8, v + 9), (v + 14, v + 10, v + 11, v + 15),
1129 (v + 6, v + 10, v + 9, v + 5),
1130 (v + 9, v + 10, v + 14, v + 13), (v + 11, v + 7, v + 4, v + 8), (v + 12, v + 15, v + 11, v + 8),
1131 (v + 3, v + 7, v + 6, v + 2),
1132 (v + 5, v + 4, v + 0, v + 1),
1133 (v + 4, v + 7, v + 3, v + 0), (v + 5, v + 1, v + 2, v + 6), (v + 17, v + 16, v + 12, v + 13),
1134 (v + 15, v + 19, v + 18, v + 14),
1135 (v + 15, v + 12, v + 16, v + 19),
1136 (v + 14, v + 18, v + 17, v + 13), (v + 29, v + 2, v + 1, v + 28),
1137 (v + 35, v + 34, v + 17, v + 18), (v + 35, v + 33, v + 32, v + 34),
1138 (v + 31, v + 29, v + 28, v + 30),
1139 (v + 33, v + 31, v + 30, v + 32), (v + 25, v + 24, v + 22, v + 23),
1140 (v + 19, v + 16, v + 26, v + 27),
1141 (v + 3, v + 21, v + 20, v + 0), (v + 25, v + 27, v + 26, v + 24),
1142 (v + 23, v + 22, v + 20, v + 21), (v + 3, v + 2, v + 29, v + 21),
1143 (v + 19, v + 27, v + 35, v + 18),
1144 (v + 31, v + 33, v + 25, v + 23), (v + 32, v + 30, v + 22, v + 24),
1145 (v + 16, v + 17, v + 34, v + 26), (v + 0, v + 20, v + 28, v + 1)])
1146 # Glass
1147 if z == 0:
1148 myfaces.extend([(v + 10, v + 9, v + 8, v + 11)])
1150 v = len(myvertex)
1152 # Faces (last glass)
1153 # ------------------------
1154 # Plastic parts
1155 # ------------------------
1156 ps = -0.004
1157 gap = -0.0002
1158 space = 0.005
1160 if hand == "R":
1161 ps *= -1
1162 gap *= -1
1163 for z in (0, sz):
1164 for x in (0, sx):
1166 if hand == "R":
1167 x *= -1
1168 myvertex.extend([(x + gap, -p, z),
1169 (x + ps, -p, z),
1170 (x + gap, -p, z + side),
1171 (x + ps, -p, z + side),
1172 (x + gap, -p - rail, z + side),
1173 (x + ps, -p - rail, z + side),
1174 (x + gap, -p - rail, z),
1175 (x + ps, -p - rail, z),
1176 (x + gap, -p + rail - space, z),
1177 (x + gap, -p - rail - space, z),
1178 (x + gap, -p + rail - space, z + (side * 1.5)),
1179 (x + gap, -p - rail - space, z + (side * 1.5)),
1180 (x + ps, -p + rail - space, z),
1181 (x + ps, -p - rail - space, z),
1182 (x + ps, -p + rail - space, z + (side * 1.5)),
1183 (x + ps, -p - rail - space, z + (side * 1.5))])
1184 myfaces.extend([(v + 12, v + 8, v + 10, v + 14), (v + 6, v + 7, v + 5, v + 4), (v + 1, v + 0, v + 2, v + 3),
1185 (v + 5, v + 3, v + 2, v + 4), (v + 8, v + 12, v + 1, v + 0),
1186 (v + 7, v + 6, v + 9, v + 13), (v + 13, v + 9, v + 11, v + 15),
1187 (v + 14, v + 10, v + 11, v + 15),
1188 (v + 10, v + 8, v + 0, v + 2, v + 4, v + 6, v + 9, v + 11),
1189 (v + 12, v + 14, v + 15, v + 13, v + 7, v + 5, v + 3, v + 1)])
1191 v = len(myvertex)
1192 ps *= -1
1193 gap *= -1
1195 side *= -1 # reverse vertical
1197 mymesh = bpy.data.meshes.new(objname)
1198 mywindow = bpy.data.objects.new(objname, mymesh)
1200 mywindow.location[0] = px
1201 mywindow.location[1] = py
1202 mywindow.location[2] = pz
1203 bpy.context.scene.objects.link(mywindow)
1205 mymesh.from_pydata(myvertex, [], myfaces)
1206 mymesh.update(calc_edges=True)
1208 set_normals(mywindow)
1210 # Lock transformation
1211 mywindow.lock_location = (False, True, True) # only X axis
1212 mywindow.lock_rotation = (True, True, True)
1214 # Handle
1215 if handle:
1216 myhandle = create_rail_handle("Handle", mat)
1217 myhandle.parent = mywindow
1218 if hand == "R":
1219 myhandle.location.x = -0.035
1220 else:
1221 myhandle.location.x = +0.035
1223 myhandle.location.y = -sy + 0.001
1224 if sz / 2 <= 1:
1225 myhandle.location.z = sz / 2
1226 else:
1227 myhandle.location.z = 1
1229 if mat and bpy.context.scene.render.engine == 'CYCLES':
1230 set_material(mywindow, matdata)
1231 # Glass
1232 glass = create_glass_material("Glass_material", False)
1233 mywindow.data.materials.append(glass)
1234 select_faces(mywindow, 32, True)
1235 set_material_faces(mywindow, 1)
1236 # Plastic
1237 plastic = create_diffuse_material("Plastic_material", False, 0.01, 0.01, 0.01, 0.1, 0.1, 0.1, 0.01)
1238 mywindow.data.materials.append(plastic)
1239 select_faces(mywindow, 65, True)
1240 for fa in range(66, 104):
1241 select_faces(mywindow, fa, False)
1243 set_material_faces(mywindow, 2)
1245 return mywindow
1248 # ------------------------------------------------------------------------------
1249 # Create leaf windows leaf
1251 # objName: Name for the new object
1252 # hand: Left or Right
1253 # sX: Size in X axis
1254 # sY: Size in Y axis
1255 # sZ: Size in Z axis
1256 # f: size of the frame_L
1257 # pX: position X axis
1258 # pY: position Y axis
1259 # pZ: position Z axis
1260 # mat: Flag for creating materials
1261 # matdata: default material
1262 # handle: include handle
1263 # ------------------------------------------------------------------------------
1264 def create_leaf_window_leaf(objname, hand, sx, sy, sz, f, px, py, pz, mat, matdata, handle):
1265 myvertex = []
1266 myfaces = []
1267 x = sx
1268 z = sz
1269 fz = f
1270 t = sy
1271 if hand == "R":
1272 x *= -1
1273 f *= -1
1274 # ------------------------
1275 # frame
1276 # ------------------------
1277 myvertex.extend([(0, 0, 0),
1278 (0, 0, z),
1279 (x, 0, z),
1280 (x, 0, 0),
1281 (f, 0, fz),
1282 (f, 0, z - fz),
1283 (x - f, 0, z - fz),
1284 (x - f, 0, fz),
1285 (f, t / 2, fz),
1286 (f, t / 2, z - fz),
1287 (x - f, t / 2, z - fz),
1288 (x - f, t / 2, fz),
1289 (f, t, fz),
1290 (f, t, z - fz),
1291 (x - f, t, z - fz),
1292 (x - f, t, fz),
1293 (0, t, 0),
1294 (0, t, z),
1295 (x, t, z),
1296 (x, t, 0)])
1297 # Faces
1298 myfaces.extend([(13, 14, 10, 9), (10, 6, 5, 9), (11, 7, 4, 8), (12, 15, 11, 8), (13, 9, 8, 12),
1299 (9, 5, 4, 8), (10, 14, 15, 11), (6, 10, 11, 7), (19, 3, 2, 18), (17, 1, 0, 16),
1300 (2, 1, 17, 18), (19, 16, 0, 3), (13, 17, 18, 14), (15, 14, 18, 19), (13, 12, 16, 17),
1301 (12, 16, 19, 15), (6, 7, 3, 2), (4, 5, 1, 0), (5, 6, 2, 1), (4, 7, 3, 0),
1302 (10, 9, 8, 11)])
1304 mymesh = bpy.data.meshes.new(objname)
1305 mywindow = bpy.data.objects.new(objname, mymesh)
1307 mywindow.location[0] = px
1308 mywindow.location[1] = py
1309 mywindow.location[2] = pz
1310 bpy.context.scene.objects.link(mywindow)
1312 mymesh.from_pydata(myvertex, [], myfaces)
1313 mymesh.update(calc_edges=True)
1315 set_normals(mywindow)
1317 # Lock transformation
1318 mywindow.lock_location = (True, True, True)
1319 mywindow.lock_rotation = (True, True, False)
1321 if handle:
1322 myhandle = create_leaf_handle("Handle", mat)
1323 if hand == "L":
1324 myhandle.rotation_euler = (0, pi, 0)
1326 myhandle.parent = mywindow
1327 if hand == "R":
1328 myhandle.location.x = -sx + 0.025
1329 else:
1330 myhandle.location.x = sx - 0.025
1332 myhandle.location.y = 0
1333 if sz / 2 <= 1:
1334 myhandle.location.z = sz / 2
1335 else:
1336 myhandle.location.z = 1
1338 set_smooth(myhandle)
1339 set_modifier_subsurf(myhandle)
1341 if mat and bpy.context.scene.render.engine == 'CYCLES':
1342 set_material(mywindow, matdata)
1343 # Glass
1344 glass = create_glass_material("Glass_material", False)
1345 mywindow.data.materials.append(glass)
1346 select_faces(mywindow, 20, True)
1347 set_material_faces(mywindow, 1)
1348 return mywindow
1351 # ------------------------------------------------------------
1352 # Generate Leaf handle
1354 # objName: Object name
1355 # mat: create materials
1356 # ------------------------------------------------------------
1357 def create_leaf_handle(objname, mat):
1358 # ------------------------------------
1359 # Mesh data
1360 # ------------------------------------
1361 minx = -0.018522918224334717
1362 maxx = 0.10613098740577698
1363 miny = -0.04866280406713486
1364 maxy = 0.0002815350890159607
1365 minz = -0.06269633769989014
1366 maxz = 0.06289216876029968
1368 # Vertex
1369 myvertex = [(minx + 0.00752672553062439, maxy - 0.0176689475774765, minz + 0.0503292977809906),
1370 (minx + 0.002989441156387329, maxy - 0.017728276550769806, minz + 0.057490378618240356),
1371 (minx + 0.002640664577484131, maxy - 0.01777590811252594, maxz - 0.05962774157524109),
1372 (minx + 0.006573766469955444, maxy - 0.017799079418182373, maxz - 0.05211767554283142),
1373 (minx + 0.013735026121139526, maxy - 0.01779157668352127, maxz - 0.04758024215698242),
1374 (minx + 0.0222054123878479, maxy - 0.017755411565303802, maxz - 0.04723122715950012),
1375 (minx + 0.02971544861793518, maxy - 0.01770026981830597, maxz - 0.0511641800403595),
1376 (minx + 0.03425273299217224, maxy - 0.017640933394432068, maxz - 0.058325231075286865),
1377 (minx + 0.03460153937339783, maxy - 0.01759330928325653, minz + 0.05879288911819458),
1378 (minx + 0.03066837787628174, maxy - 0.017570137977600098, minz + 0.051282793283462524),
1379 (minx + 0.02350717782974243, maxy - 0.017577648162841797, minz + 0.046745359897613525),
1380 (minx + 0.01503676176071167, maxy - 0.017613813281059265, minz + 0.046396344900131226),
1381 (minx + 0.007489442825317383, maxy - 0.009374044835567474, minz + 0.05037441849708557),
1382 (minx + 0.00295218825340271, maxy - 0.009433373808860779, minz + 0.05753546953201294),
1383 (minx + 0.0026033520698547363, maxy - 0.009481005370616913, maxz - 0.05958262085914612),
1384 (minx + 0.006536513566970825, maxy - 0.009206198155879974, maxz - 0.05207255482673645),
1385 (minx + 0.013697713613510132, maxy - 0.009206198155879974, maxz - 0.04753512144088745),
1386 (minx + 0.029678165912628174, maxy - 0.009206198155879974, maxz - 0.051119059324264526),
1387 (minx + 0.034215450286865234, maxy - 0.009206198155879974, maxz - 0.05828014016151428),
1388 (minx + 0.03456425666809082, maxy - 0.009298399090766907, minz + 0.05883798003196716),
1389 (minx + 0.03063112497329712, maxy - 0.00927523523569107, minz + 0.051327913999557495),
1390 (minx + 0.023469924926757812, maxy - 0.009282737970352173, minz + 0.046790480613708496),
1391 (minx + 0.014999479055404663, maxy - 0.009318903088569641, minz + 0.046441465616226196),
1392 (minx + 0.009239286184310913, maxy - 0.017671361565589905, minz + 0.052188992500305176),
1393 (minx + 0.00540238618850708, maxy - 0.017721541225910187, minz + 0.058244675397872925),
1394 (minx + 0.005107402801513672, maxy - 0.017761819064617157, maxz - 0.06018096208572388),
1395 (minx + 0.00843346118927002, maxy - 0.01778140664100647, maxz - 0.05383017659187317),
1396 (minx + 0.014489203691482544, maxy - 0.017775066196918488, maxz - 0.049993157386779785),
1397 (minx + 0.021652132272720337, maxy - 0.017744481563568115, maxz - 0.04969802498817444),
1398 (minx + 0.028002887964248657, maxy - 0.01769784837961197, maxz - 0.053023844957351685),
1399 (minx + 0.03183978796005249, maxy - 0.01764768362045288, maxz - 0.059079527854919434),
1400 (minx + 0.03213474154472351, maxy - 0.01760740578174591, minz + 0.05934610962867737),
1401 (minx + 0.02880874276161194, maxy - 0.017587818205356598, minz + 0.05299532413482666),
1402 (minx + 0.02275294065475464, maxy - 0.01759415864944458, minz + 0.04915827512741089),
1403 (minx + 0.015590071678161621, maxy - 0.017624743282794952, minz + 0.04886317253112793),
1404 (minx + 0.004389584064483643, maxy - 0.0009383484721183777, minz + 0.05804264545440674),
1405 (minx + 0.00849863886833191, maxy - 0.0009383484721183777, minz + 0.0515575110912323),
1406 (minx + 0.00407370924949646, maxy - 0.0009383484721183777, maxz - 0.05987495183944702),
1407 (minx + 0.007635623216629028, maxy - 0.0009383484721183777, maxz - 0.053073734045028687),
1408 (minx + 0.014120936393737793, maxy - 0.0009383484721183777, maxz - 0.04896456003189087),
1409 (minx + 0.021791845560073853, maxy - 0.0009383484721183777, maxz - 0.04864847660064697),
1410 (minx + 0.0285930335521698, maxy - 0.0009383484721183777, maxz - 0.052210211753845215),
1411 (minx + 0.03270205855369568, maxy - 0.0009383484721183777, maxz - 0.05869537591934204),
1412 (minx + 0.03301793336868286, maxy - 0.0009383484721183777, minz + 0.05922222137451172),
1413 (minx + 0.02945604920387268, maxy - 0.0009383484721183777, minz + 0.052421003580093384),
1414 (minx + 0.022970736026763916, maxy - 0.0009383484721183777, minz + 0.048311829566955566),
1415 (minx + 0.015299826860427856, maxy - 0.0009383484721183777, minz + 0.04799577593803406),
1416 (minx + 0.009323716163635254, maxy - 0.012187294661998749, minz + 0.05233737826347351),
1417 (minx + 0.0055314600467681885, maxy - 0.01223689317703247, minz + 0.05832257866859436),
1418 (minx + 0.005239963531494141, maxy - 0.012276701629161835, maxz - 0.06018644571304321),
1419 (minx + 0.008527249097824097, maxy - 0.012296058237552643, maxz - 0.05390956997871399),
1420 (minx + 0.01451253890991211, maxy - 0.012289784848690033, maxz - 0.05011719465255737),
1421 (minx + 0.02159211039543152, maxy - 0.012259557843208313, maxz - 0.04982548952102661),
1422 (minx + 0.027868926525115967, maxy - 0.012213476002216339, maxz - 0.05311262607574463),
1423 (minx + 0.03166118264198303, maxy - 0.012163884937763214, maxz - 0.05909779667854309),
1424 (minx + 0.03195270895957947, maxy - 0.01212407648563385, minz + 0.059411197900772095),
1425 (minx + 0.028665393590927124, maxy - 0.012104712426662445, minz + 0.05313432216644287),
1426 (minx + 0.02268010377883911, maxy - 0.012110985815525055, minz + 0.049341946840286255),
1427 (minx + 0.01560056209564209, maxy - 0.012141212821006775, minz + 0.04905024170875549),
1428 (minx + 0.009444117546081543, miny + 0.009956002235412598, minz + 0.05219161510467529),
1429 (minx + 0.005651921033859253, miny + 0.00990641862154007, minz + 0.05817681550979614),
1430 (minx + 0.005360394716262817, miny + 0.009866602718830109, maxz - 0.06033217906951904),
1431 (minx + 0.008647710084915161, miny + 0.009847238659858704, maxz - 0.05405530333518982),
1432 (minx + 0.014632970094680786, miny + 0.009853512048721313, maxz - 0.0502629280090332),
1433 (minx + 0.021712541580200195, miny + 0.00988374650478363, maxz - 0.04997122287750244),
1434 (minx + 0.02798938751220703, miny + 0.009929820895195007, maxz - 0.05325835943222046),
1435 (minx + 0.03178161382675171, miny + 0.00997941941022873, maxz - 0.05924355983734131),
1436 (minx + 0.032073140144348145, miny + 0.010019220411777496, minz + 0.05926543474197388),
1437 (minx + 0.02878585457801819, miny + 0.010038584470748901, minz + 0.05298855900764465),
1438 (minx + 0.022800534963607788, miny + 0.010032311081886292, minz + 0.04919618368148804),
1439 (minx + 0.015720993280410767, miny + 0.010002091526985168, minz + 0.04890450835227966),
1440 (minx + 0.009488403797149658, miny + 0.0001087486743927002, minz + 0.05213809013366699),
1441 (minx + 0.0056961774826049805, miny + 5.917251110076904e-05, minz + 0.058123260736465454),
1442 (minx + 0.005404621362686157, miny + 1.9356608390808105e-05, maxz - 0.06038573384284973),
1443 (minx + 0.008691936731338501, miny, maxz - 0.05410885810852051),
1444 (minx + 0.014677256345748901, miny + 6.258487701416016e-06, maxz - 0.05031648278236389),
1445 (minx + 0.021756768226623535, miny + 3.650784492492676e-05, maxz - 0.05002477765083313),
1446 (minx + 0.02803361415863037, miny + 8.258223533630371e-05, maxz - 0.05331191420555115),
1447 (minx + 0.031825870275497437, miny + 0.00013218075037002563, maxz - 0.05929708480834961),
1448 (minx + 0.03211739659309387, miny + 0.00017196685075759888, minz + 0.059211909770965576),
1449 (minx + 0.028830111026763916, miny + 0.00019133836030960083, minz + 0.052935004234313965),
1450 (minx + 0.022844791412353516, miny + 0.0001850724220275879, minz + 0.04914262890815735),
1451 (minx + 0.015765219926834106, miny + 0.00015483051538467407, minz + 0.04885092377662659),
1452 (maxx - 0.010264694690704346, miny + 0.0024030879139900208, minz + 0.0574510395526886),
1453 (maxx - 0.009389877319335938, miny + 0.0028769299387931824, minz + 0.05982285737991333),
1454 (maxx - 0.00899556279182434, miny + 0.003135383129119873, maxz - 0.06170690059661865),
1455 (maxx - 0.00918734073638916, miny + 0.003109179437160492, maxz - 0.0570487380027771),
1456 (maxx - 0.009913921356201172, miny + 0.002805367112159729, maxz - 0.0530393123626709),
1457 (maxx - 0.010980546474456787, miny + 0.002305328845977783, maxz - 0.0507529079914093),
1458 (maxx - 0.011445850133895874, miny + 0.008283689618110657, minz + 0.05754268169403076),
1459 (maxx - 0.010571062564849854, miny + 0.008757516741752625, minz + 0.059914469718933105),
1460 (maxx - 0.01017671823501587, miny + 0.009015955030918121, maxz - 0.06161528825759888),
1461 (maxx - 0.010368555784225464, miny + 0.008989766240119934, maxz - 0.056957095861434937),
1462 (maxx - 0.011095106601715088, miny + 0.008685953915119171, maxz - 0.05294764041900635),
1463 (maxx - 0.012161701917648315, miny + 0.008185915648937225, maxz - 0.050661295652389526),
1464 (maxx - 0.0007557570934295654, miny + 0.019280850887298584, minz + 0.05762714147567749),
1465 (maxx - 0.0026130378246307373, miny + 0.019916504621505737, minz + 0.05755424499511719),
1466 (maxx - 0.00020641088485717773, miny + 0.020433299243450165, minz + 0.059989362955093384),
1467 (maxx, miny + 0.021083541214466095, maxz - 0.06154590845108032),
1468 (maxx - 0.00019183754920959473, miny + 0.021057337522506714, maxz - 0.05688774585723877),
1469 (maxx - 0.0007305145263671875, miny + 0.020361721515655518, maxz - 0.05287277698516846),
1470 (maxx - 0.0014716684818267822, miny + 0.019183076918125153, maxz - 0.05057680606842041),
1471 (maxx - 0.0033288896083831787, miny + 0.0198187455534935, maxz - 0.0506497323513031),
1472 (maxx - 0.0020636916160583496, miny + 0.021068952977657318, minz + 0.05991646647453308),
1473 (maxx - 0.0018572509288787842, miny + 0.021719202399253845, maxz - 0.061618804931640625),
1474 (maxx - 0.002049088478088379, miny + 0.021692998707294464, maxz - 0.05696064233779907),
1475 (maxx - 0.002587735652923584, miny + 0.020997390151023865, maxz - 0.05294567346572876),
1476 (minx + 0.018761008977890015, miny + 9.564310312271118e-05, minz + 0.062207311391830444),
1477 (minx + 0.0222054123878479, maxy - 0.009206198155879974, maxz - 0.04723122715950012),
1478 (minx, maxy - 0.009349517524242401, minz),
1479 (minx, maxy, minz),
1480 (minx + 0.03702586889266968, maxy, minz),
1481 (minx + 0.03702586889266968, maxy - 0.009349517524242401, minz),
1482 (minx, maxy - 0.009349517524242401, maxz),
1483 (minx, maxy, maxz),
1484 (minx + 0.03702586889266968, maxy, maxz),
1485 (minx + 0.03702586889266968, maxy - 0.009349517524242401, maxz),
1486 (minx, maxy - 0.009349517524242401, minz + 0.0038556158542633057),
1487 (minx, maxy - 0.009349517524242401, maxz - 0.0038556158542633057),
1488 (minx, maxy, maxz - 0.0038556158542633057),
1489 (minx, maxy, minz + 0.0038556158542633057),
1490 (minx + 0.03702586889266968, maxy, maxz - 0.0038556158542633057),
1491 (minx + 0.03702586889266968, maxy, minz + 0.0038556158542633057),
1492 (minx + 0.03702586889266968, maxy - 0.009349517524242401, maxz - 0.0038556158542633057),
1493 (minx + 0.03702586889266968, maxy - 0.009349517524242401, minz + 0.0038556158542633057),
1494 (minx, maxy, maxz),
1495 (minx, maxy, minz),
1496 (minx + 0.03702586889266968, maxy, maxz),
1497 (minx + 0.03702586889266968, maxy, minz),
1498 (minx, maxy, maxz - 0.0038556158542633057),
1499 (minx, maxy, minz + 0.0038556158542633057),
1500 (minx + 0.03702586889266968, maxy, maxz - 0.0038556158542633057),
1501 (minx + 0.03702586889266968, maxy, minz + 0.0038556158542633057),
1502 (minx + 0.00467991828918457, maxy, maxz),
1503 (minx + 0.03234601020812988, maxy, maxz),
1504 (minx + 0.03234601020812988, maxy, minz),
1505 (minx + 0.00467991828918457, maxy, minz),
1506 (minx + 0.03234601020812988, maxy - 0.009349517524242401, maxz),
1507 (minx + 0.00467991828918457, maxy - 0.009349517524242401, maxz),
1508 (minx + 0.00467991828918457, maxy - 0.009349517524242401, minz),
1509 (minx + 0.03234601020812988, maxy - 0.009349517524242401, minz),
1510 (minx + 0.03234601020812988, maxy, maxz - 0.0038556158542633057),
1511 (minx + 0.00467991828918457, maxy, maxz - 0.0038556158542633057),
1512 (minx + 0.03234601020812988, maxy, minz + 0.0038556158542633057),
1513 (minx + 0.00467991828918457, maxy, minz + 0.0038556158542633057),
1514 (minx + 0.00467991828918457, maxy - 0.009349517524242401, maxz - 0.0038556158542633057),
1515 (minx + 0.03234601020812988, maxy - 0.009349517524242401, maxz - 0.0038556158542633057),
1516 (minx + 0.00467991828918457, maxy - 0.009349517524242401, minz + 0.0038556158542633057),
1517 (minx + 0.03234601020812988, maxy - 0.009349517524242401, minz + 0.0038556158542633057),
1518 (minx + 0.00467991828918457, maxy, minz),
1519 (minx + 0.03234601020812988, maxy, minz),
1520 (minx + 0.03234601020812988, maxy, maxz),
1521 (minx + 0.00467991828918457, maxy, maxz),
1522 (minx + 0.01765689253807068, maxy - 0.008991599082946777, maxz - 0.00847548246383667),
1523 (minx + 0.014916181564331055, maxy - 0.008991599082946777, maxz - 0.00961071252822876),
1524 (minx + 0.013780921697616577, maxy - 0.008991606533527374, maxz - 0.012351423501968384),
1525 (minx + 0.014916181564331055, maxy - 0.008991606533527374, maxz - 0.015092134475708008),
1526 (minx + 0.01765689253807068, maxy - 0.008991606533527374, maxz - 0.016227364540100098),
1527 (minx + 0.02039763331413269, maxy - 0.008991606533527374, maxz - 0.015092134475708008),
1528 (minx + 0.021532833576202393, maxy - 0.008991606533527374, maxz - 0.012351423501968384),
1529 (minx + 0.02039763331413269, maxy - 0.008991599082946777, maxz - 0.00961071252822876),
1530 (minx + 0.01765689253807068, maxy - 0.0095299631357193, maxz - 0.00847548246383667),
1531 (minx + 0.014916181564331055, maxy - 0.0095299631357193, maxz - 0.00961071252822876),
1532 (minx + 0.013780921697616577, maxy - 0.0095299631357193, maxz - 0.012351423501968384),
1533 (minx + 0.014916181564331055, maxy - 0.0095299631357193, maxz - 0.015092134475708008),
1534 (minx + 0.01765689253807068, maxy - 0.0095299631357193, maxz - 0.016227364540100098),
1535 (minx + 0.02039763331413269, maxy - 0.0095299631357193, maxz - 0.015092134475708008),
1536 (minx + 0.021532833576202393, maxy - 0.0095299631357193, maxz - 0.012351423501968384),
1537 (minx + 0.02039763331413269, maxy - 0.0095299631357193, maxz - 0.00961071252822876),
1538 (minx + 0.01765689253807068, maxy - 0.0095299631357193, maxz - 0.009734481573104858),
1539 (minx + 0.0158064067363739, maxy - 0.0095299631357193, maxz - 0.010500967502593994),
1540 (minx + 0.015039980411529541, maxy - 0.0095299631357193, maxz - 0.012351423501968384),
1541 (minx + 0.0158064067363739, maxy - 0.0095299631357193, maxz - 0.014201879501342773),
1542 (minx + 0.01765689253807068, maxy - 0.0095299631357193, maxz - 0.014968395233154297),
1543 (minx + 0.01950731873512268, maxy - 0.0095299631357193, maxz - 0.014201879501342773),
1544 (minx + 0.020273834466934204, maxy - 0.0095299631357193, maxz - 0.012351423501968384),
1545 (minx + 0.01950731873512268, maxy - 0.0095299631357193, maxz - 0.010500967502593994),
1546 (minx + 0.01765689253807068, maxy - 0.009312078356742859, maxz - 0.009734481573104858),
1547 (minx + 0.0158064067363739, maxy - 0.009312078356742859, maxz - 0.010500967502593994),
1548 (minx + 0.015039980411529541, maxy - 0.009312078356742859, maxz - 0.012351423501968384),
1549 (minx + 0.0158064067363739, maxy - 0.009312078356742859, maxz - 0.014201879501342773),
1550 (minx + 0.01765689253807068, maxy - 0.009312078356742859, maxz - 0.014968395233154297),
1551 (minx + 0.01950731873512268, maxy - 0.009312078356742859, maxz - 0.014201879501342773),
1552 (minx + 0.020273834466934204, maxy - 0.009312078356742859, maxz - 0.012351423501968384),
1553 (minx + 0.01950731873512268, maxy - 0.009312078356742859, maxz - 0.010500967502593994),
1554 (minx + 0.01765689253807068, maxy - 0.009312078356742859, maxz - 0.01099047064781189),
1555 (minx + 0.01669454574584961, maxy - 0.009312078356742859, maxz - 0.011389046907424927),
1556 (minx + 0.016295909881591797, maxy - 0.009312078356742859, maxz - 0.012351423501968384),
1557 (minx + 0.01669454574584961, maxy - 0.009312078356742859, maxz - 0.013313770294189453),
1558 (minx + 0.01765689253807068, maxy - 0.009312078356742859, maxz - 0.013712406158447266),
1559 (minx + 0.01861920952796936, maxy - 0.009312078356742859, maxz - 0.013313770294189453),
1560 (minx + 0.019017815589904785, maxy - 0.009312078356742859, maxz - 0.012351423501968384),
1561 (minx + 0.01861920952796936, maxy - 0.009312078356742859, maxz - 0.011389046907424927),
1562 (minx + 0.01765689253807068, maxy - 0.009312078356742859, maxz - 0.011496275663375854),
1563 (minx + 0.01705223321914673, maxy - 0.009312078356742859, maxz - 0.011746734380722046),
1564 (minx + 0.01680171489715576, maxy - 0.009312078356742859, maxz - 0.012351423501968384),
1565 (minx + 0.01705223321914673, maxy - 0.009312078356742859, maxz - 0.012956112623214722),
1566 (minx + 0.01765689253807068, maxy - 0.009312078356742859, maxz - 0.013206571340560913),
1567 (minx + 0.018261581659317017, maxy - 0.009312078356742859, maxz - 0.012956112623214722),
1568 (minx + 0.018512040376663208, maxy - 0.009312078356742859, maxz - 0.012351423501968384),
1569 (minx + 0.018261581659317017, maxy - 0.009312078356742859, maxz - 0.011746734380722046),
1570 (minx + 0.01765689253807068, maxy - 0.009564712643623352, maxz - 0.009734481573104858),
1571 (minx + 0.0158064067363739, maxy - 0.009564712643623352, maxz - 0.010500967502593994),
1572 (minx + 0.015039980411529541, maxy - 0.009564712643623352, maxz - 0.012351423501968384),
1573 (minx + 0.0158064067363739, maxy - 0.009564712643623352, maxz - 0.014201879501342773),
1574 (minx + 0.01765689253807068, maxy - 0.009564712643623352, maxz - 0.014968395233154297),
1575 (minx + 0.01950731873512268, maxy - 0.009564712643623352, maxz - 0.014201879501342773),
1576 (minx + 0.020273834466934204, maxy - 0.009564712643623352, maxz - 0.012351423501968384),
1577 (minx + 0.01950731873512268, maxy - 0.009564712643623352, maxz - 0.010500967502593994),
1578 (minx + 0.01765689253807068, maxy - 0.009564712643623352, maxz - 0.01099047064781189),
1579 (minx + 0.01669454574584961, maxy - 0.009564712643623352, maxz - 0.011389046907424927),
1580 (minx + 0.016295909881591797, maxy - 0.009564712643623352, maxz - 0.012351423501968384),
1581 (minx + 0.01669454574584961, maxy - 0.009564712643623352, maxz - 0.013313770294189453),
1582 (minx + 0.01765689253807068, maxy - 0.009564712643623352, maxz - 0.013712406158447266),
1583 (minx + 0.01861920952796936, maxy - 0.009564712643623352, maxz - 0.013313770294189453),
1584 (minx + 0.019017815589904785, maxy - 0.009564712643623352, maxz - 0.012351423501968384),
1585 (minx + 0.01861920952796936, maxy - 0.009564712643623352, maxz - 0.011389046907424927),
1586 (minx + 0.01765689253807068, maxy - 0.009564712643623352, maxz - 0.011496275663375854),
1587 (minx + 0.01705223321914673, maxy - 0.009564712643623352, maxz - 0.011746734380722046),
1588 (minx + 0.01680171489715576, maxy - 0.009564712643623352, maxz - 0.012351423501968384),
1589 (minx + 0.01705223321914673, maxy - 0.009564712643623352, maxz - 0.012956112623214722),
1590 (minx + 0.01765689253807068, maxy - 0.009564712643623352, maxz - 0.013206571340560913),
1591 (minx + 0.018261581659317017, maxy - 0.009564712643623352, maxz - 0.012956112623214722),
1592 (minx + 0.018512040376663208, maxy - 0.009564712643623352, maxz - 0.012351423501968384),
1593 (minx + 0.018261581659317017, maxy - 0.009564712643623352, maxz - 0.011746734380722046),
1594 (minx + 0.01765689253807068, maxy - 0.008991599082946777, minz + 0.017180711030960083),
1595 (minx + 0.014916181564331055, maxy - 0.008991599082946777, minz + 0.016045480966567993),
1596 (minx + 0.013780921697616577, maxy - 0.008991606533527374, minz + 0.01330476999282837),
1597 (minx + 0.014916181564331055, maxy - 0.008991606533527374, minz + 0.010564059019088745),
1598 (minx + 0.01765689253807068, maxy - 0.008991606533527374, minz + 0.009428799152374268),
1599 (minx + 0.02039763331413269, maxy - 0.008991606533527374, minz + 0.010564059019088745),
1600 (minx + 0.021532833576202393, maxy - 0.008991606533527374, minz + 0.01330476999282837),
1601 (minx + 0.02039763331413269, maxy - 0.008991599082946777, minz + 0.016045480966567993),
1602 (minx + 0.01765689253807068, maxy - 0.0095299631357193, minz + 0.017180711030960083),
1603 (minx + 0.014916181564331055, maxy - 0.0095299631357193, minz + 0.016045480966567993),
1604 (minx + 0.013780921697616577, maxy - 0.0095299631357193, minz + 0.01330476999282837),
1605 (minx + 0.014916181564331055, maxy - 0.0095299631357193, minz + 0.010564059019088745),
1606 (minx + 0.01765689253807068, maxy - 0.0095299631357193, minz + 0.009428799152374268),
1607 (minx + 0.02039763331413269, maxy - 0.0095299631357193, minz + 0.010564059019088745),
1608 (minx + 0.021532833576202393, maxy - 0.0095299631357193, minz + 0.01330476999282837),
1609 (minx + 0.02039763331413269, maxy - 0.0095299631357193, minz + 0.016045480966567993),
1610 (minx + 0.01765689253807068, maxy - 0.0095299631357193, minz + 0.015921711921691895),
1611 (minx + 0.0158064067363739, maxy - 0.0095299631357193, minz + 0.015155225992202759),
1612 (minx + 0.015039980411529541, maxy - 0.0095299631357193, minz + 0.01330476999282837),
1613 (minx + 0.0158064067363739, maxy - 0.0095299631357193, minz + 0.01145431399345398),
1614 (minx + 0.01765689253807068, maxy - 0.0095299631357193, minz + 0.010687828063964844),
1615 (minx + 0.01950731873512268, maxy - 0.0095299631357193, minz + 0.01145431399345398),
1616 (minx + 0.020273834466934204, maxy - 0.0095299631357193, minz + 0.01330476999282837),
1617 (minx + 0.01950731873512268, maxy - 0.0095299631357193, minz + 0.015155225992202759),
1618 (minx + 0.01765689253807068, maxy - 0.009312078356742859, minz + 0.015921711921691895),
1619 (minx + 0.0158064067363739, maxy - 0.009312078356742859, minz + 0.015155225992202759),
1620 (minx + 0.015039980411529541, maxy - 0.009312078356742859, minz + 0.01330476999282837),
1621 (minx + 0.0158064067363739, maxy - 0.009312078356742859, minz + 0.01145431399345398),
1622 (minx + 0.01765689253807068, maxy - 0.009312078356742859, minz + 0.010687828063964844),
1623 (minx + 0.01950731873512268, maxy - 0.009312078356742859, minz + 0.01145431399345398),
1624 (minx + 0.020273834466934204, maxy - 0.009312078356742859, minz + 0.01330476999282837),
1625 (minx + 0.01950731873512268, maxy - 0.009312078356742859, minz + 0.015155225992202759),
1626 (minx + 0.01765689253807068, maxy - 0.009312078356742859, minz + 0.014665752649307251),
1627 (minx + 0.01669454574584961, maxy - 0.009312078356742859, minz + 0.014267116785049438),
1628 (minx + 0.016295909881591797, maxy - 0.009312078356742859, minz + 0.01330476999282837),
1629 (minx + 0.01669454574584961, maxy - 0.009312078356742859, minz + 0.012342393398284912),
1630 (minx + 0.01765689253807068, maxy - 0.009312078356742859, minz + 0.011943817138671875),
1631 (minx + 0.01861920952796936, maxy - 0.009312078356742859, minz + 0.012342393398284912),
1632 (minx + 0.019017815589904785, maxy - 0.009312078356742859, minz + 0.01330476999282837),
1633 (minx + 0.01861920952796936, maxy - 0.009312078356742859, minz + 0.014267116785049438),
1634 (minx + 0.01765689253807068, maxy - 0.009312078356742859, minz + 0.014159917831420898),
1635 (minx + 0.01705223321914673, maxy - 0.009312078356742859, minz + 0.01390942931175232),
1636 (minx + 0.01680171489715576, maxy - 0.009312078356742859, minz + 0.01330476999282837),
1637 (minx + 0.01705223321914673, maxy - 0.009312078356742859, minz + 0.012700080871582031),
1638 (minx + 0.01765689253807068, maxy - 0.009312078356742859, minz + 0.012449592351913452),
1639 (minx + 0.018261581659317017, maxy - 0.009312078356742859, minz + 0.012700080871582031),
1640 (minx + 0.018512040376663208, maxy - 0.009312078356742859, minz + 0.01330476999282837),
1641 (minx + 0.018261581659317017, maxy - 0.009312078356742859, minz + 0.01390942931175232),
1642 (minx + 0.01765689253807068, maxy - 0.009564712643623352, minz + 0.015921711921691895),
1643 (minx + 0.0158064067363739, maxy - 0.009564712643623352, minz + 0.015155225992202759),
1644 (minx + 0.015039980411529541, maxy - 0.009564712643623352, minz + 0.01330476999282837),
1645 (minx + 0.0158064067363739, maxy - 0.009564712643623352, minz + 0.01145431399345398),
1646 (minx + 0.01765689253807068, maxy - 0.009564712643623352, minz + 0.010687828063964844),
1647 (minx + 0.01950731873512268, maxy - 0.009564712643623352, minz + 0.01145431399345398),
1648 (minx + 0.020273834466934204, maxy - 0.009564712643623352, minz + 0.01330476999282837),
1649 (minx + 0.01950731873512268, maxy - 0.009564712643623352, minz + 0.015155225992202759),
1650 (minx + 0.01765689253807068, maxy - 0.009564712643623352, minz + 0.014665752649307251),
1651 (minx + 0.01669454574584961, maxy - 0.009564712643623352, minz + 0.014267116785049438),
1652 (minx + 0.016295909881591797, maxy - 0.009564712643623352, minz + 0.01330476999282837),
1653 (minx + 0.01669454574584961, maxy - 0.009564712643623352, minz + 0.012342393398284912),
1654 (minx + 0.01765689253807068, maxy - 0.009564712643623352, minz + 0.011943817138671875),
1655 (minx + 0.01861920952796936, maxy - 0.009564712643623352, minz + 0.012342393398284912),
1656 (minx + 0.019017815589904785, maxy - 0.009564712643623352, minz + 0.01330476999282837),
1657 (minx + 0.01861920952796936, maxy - 0.009564712643623352, minz + 0.014267116785049438),
1658 (minx + 0.01765689253807068, maxy - 0.009564712643623352, minz + 0.014159917831420898),
1659 (minx + 0.01705223321914673, maxy - 0.009564712643623352, minz + 0.01390942931175232),
1660 (minx + 0.01680171489715576, maxy - 0.009564712643623352, minz + 0.01330476999282837),
1661 (minx + 0.01705223321914673, maxy - 0.009564712643623352, minz + 0.012700080871582031),
1662 (minx + 0.01765689253807068, maxy - 0.009564712643623352, minz + 0.012449592351913452),
1663 (minx + 0.018261581659317017, maxy - 0.009564712643623352, minz + 0.012700080871582031),
1664 (minx + 0.018512040376663208, maxy - 0.009564712643623352, minz + 0.01330476999282837),
1665 (minx + 0.018261581659317017, maxy - 0.009564712643623352, minz + 0.01390942931175232)]
1667 # Faces
1668 myfaces = [(12, 0, 1, 13), (13, 1, 2, 14), (14, 2, 3, 15), (15, 3, 4, 16), (17, 6, 7, 18),
1669 (18, 7, 8, 19), (19, 8, 9, 20), (20, 9, 10, 21), (21, 10, 11, 22), (22, 11, 0, 12),
1670 (1, 0, 23, 24), (2, 1, 24, 25), (3, 2, 25, 26), (4, 3, 26, 27), (5, 4, 27, 28),
1671 (6, 5, 28, 29), (7, 6, 29, 30), (8, 7, 30, 31), (9, 8, 31, 32), (10, 9, 32, 33),
1672 (11, 10, 33, 34), (0, 11, 34, 23), (24, 23, 36, 35), (25, 24, 35, 37), (26, 25, 37, 38),
1673 (27, 26, 38, 39), (28, 27, 39, 40), (29, 28, 40, 41), (30, 29, 41, 42), (31, 30, 42, 43),
1674 (32, 31, 43, 44), (33, 32, 44, 45), (34, 33, 45, 46), (23, 34, 46, 36), (48, 47, 59, 60),
1675 (49, 48, 60, 61), (50, 49, 61, 62), (51, 50, 62, 63), (52, 51, 63, 64), (53, 52, 64, 65),
1676 (54, 53, 65, 66), (55, 54, 66, 67), (56, 55, 67, 68), (57, 56, 68, 69), (58, 57, 69, 70),
1677 (59, 47, 58, 70), (60, 59, 71, 72), (61, 60, 72, 73), (62, 61, 73, 74), (63, 62, 74, 75),
1678 (64, 63, 75, 76), (70, 69, 81, 82), (70, 82, 71, 59), (81, 69, 89, 83), (80, 81, 83, 84),
1679 (79, 80, 84, 85), (78, 79, 85, 86), (77, 78, 86, 87), (76, 77, 87, 88), (64, 76, 88, 94),
1680 (69, 68, 90, 89), (68, 67, 91, 90), (67, 66, 92, 91), (66, 65, 93, 92), (65, 64, 94, 93),
1681 (83, 89, 96, 95), (84, 83, 95, 97), (85, 84, 97, 98), (86, 85, 98, 99), (87, 86, 99, 100),
1682 (88, 87, 100, 101), (94, 88, 101, 102), (89, 90, 103, 96), (90, 91, 104, 103), (91, 92, 105, 104),
1683 (92, 93, 106, 105), (93, 94, 102, 106), (100, 106, 102, 101), (99, 105, 106, 100), (98, 104, 105, 99),
1684 (97, 103, 104, 98), (95, 96, 103, 97), (72, 71, 107), (73, 72, 107), (74, 73, 107),
1685 (75, 74, 107), (76, 75, 107), (77, 76, 107), (78, 77, 107), (79, 78, 107),
1686 (80, 79, 107), (81, 80, 107), (82, 81, 107), (71, 82, 107), (17, 108, 5, 6),
1687 (5, 108, 16, 4), (130, 120, 110, 126), (143, 122, 111, 135), (132, 124, 112, 128), (147, 117, 109, 139),
1688 (150, 135, 111, 128), (152, 133, 114, 125), (125, 114, 119, 129),
1689 (129, 119, 120, 130), (134, 115, 121, 141),
1690 (141, 121, 122, 143), (127, 116, 123, 131), (131, 123, 124, 132),
1691 (138, 113, 118, 145), (145, 118, 117, 147),
1692 (117, 130, 126, 109), (122, 132, 128, 111), (140, 150, 128, 112),
1693 (138, 152, 125, 113), (113, 125, 129, 118),
1694 (118, 129, 130, 117), (115, 127, 131, 121), (121, 131, 132, 122),
1695 (120, 144, 136, 110), (144, 143, 135, 136),
1696 (124, 148, 140, 112), (148, 147, 139, 140), (126, 110, 136, 149),
1697 (149, 136, 135, 150), (127, 115, 134, 151),
1698 (151, 134, 133, 152), (114, 133, 142, 119), (133, 134, 141, 142),
1699 (119, 142, 144, 120), (142, 141, 143, 144),
1700 (116, 137, 146, 123), (137, 138, 145, 146), (123, 146, 148, 124),
1701 (146, 145, 147, 148), (109, 126, 149, 139),
1702 (139, 149, 150, 140), (116, 127, 151, 137), (137, 151, 152, 138),
1703 (153, 160, 168, 161), (160, 159, 167, 168),
1704 (159, 158, 166, 167), (158, 157, 165, 166), (157, 156, 164, 165),
1705 (156, 155, 163, 164), (155, 154, 162, 163),
1706 (154, 153, 161, 162), (161, 168, 176, 169), (168, 167, 175, 176),
1707 (167, 166, 174, 175), (166, 165, 173, 174),
1708 (165, 164, 172, 173), (164, 163, 171, 172), (163, 162, 170, 171),
1709 (162, 161, 169, 170), (169, 176, 184, 177),
1710 (176, 175, 183, 184), (175, 174, 182, 183), (174, 173, 181, 182),
1711 (173, 172, 180, 181), (172, 171, 179, 180),
1712 (171, 170, 178, 179), (170, 169, 177, 178), (197, 189, 213, 221),
1713 (184, 183, 191, 192), (196, 197, 221, 220),
1714 (182, 181, 189, 190), (185, 177, 201, 209), (180, 179, 187, 188),
1715 (195, 187, 211, 219), (178, 177, 185, 186),
1716 (198, 199, 223, 222), (192, 191, 199, 200), (191, 183, 207, 215),
1717 (190, 189, 197, 198), (200, 193, 217, 224),
1718 (188, 187, 195, 196), (189, 181, 205, 213), (186, 185, 193, 194),
1719 (194, 193, 200, 199, 198, 197, 196, 195),
1720 (201, 208, 216, 209),
1721 (207, 206, 214, 215), (205, 204, 212, 213), (203, 202, 210, 211),
1722 (209, 216, 224, 217), (215, 214, 222, 223),
1723 (213, 212, 220, 221), (211, 210, 218, 219), (194, 195, 219, 218),
1724 (199, 191, 215, 223), (178, 186, 210, 202),
1725 (193, 185, 209, 217), (177, 184, 208, 201), (180, 188, 212, 204),
1726 (183, 182, 206, 207), (182, 190, 214, 206),
1727 (186, 194, 218, 210), (181, 180, 204, 205), (184, 192, 216, 208),
1728 (188, 196, 220, 212), (179, 178, 202, 203),
1729 (190, 198, 222, 214), (192, 200, 224, 216), (187, 179, 203, 211),
1730 (225, 232, 240, 233), (232, 231, 239, 240),
1731 (231, 230, 238, 239), (230, 229, 237, 238), (229, 228, 236, 237),
1732 (228, 227, 235, 236), (227, 226, 234, 235),
1733 (226, 225, 233, 234), (233, 240, 248, 241), (240, 239, 247, 248),
1734 (239, 238, 246, 247), (238, 237, 245, 246),
1735 (237, 236, 244, 245), (236, 235, 243, 244), (235, 234, 242, 243),
1736 (234, 233, 241, 242), (241, 248, 256, 249),
1737 (248, 247, 255, 256), (247, 246, 254, 255), (246, 245, 253, 254),
1738 (245, 244, 252, 253), (244, 243, 251, 252),
1739 (243, 242, 250, 251), (242, 241, 249, 250), (269, 261, 285, 293),
1740 (256, 255, 263, 264), (268, 269, 293, 292),
1741 (254, 253, 261, 262), (257, 249, 273, 281), (252, 251, 259, 260),
1742 (267, 259, 283, 291), (250, 249, 257, 258),
1743 (270, 271, 295, 294), (264, 263, 271, 272), (263, 255, 279, 287),
1744 (262, 261, 269, 270), (272, 265, 289, 296),
1745 (260, 259, 267, 268), (261, 253, 277, 285), (258, 257, 265, 266),
1746 (266, 265, 272, 271, 270, 269, 268, 267),
1747 (273, 280, 288, 281),
1748 (279, 278, 286, 287), (277, 276, 284, 285), (275, 274, 282, 283),
1749 (281, 288, 296, 289), (287, 286, 294, 295),
1750 (285, 284, 292, 293), (283, 282, 290, 291), (266, 267, 291, 290),
1751 (271, 263, 287, 295), (250, 258, 282, 274),
1752 (265, 257, 281, 289), (249, 256, 280, 273), (252, 260, 284, 276),
1753 (255, 254, 278, 279), (254, 262, 286, 278),
1754 (258, 266, 290, 282), (253, 252, 276, 277), (256, 264, 288, 280),
1755 (260, 268, 292, 284), (251, 250, 274, 275),
1756 (262, 270, 294, 286), (264, 272, 296, 288), (259, 251, 275, 283)]
1758 mesh = bpy.data.meshes.new(objname)
1759 myobject = bpy.data.objects.new(objname, mesh)
1761 myobject.location = bpy.context.scene.cursor_location
1762 bpy.context.scene.objects.link(myobject)
1764 mesh.from_pydata(myvertex, [], myfaces)
1765 mesh.update(calc_edges=True)
1767 # Create materials
1768 if mat and bpy.context.scene.render.engine == 'CYCLES':
1769 alumat = create_glossy_material("Handle_material", False, 0.733, 0.779, 0.8)
1770 set_material(myobject, alumat)
1772 return myobject
1775 # ------------------------------------------------------------
1776 # Generate rail handle
1778 # objName: Object name
1779 # mat: create materials
1780 # ------------------------------------------------------------
1781 def create_rail_handle(objname, mat):
1782 # ------------------------------------
1783 # Mesh data
1784 # ------------------------------------
1785 minx = -0.007970962673425674
1786 maxx = 0.007971039041876793
1787 miny = -0.0038057267665863037
1788 maxy = 6.780028343200684e-07
1789 minz = -0.07533407211303711
1790 maxz = 0.05025443434715271
1792 # Vertex
1793 myvertex = [(minx, miny + 0.0009473562240600586, minz),
1794 (minx, maxy, minz),
1795 (maxx, maxy, minz),
1796 (maxx, miny + 0.0009473562240600586, minz),
1797 (minx, miny + 0.0009473562240600586, maxz),
1798 (minx, maxy, maxz),
1799 (maxx, maxy, maxz),
1800 (maxx, miny + 0.0009473562240600586, maxz),
1801 (minx, miny + 0.0009473562240600586, minz + 0.0038556158542633057),
1802 (minx, miny + 0.0009473562240600586, maxz - 0.0038556158542633057),
1803 (minx, maxy, minz + 0.0038556158542633057),
1804 (maxx, miny + 0.0009473562240600586, maxz - 0.0038556158542633057),
1805 (maxx, miny + 0.0009473562240600586, minz + 0.0038556158542633057),
1806 (minx, maxy, maxz - 0.0038556158542633057),
1807 (maxx, maxy, maxz - 0.0038556158542633057),
1808 (maxx, maxy, minz + 0.0038556158542633057),
1809 (maxx - 0.002014978788793087, maxy, maxz),
1810 (minx + 0.0020150020718574524, maxy, minz),
1811 (maxx - 0.002014978788793087, miny + 0.0009473562240600586, maxz),
1812 (minx + 0.0020150020718574524, miny + 0.0009473562240600586, maxz),
1813 (minx + 0.0020150020718574524, miny + 0.0009473562240600586, minz),
1814 (maxx - 0.002014978788793087, miny + 0.0009473562240600586, minz),
1815 (maxx - 0.002014978788793087, maxy, maxz - 0.0038556158542633057),
1816 (minx + 0.0020150020718574524, maxy, maxz - 0.0038556158542633057),
1817 (maxx - 0.002014978788793087, maxy, minz + 0.0038556158542633057),
1818 (minx + 0.0020150020718574524, maxy, minz + 0.0038556158542633057),
1819 (minx + 0.0020150020718574524, miny + 0.0009473562240600586, maxz - 0.0038556158542633057),
1820 (maxx - 0.002014978788793087, miny + 0.0009473562240600586, maxz - 0.0038556158542633057),
1821 (minx + 0.0020150020718574524, miny + 0.0009473562240600586, minz + 0.0038556158542633057),
1822 (maxx - 0.002014978788793087, miny + 0.0009473562240600586, minz + 0.0038556158542633057),
1823 (maxx - 0.002014978788793087, maxy, minz),
1824 (minx + 0.0020150020718574524, maxy, maxz),
1825 (minx + 0.007114947948139161, miny + 0.001102180453017354, maxz - 0.004768103361129761),
1826 (minx + 0.0057074506767094135, miny + 0.001102180453017354, maxz - 0.005351103842258453),
1827 (minx + 0.005124435992911458, miny + 0.001102176494896412, maxz - 0.006758600473403931),
1828 (minx + 0.0057074506767094135, miny + 0.001102176494896412, maxz - 0.008166097104549408),
1829 (minx + 0.007114947948139161, miny + 0.001102176494896412, maxz - 0.0087490975856781),
1830 (maxx - 0.0074195414781570435, miny + 0.001102176494896412, maxz - 0.008166097104549408),
1831 (maxx - 0.006836557062342763, miny + 0.001102176494896412, maxz - 0.006758600473403931),
1832 (maxx - 0.0074195414781570435, miny + 0.001102180453017354, maxz - 0.005351103842258453),
1833 (minx + 0.007114947948139161, miny + 0.0008257024455815554, maxz - 0.004768103361129761),
1834 (minx + 0.0057074506767094135, miny + 0.0008257024455815554, maxz - 0.005351103842258453),
1835 (minx + 0.005124435992911458, miny + 0.0008257024455815554, maxz - 0.006758600473403931),
1836 (minx + 0.0057074506767094135, miny + 0.0008257024455815554, maxz - 0.008166097104549408),
1837 (minx + 0.007114947948139161, miny + 0.0008257024455815554, maxz - 0.0087490975856781),
1838 (maxx - 0.0074195414781570435, miny + 0.0008257024455815554, maxz - 0.008166097104549408),
1839 (maxx - 0.006836557062342763, miny + 0.0008257024455815554, maxz - 0.006758600473403931),
1840 (maxx - 0.0074195414781570435, miny + 0.0008257024455815554, maxz - 0.005351103842258453),
1841 (minx + 0.007114947948139161, miny + 0.000937597593292594, maxz - 0.0054146647453308105),
1842 (minx + 0.006164627615362406, miny + 0.000937597593292594, maxz - 0.00580829381942749),
1843 (minx + 0.0057710278779268265, miny + 0.000937597593292594, maxz - 0.006758600473403931),
1844 (minx + 0.006164627615362406, miny + 0.000937597593292594, maxz - 0.007708907127380371),
1845 (minx + 0.007114947948139161, miny + 0.000937597593292594, maxz - 0.008102551102638245),
1846 (maxx - 0.007876764051616192, miny + 0.000937597593292594, maxz - 0.007708907127380371),
1847 (maxx - 0.007483118446543813, miny + 0.000937597593292594, maxz - 0.006758600473403931),
1848 (maxx - 0.007876764051616192, miny + 0.000937597593292594, maxz - 0.00580829381942749),
1849 (minx + 0.007114947948139161, miny + 0.000937597593292594, maxz - 0.006059680134057999),
1850 (minx + 0.006620732950977981, miny + 0.000937597593292594, maxz - 0.006264369934797287),
1851 (minx + 0.006416012765839696, miny + 0.000937597593292594, maxz - 0.006758600473403931),
1852 (minx + 0.006620732950977981, miny + 0.000937597593292594, maxz - 0.0072528161108493805),
1853 (minx + 0.007114947948139161, miny + 0.000937597593292594, maxz - 0.0074575357139110565),
1854 (minx + 0.0076091475784778595, miny + 0.000937597593292594, maxz - 0.0072528161108493805),
1855 (minx + 0.007813852455001324, miny + 0.000937597593292594, maxz - 0.006758600473403931),
1856 (minx + 0.0076091475784778595, miny + 0.000937597593292594, maxz - 0.006264369934797287),
1857 (minx + 0.007114947948139161, miny + 0.000937597593292594, maxz - 0.006319437175989151),
1858 (minx + 0.006804424105212092, miny + 0.000937597593292594, maxz - 0.0064480602741241455),
1859 (minx + 0.00667576992418617, miny + 0.000937597593292594, maxz - 0.006758600473403931),
1860 (minx + 0.006804424105212092, miny + 0.000937597593292594, maxz - 0.007069140672683716),
1861 (minx + 0.007114947948139161, miny + 0.000937597593292594, maxz - 0.00719776377081871),
1862 (minx + 0.0074254871578887105, miny + 0.000937597593292594, maxz - 0.007069140672683716),
1863 (minx + 0.007554110663477331, miny + 0.000937597593292594, maxz - 0.006758600473403931),
1864 (minx + 0.0074254871578887105, miny + 0.000937597593292594, maxz - 0.0064480602741241455),
1865 (minx + 0.007114947948139161, miny + 0.0008078569080680609, maxz - 0.0054146647453308105),
1866 (minx + 0.006164627615362406, miny + 0.0008078569080680609, maxz - 0.00580829381942749),
1867 (minx + 0.0057710278779268265, miny + 0.0008078569080680609, maxz - 0.006758600473403931),
1868 (minx + 0.006164627615362406, miny + 0.0008078569080680609, maxz - 0.007708907127380371),
1869 (minx + 0.007114947948139161, miny + 0.0008078569080680609, maxz - 0.008102551102638245),
1870 (maxx - 0.007876764051616192, miny + 0.0008078569080680609, maxz - 0.007708907127380371),
1871 (maxx - 0.007483118446543813, miny + 0.0008078569080680609, maxz - 0.006758600473403931),
1872 (maxx - 0.007876764051616192, miny + 0.0008078569080680609, maxz - 0.00580829381942749),
1873 (minx + 0.007114947948139161, miny + 0.0008078569080680609, maxz - 0.006059680134057999),
1874 (minx + 0.006620732950977981, miny + 0.0008078569080680609, maxz - 0.006264369934797287),
1875 (minx + 0.006416012765839696, miny + 0.0008078569080680609, maxz - 0.006758600473403931),
1876 (minx + 0.006620732950977981, miny + 0.0008078569080680609, maxz - 0.0072528161108493805),
1877 (minx + 0.007114947948139161, miny + 0.0008078569080680609, maxz - 0.0074575357139110565),
1878 (minx + 0.0076091475784778595, miny + 0.0008078569080680609, maxz - 0.0072528161108493805),
1879 (minx + 0.007813852455001324, miny + 0.0008078569080680609, maxz - 0.006758600473403931),
1880 (minx + 0.0076091475784778595, miny + 0.0008078569080680609, maxz - 0.006264369934797287),
1881 (minx + 0.007114947948139161, miny + 0.0008078569080680609, maxz - 0.006319437175989151),
1882 (minx + 0.006804424105212092, miny + 0.0008078569080680609, maxz - 0.0064480602741241455),
1883 (minx + 0.00667576992418617, miny + 0.0008078569080680609, maxz - 0.006758600473403931),
1884 (minx + 0.006804424105212092, miny + 0.0008078569080680609, maxz - 0.007069140672683716),
1885 (minx + 0.007114947948139161, miny + 0.0008078569080680609, maxz - 0.00719776377081871),
1886 (minx + 0.0074254871578887105, miny + 0.0008078569080680609, maxz - 0.007069140672683716),
1887 (minx + 0.007554110663477331, miny + 0.0008078569080680609, maxz - 0.006758600473403931),
1888 (minx + 0.0074254871578887105, miny + 0.0008078569080680609, maxz - 0.0064480602741241455),
1889 (minx + 0.0074254871578887105, miny + 0.0008078569080680609, minz + 0.007765233516693115),
1890 (minx + 0.007554110663477331, miny + 0.0008078569080680609, minz + 0.00745469331741333),
1891 (minx + 0.0074254871578887105, miny + 0.0008078569080680609, minz + 0.007144153118133545),
1892 (minx + 0.007114947948139161, miny + 0.0008078569080680609, minz + 0.007015526294708252),
1893 (minx + 0.006804424105212092, miny + 0.0008078569080680609, minz + 0.007144153118133545),
1894 (minx + 0.00667576992418617, miny + 0.0008078569080680609, minz + 0.00745469331741333),
1895 (minx + 0.006804424105212092, miny + 0.0008078569080680609, minz + 0.007765233516693115),
1896 (minx + 0.007114947948139161, miny + 0.0008078569080680609, minz + 0.007893860340118408),
1897 (minx + 0.0076091475784778595, miny + 0.0008078569080680609, minz + 0.007948920130729675),
1898 (minx + 0.007813852455001324, miny + 0.0008078569080680609, minz + 0.00745469331741333),
1899 (minx + 0.0076091475784778595, miny + 0.0008078569080680609, minz + 0.006960481405258179),
1900 (minx + 0.007114947948139161, miny + 0.0008078569080680609, minz + 0.006755754351615906),
1901 (minx + 0.006620732950977981, miny + 0.0008078569080680609, minz + 0.006960481405258179),
1902 (minx + 0.006416012765839696, miny + 0.0008078569080680609, minz + 0.00745469331741333),
1903 (minx + 0.006620732950977981, miny + 0.0008078569080680609, minz + 0.007948920130729675),
1904 (minx + 0.007114947948139161, miny + 0.0008078569080680609, minz + 0.00815361738204956),
1905 (maxx - 0.007876764051616192, miny + 0.0008078569080680609, minz + 0.00840499997138977),
1906 (maxx - 0.007483118446543813, miny + 0.0008078569080680609, minz + 0.00745469331741333),
1907 (maxx - 0.007876764051616192, miny + 0.0008078569080680609, minz + 0.00650438666343689),
1908 (minx + 0.007114947948139161, miny + 0.0008078569080680609, minz + 0.006110742688179016),
1909 (minx + 0.006164627615362406, miny + 0.0008078569080680609, minz + 0.00650438666343689),
1910 (minx + 0.0057710278779268265, miny + 0.0008078569080680609, minz + 0.00745469331741333),
1911 (minx + 0.006164627615362406, miny + 0.0008078569080680609, minz + 0.00840499997138977),
1912 (minx + 0.007114947948139161, miny + 0.0008078569080680609, minz + 0.00879862904548645),
1913 (minx + 0.0074254871578887105, miny + 0.000937597593292594, minz + 0.007765233516693115),
1914 (minx + 0.007554110663477331, miny + 0.000937597593292594, minz + 0.00745469331741333),
1915 (minx + 0.0074254871578887105, miny + 0.000937597593292594, minz + 0.007144153118133545),
1916 (minx + 0.007114947948139161, miny + 0.000937597593292594, minz + 0.007015526294708252),
1917 (minx + 0.006804424105212092, miny + 0.000937597593292594, minz + 0.007144153118133545),
1918 (minx + 0.00667576992418617, miny + 0.000937597593292594, minz + 0.00745469331741333),
1919 (minx + 0.006804424105212092, miny + 0.000937597593292594, minz + 0.007765233516693115),
1920 (minx + 0.007114947948139161, miny + 0.000937597593292594, minz + 0.007893860340118408),
1921 (minx + 0.0076091475784778595, miny + 0.000937597593292594, minz + 0.007948920130729675),
1922 (minx + 0.007813852455001324, miny + 0.000937597593292594, minz + 0.00745469331741333),
1923 (minx + 0.0076091475784778595, miny + 0.000937597593292594, minz + 0.006960481405258179),
1924 (minx + 0.007114947948139161, miny + 0.000937597593292594, minz + 0.006755754351615906),
1925 (minx + 0.006620732950977981, miny + 0.000937597593292594, minz + 0.006960481405258179),
1926 (minx + 0.006416012765839696, miny + 0.000937597593292594, minz + 0.00745469331741333),
1927 (minx + 0.006620732950977981, miny + 0.000937597593292594, minz + 0.007948920130729675),
1928 (minx + 0.007114947948139161, miny + 0.000937597593292594, minz + 0.00815361738204956),
1929 (maxx - 0.007876764051616192, miny + 0.000937597593292594, minz + 0.00840499997138977),
1930 (maxx - 0.007483118446543813, miny + 0.000937597593292594, minz + 0.00745469331741333),
1931 (maxx - 0.007876764051616192, miny + 0.000937597593292594, minz + 0.00650438666343689),
1932 (minx + 0.007114947948139161, miny + 0.000937597593292594, minz + 0.006110742688179016),
1933 (minx + 0.006164627615362406, miny + 0.000937597593292594, minz + 0.00650438666343689),
1934 (minx + 0.0057710278779268265, miny + 0.000937597593292594, minz + 0.00745469331741333),
1935 (minx + 0.006164627615362406, miny + 0.000937597593292594, minz + 0.00840499997138977),
1936 (minx + 0.007114947948139161, miny + 0.000937597593292594, minz + 0.00879862904548645),
1937 (maxx - 0.0074195414781570435, miny + 0.0008257024455815554, minz + 0.008862189948558807),
1938 (maxx - 0.006836557062342763, miny + 0.0008257024455815554, minz + 0.00745469331741333),
1939 (maxx - 0.0074195414781570435, miny + 0.0008257024455815554, minz + 0.006047196686267853),
1940 (minx + 0.007114947948139161, miny + 0.0008257024455815554, minz + 0.00546419620513916),
1941 (minx + 0.0057074506767094135, miny + 0.0008257024455815554, minz + 0.006047196686267853),
1942 (minx + 0.005124435992911458, miny + 0.0008257024455815554, minz + 0.00745469331741333),
1943 (minx + 0.0057074506767094135, miny + 0.0008257024455815554, minz + 0.008862189948558807),
1944 (minx + 0.007114947948139161, miny + 0.0008257024455815554, minz + 0.0094451904296875),
1945 (maxx - 0.0074195414781570435, miny + 0.001102180453017354, minz + 0.008862189948558807),
1946 (maxx - 0.006836557062342763, miny + 0.001102176494896412, minz + 0.00745469331741333),
1947 (maxx - 0.0074195414781570435, miny + 0.001102176494896412, minz + 0.006047196686267853),
1948 (minx + 0.007114947948139161, miny + 0.001102176494896412, minz + 0.00546419620513916),
1949 (minx + 0.0057074506767094135, miny + 0.001102176494896412, minz + 0.006047196686267853),
1950 (minx + 0.005124435992911458, miny + 0.001102176494896412, minz + 0.00745469331741333),
1951 (minx + 0.0057074506767094135, miny + 0.001102180453017354, minz + 0.008862189948558807),
1952 (minx + 0.007114947948139161, miny + 0.001102180453017354, minz + 0.0094451904296875),
1953 (maxx - 0.002014978788793087, maxy, maxz - 0.015039850026369095),
1954 (maxx - 0.002014978788793087, maxy, minz + 0.015039850026369095),
1955 (minx, miny + 0.0009473562240600586, minz + 0.015039850026369095),
1956 (minx, miny + 0.0009473562240600586, maxz - 0.015039850026369095),
1957 (minx, maxy, minz + 0.015039850026369095),
1958 (maxx, maxy, maxz - 0.015039850026369095),
1959 (maxx, miny + 0.0009473562240600586, maxz - 0.015039850026369095),
1960 (maxx, miny + 0.0009473562240600586, minz + 0.015039850026369095),
1961 (maxx - 0.002014978788793087, miny + 0.0009473562240600586, maxz - 0.015039850026369095),
1962 (maxx - 0.002014978788793087, miny + 0.0009473562240600586, minz + 0.015039850026369095),
1963 (minx + 0.0020150020718574524, maxy, maxz - 0.015039850026369095),
1964 (minx + 0.0020150020718574524, maxy, minz + 0.015039850026369095),
1965 (minx + 0.0020150020718574524, miny + 0.0009473562240600586, maxz - 0.015039850026369095),
1966 (minx + 0.0020150020718574524, miny + 0.0009473562240600586, minz + 0.015039850026369095),
1967 (maxx, maxy, minz + 0.015039850026369095),
1968 (minx, maxy, maxz - 0.015039850026369095),
1969 (maxx - 0.002014978788793087, maxy - 0.0017695352435112, maxz - 0.015039850026369095),
1970 (maxx - 0.002014978788793087, maxy - 0.0017695352435112, minz + 0.015039850026369095),
1971 (minx + 0.0020150020718574524, maxy - 0.0017695352435112, maxz - 0.015039850026369095),
1972 (minx + 0.0020150020718574524, maxy - 0.0017695352435112, minz + 0.015039850026369095),
1973 (maxx - 0.002014978788793087, maxy, maxz - 0.020450454205274582),
1974 (minx, miny + 0.0009473562240600586, maxz - 0.020450454205274582),
1975 (minx, maxy, maxz - 0.020450454205274582),
1976 (maxx, maxy, maxz - 0.020450454205274582),
1977 (maxx, miny + 0.0009473562240600586, maxz - 0.020450454205274582),
1978 (maxx - 0.002014978788793087, miny + 0.0009473562240600586, maxz - 0.020450454205274582),
1979 (minx + 0.0020150020718574524, maxy, maxz - 0.020450454205274582),
1980 (minx + 0.0020150020718574524, miny + 0.0009473562240600586, maxz - 0.020450454205274582),
1981 (maxx - 0.002014978788793087, maxy - 0.0017695352435112, maxz - 0.020450454205274582),
1982 (minx + 0.0020150020718574524, maxy - 0.0017695352435112, maxz - 0.020450454205274582),
1983 (minx, miny + 0.0009473562240600586, maxz - 0.04870907962322235),
1984 (maxx - 0.002014978788793087, maxy, maxz - 0.04870907962322235),
1985 (minx, maxy, maxz - 0.04870907962322235),
1986 (maxx, miny + 0.0009473562240600586, maxz - 0.04870907962322235),
1987 (maxx - 0.002014978788793087, miny + 0.0009473562240600586, maxz - 0.04870907962322235),
1988 (minx + 0.0020150020718574524, maxy, maxz - 0.04870907962322235),
1989 (minx + 0.0020150020718574524, miny + 0.0009473562240600586, maxz - 0.04870907962322235),
1990 (maxx, maxy, maxz - 0.04870907962322235),
1991 (maxx - 0.002014978788793087, maxy - 0.0017695352435112, maxz - 0.04870907962322235),
1992 (minx + 0.0020150020718574524, maxy - 0.0017695352435112, maxz - 0.04870907962322235),
1993 (maxx - 0.0027115284465253353, miny + 0.0009342432022094727, maxz - 0.020450454205274582),
1994 (minx + 0.0027115517295897007, miny + 0.0009342432022094727, maxz - 0.020450454205274582),
1995 (maxx - 0.0027115284465253353, miny + 0.0009342432022094727, maxz - 0.04870907962322235),
1996 (minx + 0.0027115517295897007, miny + 0.0009342432022094727, maxz - 0.04870907962322235),
1997 (minx, miny + 0.0009473562240600586, maxz - 0.026037774980068207),
1998 (maxx - 0.002014978788793087, maxy, maxz - 0.026037774980068207),
1999 (minx, maxy, maxz - 0.026037774980068207),
2000 (maxx, maxy, maxz - 0.026037774980068207),
2001 (maxx, miny + 0.0009473562240600586, maxz - 0.026037774980068207),
2002 (maxx - 0.002014978788793087, miny + 0.0009473562240600586, maxz - 0.026037774980068207),
2003 (minx + 0.0020150020718574524, maxy, maxz - 0.026037774980068207),
2004 (minx + 0.0020150020718574524, miny + 0.0009473562240600586, maxz - 0.026037774980068207),
2005 (maxx - 0.002014978788793087, maxy - 0.0017695352435112, maxz - 0.026037774980068207),
2006 (minx + 0.0020150020718574524, maxy - 0.0017695352435112, maxz - 0.026037774980068207),
2007 (maxx - 0.0027115284465253353, miny + 0.0009342432022094727, maxz - 0.026037774980068207),
2008 (minx + 0.0027115517295897007, miny + 0.0009342432022094727, maxz - 0.026037774980068207),
2009 (minx, miny + 0.0009473562240600586, maxz - 0.03058292716741562),
2010 (maxx - 0.002014978788793087, maxy, maxz - 0.03058292716741562),
2011 (maxx, miny + 0.0009473562240600586, maxz - 0.03058292716741562),
2012 (maxx - 0.002014978788793087, miny + 0.0009473562240600586, maxz - 0.03058292716741562),
2013 (minx + 0.0020150020718574524, maxy, maxz - 0.03058292716741562),
2014 (minx + 0.0020150020718574524, miny + 0.0009473562240600586, maxz - 0.03058292716741562),
2015 (maxx, maxy, maxz - 0.03058292716741562),
2016 (minx, maxy, maxz - 0.03058292716741562),
2017 (maxx - 0.002014978788793087, maxy - 0.0017695352435112, maxz - 0.03058292716741562),
2018 (minx + 0.0020150020718574524, maxy - 0.0017695352435112, maxz - 0.03058292716741562),
2019 (maxx - 0.0027115284465253353, miny + 0.0009342432022094727, maxz - 0.03058292716741562),
2020 (minx + 0.0027115517295897007, miny + 0.0009342432022094727, maxz - 0.03058292716741562),
2021 (maxx - 0.004523299168795347, miny, maxz - 0.026820629835128784),
2022 (minx + 0.004523322451859713, miny, maxz - 0.026820629835128784),
2023 (maxx - 0.004523299168795347, miny, maxz - 0.02980007231235504),
2024 (minx + 0.004523322451859713, miny, maxz - 0.02980007231235504)]
2026 # Faces
2027 myfaces = [(28, 8, 0, 20), (174, 167, 12, 15), (19, 4, 9, 26), (173, 162, 8, 28), (10, 25, 17, 1),
2028 (12, 29, 21, 3), (29, 28, 20, 21), (164, 171, 25, 10), (171, 161, 24, 25), (7, 18, 27, 11),
2029 (18, 19, 26, 27), (167, 169, 29, 12), (169, 173, 28, 29), (32, 40, 47, 39), (39, 47, 46, 38),
2030 (38, 46, 45, 37), (37, 45, 44, 36), (36, 44, 43, 35), (35, 43, 42, 34), (34, 42, 41, 33),
2031 (33, 41, 40, 32), (68, 92, 84, 60), (55, 63, 62, 54), (67, 91, 92, 68), (53, 61, 60, 52),
2032 (56, 80, 72, 48), (51, 59, 58, 50), (66, 90, 82, 58), (49, 57, 56, 48), (69, 93, 94, 70),
2033 (63, 71, 70, 62), (62, 86, 78, 54), (61, 69, 68, 60), (71, 95, 88, 64), (59, 67, 66, 58),
2034 (60, 84, 76, 52), (57, 65, 64, 56), (65, 66, 67, 68, 69, 70, 71, 64), (72, 80, 87, 79), (78, 86, 85, 77),
2035 (76, 84, 83, 75), (74, 82, 81, 73), (80, 88, 95, 87), (86, 94, 93, 85), (84, 92, 91, 83),
2036 (82, 90, 89, 81), (65, 89, 90, 66), (70, 94, 86, 62), (49, 73, 81, 57), (64, 88, 80, 56),
2037 (48, 55, 79, 72), (51, 75, 83, 59), (54, 53, 77, 78), (53, 77, 85, 61), (57, 81, 89, 65),
2038 (52, 51, 75, 76), (55, 79, 87, 63), (59, 83, 91, 67), (50, 49, 73, 74), (61, 85, 93, 69),
2039 (63, 87, 95, 71), (58, 82, 74, 50), (133, 109, 117, 141), (128, 104, 96, 120), (130, 106, 98, 122),
2040 (141, 142, 118, 117), (132, 108, 100, 124), (136, 112, 104, 128), (139, 140, 116, 115),
2041 (134, 110, 102, 126),
2042 (138, 114, 106, 130), (137, 138, 114, 113), (140, 116, 108, 132), (143, 136, 112, 119),
2043 (127, 103, 111, 135),
2044 (142, 118, 110, 134), (121, 97, 105, 129), (126, 102, 101, 125), (109, 101, 102, 110),
2045 (107, 99, 100, 108),
2046 (105, 97, 98, 106), (111, 103, 96, 104), (117, 109, 110, 118), (115, 107, 108, 116),
2047 (113, 105, 106, 114),
2048 (119, 111, 104, 112), (126, 125, 124, 123, 122, 121, 120, 127), (134, 126, 127, 135),
2049 (131, 107, 115, 139),
2050 (132, 124, 125, 133),
2051 (120, 96, 103, 127), (130, 122, 123, 131), (129, 105, 113, 137),
2052 (128, 120, 121, 129), (122, 98, 97, 121),
2053 (142, 134, 135, 143), (125, 101, 109, 133), (140, 132, 133, 141),
2054 (135, 111, 119, 143), (138, 130, 131, 139),
2055 (124, 100, 99, 123), (136, 128, 129, 137), (123, 99, 107, 131),
2056 (158, 150, 151, 159), (157, 149, 150, 158),
2057 (156, 148, 149, 157), (155, 147, 148, 156), (154, 146, 147, 155),
2058 (153, 145, 146, 154), (152, 144, 145, 153),
2059 (159, 151, 144, 152), (197, 193, 167, 174), (26, 9, 163, 172),
2060 (196, 190, 162, 173), (9, 13, 175, 163),
2061 (192, 195, 171, 164), (23, 22, 160, 170), (195, 191, 161, 171),
2062 (11, 27, 168, 166), (193, 194, 169, 167),
2063 (27, 26, 172, 168), (173, 169, 177, 179), (198, 199, 179, 177),
2064 (168, 172, 178, 176), (196, 173, 179, 199),
2065 (185, 168, 176, 188), (160, 165, 183, 180), (172, 163, 181, 187),
2066 (170, 160, 180, 186), (166, 168, 185, 184),
2067 (176, 178, 189, 188), (172, 187, 189, 178), (209, 185, 188, 212),
2068 (222, 218, 193, 197), (221, 216, 190, 196),
2069 (220, 217, 191, 195), (218, 219, 194, 193), (199, 198, 202, 203),
2070 (221, 196, 199, 225), (169, 194, 198, 177),
2071 (226, 227, 203, 202), (225, 199, 203, 227), (212, 188, 200, 214),
2072 (188, 189, 201, 200), (219, 209, 212, 224),
2073 (180, 183, 207, 205), (187, 181, 204, 211), (182, 186, 210, 206),
2074 (186, 180, 205, 210), (184, 185, 209, 208),
2075 (187, 211, 213, 189), (200, 201, 215, 214), (189, 213, 215, 201),
2076 (224, 212, 214, 226), (211, 204, 216, 221),
2077 (210, 205, 217, 220), (208, 209, 219, 218), (211, 221, 225, 213),
2078 (227, 226, 230, 231), (213, 225, 227, 215),
2079 (194, 219, 224, 198), (198, 224, 226, 202), (228, 229, 231, 230),
2080 (215, 227, 231, 229), (226, 214, 228, 230),
2081 (214, 215, 229, 228), (24, 15, 2, 30), (15, 12, 3, 2), (16, 6, 14, 22), (161, 174, 15, 24),
2082 (6, 7, 11, 14), (8, 10, 1, 0), (21, 30, 2, 3), (19, 31, 5, 4), (4, 5, 13, 9),
2083 (162, 164, 10, 8), (25, 24, 30, 17), (5, 31, 23, 13), (31, 16, 22, 23), (0, 1, 17, 20),
2084 (20, 17, 30, 21), (7, 6, 16, 18), (18, 16, 31, 19), (40, 72, 79, 47), (47, 79, 78, 46),
2085 (46, 78, 77, 45), (45, 77, 76, 44), (44, 76, 75, 43), (43, 75, 74, 42), (42, 74, 73, 41),
2086 (41, 73, 72, 40), (79, 55, 54, 78), (77, 53, 52, 76), (75, 51, 50, 74), (73, 49, 48, 72),
2087 (118, 142, 143, 119), (116, 140, 141, 117), (114, 138, 139, 115),
2088 (112, 136, 137, 113), (150, 118, 119, 151),
2089 (149, 117, 118, 150), (148, 116, 117, 149), (147, 115, 116, 148),
2090 (146, 114, 115, 147), (145, 113, 114, 146),
2091 (144, 112, 113, 145), (151, 119, 112, 144), (22, 14, 165, 160),
2092 (191, 197, 174, 161), (14, 11, 166, 165),
2093 (190, 192, 164, 162), (13, 23, 170, 175), (165, 166, 184, 183),
2094 (163, 175, 182, 181), (175, 170, 186, 182),
2095 (217, 222, 197, 191), (216, 223, 192, 190), (223, 220, 195, 192),
2096 (183, 184, 208, 207), (181, 182, 206, 204),
2097 (205, 207, 222, 217), (207, 208, 218, 222), (204, 206, 223, 216), (206, 210, 220, 223)]
2099 mesh = bpy.data.meshes.new(objname)
2100 myobject = bpy.data.objects.new(objname, mesh)
2102 myobject.location = bpy.context.scene.cursor_location
2103 bpy.context.scene.objects.link(myobject)
2105 mesh.from_pydata(myvertex, [], myfaces)
2106 mesh.update(calc_edges=True)
2108 # Create materials
2109 if mat and bpy.context.scene.render.engine == 'CYCLES':
2110 plastic = create_diffuse_material("Plastic_Handle_material", False, 0.01, 0.01, 0.01, 0.082, 0.079, 0.02, 0.01)
2111 set_material(myobject, plastic)
2113 return myobject
2116 # ------------------------------------------------------------------------------
2117 # Create rectangular sill
2119 # objName: Object name
2120 # x: size x axis
2121 # y: size y axis
2122 # z: size z axis
2123 # mat: material flag
2124 # ------------------------------------------------------------------------------
2125 def create_sill(objname, x, y, z, mat):
2126 myvertex = [(-x / 2, 0, 0.0),
2127 (-x / 2, y, 0.0),
2128 (x / 2, y, 0.0),
2129 (x / 2, 0, 0.0),
2130 (-x / 2, 0, -z),
2131 (-x / 2, y, -z),
2132 (x / 2, y, -z),
2133 (x / 2, 0, -z)]
2135 myfaces = [(0, 1, 2, 3), (0, 1, 5, 4), (1, 2, 6, 5), (2, 6, 7, 3), (5, 6, 7, 4), (0, 4, 7, 3)]
2137 mesh = bpy.data.meshes.new(objname)
2138 myobject = bpy.data.objects.new(objname, mesh)
2140 myobject.location = bpy.context.scene.cursor_location
2141 bpy.context.scene.objects.link(myobject)
2143 mesh.from_pydata(myvertex, [], myfaces)
2144 mesh.update(calc_edges=True)
2146 if mat and bpy.context.scene.render.engine == 'CYCLES':
2147 mymat = create_diffuse_material("Sill_material", False, 0.8, 0.8, 0.8)
2148 set_material(myobject, mymat)
2150 return myobject
2153 # ------------------------------------------------------------------------------
2154 # Create blind box
2156 # objName: Object name
2157 # x: size x axis
2158 # y: size y axis
2159 # z: size z axis
2160 # mat: material flag
2161 # ------------------------------------------------------------------------------
2162 def create_blind_box(objname, x, y, z):
2163 myvertex = [(-x / 2, 0, 0.0),
2164 (-x / 2, y, 0.0),
2165 (x / 2, y, 0.0),
2166 (x / 2, 0, 0.0),
2167 (-x / 2, 0, z),
2168 (-x / 2, y, z),
2169 (x / 2, y, z),
2170 (x / 2, 0, z)]
2172 myfaces\
2173 = [(0, 1, 2, 3), (0, 1, 5, 4), (1, 2, 6, 5), (2, 6, 7, 3), (5, 6, 7, 4), (0, 4, 7, 3)]
2175 mesh = bpy.data.meshes.new(objname)
2176 myobject = bpy.data.objects.new(objname, mesh)
2178 myobject.location = bpy.context.scene.cursor_location
2179 bpy.context.scene.objects.link(myobject)
2181 mesh.from_pydata(myvertex, [], myfaces)
2182 mesh.update(calc_edges=True)
2184 return myobject
2187 # ------------------------------------------------------------------------------
2188 # Create blind rails
2190 # objName: Name for the new object
2191 # sX: Size in X axis
2192 # sZ: Size in Z axis
2193 # pX: position X axis
2194 # pY: position Y axis
2195 # pZ: position Z axis
2196 # mat: Flag for creating materials
2197 # matdata: Aluminum material
2198 # blind_rail: distance of the rail
2199 # ------------------------------------------------------------------------------
2200 def create_blind_rail(objname, sx, sz, px, py, pz, mat, matdata, blind_rail):
2201 myvertex = []
2202 myfaces = []
2203 sideb = 0.04
2204 space = 0.012 # blind is 10 mm thick
2205 thicka = 0.002 # aluminum thickness
2206 thickb = 0.002 # aluminum thickness
2208 for x in (-sx / 2, sx / 2):
2209 for z in (0, sz):
2210 myvertex.extend([(x, 0, z),
2211 (x, blind_rail, z),
2212 (x + sideb, blind_rail, z),
2213 (x + sideb, blind_rail - thicka, z),
2214 (x + thickb, blind_rail - thicka, z),
2215 (x + thickb, blind_rail - thicka - space, z),
2216 (x + sideb, blind_rail - thicka - space, z),
2217 (x + sideb, blind_rail - thicka - space - thicka, z),
2218 (x + thickb, blind_rail - thicka - space - thicka, z),
2219 (x + thickb, 0, z)])
2221 # reverse
2222 thickb *= -1
2223 sideb *= -1
2225 # Faces
2226 myfaces.extend([(31, 30, 20, 21), (32, 31, 21, 22), (33, 32, 22, 23), (37, 36, 26, 27), (35, 34, 24, 25),
2227 (26, 36, 35, 25), (37, 27, 28, 38), (33, 23, 24, 34), (39, 38, 28, 29), (37, 38, 35, 36),
2228 (31, 32, 33, 34), (31, 34, 39, 30), (21, 24, 23, 22), (27, 26, 25, 28), (21, 20, 29, 24),
2229 (11, 1, 0, 10), (12, 2, 1, 11), (13, 14, 4, 3), (12, 13, 3, 2), (17, 7, 6, 16),
2230 (16, 6, 5, 15), (14, 15, 5, 4), (17, 18, 8, 7), (19, 9, 8, 18), (17, 16, 15, 18),
2231 (11, 14, 13, 12), (11, 10, 19, 14), (7, 8, 5, 6), (2, 3, 4, 1), (1, 4, 9, 0)])
2233 mymesh = bpy.data.meshes.new(objname)
2234 myblind = bpy.data.objects.new(objname, mymesh)
2236 myblind.location[0] = px
2237 myblind.location[1] = py
2238 myblind.location[2] = pz
2239 bpy.context.scene.objects.link(myblind)
2241 mymesh.from_pydata(myvertex, [], myfaces)
2242 mymesh.update(calc_edges=True)
2244 if mat and bpy.context.scene.render.engine == 'CYCLES':
2245 set_material(myblind, matdata)
2247 return myblind
2250 # ------------------------------------------------------------------------------
2251 # Create blind estructure
2253 # objName: Name for the new object
2254 # sX: Size in X axis
2255 # sY: Size in Y axis
2256 # sZ: Size in Z axis
2257 # pX: position X axis
2258 # pY: position Y axis
2259 # pZ: position Z axis
2260 # mat: Flag for creating materials
2261 # blind_ratio: extension factor
2262 # ------------------------------------------------------------------------------
2263 def create_blind(objname, sx, sz, px, py, pz, mat, blind_ratio):
2264 myvertex = []
2265 myfaces = []
2266 v = 0
2267 h = 0.05
2268 railgap = 0.005
2269 # calculate total pieces
2270 pieces = int((sz * (blind_ratio / 100)) / h)
2271 if pieces * h < sz:
2272 pieces += 1
2274 z = h
2275 for p in range(pieces):
2276 for x in (-sx / 2, sx / 2):
2277 myvertex.extend([(x, 0, z),
2278 (x, 0, z + h - railgap),
2279 (x, 0.002, z + h - railgap),
2280 (x, 0.002, z + h),
2281 (x, 0.008, z + h),
2282 (x, 0.008, z + h - railgap),
2283 (x, 0.01, z + h - railgap),
2284 (x, 0.01, z)])
2286 z -= h
2287 # Faces
2288 myfaces.extend([(v + 15, v + 7, v + 6, v + 14), (v + 7, v + 15, v + 8, v + 0),
2289 (v + 9, v + 1, v + 0, v + 8),
2290 (v + 10, v + 2, v + 1, v + 9), (v + 13, v + 14, v + 6, v + 5),
2291 (v + 13, v + 5, v + 4, v + 12), (v + 10, v + 11, v + 3, v + 2),
2292 (v + 4, v + 3, v + 11, v + 12)])
2293 v = len(myvertex)
2295 mymesh = bpy.data.meshes.new(objname)
2296 myblind = bpy.data.objects.new(objname, mymesh)
2298 myblind.location[0] = px
2299 myblind.location[1] = py
2300 myblind.location[2] = pz
2301 bpy.context.scene.objects.link(myblind)
2303 mymesh.from_pydata(myvertex, [], myfaces)
2304 mymesh.update(calc_edges=True)
2306 myblind.lock_location = (True, True, False) # only Z axis
2308 if mat and bpy.context.scene.render.engine == 'CYCLES':
2309 mat = create_diffuse_material("Blind_plastic_material", False, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.15)
2310 set_material(myblind, mat)
2312 return myblind