Update for changes in Blender's API
[blender-addons.git] / archimesh / achm_curtain_maker.py
blobc02d821432ab9fc16ed09758566491c2cb48d496
1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
19 # <pep8 compliant>
21 # ----------------------------------------------------------
22 # Automatic generation of curtains
23 # Author: Antonio Vazquez (antonioya)
25 # ----------------------------------------------------------
26 # noinspection PyUnresolvedReferences
27 import bpy
28 from copy import copy
29 from math import cos, sin, radians
30 from bpy.types import Operator
31 from .achm_tools import *
34 # ------------------------------------------------------------------
35 # Define UI class
36 # Japanese curtains
37 # ------------------------------------------------------------------
38 class AchmJapan(Operator):
39 bl_idname = "mesh.archimesh_japan"
40 bl_label = "Japanese curtains"
41 bl_description = "Japanese curtains Generator"
42 bl_category = 'Archimesh'
43 bl_options = {'REGISTER', 'UNDO'}
45 width = bpy.props.FloatProperty(
46 name='Width',
47 min=0.30, max=4, default=1, precision=3,
48 description='Total width',
50 height = bpy.props.FloatProperty(
51 name='Height',
52 min=0.20, max=50, default=1.8, precision=3,
53 description='Total height',
55 num = bpy.props.IntProperty(
56 name='Rails',
57 min=2, max=5, default=2,
58 description='Number total of rails',
60 palnum = bpy.props.IntProperty(
61 name='Panels',
62 min=1, max=2, default=1,
63 description='Panels by rail',
66 open01 = bpy.props.FloatProperty(
67 name='Position 01',
68 min=0, max=1, default=0, precision=3,
69 description='Position of the panel',
71 open02 = bpy.props.FloatProperty(
72 name='Position 02',
73 min=0, max=1, default=0, precision=3,
74 description='Position of the panel',
76 open03 = bpy.props.FloatProperty(
77 name='Position 03',
78 min=0, max=1, default=0, precision=3,
79 description='Position of the panel',
81 open04 = bpy.props.FloatProperty(
82 name='Position 04',
83 min=0, max=1, default=0, precision=3,
84 description='Position of the panel',
86 open05 = bpy.props.FloatProperty(
87 name='Position 05',
88 min=0, max=1, default=0, precision=3,
89 description='Position of the panel',
92 # Materials
93 crt_mat = bpy.props.BoolProperty(
94 name="Create default Cycles materials",
95 description="Create default materials for Cycles render",
96 default=True,
99 # -----------------------------------------------------
100 # Draw (create UI interface)
101 # -----------------------------------------------------
102 # noinspection PyUnusedLocal
103 def draw(self, context):
104 layout = self.layout
105 space = bpy.context.space_data
106 if not space.local_view:
107 # Imperial units warning
108 if bpy.context.scene.unit_settings.system == "IMPERIAL":
109 row = layout.row()
110 row.label("Warning: Imperial units not supported", icon='COLOR_RED')
112 box = layout.box()
113 row = box.row()
114 row.prop(self, 'width')
115 row.prop(self, 'height')
116 row = box.row()
117 row.prop(self, 'num')
118 row.prop(self, 'palnum')
120 if self.num >= 1:
121 row = box.row()
122 row.prop(self, 'open01', slider=True)
123 if self.num >= 2:
124 row = box.row()
125 row.prop(self, 'open02', slider=True)
126 if self.num >= 3:
127 row = box.row()
128 row.prop(self, 'open03', slider=True)
129 if self.num >= 4:
130 row = box.row()
131 row.prop(self, 'open04', slider=True)
132 if self.num >= 5:
133 row = box.row()
134 row.prop(self, 'open05', slider=True)
136 box = layout.box()
137 if not context.scene.render.engine == 'CYCLES':
138 box.enabled = False
139 box.prop(self, 'crt_mat')
140 if self.crt_mat:
141 box.label("* Remember to verify fabric texture folder")
142 else:
143 row = layout.row()
144 row.label("Warning: Operator does not work in local view mode", icon='ERROR')
146 # -----------------------------------------------------
147 # Execute
148 # -----------------------------------------------------
149 # noinspection PyUnusedLocal
150 def execute(self, context):
151 if bpy.context.mode == "OBJECT":
152 create_japan_mesh(self)
153 return {'FINISHED'}
154 else:
155 self.report({'WARNING'}, "Archimesh: Option only valid in Object mode")
156 return {'CANCELLED'}
159 # ------------------------------------------------------------------------------
160 # Generate mesh data
161 # All custom values are passed using self container (self.myvariable)
162 # ------------------------------------------------------------------------------
163 def create_japan_mesh(self):
164 # deactivate others
165 for o in bpy.data.objects:
166 if o.select is True:
167 o.select = False
168 bpy.ops.object.select_all(False)
169 # Create units
170 generate_japan(self)
172 return
175 # ------------------------------------------------------------------
176 # Define UI class
177 # Roller curtains
178 # ------------------------------------------------------------------
179 class AchmRoller(Operator):
180 bl_idname = "mesh.archimesh_roller"
181 bl_label = "Roller curtains"
182 bl_description = "Roller_curtains Generator"
183 bl_category = 'Archimesh'
184 bl_options = {'REGISTER', 'UNDO'}
186 width = bpy.props.FloatProperty(
187 name='Width',
188 min=0.30, max=4, default=1, precision=3,
189 description='Total width',
191 height = bpy.props.FloatProperty(
192 name='Height',
193 min=0.01, max=50, default=1.7, precision=3,
194 description='Total height',
197 # Materials
198 crt_mat = bpy.props.BoolProperty(
199 name="Create default Cycles materials",
200 description="Create default materials for Cycles render",
201 default=True,
204 # -----------------------------------------------------
205 # Draw (create UI interface)
206 # -----------------------------------------------------
207 # noinspection PyUnusedLocal
208 def draw(self, context):
209 layout = self.layout
210 space = bpy.context.space_data
211 if not space.local_view:
212 # Imperial units warning
213 if bpy.context.scene.unit_settings.system == "IMPERIAL":
214 row = layout.row()
215 row.label("Warning: Imperial units not supported", icon='COLOR_RED')
217 box = layout.box()
218 row = box.row()
219 row.prop(self, 'width')
220 row.prop(self, 'height')
222 box = layout.box()
223 if not context.scene.render.engine == 'CYCLES':
224 box.enabled = False
225 box.prop(self, 'crt_mat')
226 if self.crt_mat:
227 box.label("* Remember to verify fabric texture folder")
228 else:
229 row = layout.row()
230 row.label("Warning: Operator does not work in local view mode", icon='ERROR')
232 # -----------------------------------------------------
233 # Execute
234 # -----------------------------------------------------
235 # noinspection PyUnusedLocal
236 def execute(self, context):
237 if bpy.context.mode == "OBJECT":
238 create_roller_mesh(self)
239 return {'FINISHED'}
240 else:
241 self.report({'WARNING'}, "Archimesh: Option only valid in Object mode")
242 return {'CANCELLED'}
245 # ------------------------------------------------------------------------------
246 # Generate mesh data
247 # All custom values are passed using self container (self.myvariable)
248 # ------------------------------------------------------------------------------
249 def create_roller_mesh(self):
250 # deactivate others
251 for o in bpy.data.objects:
252 if o.select is True:
253 o.select = False
254 bpy.ops.object.select_all(False)
255 generate_roller(self)
257 return
260 # ------------------------------------------------------------------------------
261 # Generate japanese curtains
262 # All custom values are passed using self container (self.myvariable)
263 # ------------------------------------------------------------------------------
264 def generate_japan(self):
265 support = []
266 panel = []
268 location = bpy.context.scene.cursor_location
269 myloc = copy(location) # copy location to keep 3D cursor position
271 # ------------------
272 # Rail
273 # ------------------
274 myrail = create_japan_rail("Rail",
275 self.width - 0.02, self.num,
276 myloc.x, myloc.y, myloc.z,
277 self.crt_mat)
278 # refine
279 remove_doubles(myrail)
280 set_normals(myrail)
282 # --------------------------------------------------------------------------------
283 # Supports
284 # --------------------------------------------------------------------------------
285 width = (self.width / self.num) / self.palnum
286 # left
287 posx = 0.01 + 0.01
288 posy = 0.006
289 posz = 0.006
290 for x in range(self.num):
291 mysup = create_japan_support("Support_" + str(x) + ".L",
292 width - 0.02, # subtract 2 cm
293 0, 0, 0,
294 self.crt_mat)
295 support.extend([mysup])
296 mysup.parent = myrail
298 if x == 0:
299 f = self.open01
300 if x == 1:
301 f = self.open02
302 if x == 2:
303 f = self.open03
304 if x == 3:
305 f = self.open04
306 if x == 4:
307 f = self.open05
309 if self.palnum == 1:
310 maxpos = ((self.width / self.palnum) - width - 0.02) * f
311 else:
312 maxpos = ((self.width / self.palnum) - width) * f
314 mysup.location.x = posx + maxpos
315 mysup.location.y = -posy
316 mysup.location.z = posz
318 posy += 0.015
319 # Right
320 if self.palnum > 1:
321 posx = self.width - width # + 0.01
322 posy = 0.006
323 posz = 0.006
324 for x in range(self.num):
325 mysup = create_japan_support("Support_" + str(x) + ".R",
326 width - 0.02, # subtract 2 cm
327 0, 0, 0,
328 self.crt_mat)
329 support.extend([mysup])
330 mysup.parent = myrail
332 if x == 0:
333 f = self.open01
334 if x == 1:
335 f = self.open02
336 if x == 2:
337 f = self.open03
338 if x == 3:
339 f = self.open04
340 if x == 4:
341 f = self.open05
343 maxpos = ((self.width / self.palnum) - width) * f
345 mysup.location.x = posx - maxpos
346 mysup.location.y = -posy
347 mysup.location.z = posz
349 posy += 0.015
350 # --------------------------------------------------------------------------------
351 # Panels
352 # --------------------------------------------------------------------------------
353 width = ((self.width / self.num) / self.palnum) + 0.01
354 posx = -0.01
355 posy = -0.006
356 posz = -0.008
357 x = 1
358 fabricmat = None
359 if self.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
360 fabricmat = create_fabric_material("Fabric_material", False, 0.653, 0.485, 0.265,
361 0.653, 0.485, 0.265)
363 for sup in support:
364 mypanel = create_japan_panel("Panel_" + str(x),
365 width, self.height,
366 0, 0, 0,
367 self.crt_mat, fabricmat)
368 panel.extend([mypanel])
369 mypanel.parent = sup
370 mypanel.location.x = posx
371 mypanel.location.y = posy
372 mypanel.location.z = posz
373 x += 1
374 # ------------------------
375 # Strings
376 # ------------------------
377 x = myrail.location.x
378 y = myrail.location.y
379 z = myrail.location.z
381 long = -1
382 if self.height < 1:
383 long = -self.height
385 myp = [((0, 0, 0), (- 0.25, 0, 0), (0.0, 0, 0)),
386 ((0, 0, long), (- 0.01, 0, long), (0.25, 0, long))] # double element
387 mycurve1 = create_bezier("String_1", myp, (x, y, z))
388 mycurve1.parent = myrail
389 mycurve1.location.x = self.width
390 mycurve1.location.y = -0.004
391 mycurve1.location.z = 0.005
393 mycurve2 = create_bezier("String_2", myp, (x, y, z))
394 mycurve2.parent = myrail
395 mycurve2.location.x = self.width
396 mycurve2.location.y = -0.01
397 mycurve2.location.z = 0.005
399 if self.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
400 mat = create_diffuse_material("String_material", False, 0.1, 0.1, 0.1,
401 0.1, 0.1, 0.1, 0.01)
402 set_material(mycurve1, mat)
403 set_material(mycurve2, mat)
405 # refine
406 for obj in support:
407 remove_doubles(obj)
408 set_normals(obj)
410 # deactivate others
411 for o in bpy.data.objects:
412 if o.select is True:
413 o.select = False
415 myrail.select = True
416 bpy.context.scene.objects.active = myrail
418 return
421 # ------------------------------------------------------------------------------
422 # Create japan rail
424 # objName: Name for the new object
425 # sX: Size in X axis
426 # ways: Number of ways
427 # pX: position X axis
428 # pY: position Y axis
429 # pZ: position Z axis
430 # mat: Flag for creating materials
431 # ------------------------------------------------------------------------------
432 def create_japan_rail(objname, sx, ways, px, py, pz, mat):
433 myvertex = []
434 myfaces = []
436 waysize = 0.005 # gap
437 sz = 0.0145
438 size = 0.005
439 sizeint = 0.01
440 tap = 0.01
441 sy = (size * 2) + (waysize * ways) + (sizeint * (ways - 1))
442 v = 0
443 # left extension
444 myvertex.extend([(0, 0, 0), (0, 0, sz), (0, -sy, sz), (0, -sy, 0),
445 (tap, 0, 0), (tap, 0, sz), (tap, -sy, sz), (tap, -sy, 0)])
446 myfaces.extend([(0, 1, 2, 3), (4, 5, 6, 7), (0, 1, 5, 4), (3, 2, 6, 7), (2, 1, 5, 6), (3, 0, 4, 7)])
447 v += 8
448 # Center
449 myvertex.extend([(tap, -size, size), (tap, -size, 0), (tap, 0, 0), (tap, 0, sz), (tap, -sy, sz), (tap, -sy, 0),
450 (tap, -sy + size, 0), (tap, -sy + size, sz - 0.002)])
451 myvertex.extend([(sx + tap, -size, size), (sx + tap, -size, 0), (sx + tap, 0, 0),
452 (sx + tap, 0, sz), (sx + tap, -sy, sz),
453 (sx + tap, -sy, 0), (sx + tap, -sy + size, 0), (sx + tap, -sy + size, sz - 0.002)])
454 myfaces.extend([(v, v + 8, v + 9, v + 1), (v + 1, v + 9, v + 10, v + 2), (v + 2, v + 10, v + 11, v + 3),
455 (v + 3, v + 11, v + 12, v + 4),
456 (v + 4, v + 12, v + 13, v + 5), (v + 5, v + 13, v + 14, v + 6), (v + 7, v + 15, v + 14, v + 6)])
457 v += 16
458 # Right extension
459 myvertex.extend([(sx + tap, 0, 0), (sx + tap, 0, sz), (sx + tap, -sy, sz),
460 (sx + tap, -sy, 0), (sx + tap + tap, 0, 0),
461 (sx + tap + tap, 0, sz), (sx + tap + tap, -sy, sz), (sx + tap + tap, -sy, 0)])
462 myfaces.extend([(v, v + 1, v + 2, v + 3), (v + 4, v + 5, v + 6, v + 7),
463 (v, v + 1, v + 5, v + 4), (v + 3, v + 2, v + 6, v + 7),
464 (v + 2, v + 1, v + 5, v + 6), (v + 3, v, v + 4, v + 7)])
465 v += 8
467 # Internal
468 space = waysize + size
469 if ways > 1:
470 for x in range(ways - 1):
471 myvertex.extend([(tap, -space, sz), (tap, -space, 0), (tap, -space - sizeint, 0),
472 (tap, -space - sizeint, size)])
473 myvertex.extend([(sx + tap, -space, sz), (sx + tap, -space, 0), (sx + tap, -space - sizeint, 0),
474 (sx + tap, -space - sizeint, size)])
475 myfaces.extend([(v, v + 4, v + 5, v + 1), (v + 1, v + 5, v + 6, v + 2), (v + 2, v + 6, v + 7, v + 3)])
476 v += 8
477 space = space + waysize + sizeint
479 mymesh = bpy.data.meshes.new(objname)
480 myobject = bpy.data.objects.new(objname, mymesh)
482 myobject.location[0] = px
483 myobject.location[1] = py
484 myobject.location[2] = pz
485 bpy.context.scene.objects.link(myobject)
487 mymesh.from_pydata(myvertex, [], myfaces)
488 mymesh.update(calc_edges=True)
490 # ---------------------------------
491 # Materials
492 # ---------------------------------
493 if mat and bpy.context.scene.render.engine == 'CYCLES':
494 # External
495 mat = create_diffuse_material(objname + "_material", False, 0.8, 0.8, 0.8, 0.6, 0.6, 0.6, 0.15)
496 set_material(myobject, mat)
498 return myobject
501 # ------------------------------------------------------------------------------
502 # Create japan support
504 # objName: Name for the new object
505 # sX: Size in X axis
506 # pX: position X axis
507 # pY: position Y axis
508 # pZ: position Z axis
509 # mat: Flag for creating materials
510 # ------------------------------------------------------------------------------
511 def create_japan_support(objname, sx, px, py, pz, mat):
512 myvertex = []
513 myfaces = []
515 waysize = 0.008
516 sz = 0.015
517 sy = 0.006
519 myvertex.extend([(0, 0, 0), (0, 0, -sz), (0, -sy, -sz), (0, -sy, -waysize), (0, -0.003, -waysize), (0, -0.003, 0)])
520 myvertex.extend(
521 [(sx, 0, 0), (sx, 0, -sz), (sx, -sy, -sz), (sx, -sy, - waysize), (sx, -0.003, -waysize), (sx, -0.003, 0)])
522 myfaces.extend(
523 [(0, 1, 7, 6), (2, 3, 9, 8), (1, 7, 8, 2), (3, 4, 10, 9), (4, 5, 11, 10), (0, 6, 11, 5), (0, 1, 2, 3, 4, 5),
524 (6, 7, 8, 9, 10, 11)])
526 mymesh = bpy.data.meshes.new(objname)
527 myobject = bpy.data.objects.new(objname, mymesh)
529 myobject.location[0] = px
530 myobject.location[1] = py
531 myobject.location[2] = pz
532 bpy.context.scene.objects.link(myobject)
534 mymesh.from_pydata(myvertex, [], myfaces)
535 mymesh.update(calc_edges=True)
537 # ---------------------------------
538 # Materials
539 # ---------------------------------
540 if mat and bpy.context.scene.render.engine == 'CYCLES':
541 # External
542 mat = create_diffuse_material(objname + "_material", False, 0.8, 0.8, 0.8, 0.6, 0.6, 0.6, 0.15)
543 set_material(myobject, mat)
545 return myobject
548 # ------------------------------------------------------------------------------
549 # Create japan panel
551 # objName: Name for the new object
552 # sX: Size in X axis
553 # sZ: Size in Z axis
554 # pX: position X axis
555 # pY: position Y axis
556 # pZ: position Z axis
557 # mat: Flag for creating materials
558 # fabricMat: Fabric material
559 # ------------------------------------------------------------------------------
560 def create_japan_panel(objname, sx, sz, px, py, pz, mat, fabricmat):
561 myvertex = []
562 myfaces = []
564 myvertex.extend([(0, 0, 0), (0, 0, -sz), (sx, 0, -sz), (sx, 0, 0)])
565 myfaces.extend([(0, 1, 2, 3)])
567 mymesh = bpy.data.meshes.new(objname)
568 myobject = bpy.data.objects.new(objname, mymesh)
570 myobject.location[0] = px
571 myobject.location[1] = py
572 myobject.location[2] = pz
573 bpy.context.scene.objects.link(myobject)
575 mymesh.from_pydata(myvertex, [], myfaces)
576 mymesh.update(calc_edges=True)
578 # ---------------------------------
579 # Materials
580 # ---------------------------------
581 if mat and bpy.context.scene.render.engine == 'CYCLES':
582 unwrap_mesh(myobject, True)
583 # remap UV to use all texture
584 for uv_loop in myobject.data.uv_layers.active.data:
585 myvector = uv_loop.uv
586 if myvector.x > 0.0001:
587 myvector.x = 1
589 set_material(myobject, fabricmat)
590 return myobject
593 # ------------------------------------------------------------------------------
594 # Create bezier curve
595 # ------------------------------------------------------------------------------
596 def create_bezier(objname, points, origin, depth=0.001, fill='FULL'):
597 curvedata = bpy.data.curves.new(name=objname, type='CURVE')
598 curvedata.dimensions = '3D'
599 curvedata.fill_mode = fill
600 curvedata.bevel_resolution = 5
601 curvedata.bevel_depth = depth
603 myobject = bpy.data.objects.new(objname, curvedata)
604 myobject.location = origin
606 bpy.context.scene.objects.link(myobject)
608 polyline = curvedata.splines.new('BEZIER')
609 polyline.bezier_points.add(len(points) - 1)
611 for idx, (knot, h1, h2) in enumerate(points):
612 point = polyline.bezier_points[idx]
613 point.co = knot
614 point.handle_left = h1
615 point.handle_right = h2
616 point.handle_left_type = 'FREE'
617 point.handle_right_type = 'FREE'
619 return myobject
622 # ------------------------------------------------------------------------------
623 # Generate Roller curtains
624 # All custom values are passed using self container (self.myvariable)
625 # ------------------------------------------------------------------------------
626 def generate_roller(self):
627 location = bpy.context.scene.cursor_location
628 myloc = copy(location) # copy location to keep 3D cursor position
630 # ------------------
631 # Roller Top
632 # ------------------
633 fabricsolid = None
634 if self.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
635 fabricsolid = create_diffuse_material("Fabric_solid_material", False, 0.653, 0.485, 0.265)
637 myroller = create_roller_rail("Roller",
638 self.width,
639 0.035,
640 myloc.x, myloc.y, myloc.z,
641 self.crt_mat, fabricsolid)
642 # refine
643 remove_doubles(myroller)
644 set_normals(myroller)
646 # --------------------------------------------------------------------------------
647 # Sides
648 # --------------------------------------------------------------------------------
649 plastic = None
650 if self.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
651 plastic = create_diffuse_material("Plastic_roller_material", False, 0.653, 0.485, 0.265, 0.653, 0.485, 0.265,
652 0.2)
654 myside_l = create_roller_sides(myroller, "L",
655 0.026, 0, 0,
656 self.crt_mat, plastic)
657 # refine
658 remove_doubles(myside_l)
659 set_normals(myside_l)
661 myside_r = create_roller_sides(myroller, "R",
662 self.width - 0.026, 0, 0,
663 self.crt_mat, plastic)
664 # refine
665 remove_doubles(myside_r)
666 set_normals(myside_r)
668 # --------------------------------------------------------------------------------
669 # Panel
670 # --------------------------------------------------------------------------------
671 fabricmat = None
672 if self.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
673 fabricmat = create_fabric_material("Fabric_translucent_material", False, 0.653, 0.485, 0.265, 0.653, 0.485,
674 0.265)
676 mypanel = create_japan_panel("Panel",
677 self.width, self.height,
678 0, 0, 0,
679 self.crt_mat, fabricmat)
680 mypanel.parent = myroller
681 mypanel.location.x = 0
682 mypanel.location.y = 0.035
683 mypanel.location.z = 0
684 # ------------------
685 # Roller Bottom
686 # ------------------
687 mybottom = create_roller_rail("Roller_bottom",
688 self.width,
689 0.001,
690 0, 0, -self.height,
691 self.crt_mat, plastic)
692 mybottom.parent = mypanel
693 # refine
694 remove_doubles(myroller)
695 set_normals(myroller)
697 # ------------------------
698 # Strings
699 # ------------------------
700 myp = [((0.0000, -0.0328, -0.0000), (0.0000, -0.0403, -0.3327), (0.0000, -0.0293, 0.1528)),
701 ((0.0000, 0.0000, 0.3900), (0.0000, -0.0264, 0.3900), (-0.0000, 0.0226, 0.3900)),
702 ((-0.0000, 0.0212, 0.0000), (-0.0000, 0.0189, 0.1525), (-0.0000, 0.0260, -0.3326)),
703 ((-0.0000, -0.0000, -0.8518), (-0.0000, 0.0369, -0.8391), (0.0000, -0.0373, -0.8646))] # double element
704 mycurve = create_bezier("String", myp, (0, 0, 0))
705 set_curve_cycle(mycurve)
706 mycurve.parent = myroller
707 mycurve.location.x = self.width + 0.015
708 mycurve.location.y = 0
709 mycurve.location.z = -0.38
710 if self.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
711 mat = create_diffuse_material("String_material", False, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.01)
712 set_material(mycurve, mat)
714 # deactivate others
715 for o in bpy.data.objects:
716 if o.select is True:
717 o.select = False
719 myroller.select = True
720 bpy.context.scene.objects.active = myroller
722 return
725 # ------------------------------------------------------------------------------
726 # Create roller
728 # objName: Object name
729 # width: Total width of roller
730 # radio: Roll radio
731 # pX: position X axis
732 # pY: position Y axis
733 # pZ: position Z axis
734 # mat: create default cycles material
735 # mymaterial: plastic material or fabric
736 # ------------------------------------------------------------------------------
737 def create_roller_rail(objname, width, radio, px, py, pz, mat, mymaterial):
738 myvertex = []
739 myfaces = []
740 pies = 16
741 seg = 0
743 # Add right circle
744 for i in range(pies):
745 x = cos(radians(seg)) * radio
746 y = sin(radians(seg)) * radio
747 mypoint = [(0.0, x, y)]
748 myvertex.extend(mypoint)
749 seg += 360 / pies
750 # Add left circle
751 seg = 0
752 for i in range(pies):
753 x = cos(radians(seg)) * radio
754 y = sin(radians(seg)) * radio
755 mypoint = [(width, x, y)]
756 myvertex.extend(mypoint)
757 seg += 360 / pies
758 # -------------------------------------
759 # Faces
760 # -------------------------------------
761 t = 1
762 for n in range(0, pies):
763 t += 1
764 if t > pies:
765 t = 1
766 myface = [(n, n - pies + 1, n + 1, n + pies)]
767 myfaces.extend(myface)
768 else:
769 myface = [(n, n + 1, n + pies + 1, n + pies)]
770 myfaces.extend(myface)
772 mymesh = bpy.data.meshes.new(objname)
773 myroll = bpy.data.objects.new(objname, mymesh)
774 bpy.context.scene.objects.link(myroll)
776 mymesh.from_pydata(myvertex, [], myfaces)
777 mymesh.update(calc_edges=True)
778 # Position
779 myroll.location.x = px
780 myroll.location.y = py
781 myroll.location.z = pz
783 # Materials
784 if mat and bpy.context.scene.render.engine == 'CYCLES':
785 set_material(myroll, mymaterial)
787 # Smooth
788 set_smooth(myroll)
790 return myroll
793 # ------------------------------------------------------------------------------
794 # Create roller sides
796 # myRoller: Roller to add sides
797 # side: Side of the cap R/L
798 # pX: position X axis
799 # pY: position Y axis
800 # pZ: position Z axis
801 # mat: create default cycles material
802 # plastic: plastic material
803 # ------------------------------------------------------------------------------
804 def create_roller_sides(myroller, side, px, py, pz, mat, plastic):
805 # Retry mesh data
806 mydata = roller_side()
808 # move data
809 myvertex = mydata[0]
810 myfaces = mydata[1]
812 mymesh = bpy.data.meshes.new("Side." + side)
813 myside = bpy.data.objects.new("Side." + side, mymesh)
814 bpy.context.scene.objects.link(myside)
815 mymesh.from_pydata(myvertex, [], myfaces)
816 mymesh.update(calc_edges=True)
817 # Position
818 myside.location.x = px
819 myside.location.y = py
820 myside.location.z = pz
821 # rotate
822 if side == "L":
823 myside.rotation_euler = (0, 0, radians(180))
824 # parent
825 myside.parent = myroller
827 # Materials
828 if mat and bpy.context.scene.render.engine == 'CYCLES':
829 set_material(myside, plastic)
831 # Smooth
832 set_smooth(myside)
833 set_modifier_subsurf(myside)
835 return myside
838 # ----------------------------------------------
839 # Roller side data
840 # ----------------------------------------------
841 def roller_side():
842 # ------------------------------------
843 # Mesh data
844 # ------------------------------------
845 minx = -7.54842304218073e-08
846 maxx = 0.05209559202194214
847 miny = -0.04486268758773804
848 maxy = 0.04486268758773804
849 minz = -0.04486268758773804
850 maxz = 0.08202265202999115
852 # Vertex
853 myvertex = [(maxx - 0.004684023559093475, maxy, minz + 0.04486270064847542),
854 (maxx - 0.004684023559093475, maxy - 0.0034149661660194397, minz + 0.027694489806890488),
855 (maxx - 0.004684023559093475, maxy - 0.013139978051185608, minz + 0.013139985501766205),
856 (maxx - 0.004684023559093475, maxy - 0.02769448049366474, minz + 0.0034149736166000366),
857 (maxx - 0.004684023559093475, miny + 0.044862685327428764, minz),
858 (maxx - 0.004684023559093475, miny + 0.027694476768374443, minz + 0.0034149736166000366),
859 (maxx - 0.004684023559093475, miny + 0.013139978051185608, minz + 0.013139985501766205),
860 (maxx - 0.004684023559093475, miny + 0.0034149661660194397, minz + 0.02769448794424534),
861 (maxx - 0.004684023559093475, miny, minz + 0.04486269387439812),
862 (maxx - 0.004684023559093475, miny + 0.0034149624407291412, minz + 0.06203090213239193),
863 (maxx - 0.004684023559093475, miny + 0.013139966875314713, maxz - 0.050299935042858124),
864 (maxx - 0.004684023559093475, miny + 0.027694474905729294, maxz - 0.04057491198182106),
865 (maxx - 0.004684023559093475, maxy - 0.027694473043084145, maxz - 0.04057491570711136),
866 (maxx - 0.004684023559093475, maxy - 0.013139966875314713, maxz - 0.05029993876814842),
867 (maxx - 0.004684023559093475, maxy - 0.0034149587154388428, minz + 0.062030890956521034),
868 (maxx - 0.0046574510633945465, miny + 0.028278490528464317, minz + 0.0048249028623104095),
869 (maxx - 0.0046574510633945465, miny + 0.014219092205166817, minz + 0.014219097793102264),
870 (maxx - 0.0046574510633945465, miny + 0.004824899137020111, minz + 0.028278499841690063),
871 (maxx - 0.003122705966234207, maxy, minz + 0.04486270064847542),
872 (maxx - 0.003122705966234207, maxy - 0.0034149661660194397, minz + 0.027694489806890488),
873 (maxx - 0.003122705966234207, maxy - 0.013139978051185608, minz + 0.013139985501766205),
874 (maxx - 0.003122705966234207, maxy - 0.02769448049366474, minz + 0.0034149736166000366),
875 (maxx - 0.003149278461933136, maxy - 0.04486268735455812, maxz - 0.03868604078888893),
876 (maxx - 0.003149278461933136, maxy - 0.02827848680317402, maxz - 0.04198484495282173),
877 (maxx - 0.003149278461933136, maxy - 0.014219081029295921, maxz - 0.05137905105948448),
878 (maxx - 0.003149278461933136, maxy - 0.004824887961149216, minz + 0.06144687905907631),
879 (maxx - 0.02118653617799282, miny + 0.027694474905729294, maxz - 0.04057491570711136),
880 (maxx - 0.02118653617799282, miny + 0.013139966875314713, maxz - 0.050299935042858124),
881 (maxx - 0.02118653617799282, miny + 0.0034149624407291412, minz + 0.06203090213239193),
882 (maxx - 0.02118653617799282, miny, minz + 0.04486269262849252),
883 (maxx - 0.003122705966234207, miny, minz + 0.04486269387439812),
884 (maxx - 0.003122705966234207, miny + 0.0034149624407291412, minz + 0.06203090213239193),
885 (maxx - 0.003122705966234207, miny + 0.013139966875314713, maxz - 0.050299935042858124),
886 (maxx - 0.003122705966234207, miny + 0.027694474905729294, maxz - 0.04057491198182106),
887 (maxx - 0.02118653617799282, maxy - 0.02769448049366474, minz + 0.0034149661660194397),
888 (maxx - 0.02118653617799282, maxy - 0.013139978051185608, minz + 0.013139981776475906),
889 (maxx - 0.02118653617799282, maxy - 0.0034149661660194397, minz + 0.02769448794424534),
890 (maxx - 0.02118653617799282, maxy, minz + 0.044862699402576034),
891 (maxx - 0.020517520606517792, miny + 0.01146744191646576, minz + 0.03102993033826351),
892 (maxx - 0.020517520606517792, miny + 0.01930307224392891, minz + 0.019303075969219208),
893 (maxx - 0.020517520606517792, miny + 0.031029919162392616, minz + 0.01146744191646576),
894 (maxx - 0.020517520606517792, miny + 0.04486268576937835, minz + 0.008715935051441193),
895 (maxx - 0.003122705966234207, maxy - 0.013139966875314713, maxz - 0.02605174481868744),
896 (maxx, miny + 0.013139966875314713, maxz - 0.026319395750761032),
897 (maxx, miny + 0.027694474905729294, maxz - 0.026230186223983765),
898 (maxx, maxy - 0.013139966875314713, maxz - 0.02605174481868744),
899 (maxx - 0.0046574510633945465, miny + 0.0015261024236679077, minz + 0.04486269394558251),
900 (maxx - 0.0046574510633945465, miny + 0.004824895411729813, minz + 0.061446888372302055),
901 (maxx - 0.0046574510633945465, miny + 0.014219081029295921, maxz - 0.05137904919683933),
902 (maxx - 0.0046574510633945465, miny + 0.02827848680317402, maxz - 0.04198484495282173),
903 (maxx, maxy - 0.027694473043084145, maxz - 0.026230186223983765),
904 (maxx, maxy - 0.04486268735205459, maxz - 0.02629481628537178),
905 (maxx - 0.003122705966234207, maxy - 0.027694473043084145, maxz - 0.04057491570711136),
906 (maxx - 0.003122705966234207, maxy - 0.013139966875314713, maxz - 0.05029993876814842),
907 (maxx - 0.003122705966234207, maxy - 0.0034149587154388428, minz + 0.062030890956521034),
908 (maxx - 0.003149278461933136, maxy - 0.0015261024236679077, minz + 0.044862700489230356),
909 (maxx - 0.003149278461933136, maxy - 0.004824899137020111, minz + 0.028278501704335213),
910 (maxx - 0.003149278461933136, maxy - 0.014219092205166817, minz + 0.014219097793102264),
911 (maxx - 0.003149278461933136, maxy - 0.028278492391109467, minz + 0.0048249028623104095),
912 (maxx - 0.003149278461933136, miny + 0.0015261024236679077, minz + 0.04486269394558251),
913 (maxx - 0.003149278461933136, miny + 0.004824895411729813, minz + 0.061446888372302055),
914 (maxx - 0.003149278461933136, miny + 0.014219081029295921, maxz - 0.05137904919683933),
915 (maxx - 0.003149278461933136, miny + 0.02827848680317402, maxz - 0.04198484495282173),
916 (maxx - 0.02118653617799282, maxy - 0.0034149587154388428, minz + 0.062030889093875885),
917 (maxx - 0.02118653617799282, maxy - 0.013139966875314713, maxz - 0.05029993876814842),
918 (maxx - 0.02118653617799282, maxy - 0.027694473043084145, maxz - 0.04057491570711136),
919 (maxx - 0.02118653617799282, maxy - 0.04486268735205459, maxz - 0.03715994209051132),
920 (maxx - 0.020517520606517792, maxy - 0.011467430740594864, minz + 0.058695447631180286),
921 (maxx - 0.020517520606517792, maxy - 0.019303061068058014, maxz - 0.05646303482353687),
922 (maxx - 0.020517520606517792, maxy - 0.031029915437102318, maxz - 0.04862739145755768),
923 (maxx - 0.020517520606517792, maxy - 0.044862687395027134, maxz - 0.045875877141952515),
924 (maxx, miny + 0.0034149661660194397, minz + 0.02769448794424534),
925 (maxx, miny + 0.013139978051185608, minz + 0.013139985501766205),
926 (maxx, miny + 0.027694476768374443, minz + 0.0034149736166000366),
927 (maxx, miny + 0.044862685327428764, minz),
928 (maxx - 0.02118653617799282, miny + 0.0034149661660194397, minz + 0.02769448794424534),
929 (maxx - 0.02118653617799282, miny + 0.013139978051185608, minz + 0.013139981776475906),
930 (maxx - 0.02118653617799282, miny + 0.027694476768374443, minz + 0.0034149661660194397),
931 (maxx - 0.02118653617799282, miny + 0.044862685327428764, minz),
932 (maxx - 0.020517520606517792, maxy - 0.031029922887682915, minz + 0.01146744191646576),
933 (maxx - 0.020517520606517792, maxy - 0.01930307224392891, minz + 0.019303075969219208),
934 (maxx - 0.020517520606517792, maxy - 0.01146744191646576, minz + 0.03102993033826351),
935 (maxx - 0.020517520606517792, maxy - 0.008715927600860596, minz + 0.04486269835125789),
936 (maxx - 0.0046574510633945465, maxy - 0.04486268735455812, maxz - 0.03868604078888893),
937 (maxx - 0.0046574510633945465, maxy - 0.02827848680317402, maxz - 0.04198484495282173),
938 (maxx - 0.0046574510633945465, maxy - 0.014219081029295921, maxz - 0.05137905105948448),
939 (maxx - 0.0046574510633945465, maxy - 0.004824887961149216, minz + 0.06144687905907631),
940 (maxx - 0.0046574510633945465, maxy - 0.0015261024236679077, minz + 0.044862700489230356),
941 (maxx - 0.0046574510633945465, maxy - 0.004824899137020111, minz + 0.028278501704335213),
942 (maxx - 0.0046574510633945465, maxy - 0.014219092205166817, minz + 0.014219097793102264),
943 (maxx - 0.0046574510633945465, maxy - 0.028278492391109467, minz + 0.0048249028623104095),
944 (maxx - 0.003149278461933136, miny + 0.004824899137020111, minz + 0.028278499841690063),
945 (maxx - 0.003149278461933136, miny + 0.014219092205166817, minz + 0.014219097793102264),
946 (maxx - 0.003149278461933136, miny + 0.028278490528464317, minz + 0.0048249028623104095),
947 (maxx, miny, minz + 0.04486269387439812),
948 (maxx, miny + 0.0034149624407291412, minz + 0.06203090213239193),
949 (maxx, miny + 0.013139966875314713, maxz - 0.050299935042858124),
950 (maxx, miny + 0.027694474905729294, maxz - 0.04057491198182106),
951 (maxx - 0.020517520606517792, miny + 0.031029917299747467, maxz - 0.04862739145755768),
952 (maxx - 0.020517520606517792, miny + 0.019303061068058014, maxz - 0.056463029235601425),
953 (maxx - 0.020517520606517792, miny + 0.011467434465885162, minz + 0.05869545880705118),
954 (maxx - 0.020517520606517792, miny + 0.008715927600860596, minz + 0.04486269289324163),
955 (maxx - 0.003122705966234207, miny + 0.0034149661660194397, minz + 0.02769448794424534),
956 (maxx - 0.003122705966234207, miny + 0.013139978051185608, minz + 0.013139985501766205),
957 (maxx - 0.003122705966234207, miny + 0.027694476768374443, minz + 0.0034149736166000366),
958 (maxx - 0.003122705966234207, miny + 0.044862685327428764, minz),
959 (maxx, maxy - 0.02769448049366474, minz + 0.0034149736166000366),
960 (maxx, maxy - 0.013139978051185608, minz + 0.013139985501766205),
961 (maxx, maxy - 0.0034149661660194397, minz + 0.027694489806890488),
962 (maxx, maxy, minz + 0.04486270064847542),
963 (maxx, maxy - 0.0034149587154388428, minz + 0.062030890956521034),
964 (maxx, maxy - 0.013139966875314713, maxz - 0.05029993876814842),
965 (maxx, maxy - 0.027694473043084145, maxz - 0.04057491570711136),
966 (maxx, maxy - 0.04486268735205459, maxz - 0.03715994209051132),
967 (maxx - 0.003122705966234207, maxy - 0.027694473043084145, maxz - 0.026230186223983765),
968 (maxx - 0.003122705966234207, maxy - 0.04486268735205459, maxz - 0.02629481628537178),
969 (maxx - 0.003122705966234207, miny + 0.027694474905729294, maxz - 0.026230186223983765),
970 (maxx - 0.003122705966234207, miny + 0.013139966875314713, maxz - 0.026319395750761032),
971 (maxx - 0.003122705966234207, miny + 0.013139966875314713, maxz - 0.0018796995282173157),
972 (maxx - 0.01466318964958191, miny + 0.013139966875314713, maxz - 0.0018796995282173157),
973 (maxx, miny + 0.027694474905729294, maxz - 0.0017904937267303467),
974 (maxx, maxy - 0.013139966875314713, maxz - 0.001612052321434021),
975 (maxx - 0.009187713265419006, maxy - 0.013139966875314713, maxz - 0.02605174481868744),
976 (maxx - 0.009187713265419006, maxy - 0.027694473043084145, maxz - 0.026230186223983765),
977 (maxx - 0.009187713265419006, maxy - 0.04486268735205459, maxz - 0.02629481628537178),
978 (maxx - 0.009187713265419006, miny + 0.027694474905729294, maxz - 0.026230186223983765),
979 (maxx - 0.009187713265419006, miny + 0.013139966875314713, maxz - 0.026319395750761032),
980 (maxx - 0.003122705966234207, maxy - 0.013139966875314713, maxz - 0.001612052321434021),
981 (maxx - 0.01466318964958191, miny + 0.027694474905729294, maxz - 0.0017904937267303467),
982 (maxx, miny + 0.022660084068775177, minz + 0.03566607739776373),
983 (maxx, miny + 0.02786955051124096, minz + 0.027869559824466705),
984 (maxx, miny + 0.03566606715321541, minz + 0.022660093382000923),
985 (maxx, miny + 0.04486268649608238, minz + 0.020830770954489708),
986 (maxx, miny + 0.02083076350390911, minz + 0.044862694725740226),
987 (maxx, miny + 0.022660082206130028, minz + 0.05405931267887354),
988 (maxx, miny + 0.02786954492330551, minz + 0.061855828389525414),
989 (maxx, miny + 0.035666066221892834, maxz - 0.059820037335157394),
990 (maxx, maxy - 0.03566606715321541, minz + 0.022660093382000923),
991 (maxx, maxy - 0.02786955051124096, minz + 0.027869559824466705),
992 (maxx, maxy - 0.022660084068775177, minz + 0.035666078329086304),
993 (maxx, maxy - 0.02083076350390911, minz + 0.044862698354463326),
994 (maxx, maxy - 0.02266007848083973, minz + 0.05405930709093809),
995 (maxx, maxy - 0.02786954492330551, minz + 0.061855828389525414),
996 (maxx, maxy - 0.035666064359247684, maxz - 0.059820037335157394),
997 (maxx, maxy - 0.04486268734234705, maxz - 0.05799071677029133),
998 (maxx, miny + 0.04486268733843682, minz + 0.04486269544876009),
999 (maxx - 0.009557131677865982, maxy - 0.04486268735205459, maxz - 0.02464577928185463),
1000 (maxx - 0.009557131677865982, miny + 0.027694474905729294, maxz - 0.024581149220466614),
1001 (maxx - 0.009557131677865982, maxy - 0.013139966875314713, maxz - 0.024402707815170288),
1002 (maxx - 0.009557131677865982, miny + 0.013139966875314713, maxz - 0.02467035874724388),
1003 (maxx - 0.009557131677865982, maxy - 0.027694473043084145, maxz - 0.024581149220466614),
1004 (maxx - 0.015024378895759583, miny + 0.027694474905729294, maxz - 0.00017844140529632568),
1005 (maxx - 0.015024378895759583, miny + 0.013139966875314713, maxz - 0.0002676546573638916),
1006 (maxx - 0.015024378895759583, maxy - 0.04486268735205459, maxz - 0.0002430751919746399),
1007 (maxx - 0.015024378895759583, maxy - 0.027694473043084145, maxz - 0.00017844140529632568),
1008 (maxx - 0.015024378895759583, maxy - 0.013139966875314713, maxz),
1009 (maxx, miny + 0.013139966875314713, maxz - 0.0018796995282173157),
1010 (maxx - 0.01466318964958191, maxy - 0.04486268735205459, maxz - 0.001855120062828064),
1011 (maxx, maxy - 0.04486268735205459, maxz - 0.001855120062828064),
1012 (maxx - 0.01466318964958191, maxy - 0.027694473043084145, maxz - 0.0017904937267303467),
1013 (maxx - 0.01466318964958191, maxy - 0.013139966875314713, maxz - 0.001612052321434021),
1014 (maxx, maxy - 0.027694473043084145, maxz - 0.0017904937267303467),
1015 (maxx - 0.020517520606517792, miny + 0.014739999547600746, minz + 0.03238546848297119),
1016 (maxx - 0.020517520606517792, miny + 0.021807780489325523, minz + 0.02180778607726097),
1017 (maxx - 0.020517520606517792, miny + 0.03238545823842287, minz + 0.014740003272891045),
1018 (maxx - 0.020517520606517792, miny + 0.044862685933359736, minz + 0.012258127331733704),
1019 (maxx - 0.020517520606517792, maxy - 0.014739990234375, minz + 0.05733991041779518),
1020 (maxx - 0.020517520606517792, maxy - 0.021807771176099777, maxz - 0.05896773934364319),
1021 (maxx - 0.020517520606517792, maxy - 0.03238545451313257, maxz - 0.051899950951337814),
1022 (maxx - 0.020517520606517792, maxy - 0.044862687428120204, maxz - 0.049418069422245026),
1023 (maxx - 0.020517520606517792, maxy - 0.03238546196371317, minz + 0.014740003272891045),
1024 (maxx - 0.020517520606517792, maxy - 0.021807780489325523, minz + 0.02180778607726097),
1025 (maxx - 0.020517520606517792, maxy - 0.014739999547600746, minz + 0.03238546848297119),
1026 (maxx - 0.020517520606517792, maxy - 0.012258119881153107, minz + 0.04486269794694575),
1027 (maxx - 0.020517520606517792, miny + 0.03238545544445515, maxz - 0.051899950951337814),
1028 (maxx - 0.020517520606517792, miny + 0.021807771176099777, maxz - 0.05896773561835289),
1029 (maxx - 0.020517520606517792, miny + 0.014739995822310448, minz + 0.05733991973102093),
1030 (maxx - 0.020517520606517792, miny + 0.012258119881153107, minz + 0.04486269302378876),
1031 (minx, miny + 0.014739999547600746, minz + 0.03238546848297119),
1032 (minx, miny + 0.021807780489325523, minz + 0.02180778607726097),
1033 (minx, miny + 0.03238545823842287, minz + 0.014740003272891045),
1034 (minx, miny + 0.044862685933359736, minz + 0.012258127331733704),
1035 (minx, maxy - 0.014739990234375, minz + 0.05733991041779518),
1036 (minx, maxy - 0.021807771176099777, maxz - 0.05896773934364319),
1037 (minx, maxy - 0.03238545451313257, maxz - 0.051899950951337814),
1038 (minx, maxy - 0.044862687428120204, maxz - 0.049418069422245026),
1039 (minx, maxy - 0.03238546196371317, minz + 0.014740003272891045),
1040 (minx, maxy - 0.021807780489325523, minz + 0.02180778607726097),
1041 (minx, maxy - 0.014739999547600746, minz + 0.03238546848297119),
1042 (minx, maxy - 0.012258119881153107, minz + 0.04486269794694575),
1043 (minx, miny + 0.03238545544445515, maxz - 0.051899950951337814),
1044 (minx, miny + 0.021807771176099777, maxz - 0.05896773561835289),
1045 (minx, miny + 0.014739995822310448, minz + 0.05733991973102093),
1046 (minx, miny + 0.012258119881153107, minz + 0.04486269302378876)]
1048 # Faces
1049 myfaces = [(37, 0, 1, 36), (36, 1, 2, 35), (35, 2, 3, 34), (34, 3, 4, 78), (78, 4, 5, 77),
1050 (77, 5, 6, 76), (76, 6, 7, 75), (75, 7, 8, 29), (29, 8, 9, 28), (28, 9, 10, 27),
1051 (27, 10, 11, 26), (65, 12, 13, 64), (8, 7, 17, 46), (63, 14, 0, 37), (64, 13, 14, 63),
1052 (34, 78, 41, 79), (64, 63, 67, 68), (76, 75, 38, 39), (65, 64, 68, 69), (27, 26, 98, 99),
1053 (78, 77, 40, 41), (28, 27, 99, 100), (35, 34, 79, 80), (63, 37, 82, 67), (29, 28, 100, 101),
1054 (26, 66, 70, 98), (36, 35, 80, 81), (66, 65, 69, 70), (77, 76, 39, 40), (37, 36, 81, 82),
1055 (75, 29, 101, 38), (19, 18, 109, 108), (31, 32, 61, 60), (2, 1, 88, 89), (103, 102, 91, 92),
1056 (7, 6, 16, 17), (54, 18, 55, 25), (32, 33, 62, 61), (18, 19, 56, 55), (6, 5, 15, 16),
1057 (11, 10, 48, 49), (52, 53, 24, 23), (0, 14, 86, 87), (94, 71, 129, 133), (97, 113, 51, 44),
1058 (33, 32, 117, 116), (18, 54, 110, 109), (32, 31, 95, 96), (96, 97, 44, 43), (102, 103, 72, 71),
1059 (53, 52, 114, 42), (21, 20, 107, 106), (103, 104, 73, 72), (31, 30, 94, 95), (20, 19, 108, 107),
1060 (30, 102, 71, 94), (105, 21, 106, 74), (54, 53, 111, 110), (104, 105, 74, 73), (47, 46, 59, 60),
1061 (90, 89, 57, 58), (87, 86, 25, 55), (48, 47, 60, 61), (49, 48, 61, 62), (83, 49, 62, 22),
1062 (16, 15, 93, 92), (88, 87, 55, 56), (84, 83, 22, 23), (17, 16, 92, 91), (85, 84, 23, 24),
1063 (46, 17, 91, 59), (89, 88, 56, 57), (86, 85, 24, 25), (104, 103, 92, 93), (3, 2, 89, 90),
1064 (20, 21, 58, 57), (13, 12, 84, 85), (9, 8, 46, 47), (102, 30, 59, 91), (30, 31, 60, 59),
1065 (19, 20, 57, 56), (14, 13, 85, 86), (53, 54, 25, 24), (10, 9, 47, 48), (1, 0, 87, 88),
1066 (111, 53, 42, 45), (112, 111, 45, 50), (32, 96, 43, 117), (113, 112, 50, 51), (115, 116, 125, 124),
1067 (42, 114, 123, 122), (116, 117, 126, 125), (114, 115, 124, 123), (112, 113, 144, 143),
1068 (95, 94, 133, 134),
1069 (110, 111, 142, 141), (96, 95, 134, 135), (74, 106, 137, 132), (97, 96, 135, 136), (73, 74, 132, 131),
1070 (107, 108, 139, 138), (113, 97, 136, 144), (72, 73, 131, 130), (108, 109, 140, 139),
1071 (109, 110, 141, 140),
1072 (71, 72, 130, 129), (106, 107, 138, 137), (111, 112, 143, 142), (135, 134, 145), (137, 138, 145),
1073 (142, 143, 145), (136, 135, 145), (131, 132, 145), (143, 144, 145), (144, 136, 145),
1074 (130, 131, 145), (141, 142, 145), (129, 130, 145), (132, 137, 145), (133, 129, 145),
1075 (138, 139, 145), (134, 133, 145), (139, 140, 145), (140, 141, 145), (26, 11, 83, 66),
1076 (66, 83, 12, 65), (12, 83, 84), (22, 52, 23), (83, 11, 49), (21, 105, 58),
1077 (4, 90, 58, 105), (15, 4, 105, 93), (33, 22, 62), (4, 3, 90), (105, 104, 93),
1078 (5, 4, 15), (52, 22, 115, 114), (22, 33, 116, 115), (124, 125, 147, 146), (122, 123, 150, 148),
1079 (125, 126, 149, 147), (123, 124, 146, 150), (157, 128, 151, 153), (159, 157, 153, 154),
1080 (160, 159, 154, 155),
1081 (128, 119, 152, 151), (146, 147, 128, 157), (150, 146, 157, 159), (148, 150, 159, 160),
1082 (147, 149, 119, 128),
1083 (69, 68, 167, 168), (101, 100, 176, 177), (39, 38, 162, 163), (100, 99, 175, 176), (41, 40, 164, 165),
1084 (80, 79, 170, 171), (82, 81, 172, 173), (67, 82, 173, 166), (70, 69, 168, 169), (38, 101, 177, 162),
1085 (98, 70, 169, 174), (40, 39, 163, 164), (79, 41, 165, 170), (99, 98, 174, 175), (81, 80, 171, 172),
1086 (68, 67, 166, 167), (169, 168, 184, 185), (170, 165, 181, 186), (172, 171, 187, 188),
1087 (162, 177, 193, 178),
1088 (164, 163, 179, 180), (167, 166, 182, 183), (174, 169, 185, 190), (168, 167, 183, 184),
1089 (175, 174, 190, 191),
1090 (171, 170, 186, 187), (173, 172, 188, 189), (163, 162, 178, 179), (165, 164, 180, 181),
1091 (177, 176, 192, 193),
1092 (166, 173, 189, 182), (176, 175, 191, 192), (51, 50, 161, 158), (127, 160, 155), (156, 120, 151, 152),
1093 (155, 154, 161, 121), (161, 154, 153, 158), (42, 122, 148), (117, 149, 126), (127, 42, 148, 160),
1094 (118, 152, 119), (158, 153, 151, 120), (50, 45, 121, 161), (117, 118, 119, 149), (43, 44, 120, 156),
1095 (44, 51, 158, 120), (117, 43, 156, 118), (45, 42, 127, 121)]
1097 return myvertex, myfaces
1100 # --------------------------------------------------------------------
1101 # Set curve cycle
1103 # myObject: Curve obejct
1104 # --------------------------------------------------------------------
1105 def set_curve_cycle(myobject):
1106 bpy.context.scene.objects.active = myobject
1107 # go edit mode
1108 bpy.ops.object.mode_set(mode='EDIT')
1109 # select all faces
1110 bpy.ops.curve.select_all(action='SELECT')
1111 # St cyclic
1112 bpy.ops.curve.cyclic_toggle(direction='CYCLIC_U')
1113 # go object mode again
1114 bpy.ops.object.editmode_toggle()