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 (
18 from mathutils
import (
22 from bpy_extras
import object_utils
25 last_generated_object
= None
26 last_imported_mesh
= None
28 imported_hubmesh_to_use
= None
30 geodesic_not_yet_called
= True
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",
44 description
= "GeodesicDome")
45 change
: BoolProperty(name
= "Change",
47 description
= "change Geodesic Dome")
49 gd_help_text_width
: IntProperty(
51 description
="The width above which the text wraps",
55 mainpages
: EnumProperty(
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"),
67 facetype_menu
: EnumProperty(
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"),
84 facetoggle
: BoolProperty(
85 name
="Activate: Face Object",
86 description
="Activate Faces for Geodesic object",
89 face_use_imported_object
: BoolProperty(
90 name
="Use: Imported Object",
91 description
="Activate faces on your Imported object",
94 facewidth
: FloatProperty(
96 min=-1, soft_min
=0.001, max=4,
103 faceheight
: FloatProperty(
112 face_detach
: BoolProperty(
116 fmeshname
: StringProperty(
117 name
="Face Mesh name",
118 default
="defaultface"
120 geodesic_types
: EnumProperty(
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"),
134 import_mesh_name
: StringProperty(
135 name
="Mesh to import",
136 description
="the name has to be the name of a meshobject",
139 base_type
: EnumProperty(
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(
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"),
157 geodesic_class
: EnumProperty(
159 description
="Subdivide Basic/Triacon",
160 items
=[("Class_1", "Class 1", "class one"),
161 ("Class_2", "Class 2", "class two"),
165 tri_hex_star
: EnumProperty(
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)"),
174 spherical_flat
: EnumProperty(
176 description
="Choose between spherical or flat ",
177 items
=[("spherical", "spherical", "Generate spherical"),
178 ("flat", "flat", "Generate flat"),
182 use_imported_mesh
: BoolProperty(
184 description
="Use an imported mesh",
189 name
="Resolution x/y",
191 description
="Number of faces around x/y",
197 description
="Number of faces in z direction",
200 cyxsz
: FloatProperty(
203 description
="Scale in x/y direction",
206 cyysz
: FloatProperty(
209 description
="Scale in z direction",
212 cyxell
: FloatProperty(
215 description
="Stretch in x direction",
218 cygap
: FloatProperty(
221 description
="Shrink in % around radius",
224 cygphase
: FloatProperty(
225 name
="Phase", min=-4, #max=4,
226 description
="Rotate around pivot x/y",
231 name
="Resolution x/y",
233 description
="Number of faces around x/y",
239 description
="Number of faces in z direction",
242 paxsz
: FloatProperty(
245 description
="scale in x/y direction",
248 paysz
: FloatProperty(
251 description
="Scale in z direction",
254 paxell
: FloatProperty(
257 description
="Stretch in x direction",
260 pagap
: FloatProperty(
263 description
="Shrink in % around radius",
266 pagphase
: FloatProperty(
269 description
="Rotate around pivot x/y",
274 name
="Resolution x/y",
276 description
="Number of faces around x/y",
281 description
="Number of faces in z direction",
286 description
="Radius in x/y plane",
292 description
="Radius in z plane",
295 uellipse
: FloatProperty(
298 description
="Number of faces in z direction",
301 vellipse
: FloatProperty(
304 description
="Number of faces in z direction",
307 upart
: FloatProperty(
310 description
="Shrink faces around x/y",
313 vpart
: FloatProperty(
316 description
="Shrink faces in z direction",
322 description
="Rotate around pivot x/y",
328 description
="Rotate around pivot z",
331 uphase
: FloatProperty(
334 description
="Number of faces in z direction",
337 vphase
: FloatProperty(
340 description
="Number of faces in z direction",
346 description
="Number of faces in z direction",
352 description
="Number of faces in z direction",
355 usuper
: FloatProperty(
358 description
="First set of superform parameters",
361 vsuper
: FloatProperty(
364 description
="Second set of superform parameters",
367 utwist
: FloatProperty(
370 description
="Use with superformular u",
373 vtwist
: FloatProperty(
376 description
="Use with superformular v",
381 name
="Resolution x/y",
383 description
="Number of faces around x/y",
389 description
="Number of faces in z direction",
392 burad
: FloatProperty(
395 description
="overall radius",
398 bupart
: FloatProperty(
401 description
="Shrink faces around x/y",
404 bvpart
: FloatProperty(
407 description
="Shrink faces in z direction",
410 buphase
: FloatProperty(
413 description
="Rotate around pivot x/y",
416 bvphase
: FloatProperty(
419 description
="Rotate around pivot z",
422 buellipse
: FloatProperty(
425 description
="Stretch in the x direction",
428 bvellipse
: FloatProperty(
431 description
="Stretch in the z direction",
437 min=2, #soft_max=10, max=20,
438 description
="Number of faces in x direction",
444 #soft_max=10, max=20,
445 description
="Number of faces in x direction",
448 grxsz
: FloatProperty(
450 min=1, soft_min
=0.01,
452 description
="X size",
455 grysz
: FloatProperty(
457 min=1, soft_min
=0.01,
459 description
="Y size",
463 # PKHG_TODO_??? what means cart
469 frequency
: IntProperty(
472 description
="Subdivide base triangles",
475 eccentricity
: FloatProperty(
478 description
="Scaling in x/y dimension",
481 squish
: FloatProperty(
485 description
="Scaling in z dimension",
488 radius
: FloatProperty(
492 description
="Overall radius",
495 squareness
: FloatProperty(
498 description
="Superelipse action in x/y",
501 squarez
: FloatProperty(
503 min=0.1, #soft_max=5, max=10,
504 description
="Superelipse action in z",
507 baselevel
: IntProperty(
513 description
="Faces become verts, "
514 "verts become faces, edges flip",
517 rotxy
: FloatProperty(
520 description
="Rotate superelipse action in x/y",
526 description
="Rotate superelipse action in z",
530 # for choice of superformula
532 name
="Superformula u (x/y)",
533 description
="Activate superformula u parameters",
537 name
="Superformula v (z)",
538 description
="Activate superformula v parameters",
545 description
="Pinch the mesh on x/y",
552 description
="Squash the mesh x/y",
559 description
="Inflate the mesh x/y",
566 description
="Roundify x/y",
573 description
="Shrink",
580 description
="Shrink y/x",
587 description
="Scale Z Base",
591 name
="Scale lock Top Z",
594 description
="Scale lock Top Z",
601 description
="Inflate Base",
608 description
="Inflate",
615 description
="Scale 1",
622 description
="Scale 2",
626 uturn
: FloatProperty(
627 name
="x/y Vert cycle",
630 description
="x/y Vert cycle",
633 vturn
: FloatProperty(
637 description
="z Vert cycle",
640 utwist
: FloatProperty(
641 name
="x/y Twist cycle",
644 description
="x/y Twist cycle",
647 vtwist
: FloatProperty(
648 name
="z Twist cycle",
651 description
="z Twist cycle",
655 struttype
: IntProperty(
659 struttoggle
: BoolProperty(
663 strutimporttoggle
: BoolProperty(
664 name
="Strut import toggle",
667 strutimpmesh
: StringProperty(
668 name
="Strut import mesh",
671 strutwidth
: FloatProperty(
681 strutheight
: FloatProperty(
691 strutshrink
: FloatProperty(
700 stretch
: FloatProperty(
710 smeshname
: StringProperty(
711 name
="Strut mesh name",
712 default
="defaultstrut"
715 hubtype
: BoolProperty(
717 description
="not used",
720 hubtoggle
: BoolProperty(
724 hubimporttoggle
: BoolProperty(
726 description
="Import a mesh",
729 hubimpmesh
: StringProperty(
730 name
="Hub mesh import",
731 description
="Name of mesh to import",
734 hubwidth
: FloatProperty(
743 hubheight
: FloatProperty(
752 hublength
: FloatProperty(
761 hmeshname
: StringProperty(
762 name
="Hub mesh name",
763 description
="Name of an existing mesh needed!",
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',
799 def write_params(self
, filename
):
800 file = open(filename
, "w", encoding
="utf8", newline
="\n")
803 for el
in self
.name_list
:
805 fw(repr(getattr(self
, el
)))
809 def read_file(self
, filename
):
810 file = open(filename
, "r", newline
="\n")
812 line
= file.readline()
814 tmp
= line
.split(", ")
815 result
.append(eval(tmp
[1]))
816 line
= file.readline()
819 def draw(self
, context
):
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:")
838 row
.prop(self
, "frequency")
840 row
.prop(self
, "radius")
842 row
.prop(self
, "eccentricity")
844 row
.prop(self
, "squish")
846 row
.prop(self
, "squareness")
848 row
.prop(self
, "squarez")
850 row
.prop(self
, "rotxy")
852 row
.prop(self
, "rotz")
854 row
.prop(self
, "dual")
856 col
.label(text
="Torus Parameters")
858 row
.prop(self
, "ures")
860 row
.prop(self
, "vres")
862 row
.prop(self
, "urad")
864 row
.prop(self
, "vrad")
866 row
.prop(self
, "uellipse")
868 row
.prop(self
, "vellipse")
870 row
.prop(self
, "upart")
872 row
.prop(self
, "vpart")
874 row
.prop(self
, "ugap")
875 row
.prop(self
, "vgap")
878 elif tmp
== 'Sphere':
879 col
.label(text
="Sphere Parameters")
881 row
.prop(self
, "bures")
883 row
.prop(self
, "bvres")
885 row
.prop(self
, "burad")
887 row
.prop(self
, "bupart")
889 row
.prop(self
, "buphase")
891 row
.prop(self
, "bvpart")
893 row
.prop(self
, "bvphase")
895 row
.prop(self
, "buellipse")
897 row
.prop(self
, "bvellipse")
898 elif tmp
== 'Parabola':
899 col
.label(text
="Parabola Parameters")
901 row
.prop(self
, "paxres")
903 row
.prop(self
, "payres")
905 row
.prop(self
, "paxsz")
907 row
.prop(self
, "paysz")
909 row
.prop(self
, "paxell")
911 row
.prop(self
, "pagap")
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")
924 col
.label(text
="Grid Parameters")
926 row
.prop(self
, "grxres")
928 row
.prop(self
, "gryres")
930 row
.prop(self
, "grxsz")
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
938 row
.prop(self
, "uact")
940 row
.prop(self
, "vact")
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")
946 row
.label(text
="Superform Parameters")
951 row
.prop(self
, "un1")
953 row
.prop(self
, "un2")
955 row
.prop(self
, "un3")
961 row
.prop(self
, "uturn")
963 row
.prop(self
, "utwist")
968 row
.prop(self
, "vn1")
970 row
.prop(self
, "vn2")
972 row
.prop(self
, "vn3")
978 row
.prop(self
, "vturn")
980 row
.prop(self
, "vtwist")
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)
990 elif which_mainpages
== "Hubs":
992 row
.prop(self
, "hubtoggle")
994 if self
.hubimpmesh
== "None":
996 row
.label(text
="Name of a hub to use")
998 row
.prop(self
, "hubimpmesh")
1000 if self
.hmeshname
== "None":
1002 row
.label(text
="Name of mesh to be filled in")
1004 row
.prop(self
, "hmeshname")
1006 row
.prop(self
, "hwtog")
1008 row
.prop(self
, "hubwidth")
1010 row
.prop(self
, "hhtog")
1012 row
.prop(self
, "hubheight")
1014 row
.prop(self
, "hublength")
1015 elif which_mainpages
== "Struts":
1017 row
.prop(self
, "struttype")
1018 row
.prop(self
, "struttoggle")
1021 row
.prop(self
, "strutimpmesh")
1023 row
.prop(self
, "swtog")
1025 row
.prop(self
, "strutwidth")
1027 row
.prop(self
, "shtog")
1029 row
.prop(self
, "strutheight")
1031 row
.prop(self
, "sstog")
1033 row
.prop(self
, "strutshrink")
1035 row
.prop(self
, "stretch")
1037 row
.prop(self
, "lift")
1039 row
.prop(self
, "smeshname")
1040 elif which_mainpages
== "Faces":
1042 row
.prop(self
, "facetoggle")
1044 row
.prop(self
, "face_use_imported_object")
1046 row
.prop(self
, "facetype_menu")
1048 row
.prop(self
, "fwtog")
1050 row
.prop(self
, "facewidth")
1052 row
.prop(self
, "fhtog")
1054 row
.prop(self
, "faceheight")
1056 row
.prop(self
, "face_detach")
1058 row
.prop(self
, "fmeshname")
1062 elif which_mainpages
== "Help":
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
])
1079 help_text
= ["To Use",
1080 "If normals look inverted:",
1081 "Once mesh is finished,",
1082 "You may recalc normals outside.",
1084 "To use your own mesh with the:",
1086 "Import your mesh in the:",
1087 "Objects: Geodesic menu.",
1088 "You must type in the name",
1089 "Of your custom object first.",
1091 "To use your own mesh with the: ",
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
]
1110 if self
.mainpages
== 'Main':
1111 if self
.geodesic_types
== "Geodesic":
1112 tmp_fs
= self
.tri_hex_star
1113 faceshape
= 0 # tri!
1116 elif tmp_fs
== "star":
1118 tmp_cl
= self
.geodesic_class
1120 if tmp_cl
== "Class_2":
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
,
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")
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
)
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
1196 hubheight
= self
.hubheight
1198 hublength
= self
.hublength
1200 hmeshname
= self
.hmeshname
1202 if not (hmeshname
== "None") and not (hubimpmesh
== "None") and hubtoggle
:
1204 hub_obj
= vefm_271
.importmesh(hmeshname
, 0)
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
)
1215 message
= "***ERROR*** \nEither no mesh for hub\nor " + \
1216 hmeshname
+ " available"
1217 error_message
= message
1219 mesh
= vefm_271
.vefm_add_object(basegeodesic
)
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
1232 strutheight
= self
.strutheight
1234 strutshrink
= self
.strutshrink
1236 stretch
= self
.stretch
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
)
1251 message
= "***ERROR***\nStrut object " + strutimpmesh
+ "\nis not a Mesh"
1252 error_message
= message
1253 print("***ERROR*** Strut object is not a Mesh")
1255 mesh
= vefm_271
.vefm_add_object(basegeodesic
)
1256 elif self
.mainpages
== "Faces":
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
1276 if last_imported_mesh
:
1277 faceobject
= vefm_271
.facetype(
1278 last_imported_mesh
, facedata
,
1279 self
.facewidth
, self
.faceheight
, self
.fwtog
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
)
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
1300 oldmeshname
= obj
.data
.name
1302 for material
in oldmesh
.materials
:
1303 obj
.data
.materials
.append(material
)
1304 bpy
.data
.meshes
.remove(oldmesh
)
1305 obj
.data
.name
= oldmeshname
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')
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
)
1337 def creategeo(polytype
, orientation
, parameters
):
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
)
1363 basegeodesic
, fmeshname
, smeshname
, hmeshname
, outputmeshname
, strutimpmesh
, hubimpmesh
= [None] * 7
1366 def finalfill(source
, target
):
1368 for point
in source
.verts
:
1369 newvert
= vefm_271
.vertex(point
.vector
)
1370 target
.verts
.append(newvert
)
1373 for facey
in source
.faces
:
1374 row
= len(facey
.vertices
)
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
):
1381 a
= target
.verts
[facey
.vertices
[-1].index
]
1382 b
= target
.verts
[facey
.vertices
[0].index
]
1384 a
= target
.verts
[facey
.vertices
[i
].index
]
1385 b
= target
.verts
[facey
.vertices
[i
+ 1].index
]
1388 target
.faces
.append(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"
1403 def draw(self
, context
):
1404 layout
= self
.layout
1405 message
= error_message
1406 col
= layout
.column()
1407 tmp
= message
.split("\n")
1409 col
.label(text
= "")
1411 def execute(self
, context
):
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",
1425 "face_use_imported_object",
1439 "use_imported_mesh",
1516 "strutimporttoggle",
1539 return GeodesicDomeParameters