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