File headers: use SPDX license identifiers
[blender-addons.git] / add_mesh_geodesic_domes / third_domes_panel_271.py
blobd95de427835ab0f20722ac7f5416352fb6f3cc2f
1 import bpy
2 import os
3 from . import vefm_271
4 from . import forms_271
5 from . import geodesic_classes_271
6 from . import add_shape_geodesic
8 from bpy.types import Operator
9 from bpy.props import (
10 EnumProperty,
11 IntProperty,
12 FloatProperty,
13 StringProperty,
14 BoolProperty,
15 FloatVectorProperty,
17 from math import pi
18 from mathutils import (
19 Vector,
20 Matrix,
22 from bpy_extras import object_utils
24 # global #
25 last_generated_object = None
26 last_imported_mesh = None
27 basegeodesic = None
28 imported_hubmesh_to_use = None
29 error_message = ""
30 geodesic_not_yet_called = True
31 # global end #
33 # ###### EIND FOR SHAPEKEYS ######
36 class GenerateGeodesicDome(Operator, object_utils.AddObjectHelper):
37 bl_label = "Modify Geodesic Objects"
38 bl_idname = "mesh.generate_geodesic_dome"
39 bl_description = "Create Geodesic Object Types"
40 bl_options = {'REGISTER', 'UNDO', 'PRESET'}
42 GeodesicDome : BoolProperty(name = "GeodesicDome",
43 default = True,
44 description = "GeodesicDome")
45 change : BoolProperty(name = "Change",
46 default = False,
47 description = "change Geodesic Dome")
49 gd_help_text_width: IntProperty(
50 name="Text Width",
51 description="The width above which the text wraps",
52 default=60,
53 max=180, min=20
55 mainpages: EnumProperty(
56 name="Menu",
57 description="Create Faces, Struts & Hubs",
58 items=[("Main", "Main", "Geodesic objects"),
59 ("Faces", "Faces", "Generate Faces"),
60 ("Struts", "Struts", "Generate Struts"),
61 ("Hubs", "Hubs", "Generate Hubs"),
62 ("Help", "Help", "Not implemented"),
64 default='Main'
66 # for Faces
67 facetype_menu: EnumProperty(
68 name="Faces",
69 description="choose a facetype",
70 items=[("0", "strip", "strip"),
71 ("1", "open vertical", "vertical"),
72 ("2", "open slanted", "slanted"),
73 ("3", "closed point", "closed point"),
74 ("4", "pillow", "pillow"),
75 ("5", "closed vertical", "closed vertical"),
76 ("6", "stepped", "stepped"),
77 ("7", "spikes", "spikes"),
78 ("8", "boxed", "boxed"),
79 ("9", "diamond", "diamond"),
80 # ("10", "bar", "bar"),
82 default='0'
84 facetoggle: BoolProperty(
85 name="Activate: Face Object",
86 description="Activate Faces for Geodesic object",
87 default=True
89 face_use_imported_object: BoolProperty(
90 name="Use: Imported Object",
91 description="Activate faces on your Imported object",
92 default=False
94 facewidth: FloatProperty(
95 name="Face Width",
96 min=-1, soft_min=0.001, max=4,
97 default=.50
99 fwtog: BoolProperty(
100 name="Width tweak",
101 default=False
103 faceheight: FloatProperty(
104 name="Face Height",
105 min=0.001, max=4,
106 default=1
108 fhtog: BoolProperty(
109 name="Height tweak",
110 default=False
112 face_detach: BoolProperty(
113 name="Detach Faces",
114 default=False
116 fmeshname: StringProperty(
117 name="Face Mesh name",
118 default="defaultface"
120 geodesic_types: EnumProperty(
121 name="Objects",
122 description="Choose Geodesic, Grid, Cylinder, Parabola, "
123 "Torus, Sphere, Import your mesh or Superparameters",
124 items=[("Geodesic", "Geodesic", "Generate Geodesic"),
125 ("Grid", "Grid", "Generate Grid"),
126 ("Cylinder", "Cylinder", "Generate Cylinder"),
127 ("Parabola", "Parabola", "Generate Parabola"),
128 ("Torus", "Torus", "Generate Torus"),
129 ("Sphere", "Sphere", "Generate Sphere"),
130 ("Import_your_mesh", "Import your mesh", "Import Your Mesh"),
132 default='Geodesic'
134 import_mesh_name: StringProperty(
135 name="Mesh to import",
136 description="the name has to be the name of a meshobject",
137 default="None"
139 base_type: EnumProperty(
140 name="Hedron",
141 description="Choose between Tetrahedron, Octahedron, Icosahedron ",
142 items=[("Tetrahedron", "Tetrahedron", "Generate Tetrahedron"),
143 ("Octahedron", "Octahedron", "Generate Octahedron"),
144 ("Icosahedron", "Icosahedron", "Generate Icosahedron"),
146 default='Tetrahedron'
148 orientation: EnumProperty(
149 name="Point^",
150 description="Point (Vert), Edge or Face pointing upwards",
151 items=[("PointUp", "PointUp", "Point up"),
152 ("EdgeUp", "EdgeUp", "Edge up"),
153 ("FaceUp", "FaceUp", "Face up"),
155 default='PointUp'
157 geodesic_class: EnumProperty(
158 name="Class",
159 description="Subdivide Basic/Triacon",
160 items=[("Class_1", "Class 1", "class one"),
161 ("Class_2", "Class 2", "class two"),
163 default='Class_1'
165 tri_hex_star: EnumProperty(
166 name="Shape",
167 description="Choose between tri hex star face types",
168 items=[("tri", "tri", "tri faces"),
169 ("hex", "hex", "hex faces(by tri)"),
170 ("star", "star", "star faces(by tri)"),
172 default='tri'
174 spherical_flat: EnumProperty(
175 name="Round",
176 description="Choose between spherical or flat ",
177 items=[("spherical", "spherical", "Generate spherical"),
178 ("flat", "flat", "Generate flat"),
180 default='spherical'
182 use_imported_mesh: BoolProperty(
183 name="use import",
184 description="Use an imported mesh",
185 default=False
187 # Cylinder
188 cyxres: IntProperty(
189 name="Resolution x/y",
190 min=3, #max=32,
191 description="Number of faces around x/y",
192 default=5
194 cyyres: IntProperty(
195 name="Resolution z",
196 min=3, #max=32,
197 description="Number of faces in z direction",
198 default=5
200 cyxsz: FloatProperty(
201 name="Scale x/y",
202 min=0.01, #max=10,
203 description="Scale in x/y direction",
204 default=1
206 cyysz: FloatProperty(
207 name="Scale z",
208 min=0.01, #max=10,
209 description="Scale in z direction",
210 default=1
212 cyxell: FloatProperty(
213 name="Stretch x",
214 min=0.001, #max=4,
215 description="Stretch in x direction",
216 default=1
218 cygap: FloatProperty(
219 name="Gap",
220 min=-2, #max=2,
221 description="Shrink in % around radius",
222 default=1
224 cygphase: FloatProperty(
225 name="Phase", min=-4, #max=4,
226 description="Rotate around pivot x/y",
227 default=0
229 # Parabola
230 paxres: IntProperty(
231 name="Resolution x/y",
232 min=3, #max=32,
233 description="Number of faces around x/y",
234 default=5
236 payres: IntProperty(
237 name="Resolution z",
238 min=3, #max=32,
239 description="Number of faces in z direction",
240 default=5
242 paxsz: FloatProperty(
243 name="Scale x/y",
244 min=0.001, #max=10,
245 description="scale in x/y direction",
246 default=0.30
248 paysz: FloatProperty(
249 name="Scale z",
250 min=0.001, #max=10,
251 description="Scale in z direction",
252 default=1
254 paxell: FloatProperty(
255 name="Stretch x",
256 min=0.001, #max=4,
257 description="Stretch in x direction",
258 default=1
260 pagap: FloatProperty(
261 name="Gap",
262 min=-2, #max=2,
263 description="Shrink in % around radius",
264 default=1
266 pagphase: FloatProperty(
267 name="Phase",
268 min=-4, #max=4,
269 description="Rotate around pivot x/y",
270 default=0
272 # Torus
273 ures: IntProperty(
274 name="Resolution x/y",
275 min=3, #max=32,
276 description="Number of faces around x/y",
277 default=8)
278 vres: IntProperty(
279 name="Resolution z",
280 min=3, #max=32,
281 description="Number of faces in z direction",
282 default=8)
283 urad: FloatProperty(
284 name="Radius x/y",
285 min=0.001, #max=10,
286 description="Radius in x/y plane",
287 default=1
289 vrad: FloatProperty(
290 name="Radius z",
291 min=0.001, #max=10,
292 description="Radius in z plane",
293 default=0.250
295 uellipse: FloatProperty(
296 name="Stretch x",
297 min=0.001, #max=10,
298 description="Number of faces in z direction",
299 default=1
301 vellipse: FloatProperty(
302 name="Stretch z",
303 min=0.001, #max=10,
304 description="Number of faces in z direction",
305 default=1
307 upart: FloatProperty(
308 name="Gap x/y",
309 min=-4,# max=4,
310 description="Shrink faces around x/y",
311 default=1
313 vpart: FloatProperty(
314 name="Gap z",
315 min=-4, #max=4,
316 description="Shrink faces in z direction",
317 default=1
319 ugap: FloatProperty(
320 name="Phase x/y",
321 min=-4, #max=4,
322 description="Rotate around pivot x/y",
323 default=0
325 vgap: FloatProperty(
326 name="Phase z",
327 min=-4, #max=4,
328 description="Rotate around pivot z",
329 default=0
331 uphase: FloatProperty(
332 name="uphase",
333 min=-4, #max=4,
334 description="Number of faces in z direction",
335 default=0
337 vphase: FloatProperty(
338 name="vphase",
339 min=-4, #max=4,
340 description="Number of faces in z direction",
341 default=0
343 uexp: FloatProperty(
344 name="uexp",
345 min=-4, #max=4,
346 description="Number of faces in z direction",
347 default=0
349 vexp: FloatProperty(
350 name="vexp",
351 min=-4, #max=4,
352 description="Number of faces in z direction",
353 default=0
355 usuper: FloatProperty(
356 name="usuper",
357 min=-4, #max=4,
358 description="First set of superform parameters",
359 default=2
361 vsuper: FloatProperty(
362 name="vsuper",
363 min=-4, #max=4,
364 description="Second set of superform parameters",
365 default=2
367 utwist: FloatProperty(
368 name="Twist x/y",
369 min=-4, #max=4,
370 description="Use with superformular u",
371 default=0
373 vtwist: FloatProperty(
374 name="Twist z",
375 min=-4, #max=4,
376 description="Use with superformular v",
377 default=0
379 # Sphere
380 bures: IntProperty(
381 name="Resolution x/y",
382 min=3, #max=32,
383 description="Number of faces around x/y",
384 default=8
386 bvres: IntProperty(
387 name="Resolution z",
388 min=3, #max=32,
389 description="Number of faces in z direction",
390 default=8
392 burad: FloatProperty(
393 name="Radius",
394 min=-4, #max=4,
395 description="overall radius",
396 default=1
398 bupart: FloatProperty(
399 name="Gap x/y",
400 min=-4, #max=4,
401 description="Shrink faces around x/y",
402 default=1
404 bvpart: FloatProperty(
405 name="Gap z",
406 min=-4, #max=4,
407 description="Shrink faces in z direction",
408 default=1
410 buphase: FloatProperty(
411 name="Phase x/y",
412 min=-4, #max=4,
413 description="Rotate around pivot x/y",
414 default=0
416 bvphase: FloatProperty(
417 name="Phase z",
418 min=-4, #max=4,
419 description="Rotate around pivot z",
420 default=0
422 buellipse: FloatProperty(
423 name="Stretch x",
424 min=0.001, #max=4,
425 description="Stretch in the x direction",
426 default=1
428 bvellipse: FloatProperty(
429 name="Stretch z",
430 min=0.001, #max=4,
431 description="Stretch in the z direction",
432 default=1
434 # Grid
435 grxres: IntProperty(
436 name="Resolution x",
437 min=2, #soft_max=10, max=20,
438 description="Number of faces in x direction",
439 default=5
441 gryres: IntProperty(
442 name="Resolution z",
443 min=2, soft_min=2,
444 #soft_max=10, max=20,
445 description="Number of faces in x direction",
446 default=2
448 grxsz: FloatProperty(
449 name="X size",
450 min=1, soft_min=0.01,
451 #soft_max=5, max=10,
452 description="X size",
453 default=2.0
455 grysz: FloatProperty(
456 name="Y size",
457 min=1, soft_min=0.01,
458 #soft_max=5, max=10,
459 description="Y size",
460 default=1.0
463 # PKHG_TODO_??? what means cart
464 cart: IntProperty(
465 name="cart",
466 min=0, #max=2,
467 default=0
469 frequency: IntProperty(
470 name="Frequency",
471 min=1, #max=8,
472 description="Subdivide base triangles",
473 default=1
475 eccentricity: FloatProperty(
476 name="Eccentricity",
477 min=0.01, #max=4,
478 description="Scaling in x/y dimension",
479 default=1
481 squish: FloatProperty(
482 name="Squish",
483 min=0.01,
484 #soft_max=4, max=10,
485 description="Scaling in z dimension",
486 default=1
488 radius: FloatProperty(
489 name="Radius",
490 min=0.01,
491 #soft_max=4, max=10,
492 description="Overall radius",
493 default=1
495 squareness: FloatProperty(
496 name="Square x/y",
497 min=0.1, #max=5,
498 description="Superelipse action in x/y",
499 default=2
501 squarez: FloatProperty(
502 name="Square z",
503 min=0.1, #soft_max=5, max=10,
504 description="Superelipse action in z",
505 default=2
507 baselevel: IntProperty(
508 name="baselevel",
509 default=5
511 dual: BoolProperty(
512 name="Dual",
513 description="Faces become verts, "
514 "verts become faces, edges flip",
515 default=False
517 rotxy: FloatProperty(
518 name="Rotate x/y",
519 min=-4, #max=4,
520 description="Rotate superelipse action in x/y",
521 default=0
523 rotz: FloatProperty(
524 name="Rotate z",
525 min=-4, #max=4,
526 description="Rotate superelipse action in z",
527 default=0
530 # for choice of superformula
531 uact: BoolProperty(
532 name="Superformula u (x/y)",
533 description="Activate superformula u parameters",
534 default=False
536 vact: BoolProperty(
537 name="Superformula v (z)",
538 description="Activate superformula v parameters",
539 default=False
541 um: FloatProperty(
542 name="Pinch x/y",
543 min=0, soft_min=0.1,
544 #soft_max=5, max=10,
545 description="Pinch the mesh on x/y",
546 default=3
548 un1: FloatProperty(
549 name="Squash x/y",
550 min=0, soft_min=0.1,
551 #soft_max=5, max=20,
552 description="Squash the mesh x/y",
553 default=1
555 un2: FloatProperty(
556 name="Inflate x/y",
557 min=0, soft_min=0.1,
558 #soft_max=5, max=10,
559 description="Inflate the mesh x/y",
560 default=1
562 un3: FloatProperty(
563 name="Roundify x/y",
564 min=0, soft_min=0.1,
565 #soft_max=5, max=10,
566 description="Roundify x/y",
567 default=1
569 ua: FloatProperty(
570 name="Shrink",
571 min=0, soft_min=0.1,
572 #soft_max=5, max=10,
573 description="Shrink",
574 default=1.0
576 ub: FloatProperty(
577 name="Shrink x/y",
578 min=0, soft_min=0.1,
579 #soft_max=5, max=10,
580 description="Shrink y/x",
581 default=4.0
583 vm: FloatProperty(
584 name="Scale Z Base",
585 min=0, soft_min=0.1,
586 #soft_max=5, max=10,
587 description="Scale Z Base",
588 default=1
590 vn1: FloatProperty(
591 name="Scale lock Top Z",
592 min=0, soft_min=0.1,
593 #soft_max=5, max=10,
594 description="Scale lock Top Z",
595 default=1
597 vn2: FloatProperty(
598 name="Inflate Base",
599 min=0, soft_min=0.1,
600 #soft_max=5, max=10,
601 description="Inflate Base",
602 default=1
604 vn3: FloatProperty(
605 name="Inflate",
606 min=0, soft_min=0.1,
607 #soft_max=5, max=10,
608 description="Inflate",
609 default=1
611 va: FloatProperty(
612 name="Scale 1",
613 min=0, soft_min=0.1,
614 #soft_max=5, max=10,
615 description="Scale 1",
616 default=1
618 vb: FloatProperty(
619 name="Scale 2",
620 min=0, soft_min=0.1,
621 #soft_max=5, max=10,
622 description="Scale 2",
623 default=1
626 uturn: FloatProperty(
627 name="x/y Vert cycle",
628 min=0, soft_min=0.1,
629 #soft_max=5, max=10,
630 description="x/y Vert cycle",
631 default=0
633 vturn: FloatProperty(
634 name="z Vert cycle",
635 min=0, soft_min=0.1,
636 #soft_max=5, max=10,
637 description="z Vert cycle",
638 default=0
640 utwist: FloatProperty(
641 name="x/y Twist cycle",
642 min=0, soft_min=0.1,
643 #soft_max=5, max=10,
644 description="x/y Twist cycle",
645 default=0
647 vtwist: FloatProperty(
648 name="z Twist cycle",
649 min=0, soft_min=0.1,
650 #soft_max=5, max=10,
651 description="z Twist cycle",
652 default=0
654 # Strut
655 struttype: IntProperty(
656 name="Strut type",
657 default=0
659 struttoggle: BoolProperty(
660 name="Use Struts",
661 default=False
663 strutimporttoggle: BoolProperty(
664 name="Strut import toggle",
665 default=False
667 strutimpmesh: StringProperty(
668 name="Strut import mesh",
669 default="None"
671 strutwidth: FloatProperty(
672 name="Strut width",
673 min=-10, soft_min=5,
674 #soft_max=5, max=10,
675 default=1
677 swtog: BoolProperty(
678 name="Width enable",
679 default=False
681 strutheight: FloatProperty(
682 name="Strut height",
683 min=-5, soft_min=-1,
684 #soft_max=5, max=10,
685 default=1
687 shtog: BoolProperty(
688 name="Height tweak",
689 default=False
691 strutshrink: FloatProperty(
692 name="Strut shrink",
693 min=0.001, #max=4,
694 default=1
696 sstog: BoolProperty(
697 name="Shrink tweak",
698 default=False
700 stretch: FloatProperty(
701 name="Stretch",
702 min=-4, #max=4,
703 default=1.0
705 lift: FloatProperty(
706 name="Lift",
707 min=0.001, #max=10,
708 default=0
710 smeshname: StringProperty(
711 name="Strut mesh name",
712 default="defaultstrut"
714 # Hubs
715 hubtype: BoolProperty(
716 name="Hub type",
717 description="not used",
718 default=True
720 hubtoggle: BoolProperty(
721 name="Use Hubs",
722 default=False
724 hubimporttoggle: BoolProperty(
725 name="New import",
726 description="Import a mesh",
727 default=False
729 hubimpmesh: StringProperty(
730 name="Hub mesh import",
731 description="Name of mesh to import",
732 default="None"
734 hubwidth: FloatProperty(
735 name="Hub width",
736 min=0.01, #max=10,
737 default=1
739 hwtog: BoolProperty(
740 name="Width tweak",
741 default=False
743 hubheight: FloatProperty(
744 name="Hub height",
745 min=0.01, #max=10,
746 default=1
748 hhtog: BoolProperty(
749 name="Height tweak",
750 default=False
752 hublength: FloatProperty(
753 name="Hub length",
754 min=0.1, #max=10,
755 default=1
757 hstog: BoolProperty(
758 name="Hub s tweak",
759 default=False
761 hmeshname: StringProperty(
762 name="Hub mesh name",
763 description="Name of an existing mesh needed!",
764 default="None"
766 name_list = [
767 'facetype_menu', 'facetoggle', 'face_use_imported_object',
768 'facewidth', 'fwtog', 'faceheight', 'fhtog',
769 'face_detach', 'fmeshname', 'geodesic_types', 'import_mesh_name',
770 'base_type', 'orientation', 'geodesic_class', 'tri_hex_star',
771 'spherical_flat', 'use_imported_mesh', 'cyxres', 'cyyres',
772 'cyxsz', 'cyysz', 'cyxell', 'cygap',
773 'cygphase', 'paxres', 'payres', 'paxsz',
774 'paysz', 'paxell', 'pagap', 'pagphase',
775 'ures', 'vres', 'urad', 'vrad',
776 'uellipse', 'vellipse', 'upart', 'vpart',
777 'ugap', 'vgap', 'uphase', 'vphase',
778 'uexp', 'vexp', 'usuper', 'vsuper',
779 'utwist', 'vtwist', 'bures', 'bvres',
780 'burad', 'bupart', 'bvpart', 'buphase',
781 'bvphase', 'buellipse', 'bvellipse', 'grxres',
782 'gryres', 'grxsz', 'grysz',
783 'cart', 'frequency', 'eccentricity', 'squish',
784 'radius', 'squareness', 'squarez', 'baselevel',
785 'dual', 'rotxy', 'rotz',
786 'uact', 'vact', 'um', 'un1',
787 'un2', 'un3', 'ua', 'ub',
788 'vm', 'vn1', 'vn2', 'vn3',
789 'va', 'vb', 'uturn', 'vturn',
790 'utwist', 'vtwist', 'struttype', 'struttoggle',
791 'strutimporttoggle', 'strutimpmesh', 'strutwidth', 'swtog',
792 'strutheight', 'shtog', 'strutshrink', 'sstog',
793 'stretch', 'lift', 'smeshname', 'hubtype',
794 'hubtoggle', 'hubimporttoggle', 'hubimpmesh', 'hubwidth',
795 'hwtog', 'hubheight', 'hhtog', 'hublength',
796 'hstog', 'hmeshname'
799 def write_params(self, filename):
800 file = open(filename, "w", encoding="utf8", newline="\n")
801 fw = file.write
802 # for Faces!
803 for el in self.name_list:
804 fw(el + ", ")
805 fw(repr(getattr(self, el)))
806 fw(", \n")
807 file.close()
809 def read_file(self, filename):
810 file = open(filename, "r", newline="\n")
811 result = []
812 line = file.readline()
813 while(line):
814 tmp = line.split(", ")
815 result.append(eval(tmp[1]))
816 line = file.readline()
817 return result
819 def draw(self, context):
820 layout = self.layout
821 row = layout.row()
822 col = layout.column()
823 col.prop(self, "mainpages")
824 which_mainpages = self.mainpages
825 if which_mainpages == 'Main':
826 col = layout.column()
827 col.prop(self, "geodesic_types")
828 tmp = self.geodesic_types
829 if tmp == "Geodesic":
830 col.label(text="Geodesic Object Types:")
831 col.prop(self, "geodesic_class")
832 col.prop(self, "base_type")
833 col.prop(self, "orientation")
834 col.prop(self, "tri_hex_star")
835 col.prop(self, "spherical_flat")
836 col.label(text="Geodesic Object Parameters:")
837 row = layout.row()
838 row.prop(self, "frequency")
839 row = layout.row()
840 row.prop(self, "radius")
841 row = layout.row()
842 row.prop(self, "eccentricity")
843 row = layout.row()
844 row.prop(self, "squish")
845 row = layout.row()
846 row.prop(self, "squareness")
847 row = layout.row()
848 row.prop(self, "squarez")
849 row = layout.row()
850 row.prop(self, "rotxy")
851 row = layout.row()
852 row.prop(self, "rotz")
853 row = layout.row()
854 row.prop(self, "dual")
855 elif tmp == 'Torus':
856 col.label(text="Torus Parameters")
857 row = layout.row()
858 row.prop(self, "ures")
859 row = layout.row()
860 row.prop(self, "vres")
861 row = layout.row()
862 row.prop(self, "urad")
863 row = layout.row()
864 row.prop(self, "vrad")
865 row = layout.row()
866 row.prop(self, "uellipse")
867 row = layout.row()
868 row.prop(self, "vellipse")
869 row = layout.row()
870 row.prop(self, "upart")
871 row = layout.row()
872 row.prop(self, "vpart")
873 row = layout.row()
874 row.prop(self, "ugap")
875 row.prop(self, "vgap")
876 row = layout.row()
878 elif tmp == 'Sphere':
879 col.label(text="Sphere Parameters")
880 row = layout.row()
881 row.prop(self, "bures")
882 row = layout.row()
883 row.prop(self, "bvres")
884 row = layout.row()
885 row.prop(self, "burad")
886 row = layout.row()
887 row.prop(self, "bupart")
888 row = layout.row()
889 row.prop(self, "buphase")
890 row = layout.row()
891 row.prop(self, "bvpart")
892 row = layout.row()
893 row.prop(self, "bvphase")
894 row = layout.row()
895 row.prop(self, "buellipse")
896 row = layout.row()
897 row.prop(self, "bvellipse")
898 elif tmp == 'Parabola':
899 col.label(text="Parabola Parameters")
900 row = layout.row()
901 row.prop(self, "paxres")
902 row = layout.row()
903 row.prop(self, "payres")
904 row = layout.row()
905 row.prop(self, "paxsz")
906 row = layout.row()
907 row.prop(self, "paysz")
908 row = layout.row()
909 row.prop(self, "paxell")
910 row = layout.row()
911 row.prop(self, "pagap")
912 row = layout.row()
913 row.prop(self, "pagphase")
914 elif tmp == 'Cylinder':
915 col.label(text="Cylinder Parameters")
916 col.prop(self, "cyxres")
917 col.prop(self, "cyyres")
918 col.prop(self, "cyxsz")
919 col.prop(self, "cyysz")
920 col.prop(self, "cyxell")
921 col.prop(self, "cygap")
922 col.prop(self, "cygphase")
923 elif tmp == 'Grid':
924 col.label(text="Grid Parameters")
925 row = layout.row()
926 row.prop(self, "grxres")
927 row = layout.row()
928 row.prop(self, "gryres")
929 row = layout.row()
930 row.prop(self, "grxsz")
931 row = layout.row()
932 row.prop(self, "grysz")
933 elif tmp == 'Import_your_mesh':
934 col.prop(self, "use_imported_mesh")
935 col.prop(self, "import_mesh_name")
936 # superform parameters only where possible
937 row = layout.row()
938 row.prop(self, "uact")
939 row = layout.row()
940 row.prop(self, "vact")
941 row = layout.row()
942 if tmp != 'Import_your_mesh':
943 if (self.uact is False) and (self.vact is False):
944 row.label(text="No checkbox active", icon="INFO")
945 else:
946 row.label(text="Superform Parameters")
947 if self.uact:
948 row = layout.row()
949 row.prop(self, "um")
950 row = layout.row()
951 row.prop(self, "un1")
952 row = layout.row()
953 row.prop(self, "un2")
954 row = layout.row()
955 row.prop(self, "un3")
956 row = layout.row()
957 row.prop(self, "ua")
958 row = layout.row()
959 row.prop(self, "ub")
960 row = layout.row()
961 row.prop(self, "uturn")
962 row = layout.row()
963 row.prop(self, "utwist")
964 if self.vact:
965 row = layout.row()
966 row.prop(self, "vm")
967 row = layout.row()
968 row.prop(self, "vn1")
969 row = layout.row()
970 row.prop(self, "vn2")
971 row = layout.row()
972 row.prop(self, "vn3")
973 row = layout.row()
974 row.prop(self, "va")
975 row = layout.row()
976 row.prop(self, "vb")
977 row = layout.row()
978 row.prop(self, "vturn")
979 row = layout.row()
980 row.prop(self, "vtwist")
981 box = layout.box()
982 if self.change == False:
983 col = layout.column(align=True)
984 col.prop(self, 'align', expand=True)
985 col = layout.column(align=True)
986 col.prop(self, 'location', expand=True)
987 col = layout.column(align=True)
988 col.prop(self, 'rotation', expand=True)
989 # einde superform
990 elif which_mainpages == "Hubs":
991 row = layout.row()
992 row.prop(self, "hubtoggle")
993 row = layout.row()
994 if self.hubimpmesh == "None":
995 row = layout.row()
996 row.label(text="Name of a hub to use")
997 row = layout.row()
998 row.prop(self, "hubimpmesh")
999 row = layout.row()
1000 if self.hmeshname == "None":
1001 row = layout.row()
1002 row.label(text="Name of mesh to be filled in")
1003 row = layout.row()
1004 row.prop(self, "hmeshname")
1005 row = layout.row()
1006 row.prop(self, "hwtog")
1007 if self.hwtog:
1008 row.prop(self, "hubwidth")
1009 row = layout.row()
1010 row.prop(self, "hhtog")
1011 if self.hhtog:
1012 row.prop(self, "hubheight")
1013 row = layout.row()
1014 row.prop(self, "hublength")
1015 elif which_mainpages == "Struts":
1016 row = layout.row()
1017 row.prop(self, "struttype")
1018 row.prop(self, "struttoggle")
1020 row = layout.row()
1021 row.prop(self, "strutimpmesh")
1022 row = layout.row()
1023 row.prop(self, "swtog")
1024 if self.swtog:
1025 row.prop(self, "strutwidth")
1026 row = layout.row()
1027 row.prop(self, "shtog")
1028 if self.shtog:
1029 row.prop(self, "strutheight")
1030 row = layout.row()
1031 row.prop(self, "sstog")
1032 if self.sstog:
1033 row.prop(self, "strutshrink")
1034 row = layout.row()
1035 row.prop(self, "stretch")
1036 row = layout.row()
1037 row.prop(self, "lift")
1038 row = layout.row()
1039 row.prop(self, "smeshname")
1040 elif which_mainpages == "Faces":
1041 row = layout.row()
1042 row.prop(self, "facetoggle")
1043 row = layout.row()
1044 row.prop(self, "face_use_imported_object")
1045 row = layout.row()
1046 row.prop(self, "facetype_menu")
1047 row = layout.row()
1048 row.prop(self, "fwtog")
1049 if self.fwtog:
1050 row.prop(self, "facewidth")
1051 row = layout.row()
1052 row.prop(self, "fhtog")
1053 if self.fhtog:
1054 row.prop(self, "faceheight")
1055 row = layout.row()
1056 row.prop(self, "face_detach")
1057 row = layout.row()
1058 row.prop(self, "fmeshname")
1059 row = layout.row()
1061 # help menu GUI
1062 elif which_mainpages == "Help":
1063 import textwrap
1065 # a function that allows for multiple labels with text that wraps
1066 # you can allow the user to set where the text wraps with the
1067 # text_width parameter
1068 # other parameters are ui : here you usually pass layout
1069 # text: is a list with each index representing a line of text
1071 def multi_label(text, ui, text_width=120):
1072 for x in range(0, len(text)):
1073 el = textwrap.wrap(text[x], width=text_width)
1075 for y in range(0, len(el)):
1076 ui.label(text=el[y])
1078 box = layout.box()
1079 help_text = ["To Use",
1080 "If normals look inverted:",
1081 "Once mesh is finished,",
1082 "You may recalc normals outside.",
1083 "--------",
1084 "To use your own mesh with the:",
1085 "Faces:",
1086 "Import your mesh in the:",
1087 "Objects: Geodesic menu.",
1088 "You must type in the name",
1089 "Of your custom object first.",
1090 "--------",
1091 "To use your own mesh with the: ",
1092 "Struts/Hubs:",
1093 "You must type in the name",
1094 "Of your custom object/s first,"]
1095 text_width = self.gd_help_text_width
1096 box.prop(self, "gd_help_text_width", slider=True)
1097 multi_label(help_text, box, text_width)
1099 def execute(self, context):
1101 global last_generated_object, last_imported_mesh, basegeodesic, imported_hubmesh_to_use, error_message
1102 # default superformparam = [3, 10, 10, 10, 1, 1, 4, 10, 10, 10, 1, 1, 0, 0, 0.0, 0.0, 0, 0]]
1103 superformparam = [self.um, self.un1, self.un2, self.un3, self.ua,
1104 self.ub, self.vm, self.vn1, self.vn2, self.vn3,
1105 self.va, self.vb, self.uact, self.vact,
1106 self.uturn * pi, self.vturn * pi,
1107 self.utwist, self.vtwist]
1108 error_message = ""
1109 mesh = None
1110 if self.mainpages == 'Main':
1111 if self.geodesic_types == "Geodesic":
1112 tmp_fs = self.tri_hex_star
1113 faceshape = 0 # tri!
1114 if tmp_fs == "hex":
1115 faceshape = 1
1116 elif tmp_fs == "star":
1117 faceshape = 2
1118 tmp_cl = self.geodesic_class
1119 klass = 0
1120 if tmp_cl == "Class_2":
1121 klass = 1
1122 shape = 0
1123 parameters = [self.frequency, self.eccentricity, self.squish,
1124 self.radius, self.squareness, self.squarez, 0,
1125 shape, self.baselevel, faceshape, self.dual,
1126 self.rotxy, self.rotz, klass, superformparam]
1128 basegeodesic = creategeo(self.base_type, self.orientation, parameters)
1129 basegeodesic.makegeodesic()
1130 basegeodesic.connectivity()
1131 basemesh = vefm_271.mesh()
1132 vefm_271.finalfill(basegeodesic, basemesh) # always! for hexifiy etc. necessary!!!
1133 mesh = vefm_271.vefm_add_object(basegeodesic)
1134 elif self.geodesic_types == 'Grid':
1135 basegeodesic = forms_271.grid(self.grxres, self.gryres,
1136 self.grxsz, self.grysz, 1.0, 1.0, 0, 0, 0,
1137 0, 1.0, 1.0, superformparam)
1138 mesh = vefm_271.vefm_add_object(basegeodesic)
1139 elif self.geodesic_types == "Cylinder":
1140 basegeodesic = forms_271.cylinder(
1141 self.cyxres, self.cyyres,
1142 self.cyxsz, self.cyysz, self.cygap,
1143 1.0, self.cygphase, 0, 0, 0, self.cyxell,
1144 1.0, superformparam
1146 mesh = vefm_271.vefm_add_object(basegeodesic)
1147 elif self.geodesic_types == "Parabola":
1148 basegeodesic = forms_271.parabola(
1149 self.paxres, self.payres,
1150 self.paxsz, self.paysz, self.pagap, 1.0, self.pagphase,
1151 0, 0, 0, self.paxell, 1.0, superformparam
1153 mesh = vefm_271.vefm_add_object(basegeodesic)
1154 elif self.geodesic_types == "Torus":
1155 basegeodesic = forms_271.torus(
1156 self.ures, self.vres,
1157 self.vrad, self.urad, self.upart, self.vpart,
1158 self.ugap, self.vgap, 0, 0, self.uellipse,
1159 self.vellipse, superformparam
1161 mesh = vefm_271.vefm_add_object(basegeodesic)
1162 elif self.geodesic_types == "Sphere":
1163 basegeodesic = forms_271.sphere(
1164 self.bures, self.bvres,
1165 self.burad, 1.0, self.bupart, self.bvpart,
1166 self.buphase, self.bvphase, 0, 0, self.buellipse,
1167 self.bvellipse, superformparam
1169 mesh = vefm_271.vefm_add_object(basegeodesic)
1170 elif self.geodesic_types == "Import_your_mesh":
1171 obj_name = self.import_mesh_name
1172 if obj_name == "None":
1173 message = "Fill in a name \nof an existing mesh\nto be imported"
1174 error_message = message
1175 self.report({"INFO"}, message)
1176 print("***INFO*** You have to fill in the name of an existing mesh")
1177 else:
1178 names = [el.name for el in context.scene.objects]
1179 if obj_name in names and context.scene.objects[obj_name].type == "MESH":
1180 obj = context.scene.objects[obj_name]
1181 your_obj = vefm_271.importmesh(obj.name, False)
1182 last_imported_mesh = your_obj
1183 mesh = vefm_271.vefm_add_object(your_obj)
1184 else:
1185 message = obj_name + " does not exist \nor is not a Mesh"
1186 error_message = message
1187 self.report({'ERROR'}, message)
1188 print("***ERROR***" + obj_name + " does not exist or is not a Mesh")
1189 elif self.mainpages == "Hubs":
1190 hubtype = self.hubtype
1191 hubtoggle = self.hubtoggle
1192 hubimporttoggle = self.hubimporttoggle
1193 hubimpmesh = self.hubimpmesh
1194 hubwidth = self.hubwidth
1195 hwtog = self.hwtog
1196 hubheight = self.hubheight
1197 hhtog = self.hhtog
1198 hublength = self.hublength
1199 hstog = self.hstog
1200 hmeshname = self.hmeshname
1202 if not (hmeshname == "None") and not (hubimpmesh == "None") and hubtoggle:
1203 try:
1204 hub_obj = vefm_271.importmesh(hmeshname, 0)
1206 hub = vefm_271.hub(
1207 hub_obj, True,
1208 hubwidth, hubheight, hublength,
1209 hwtog, hhtog, hstog, hubimpmesh
1211 hubmesh = vefm_271.mesh("test")
1212 vefm_271.finalfill(hub, hubmesh)
1213 mesh = vefm_271.vefm_add_object(hubmesh)
1214 except:
1215 message = "***ERROR*** \nEither no mesh for hub\nor " + \
1216 hmeshname + " available"
1217 error_message = message
1218 print(message)
1219 mesh = vefm_271.vefm_add_object(basegeodesic)
1220 else:
1221 message = "***INFO***\nEnable Hubs first"
1222 error_message = message
1223 print("\n***INFO*** Enable Hubs first")
1224 mesh = vefm_271.vefm_add_object(basegeodesic)
1225 elif self.mainpages == "Struts":
1226 struttype = self.struttype
1227 struttoggle = self.struttoggle
1228 strutimporttoggle = self.strutimporttoggle
1229 strutimpmesh = self.strutimpmesh
1230 strutwidth = self.strutwidth
1231 swtog = self.swtog
1232 strutheight = self.strutheight
1233 shtog = self.shtog
1234 strutshrink = self.strutshrink
1235 sstog = self.sstog
1236 stretch = self.stretch
1237 lift = self.lift
1238 smeshname = self.smeshname
1239 if not (strutimpmesh == "None") and struttoggle:
1240 names = [el.name for el in context.scene.objects]
1241 if strutimpmesh in names and context.scene.objects[strutimpmesh].type == "MESH":
1242 strut = vefm_271.strut(
1243 basegeodesic, struttype, strutwidth,
1244 strutheight, stretch, swtog, shtog, swtog,
1245 strutimpmesh, sstog, lift
1247 strutmesh = vefm_271.mesh()
1248 vefm_271.finalfill(strut, strutmesh)
1249 mesh = vefm_271.vefm_add_object(strutmesh)
1250 else:
1251 message = "***ERROR***\nStrut object " + strutimpmesh + "\nis not a Mesh"
1252 error_message = message
1253 print("***ERROR*** Strut object is not a Mesh")
1254 else:
1255 mesh = vefm_271.vefm_add_object(basegeodesic)
1256 elif self.mainpages == "Faces":
1257 if self.facetoggle:
1258 faceparams = [[self.face_detach, 0, [[0.5, 0.0]]], # 0 strip
1259 [self.face_detach, 0, [[0.0, 0.5]]], # 1 vertical
1260 [self.face_detach, 0, [[0.5, 0.5]]], # 2 slanted
1261 [self.face_detach, 1, [[0.25, 0.25], [0.5, 0.5]]], # 3 closed point
1262 [self.face_detach, 1, [[0.1, 0.03], [0.33, 0.06], [0.0, 0.1]]], # 4 pillow
1263 [self.face_detach, 2, [[0.0, 0.5]]], # 5 closed vertical
1264 [self.face_detach, 2, [[0.0, 0.25], [0.25, 0.25], [0.25, 0.5]]], # 6 stepped
1265 [self.face_detach, 1, [[0.2, 0.1], [0.4, 0.2], [0.0, 1.0]]], # 7 spikes
1266 [self.face_detach, 3, [[0.25, 0.0], [0.25, 0.5], [0.0, 0.5]]], # 8 boxed
1267 [self.face_detach, 3, [[0.25, 0.5], [0.5, 0.0], [0.25, -0.5]]], # 9 diamond
1268 [self.face_detach, 4, [[0.5, 0.0], [0.5, 0.5], [0.0, 0.5]]], ] # 10 bar
1269 facedata = faceparams[int(self.facetype_menu)]
1270 if not self.face_use_imported_object:
1271 faceobject = vefm_271.facetype(
1272 basegeodesic, facedata, self.facewidth,
1273 self.faceheight, self.fwtog
1275 else:
1276 if last_imported_mesh:
1277 faceobject = vefm_271.facetype(
1278 last_imported_mesh, facedata,
1279 self.facewidth, self.faceheight, self.fwtog
1281 else:
1282 message = "***ERROR***\nNo imported message available\n" + "last geodesic used"
1283 error_message = message
1284 print("\n***ERROR*** No imported mesh available \nLast geodesic used!")
1285 faceobject = vefm_271.facetype(
1286 basegeodesic, facedata,
1287 self.facewidth, self.faceheight, self.fwtog
1289 facemesh = vefm_271.mesh()
1290 finalfill(faceobject, facemesh)
1291 mesh = vefm_271.vefm_add_object(facemesh)
1293 if mesh != None:
1294 if bpy.context.mode == "OBJECT":
1295 if context.selected_objects != [] and context.active_object and \
1296 (context.active_object.data is not None) and \
1297 ('GeodesicDome' in context.active_object.data.keys()) and (self.change == True):
1298 obj = context.active_object
1299 oldmesh = obj.data
1300 oldmeshname = obj.data.name
1301 obj.data = mesh
1302 for material in oldmesh.materials:
1303 obj.data.materials.append(material)
1304 bpy.data.meshes.remove(oldmesh)
1305 obj.data.name = oldmeshname
1306 else:
1307 obj = object_utils.object_data_add(context, mesh, operator=self)
1309 obj.data["GeodesicDome"] = True
1310 obj.data["change"] = False
1311 for prm in GeodesicDomeParameters():
1312 obj.data[prm] = getattr(self, prm)
1314 if bpy.context.mode == "EDIT_MESH":
1315 active_object = context.active_object
1316 name_active_object = active_object.name
1317 bpy.ops.object.mode_set(mode='OBJECT')
1318 obj = object_utils.object_data_add(context, mesh, operator=self)
1319 obj.select_set(True)
1320 active_object.select_set(True)
1321 bpy.ops.object.join()
1322 context.active_object.name = name_active_object
1323 bpy.ops.object.mode_set(mode='EDIT')
1325 return {'FINISHED'}
1327 def invoke(self, context, event):
1328 global basegeodesic, geodesic_not_yet_called
1329 if geodesic_not_yet_called:
1330 geodesic_not_yet_called = False
1331 bpy.context.view_layer.update()
1332 self.execute(context)
1334 return {'FINISHED'}
1337 def creategeo(polytype, orientation, parameters):
1338 geo = None
1339 if polytype == "Tetrahedron":
1340 if orientation == "PointUp":
1341 geo = geodesic_classes_271.tetrahedron(parameters)
1342 elif orientation == "EdgeUp":
1343 geo = geodesic_classes_271.tetraedge(parameters)
1344 elif orientation == "FaceUp":
1345 geo = geodesic_classes_271.tetraface(parameters)
1346 elif polytype == "Octahedron":
1347 if orientation == "PointUp":
1348 geo = geodesic_classes_271.octahedron(parameters)
1349 elif orientation == "EdgeUp":
1350 geo = geodesic_classes_271.octaedge(parameters)
1351 elif orientation == "FaceUp":
1352 geo = geodesic_classes_271.octaface(parameters)
1353 elif polytype == "Icosahedron":
1354 if orientation == "PointUp":
1355 geo = geodesic_classes_271.icosahedron(parameters)
1356 elif orientation == "EdgeUp":
1357 geo = geodesic_classes_271.icoedge(parameters)
1358 elif orientation == "FaceUp":
1359 geo = geodesic_classes_271.icoface(parameters)
1360 return geo
1363 basegeodesic, fmeshname, smeshname, hmeshname, outputmeshname, strutimpmesh, hubimpmesh = [None] * 7
1366 def finalfill(source, target):
1367 count = 0
1368 for point in source.verts:
1369 newvert = vefm_271.vertex(point.vector)
1370 target.verts.append(newvert)
1371 point.index = count
1372 count += 1
1373 for facey in source.faces:
1374 row = len(facey.vertices)
1375 if row >= 5:
1376 newvert = vefm_271.average(facey.vertices).centroid()
1377 centre = vefm_271.vertex(newvert.vector)
1378 target.verts.append(centre)
1379 for i in range(row):
1380 if i == row - 1:
1381 a = target.verts[facey.vertices[-1].index]
1382 b = target.verts[facey.vertices[0].index]
1383 else:
1384 a = target.verts[facey.vertices[i].index]
1385 b = target.verts[facey.vertices[i + 1].index]
1386 c = centre
1387 f = [a, b, c]
1388 target.faces.append(f)
1389 else:
1390 f = []
1391 for j in range(len(facey.vertices)):
1393 a = facey.vertices[j]
1394 f.append(target.verts[a.index])
1395 target.faces.append(f)
1398 # for error messages
1399 class DialogOperator(Operator):
1400 bl_idname = "object.dialog_operator"
1401 bl_label = "INFO"
1403 def draw(self, context):
1404 layout = self.layout
1405 message = error_message
1406 col = layout.column()
1407 tmp = message.split("\n")
1408 for el in tmp:
1409 col.label(text = "")
1411 def execute(self, context):
1412 return {'FINISHED'}
1414 def invoke(self, context, event):
1415 wm = context.window_manager
1416 return wm.invoke_props_dialog(self)
1419 def GeodesicDomeParameters():
1420 GeodesicDomeParameters = [
1421 "gd_help_text_width",
1422 "mainpages",
1423 "facetype_menu",
1424 "facetoggle",
1425 "face_use_imported_object",
1426 "facewidth",
1427 "fwtog",
1428 "faceheight",
1429 "fhtog",
1430 "face_detach",
1431 "fmeshname",
1432 "geodesic_types",
1433 "import_mesh_name",
1434 "base_type",
1435 "orientation",
1436 "geodesic_class",
1437 "tri_hex_star",
1438 "spherical_flat",
1439 "use_imported_mesh",
1440 "cyxres",
1441 "cyyres",
1442 "cyxsz",
1443 "cyysz",
1444 "cyxell",
1445 "cygap",
1446 "cygphase",
1447 "paxres",
1448 "payres",
1449 "paxsz",
1450 "paysz",
1451 "paxell",
1452 "pagap",
1453 "pagphase",
1454 "ures",
1455 "vres",
1456 "urad",
1457 "vrad",
1458 "uellipse",
1459 "vellipse",
1460 "upart",
1461 "vpart",
1462 "ugap",
1463 "vgap",
1464 "uphase",
1465 "vphase",
1466 "uexp",
1467 "vexp",
1468 "usuper",
1469 "vsuper",
1470 "utwist",
1471 "vtwist",
1472 "bures",
1473 "bvres",
1474 "burad",
1475 "bupart",
1476 "bvpart",
1477 "buphase",
1478 "bvphase",
1479 "buellipse",
1480 "bvellipse",
1481 "grxres",
1482 "gryres",
1483 "grxsz",
1484 "grysz",
1485 "cart",
1486 "frequency",
1487 "eccentricity",
1488 "squish",
1489 "radius",
1490 "squareness",
1491 "squarez",
1492 "baselevel",
1493 "dual",
1494 "rotxy",
1495 "rotz",
1496 "uact",
1497 "vact",
1498 "um",
1499 "un1",
1500 "un2",
1501 "un3",
1502 "ua",
1503 "ub",
1504 "vm",
1505 "vn1",
1506 "vn2",
1507 "vn3",
1508 "va",
1509 "vb",
1510 "uturn",
1511 "vturn",
1512 "utwist",
1513 "vtwist",
1514 "struttype",
1515 "struttoggle",
1516 "strutimporttoggle",
1517 "strutimpmesh",
1518 "strutwidth",
1519 "swtog",
1520 "strutheight",
1521 "shtog",
1522 "strutshrink",
1523 "sstog",
1524 "stretch",
1525 "lift",
1526 "smeshname",
1527 "hubtype",
1528 "hubtoggle",
1529 "hubimporttoggle",
1530 "hubimpmesh",
1531 "hubwidth",
1532 "hwtog",
1533 "hubheight",
1534 "hhtog",
1535 "hublength",
1536 "hstog",
1537 "hmeshname",
1539 return GeodesicDomeParameters