1 # SPDX-License-Identifier: GPL-2.0-or-later
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 (
20 from mathutils
import (
24 from bpy_extras
import object_utils
27 last_generated_object
= None
28 last_imported_mesh
= None
30 imported_hubmesh_to_use
= None
32 geodesic_not_yet_called
= True
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",
46 description
= "GeodesicDome")
47 change
: BoolProperty(name
= "Change",
49 description
= "change Geodesic Dome")
51 gd_help_text_width
: IntProperty(
53 description
="The width above which the text wraps",
57 mainpages
: EnumProperty(
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"),
69 facetype_menu
: EnumProperty(
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"),
86 facetoggle
: BoolProperty(
87 name
="Activate: Face Object",
88 description
="Activate Faces for Geodesic object",
91 face_use_imported_object
: BoolProperty(
92 name
="Use: Imported Object",
93 description
="Activate faces on your Imported object",
96 facewidth
: FloatProperty(
98 min=-1, soft_min
=0.001, max=4,
105 faceheight
: FloatProperty(
114 face_detach
: BoolProperty(
118 fmeshname
: StringProperty(
119 name
="Face Mesh name",
120 default
="defaultface"
122 geodesic_types
: EnumProperty(
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"),
136 import_mesh_name
: StringProperty(
137 name
="Mesh to import",
138 description
="the name has to be the name of a meshobject",
141 base_type
: EnumProperty(
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(
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"),
159 geodesic_class
: EnumProperty(
161 description
="Subdivide Basic/Triacon",
162 items
=[("Class_1", "Class 1", "class one"),
163 ("Class_2", "Class 2", "class two"),
167 tri_hex_star
: EnumProperty(
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)"),
176 spherical_flat
: EnumProperty(
178 description
="Choose between spherical or flat ",
179 items
=[("spherical", "spherical", "Generate spherical"),
180 ("flat", "flat", "Generate flat"),
184 use_imported_mesh
: BoolProperty(
186 description
="Use an imported mesh",
191 name
="Resolution x/y",
193 description
="Number of faces around x/y",
199 description
="Number of faces in z direction",
202 cyxsz
: FloatProperty(
205 description
="Scale in x/y direction",
208 cyysz
: FloatProperty(
211 description
="Scale in z direction",
214 cyxell
: FloatProperty(
217 description
="Stretch in x direction",
220 cygap
: FloatProperty(
223 description
="Shrink in % around radius",
226 cygphase
: FloatProperty(
227 name
="Phase", min=-4, #max=4,
228 description
="Rotate around pivot x/y",
233 name
="Resolution x/y",
235 description
="Number of faces around x/y",
241 description
="Number of faces in z direction",
244 paxsz
: FloatProperty(
247 description
="scale in x/y direction",
250 paysz
: FloatProperty(
253 description
="Scale in z direction",
256 paxell
: FloatProperty(
259 description
="Stretch in x direction",
262 pagap
: FloatProperty(
265 description
="Shrink in % around radius",
268 pagphase
: FloatProperty(
271 description
="Rotate around pivot x/y",
276 name
="Resolution x/y",
278 description
="Number of faces around x/y",
283 description
="Number of faces in z direction",
288 description
="Radius in x/y plane",
294 description
="Radius in z plane",
297 uellipse
: FloatProperty(
300 description
="Number of faces in z direction",
303 vellipse
: FloatProperty(
306 description
="Number of faces in z direction",
309 upart
: FloatProperty(
312 description
="Shrink faces around x/y",
315 vpart
: FloatProperty(
318 description
="Shrink faces in z direction",
324 description
="Rotate around pivot x/y",
330 description
="Rotate around pivot z",
333 uphase
: FloatProperty(
336 description
="Number of faces in z direction",
339 vphase
: FloatProperty(
342 description
="Number of faces in z direction",
348 description
="Number of faces in z direction",
354 description
="Number of faces in z direction",
357 usuper
: FloatProperty(
360 description
="First set of superform parameters",
363 vsuper
: FloatProperty(
366 description
="Second set of superform parameters",
369 utwist
: FloatProperty(
372 description
="Use with superformular u",
375 vtwist
: FloatProperty(
378 description
="Use with superformular v",
383 name
="Resolution x/y",
385 description
="Number of faces around x/y",
391 description
="Number of faces in z direction",
394 burad
: FloatProperty(
397 description
="overall radius",
400 bupart
: FloatProperty(
403 description
="Shrink faces around x/y",
406 bvpart
: FloatProperty(
409 description
="Shrink faces in z direction",
412 buphase
: FloatProperty(
415 description
="Rotate around pivot x/y",
418 bvphase
: FloatProperty(
421 description
="Rotate around pivot z",
424 buellipse
: FloatProperty(
427 description
="Stretch in the x direction",
430 bvellipse
: FloatProperty(
433 description
="Stretch in the z direction",
439 min=2, #soft_max=10, max=20,
440 description
="Number of faces in x direction",
446 #soft_max=10, max=20,
447 description
="Number of faces in x direction",
450 grxsz
: FloatProperty(
452 min=1, soft_min
=0.01,
454 description
="X size",
457 grysz
: FloatProperty(
459 min=1, soft_min
=0.01,
461 description
="Y size",
465 # PKHG_TODO_??? what means cart
471 frequency
: IntProperty(
474 description
="Subdivide base triangles",
477 eccentricity
: FloatProperty(
480 description
="Scaling in x/y dimension",
483 squish
: FloatProperty(
487 description
="Scaling in z dimension",
490 radius
: FloatProperty(
494 description
="Overall radius",
497 squareness
: FloatProperty(
500 description
="Superelipse action in x/y",
503 squarez
: FloatProperty(
505 min=0.1, #soft_max=5, max=10,
506 description
="Superelipse action in z",
509 baselevel
: IntProperty(
515 description
="Faces become verts, "
516 "verts become faces, edges flip",
519 rotxy
: FloatProperty(
522 description
="Rotate superelipse action in x/y",
528 description
="Rotate superelipse action in z",
532 # for choice of superformula
534 name
="Superformula u (x/y)",
535 description
="Activate superformula u parameters",
539 name
="Superformula v (z)",
540 description
="Activate superformula v parameters",
547 description
="Pinch the mesh on x/y",
554 description
="Squash the mesh x/y",
561 description
="Inflate the mesh x/y",
568 description
="Roundify x/y",
575 description
="Shrink",
582 description
="Shrink y/x",
589 description
="Scale Z Base",
593 name
="Scale lock Top Z",
596 description
="Scale lock Top Z",
603 description
="Inflate Base",
610 description
="Inflate",
617 description
="Scale 1",
624 description
="Scale 2",
628 uturn
: FloatProperty(
629 name
="x/y Vert cycle",
632 description
="x/y Vert cycle",
635 vturn
: FloatProperty(
639 description
="z Vert cycle",
642 utwist
: FloatProperty(
643 name
="x/y Twist cycle",
646 description
="x/y Twist cycle",
649 vtwist
: FloatProperty(
650 name
="z Twist cycle",
653 description
="z Twist cycle",
657 struttype
: IntProperty(
661 struttoggle
: BoolProperty(
665 strutimporttoggle
: BoolProperty(
666 name
="Strut import toggle",
669 strutimpmesh
: StringProperty(
670 name
="Strut import mesh",
673 strutwidth
: FloatProperty(
683 strutheight
: FloatProperty(
693 strutshrink
: FloatProperty(
702 stretch
: FloatProperty(
712 smeshname
: StringProperty(
713 name
="Strut mesh name",
714 default
="defaultstrut"
717 hubtype
: BoolProperty(
719 description
="not used",
722 hubtoggle
: BoolProperty(
726 hubimporttoggle
: BoolProperty(
728 description
="Import a mesh",
731 hubimpmesh
: StringProperty(
732 name
="Hub mesh import",
733 description
="Name of mesh to import",
736 hubwidth
: FloatProperty(
745 hubheight
: FloatProperty(
754 hublength
: FloatProperty(
763 hmeshname
: StringProperty(
764 name
="Hub mesh name",
765 description
="Name of an existing mesh needed!",
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',
801 def write_params(self
, filename
):
802 file = open(filename
, "w", encoding
="utf8", newline
="\n")
805 for el
in self
.name_list
:
807 fw(repr(getattr(self
, el
)))
811 def read_file(self
, filename
):
812 file = open(filename
, "r", newline
="\n")
814 line
= file.readline()
816 tmp
= line
.split(", ")
817 result
.append(eval(tmp
[1]))
818 line
= file.readline()
821 def draw(self
, context
):
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:")
840 row
.prop(self
, "frequency")
842 row
.prop(self
, "radius")
844 row
.prop(self
, "eccentricity")
846 row
.prop(self
, "squish")
848 row
.prop(self
, "squareness")
850 row
.prop(self
, "squarez")
852 row
.prop(self
, "rotxy")
854 row
.prop(self
, "rotz")
856 row
.prop(self
, "dual")
858 col
.label(text
="Torus Parameters")
860 row
.prop(self
, "ures")
862 row
.prop(self
, "vres")
864 row
.prop(self
, "urad")
866 row
.prop(self
, "vrad")
868 row
.prop(self
, "uellipse")
870 row
.prop(self
, "vellipse")
872 row
.prop(self
, "upart")
874 row
.prop(self
, "vpart")
876 row
.prop(self
, "ugap")
877 row
.prop(self
, "vgap")
880 elif tmp
== 'Sphere':
881 col
.label(text
="Sphere Parameters")
883 row
.prop(self
, "bures")
885 row
.prop(self
, "bvres")
887 row
.prop(self
, "burad")
889 row
.prop(self
, "bupart")
891 row
.prop(self
, "buphase")
893 row
.prop(self
, "bvpart")
895 row
.prop(self
, "bvphase")
897 row
.prop(self
, "buellipse")
899 row
.prop(self
, "bvellipse")
900 elif tmp
== 'Parabola':
901 col
.label(text
="Parabola Parameters")
903 row
.prop(self
, "paxres")
905 row
.prop(self
, "payres")
907 row
.prop(self
, "paxsz")
909 row
.prop(self
, "paysz")
911 row
.prop(self
, "paxell")
913 row
.prop(self
, "pagap")
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")
926 col
.label(text
="Grid Parameters")
928 row
.prop(self
, "grxres")
930 row
.prop(self
, "gryres")
932 row
.prop(self
, "grxsz")
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
940 row
.prop(self
, "uact")
942 row
.prop(self
, "vact")
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")
948 row
.label(text
="Superform Parameters")
953 row
.prop(self
, "un1")
955 row
.prop(self
, "un2")
957 row
.prop(self
, "un3")
963 row
.prop(self
, "uturn")
965 row
.prop(self
, "utwist")
970 row
.prop(self
, "vn1")
972 row
.prop(self
, "vn2")
974 row
.prop(self
, "vn3")
980 row
.prop(self
, "vturn")
982 row
.prop(self
, "vtwist")
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)
992 elif which_mainpages
== "Hubs":
994 row
.prop(self
, "hubtoggle")
996 if self
.hubimpmesh
== "None":
998 row
.label(text
="Name of a hub to use")
1000 row
.prop(self
, "hubimpmesh")
1002 if self
.hmeshname
== "None":
1004 row
.label(text
="Name of mesh to be filled in")
1006 row
.prop(self
, "hmeshname")
1008 row
.prop(self
, "hwtog")
1010 row
.prop(self
, "hubwidth")
1012 row
.prop(self
, "hhtog")
1014 row
.prop(self
, "hubheight")
1016 row
.prop(self
, "hublength")
1017 elif which_mainpages
== "Struts":
1019 row
.prop(self
, "struttype")
1020 row
.prop(self
, "struttoggle")
1023 row
.prop(self
, "strutimpmesh")
1025 row
.prop(self
, "swtog")
1027 row
.prop(self
, "strutwidth")
1029 row
.prop(self
, "shtog")
1031 row
.prop(self
, "strutheight")
1033 row
.prop(self
, "sstog")
1035 row
.prop(self
, "strutshrink")
1037 row
.prop(self
, "stretch")
1039 row
.prop(self
, "lift")
1041 row
.prop(self
, "smeshname")
1042 elif which_mainpages
== "Faces":
1044 row
.prop(self
, "facetoggle")
1046 row
.prop(self
, "face_use_imported_object")
1048 row
.prop(self
, "facetype_menu")
1050 row
.prop(self
, "fwtog")
1052 row
.prop(self
, "facewidth")
1054 row
.prop(self
, "fhtog")
1056 row
.prop(self
, "faceheight")
1058 row
.prop(self
, "face_detach")
1060 row
.prop(self
, "fmeshname")
1064 elif which_mainpages
== "Help":
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
])
1081 help_text
= ["To Use",
1082 "If normals look inverted:",
1083 "Once mesh is finished,",
1084 "You may recalc normals outside.",
1086 "To use your own mesh with the:",
1088 "Import your mesh in the:",
1089 "Objects: Geodesic menu.",
1090 "You must type in the name",
1091 "Of your custom object first.",
1093 "To use your own mesh with the: ",
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
]
1112 if self
.mainpages
== 'Main':
1113 if self
.geodesic_types
== "Geodesic":
1114 tmp_fs
= self
.tri_hex_star
1115 faceshape
= 0 # tri!
1118 elif tmp_fs
== "star":
1120 tmp_cl
= self
.geodesic_class
1122 if tmp_cl
== "Class_2":
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
,
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")
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
)
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
1198 hubheight
= self
.hubheight
1200 hublength
= self
.hublength
1202 hmeshname
= self
.hmeshname
1204 if not (hmeshname
== "None") and not (hubimpmesh
== "None") and hubtoggle
:
1206 hub_obj
= vefm_271
.importmesh(hmeshname
, 0)
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
)
1217 message
= "***ERROR*** \nEither no mesh for hub\nor " + \
1218 hmeshname
+ " available"
1219 error_message
= message
1221 mesh
= vefm_271
.vefm_add_object(basegeodesic
)
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
1234 strutheight
= self
.strutheight
1236 strutshrink
= self
.strutshrink
1238 stretch
= self
.stretch
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
)
1253 message
= "***ERROR***\nStrut object " + strutimpmesh
+ "\nis not a Mesh"
1254 error_message
= message
1255 print("***ERROR*** Strut object is not a Mesh")
1257 mesh
= vefm_271
.vefm_add_object(basegeodesic
)
1258 elif self
.mainpages
== "Faces":
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
1278 if last_imported_mesh
:
1279 faceobject
= vefm_271
.facetype(
1280 last_imported_mesh
, facedata
,
1281 self
.facewidth
, self
.faceheight
, self
.fwtog
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
)
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
1302 oldmeshname
= obj
.data
.name
1304 for material
in oldmesh
.materials
:
1305 obj
.data
.materials
.append(material
)
1306 bpy
.data
.meshes
.remove(oldmesh
)
1307 obj
.data
.name
= oldmeshname
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')
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
)
1339 def creategeo(polytype
, orientation
, parameters
):
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
)
1365 basegeodesic
, fmeshname
, smeshname
, hmeshname
, outputmeshname
, strutimpmesh
, hubimpmesh
= [None] * 7
1368 def finalfill(source
, target
):
1370 for point
in source
.verts
:
1371 newvert
= vefm_271
.vertex(point
.vector
)
1372 target
.verts
.append(newvert
)
1375 for facey
in source
.faces
:
1376 row
= len(facey
.vertices
)
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
):
1383 a
= target
.verts
[facey
.vertices
[-1].index
]
1384 b
= target
.verts
[facey
.vertices
[0].index
]
1386 a
= target
.verts
[facey
.vertices
[i
].index
]
1387 b
= target
.verts
[facey
.vertices
[i
+ 1].index
]
1390 target
.faces
.append(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"
1405 def draw(self
, context
):
1406 layout
= self
.layout
1407 message
= error_message
1408 col
= layout
.column()
1409 tmp
= message
.split("\n")
1411 col
.label(text
= "")
1413 def execute(self
, context
):
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",
1427 "face_use_imported_object",
1441 "use_imported_mesh",
1518 "strutimporttoggle",
1541 return GeodesicDomeParameters