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