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