1 # SPDX-FileCopyrightText: 2016-2022 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
8 from . import forms_271
9 from . import geodesic_classes_271
10 from . import add_shape_geodesic
12 from bpy
.types
import Operator
13 from bpy
.props
import (
22 from mathutils
import (
26 from bpy_extras
import object_utils
29 last_generated_object
= None
30 last_imported_mesh
= None
32 imported_hubmesh_to_use
= None
34 geodesic_not_yet_called
= True
37 # ###### EIND FOR SHAPEKEYS ######
40 class GenerateGeodesicDome(Operator
, object_utils
.AddObjectHelper
):
41 bl_label
= "Modify Geodesic Objects"
42 bl_idname
= "mesh.generate_geodesic_dome"
43 bl_description
= "Create Geodesic Object Types"
44 bl_options
= {'REGISTER', 'UNDO', 'PRESET'}
46 GeodesicDome
: BoolProperty(name
= "GeodesicDome",
48 description
= "GeodesicDome")
49 change
: BoolProperty(name
= "Change",
51 description
= "change Geodesic Dome")
53 gd_help_text_width
: IntProperty(
55 description
="The width above which the text wraps",
59 mainpages
: EnumProperty(
61 description
="Create Faces, Struts & Hubs",
62 items
=[("Main", "Main", "Geodesic objects"),
63 ("Faces", "Faces", "Generate Faces"),
64 ("Struts", "Struts", "Generate Struts"),
65 ("Hubs", "Hubs", "Generate Hubs"),
66 ("Help", "Help", "Not implemented"),
71 facetype_menu
: EnumProperty(
73 description
="choose a facetype",
74 items
=[("0", "strip", "strip"),
75 ("1", "open vertical", "vertical"),
76 ("2", "open slanted", "slanted"),
77 ("3", "closed point", "closed point"),
78 ("4", "pillow", "pillow"),
79 ("5", "closed vertical", "closed vertical"),
80 ("6", "stepped", "stepped"),
81 ("7", "spikes", "spikes"),
82 ("8", "boxed", "boxed"),
83 ("9", "diamond", "diamond"),
84 # ("10", "bar", "bar"),
88 facetoggle
: BoolProperty(
89 name
="Activate: Face Object",
90 description
="Activate Faces for Geodesic object",
93 face_use_imported_object
: BoolProperty(
94 name
="Use: Imported Object",
95 description
="Activate faces on your Imported object",
98 facewidth
: FloatProperty(
100 min=-1, soft_min
=0.001, max=4,
107 faceheight
: FloatProperty(
116 face_detach
: BoolProperty(
120 fmeshname
: StringProperty(
121 name
="Face Mesh name",
122 default
="defaultface"
124 geodesic_types
: EnumProperty(
126 description
="Choose Geodesic, Grid, Cylinder, Parabola, "
127 "Torus, Sphere, Import your mesh or Superparameters",
128 items
=[("Geodesic", "Geodesic", "Generate Geodesic"),
129 ("Grid", "Grid", "Generate Grid"),
130 ("Cylinder", "Cylinder", "Generate Cylinder"),
131 ("Parabola", "Parabola", "Generate Parabola"),
132 ("Torus", "Torus", "Generate Torus"),
133 ("Sphere", "Sphere", "Generate Sphere"),
134 ("Import_your_mesh", "Import your mesh", "Import Your Mesh"),
138 import_mesh_name
: StringProperty(
139 name
="Mesh to import",
140 description
="the name has to be the name of a meshobject",
143 base_type
: EnumProperty(
145 description
="Choose between Tetrahedron, Octahedron, Icosahedron ",
146 items
=[("Tetrahedron", "Tetrahedron", "Generate Tetrahedron"),
147 ("Octahedron", "Octahedron", "Generate Octahedron"),
148 ("Icosahedron", "Icosahedron", "Generate Icosahedron"),
150 default
='Tetrahedron'
152 orientation
: EnumProperty(
154 description
="Point (Vert), Edge or Face pointing upwards",
155 items
=[("PointUp", "PointUp", "Point up"),
156 ("EdgeUp", "EdgeUp", "Edge up"),
157 ("FaceUp", "FaceUp", "Face up"),
161 geodesic_class
: EnumProperty(
163 description
="Subdivide Basic/Triacon",
164 items
=[("Class_1", "Class 1", "class one"),
165 ("Class_2", "Class 2", "class two"),
169 tri_hex_star
: EnumProperty(
171 description
="Choose between tri hex star face types",
172 items
=[("tri", "tri", "tri faces"),
173 ("hex", "hex", "hex faces(by tri)"),
174 ("star", "star", "star faces(by tri)"),
178 spherical_flat
: EnumProperty(
180 description
="Choose between spherical or flat ",
181 items
=[("spherical", "spherical", "Generate spherical"),
182 ("flat", "flat", "Generate flat"),
186 use_imported_mesh
: BoolProperty(
188 description
="Use an imported mesh",
193 name
="Resolution x/y",
195 description
="Number of faces around x/y",
201 description
="Number of faces in z direction",
204 cyxsz
: FloatProperty(
207 description
="Scale in x/y direction",
210 cyysz
: FloatProperty(
213 description
="Scale in z direction",
216 cyxell
: FloatProperty(
219 description
="Stretch in x direction",
222 cygap
: FloatProperty(
225 description
="Shrink in % around radius",
228 cygphase
: FloatProperty(
229 name
="Phase", min=-4, #max=4,
230 description
="Rotate around pivot x/y",
235 name
="Resolution x/y",
237 description
="Number of faces around x/y",
243 description
="Number of faces in z direction",
246 paxsz
: FloatProperty(
249 description
="scale in x/y direction",
252 paysz
: FloatProperty(
255 description
="Scale in z direction",
258 paxell
: FloatProperty(
261 description
="Stretch in x direction",
264 pagap
: FloatProperty(
267 description
="Shrink in % around radius",
270 pagphase
: FloatProperty(
273 description
="Rotate around pivot x/y",
278 name
="Resolution x/y",
280 description
="Number of faces around x/y",
285 description
="Number of faces in z direction",
290 description
="Radius in x/y plane",
296 description
="Radius in z plane",
299 uellipse
: FloatProperty(
302 description
="Number of faces in z direction",
305 vellipse
: FloatProperty(
308 description
="Number of faces in z direction",
311 upart
: FloatProperty(
314 description
="Shrink faces around x/y",
317 vpart
: FloatProperty(
320 description
="Shrink faces in z direction",
326 description
="Rotate around pivot x/y",
332 description
="Rotate around pivot z",
335 uphase
: FloatProperty(
338 description
="Number of faces in z direction",
341 vphase
: FloatProperty(
344 description
="Number of faces in z direction",
350 description
="Number of faces in z direction",
356 description
="Number of faces in z direction",
359 usuper
: FloatProperty(
362 description
="First set of superform parameters",
365 vsuper
: FloatProperty(
368 description
="Second set of superform parameters",
371 utwist
: FloatProperty(
374 description
="Use with superformular u",
377 vtwist
: FloatProperty(
380 description
="Use with superformular v",
385 name
="Resolution x/y",
387 description
="Number of faces around x/y",
393 description
="Number of faces in z direction",
396 burad
: FloatProperty(
399 description
="overall radius",
402 bupart
: FloatProperty(
405 description
="Shrink faces around x/y",
408 bvpart
: FloatProperty(
411 description
="Shrink faces in z direction",
414 buphase
: FloatProperty(
417 description
="Rotate around pivot x/y",
420 bvphase
: FloatProperty(
423 description
="Rotate around pivot z",
426 buellipse
: FloatProperty(
429 description
="Stretch in the x direction",
432 bvellipse
: FloatProperty(
435 description
="Stretch in the z direction",
441 min=2, #soft_max=10, max=20,
442 description
="Number of faces in x direction",
448 #soft_max=10, max=20,
449 description
="Number of faces in x direction",
452 grxsz
: FloatProperty(
454 min=1, soft_min
=0.01,
456 description
="X size",
459 grysz
: FloatProperty(
461 min=1, soft_min
=0.01,
463 description
="Y size",
467 # PKHG_TODO_??? what means cart
473 frequency
: IntProperty(
476 description
="Subdivide base triangles",
479 eccentricity
: FloatProperty(
482 description
="Scaling in x/y dimension",
485 squish
: FloatProperty(
489 description
="Scaling in z dimension",
492 radius
: FloatProperty(
496 description
="Overall radius",
499 squareness
: FloatProperty(
502 description
="Superelipse action in x/y",
505 squarez
: FloatProperty(
507 min=0.1, #soft_max=5, max=10,
508 description
="Superelipse action in z",
511 baselevel
: IntProperty(
517 description
="Faces become verts, "
518 "verts become faces, edges flip",
521 rotxy
: FloatProperty(
524 description
="Rotate superelipse action in x/y",
530 description
="Rotate superelipse action in z",
534 # for choice of superformula
536 name
="Superformula u (x/y)",
537 description
="Activate superformula u parameters",
541 name
="Superformula v (z)",
542 description
="Activate superformula v parameters",
549 description
="Pinch the mesh on x/y",
556 description
="Squash the mesh x/y",
563 description
="Inflate the mesh x/y",
570 description
="Roundify x/y",
577 description
="Shrink",
584 description
="Shrink y/x",
591 description
="Scale Z Base",
595 name
="Scale lock Top Z",
598 description
="Scale lock Top Z",
605 description
="Inflate Base",
612 description
="Inflate",
619 description
="Scale 1",
626 description
="Scale 2",
630 uturn
: FloatProperty(
631 name
="x/y Vert cycle",
634 description
="x/y Vert cycle",
637 vturn
: FloatProperty(
641 description
="z Vert cycle",
644 utwist
: FloatProperty(
645 name
="x/y Twist cycle",
648 description
="x/y Twist cycle",
651 vtwist
: FloatProperty(
652 name
="z Twist cycle",
655 description
="z Twist cycle",
659 struttype
: IntProperty(
663 struttoggle
: BoolProperty(
667 strutimporttoggle
: BoolProperty(
668 name
="Strut import toggle",
671 strutimpmesh
: StringProperty(
672 name
="Strut import mesh",
675 strutwidth
: FloatProperty(
685 strutheight
: FloatProperty(
695 strutshrink
: FloatProperty(
704 stretch
: FloatProperty(
714 smeshname
: StringProperty(
715 name
="Strut mesh name",
716 default
="defaultstrut"
719 hubtype
: BoolProperty(
721 description
="not used",
724 hubtoggle
: BoolProperty(
728 hubimporttoggle
: BoolProperty(
730 description
="Import a mesh",
733 hubimpmesh
: StringProperty(
734 name
="Hub mesh import",
735 description
="Name of mesh to import",
738 hubwidth
: FloatProperty(
747 hubheight
: FloatProperty(
756 hublength
: FloatProperty(
765 hmeshname
: StringProperty(
766 name
="Hub mesh name",
767 description
="Name of an existing mesh needed!",
771 'facetype_menu', 'facetoggle', 'face_use_imported_object',
772 'facewidth', 'fwtog', 'faceheight', 'fhtog',
773 'face_detach', 'fmeshname', 'geodesic_types', 'import_mesh_name',
774 'base_type', 'orientation', 'geodesic_class', 'tri_hex_star',
775 'spherical_flat', 'use_imported_mesh', 'cyxres', 'cyyres',
776 'cyxsz', 'cyysz', 'cyxell', 'cygap',
777 'cygphase', 'paxres', 'payres', 'paxsz',
778 'paysz', 'paxell', 'pagap', 'pagphase',
779 'ures', 'vres', 'urad', 'vrad',
780 'uellipse', 'vellipse', 'upart', 'vpart',
781 'ugap', 'vgap', 'uphase', 'vphase',
782 'uexp', 'vexp', 'usuper', 'vsuper',
783 'utwist', 'vtwist', 'bures', 'bvres',
784 'burad', 'bupart', 'bvpart', 'buphase',
785 'bvphase', 'buellipse', 'bvellipse', 'grxres',
786 'gryres', 'grxsz', 'grysz',
787 'cart', 'frequency', 'eccentricity', 'squish',
788 'radius', 'squareness', 'squarez', 'baselevel',
789 'dual', 'rotxy', 'rotz',
790 'uact', 'vact', 'um', 'un1',
791 'un2', 'un3', 'ua', 'ub',
792 'vm', 'vn1', 'vn2', 'vn3',
793 'va', 'vb', 'uturn', 'vturn',
794 'utwist', 'vtwist', 'struttype', 'struttoggle',
795 'strutimporttoggle', 'strutimpmesh', 'strutwidth', 'swtog',
796 'strutheight', 'shtog', 'strutshrink', 'sstog',
797 'stretch', 'lift', 'smeshname', 'hubtype',
798 'hubtoggle', 'hubimporttoggle', 'hubimpmesh', 'hubwidth',
799 'hwtog', 'hubheight', 'hhtog', 'hublength',
803 def write_params(self
, filename
):
804 file = open(filename
, "w", encoding
="utf8", newline
="\n")
807 for el
in self
.name_list
:
809 fw(repr(getattr(self
, el
)))
813 def read_file(self
, filename
):
814 file = open(filename
, "r", newline
="\n")
816 line
= file.readline()
818 tmp
= line
.split(", ")
819 result
.append(eval(tmp
[1]))
820 line
= file.readline()
823 def draw(self
, context
):
826 col
= layout
.column()
827 col
.prop(self
, "mainpages")
828 which_mainpages
= self
.mainpages
829 if which_mainpages
== 'Main':
830 col
= layout
.column()
831 col
.prop(self
, "geodesic_types")
832 tmp
= self
.geodesic_types
833 if tmp
== "Geodesic":
834 col
.label(text
="Geodesic Object Types:")
835 col
.prop(self
, "geodesic_class")
836 col
.prop(self
, "base_type")
837 col
.prop(self
, "orientation")
838 col
.prop(self
, "tri_hex_star")
839 col
.prop(self
, "spherical_flat")
840 col
.label(text
="Geodesic Object Parameters:")
842 row
.prop(self
, "frequency")
844 row
.prop(self
, "radius")
846 row
.prop(self
, "eccentricity")
848 row
.prop(self
, "squish")
850 row
.prop(self
, "squareness")
852 row
.prop(self
, "squarez")
854 row
.prop(self
, "rotxy")
856 row
.prop(self
, "rotz")
858 row
.prop(self
, "dual")
860 col
.label(text
="Torus Parameters")
862 row
.prop(self
, "ures")
864 row
.prop(self
, "vres")
866 row
.prop(self
, "urad")
868 row
.prop(self
, "vrad")
870 row
.prop(self
, "uellipse")
872 row
.prop(self
, "vellipse")
874 row
.prop(self
, "upart")
876 row
.prop(self
, "vpart")
878 row
.prop(self
, "ugap")
879 row
.prop(self
, "vgap")
882 elif tmp
== 'Sphere':
883 col
.label(text
="Sphere Parameters")
885 row
.prop(self
, "bures")
887 row
.prop(self
, "bvres")
889 row
.prop(self
, "burad")
891 row
.prop(self
, "bupart")
893 row
.prop(self
, "buphase")
895 row
.prop(self
, "bvpart")
897 row
.prop(self
, "bvphase")
899 row
.prop(self
, "buellipse")
901 row
.prop(self
, "bvellipse")
902 elif tmp
== 'Parabola':
903 col
.label(text
="Parabola Parameters")
905 row
.prop(self
, "paxres")
907 row
.prop(self
, "payres")
909 row
.prop(self
, "paxsz")
911 row
.prop(self
, "paysz")
913 row
.prop(self
, "paxell")
915 row
.prop(self
, "pagap")
917 row
.prop(self
, "pagphase")
918 elif tmp
== 'Cylinder':
919 col
.label(text
="Cylinder Parameters")
920 col
.prop(self
, "cyxres")
921 col
.prop(self
, "cyyres")
922 col
.prop(self
, "cyxsz")
923 col
.prop(self
, "cyysz")
924 col
.prop(self
, "cyxell")
925 col
.prop(self
, "cygap")
926 col
.prop(self
, "cygphase")
928 col
.label(text
="Grid Parameters")
930 row
.prop(self
, "grxres")
932 row
.prop(self
, "gryres")
934 row
.prop(self
, "grxsz")
936 row
.prop(self
, "grysz")
937 elif tmp
== 'Import_your_mesh':
938 col
.prop(self
, "use_imported_mesh")
939 col
.prop(self
, "import_mesh_name")
940 # superform parameters only where possible
942 row
.prop(self
, "uact")
944 row
.prop(self
, "vact")
946 if tmp
!= 'Import_your_mesh':
947 if (self
.uact
is False) and (self
.vact
is False):
948 row
.label(text
="No checkbox active", icon
="INFO")
950 row
.label(text
="Superform Parameters")
955 row
.prop(self
, "un1")
957 row
.prop(self
, "un2")
959 row
.prop(self
, "un3")
965 row
.prop(self
, "uturn")
967 row
.prop(self
, "utwist")
972 row
.prop(self
, "vn1")
974 row
.prop(self
, "vn2")
976 row
.prop(self
, "vn3")
982 row
.prop(self
, "vturn")
984 row
.prop(self
, "vtwist")
986 if self
.change
== False:
987 col
= layout
.column(align
=True)
988 col
.prop(self
, 'align', expand
=True)
989 col
= layout
.column(align
=True)
990 col
.prop(self
, 'location', expand
=True)
991 col
= layout
.column(align
=True)
992 col
.prop(self
, 'rotation', expand
=True)
994 elif which_mainpages
== "Hubs":
996 row
.prop(self
, "hubtoggle")
998 if self
.hubimpmesh
== "None":
1000 row
.label(text
="Name of a hub to use")
1002 row
.prop(self
, "hubimpmesh")
1004 if self
.hmeshname
== "None":
1006 row
.label(text
="Name of mesh to be filled in")
1008 row
.prop(self
, "hmeshname")
1010 row
.prop(self
, "hwtog")
1012 row
.prop(self
, "hubwidth")
1014 row
.prop(self
, "hhtog")
1016 row
.prop(self
, "hubheight")
1018 row
.prop(self
, "hublength")
1019 elif which_mainpages
== "Struts":
1021 row
.prop(self
, "struttype")
1022 row
.prop(self
, "struttoggle")
1025 row
.prop(self
, "strutimpmesh")
1027 row
.prop(self
, "swtog")
1029 row
.prop(self
, "strutwidth")
1031 row
.prop(self
, "shtog")
1033 row
.prop(self
, "strutheight")
1035 row
.prop(self
, "sstog")
1037 row
.prop(self
, "strutshrink")
1039 row
.prop(self
, "stretch")
1041 row
.prop(self
, "lift")
1043 row
.prop(self
, "smeshname")
1044 elif which_mainpages
== "Faces":
1046 row
.prop(self
, "facetoggle")
1048 row
.prop(self
, "face_use_imported_object")
1050 row
.prop(self
, "facetype_menu")
1052 row
.prop(self
, "fwtog")
1054 row
.prop(self
, "facewidth")
1056 row
.prop(self
, "fhtog")
1058 row
.prop(self
, "faceheight")
1060 row
.prop(self
, "face_detach")
1062 row
.prop(self
, "fmeshname")
1066 elif which_mainpages
== "Help":
1069 # a function that allows for multiple labels with text that wraps
1070 # you can allow the user to set where the text wraps with the
1071 # text_width parameter
1072 # other parameters are ui : here you usually pass layout
1073 # text: is a list with each index representing a line of text
1075 def multi_label(text
, ui
, text_width
=120):
1076 for x
in range(0, len(text
)):
1077 el
= textwrap
.wrap(text
[x
], width
=text_width
)
1079 for y
in range(0, len(el
)):
1080 ui
.label(text
=el
[y
])
1083 help_text
= ["To Use",
1084 "If normals look inverted:",
1085 "Once mesh is finished,",
1086 "You may recalc normals outside.",
1088 "To use your own mesh with the:",
1090 "Import your mesh in the:",
1091 "Objects: Geodesic menu.",
1092 "You must type in the name",
1093 "Of your custom object first.",
1095 "To use your own mesh with the: ",
1097 "You must type in the name",
1098 "Of your custom object/s first,"]
1099 text_width
= self
.gd_help_text_width
1100 box
.prop(self
, "gd_help_text_width", slider
=True)
1101 multi_label(help_text
, box
, text_width
)
1103 def execute(self
, context
):
1105 global last_generated_object
, last_imported_mesh
, basegeodesic
, imported_hubmesh_to_use
, error_message
1106 # default superformparam = [3, 10, 10, 10, 1, 1, 4, 10, 10, 10, 1, 1, 0, 0, 0.0, 0.0, 0, 0]]
1107 superformparam
= [self
.um
, self
.un1
, self
.un2
, self
.un3
, self
.ua
,
1108 self
.ub
, self
.vm
, self
.vn1
, self
.vn2
, self
.vn3
,
1109 self
.va
, self
.vb
, self
.uact
, self
.vact
,
1110 self
.uturn
* pi
, self
.vturn
* pi
,
1111 self
.utwist
, self
.vtwist
]
1114 if self
.mainpages
== 'Main':
1115 if self
.geodesic_types
== "Geodesic":
1116 tmp_fs
= self
.tri_hex_star
1117 faceshape
= 0 # tri!
1120 elif tmp_fs
== "star":
1122 tmp_cl
= self
.geodesic_class
1124 if tmp_cl
== "Class_2":
1127 parameters
= [self
.frequency
, self
.eccentricity
, self
.squish
,
1128 self
.radius
, self
.squareness
, self
.squarez
, 0,
1129 shape
, self
.baselevel
, faceshape
, self
.dual
,
1130 self
.rotxy
, self
.rotz
, klass
, superformparam
]
1132 basegeodesic
= creategeo(self
.base_type
, self
.orientation
, parameters
)
1133 basegeodesic
.makegeodesic()
1134 basegeodesic
.connectivity()
1135 basemesh
= vefm_271
.mesh()
1136 vefm_271
.finalfill(basegeodesic
, basemesh
) # always! for hexifiy etc. necessary!!!
1137 mesh
= vefm_271
.vefm_add_object(basegeodesic
)
1138 elif self
.geodesic_types
== 'Grid':
1139 basegeodesic
= forms_271
.grid(self
.grxres
, self
.gryres
,
1140 self
.grxsz
, self
.grysz
, 1.0, 1.0, 0, 0, 0,
1141 0, 1.0, 1.0, superformparam
)
1142 mesh
= vefm_271
.vefm_add_object(basegeodesic
)
1143 elif self
.geodesic_types
== "Cylinder":
1144 basegeodesic
= forms_271
.cylinder(
1145 self
.cyxres
, self
.cyyres
,
1146 self
.cyxsz
, self
.cyysz
, self
.cygap
,
1147 1.0, self
.cygphase
, 0, 0, 0, self
.cyxell
,
1150 mesh
= vefm_271
.vefm_add_object(basegeodesic
)
1151 elif self
.geodesic_types
== "Parabola":
1152 basegeodesic
= forms_271
.parabola(
1153 self
.paxres
, self
.payres
,
1154 self
.paxsz
, self
.paysz
, self
.pagap
, 1.0, self
.pagphase
,
1155 0, 0, 0, self
.paxell
, 1.0, superformparam
1157 mesh
= vefm_271
.vefm_add_object(basegeodesic
)
1158 elif self
.geodesic_types
== "Torus":
1159 basegeodesic
= forms_271
.torus(
1160 self
.ures
, self
.vres
,
1161 self
.vrad
, self
.urad
, self
.upart
, self
.vpart
,
1162 self
.ugap
, self
.vgap
, 0, 0, self
.uellipse
,
1163 self
.vellipse
, superformparam
1165 mesh
= vefm_271
.vefm_add_object(basegeodesic
)
1166 elif self
.geodesic_types
== "Sphere":
1167 basegeodesic
= forms_271
.sphere(
1168 self
.bures
, self
.bvres
,
1169 self
.burad
, 1.0, self
.bupart
, self
.bvpart
,
1170 self
.buphase
, self
.bvphase
, 0, 0, self
.buellipse
,
1171 self
.bvellipse
, superformparam
1173 mesh
= vefm_271
.vefm_add_object(basegeodesic
)
1174 elif self
.geodesic_types
== "Import_your_mesh":
1175 obj_name
= self
.import_mesh_name
1176 if obj_name
== "None":
1177 message
= "Fill in a name \nof an existing mesh\nto be imported"
1178 error_message
= message
1179 self
.report({"INFO"}, message
)
1180 print("***INFO*** You have to fill in the name of an existing mesh")
1182 names
= [el
.name
for el
in context
.scene
.objects
]
1183 if obj_name
in names
and context
.scene
.objects
[obj_name
].type == "MESH":
1184 obj
= context
.scene
.objects
[obj_name
]
1185 your_obj
= vefm_271
.importmesh(obj
.name
, False)
1186 last_imported_mesh
= your_obj
1187 mesh
= vefm_271
.vefm_add_object(your_obj
)
1189 message
= obj_name
+ " does not exist \nor is not a Mesh"
1190 error_message
= message
1191 self
.report({'ERROR'}, message
)
1192 print("***ERROR***" + obj_name
+ " does not exist or is not a Mesh")
1193 elif self
.mainpages
== "Hubs":
1194 hubtype
= self
.hubtype
1195 hubtoggle
= self
.hubtoggle
1196 hubimporttoggle
= self
.hubimporttoggle
1197 hubimpmesh
= self
.hubimpmesh
1198 hubwidth
= self
.hubwidth
1200 hubheight
= self
.hubheight
1202 hublength
= self
.hublength
1204 hmeshname
= self
.hmeshname
1206 if not (hmeshname
== "None") and not (hubimpmesh
== "None") and hubtoggle
:
1208 hub_obj
= vefm_271
.importmesh(hmeshname
, 0)
1212 hubwidth
, hubheight
, hublength
,
1213 hwtog
, hhtog
, hstog
, hubimpmesh
1215 hubmesh
= vefm_271
.mesh("test")
1216 vefm_271
.finalfill(hub
, hubmesh
)
1217 mesh
= vefm_271
.vefm_add_object(hubmesh
)
1219 message
= "***ERROR*** \nEither no mesh for hub\nor " + \
1220 hmeshname
+ " available"
1221 error_message
= message
1223 mesh
= vefm_271
.vefm_add_object(basegeodesic
)
1225 message
= "***INFO***\nEnable Hubs first"
1226 error_message
= message
1227 print("\n***INFO*** Enable Hubs first")
1228 mesh
= vefm_271
.vefm_add_object(basegeodesic
)
1229 elif self
.mainpages
== "Struts":
1230 struttype
= self
.struttype
1231 struttoggle
= self
.struttoggle
1232 strutimporttoggle
= self
.strutimporttoggle
1233 strutimpmesh
= self
.strutimpmesh
1234 strutwidth
= self
.strutwidth
1236 strutheight
= self
.strutheight
1238 strutshrink
= self
.strutshrink
1240 stretch
= self
.stretch
1242 smeshname
= self
.smeshname
1243 if not (strutimpmesh
== "None") and struttoggle
:
1244 names
= [el
.name
for el
in context
.scene
.objects
]
1245 if strutimpmesh
in names
and context
.scene
.objects
[strutimpmesh
].type == "MESH":
1246 strut
= vefm_271
.strut(
1247 basegeodesic
, struttype
, strutwidth
,
1248 strutheight
, stretch
, swtog
, shtog
, swtog
,
1249 strutimpmesh
, sstog
, lift
1251 strutmesh
= vefm_271
.mesh()
1252 vefm_271
.finalfill(strut
, strutmesh
)
1253 mesh
= vefm_271
.vefm_add_object(strutmesh
)
1255 message
= "***ERROR***\nStrut object " + strutimpmesh
+ "\nis not a Mesh"
1256 error_message
= message
1257 print("***ERROR*** Strut object is not a Mesh")
1259 mesh
= vefm_271
.vefm_add_object(basegeodesic
)
1260 elif self
.mainpages
== "Faces":
1262 faceparams
= [[self
.face_detach
, 0, [[0.5, 0.0]]], # 0 strip
1263 [self
.face_detach
, 0, [[0.0, 0.5]]], # 1 vertical
1264 [self
.face_detach
, 0, [[0.5, 0.5]]], # 2 slanted
1265 [self
.face_detach
, 1, [[0.25, 0.25], [0.5, 0.5]]], # 3 closed point
1266 [self
.face_detach
, 1, [[0.1, 0.03], [0.33, 0.06], [0.0, 0.1]]], # 4 pillow
1267 [self
.face_detach
, 2, [[0.0, 0.5]]], # 5 closed vertical
1268 [self
.face_detach
, 2, [[0.0, 0.25], [0.25, 0.25], [0.25, 0.5]]], # 6 stepped
1269 [self
.face_detach
, 1, [[0.2, 0.1], [0.4, 0.2], [0.0, 1.0]]], # 7 spikes
1270 [self
.face_detach
, 3, [[0.25, 0.0], [0.25, 0.5], [0.0, 0.5]]], # 8 boxed
1271 [self
.face_detach
, 3, [[0.25, 0.5], [0.5, 0.0], [0.25, -0.5]]], # 9 diamond
1272 [self
.face_detach
, 4, [[0.5, 0.0], [0.5, 0.5], [0.0, 0.5]]], ] # 10 bar
1273 facedata
= faceparams
[int(self
.facetype_menu
)]
1274 if not self
.face_use_imported_object
:
1275 faceobject
= vefm_271
.facetype(
1276 basegeodesic
, facedata
, self
.facewidth
,
1277 self
.faceheight
, self
.fwtog
1280 if last_imported_mesh
:
1281 faceobject
= vefm_271
.facetype(
1282 last_imported_mesh
, facedata
,
1283 self
.facewidth
, self
.faceheight
, self
.fwtog
1286 message
= "***ERROR***\nNo imported message available\n" + "last geodesic used"
1287 error_message
= message
1288 print("\n***ERROR*** No imported mesh available \nLast geodesic used!")
1289 faceobject
= vefm_271
.facetype(
1290 basegeodesic
, facedata
,
1291 self
.facewidth
, self
.faceheight
, self
.fwtog
1293 facemesh
= vefm_271
.mesh()
1294 finalfill(faceobject
, facemesh
)
1295 mesh
= vefm_271
.vefm_add_object(facemesh
)
1298 if bpy
.context
.mode
== "OBJECT":
1299 if context
.selected_objects
!= [] and context
.active_object
and \
1300 (context
.active_object
.data
is not None) and \
1301 ('GeodesicDome' in context
.active_object
.data
.keys()) and (self
.change
== True):
1302 obj
= context
.active_object
1304 oldmeshname
= obj
.data
.name
1306 for material
in oldmesh
.materials
:
1307 obj
.data
.materials
.append(material
)
1308 bpy
.data
.meshes
.remove(oldmesh
)
1309 obj
.data
.name
= oldmeshname
1311 obj
= object_utils
.object_data_add(context
, mesh
, operator
=self
)
1313 obj
.data
["GeodesicDome"] = True
1314 obj
.data
["change"] = False
1315 for prm
in GeodesicDomeParameters():
1316 obj
.data
[prm
] = getattr(self
, prm
)
1318 if bpy
.context
.mode
== "EDIT_MESH":
1319 active_object
= context
.active_object
1320 name_active_object
= active_object
.name
1321 bpy
.ops
.object.mode_set(mode
='OBJECT')
1322 obj
= object_utils
.object_data_add(context
, mesh
, operator
=self
)
1323 obj
.select_set(True)
1324 active_object
.select_set(True)
1325 bpy
.ops
.object.join()
1326 context
.active_object
.name
= name_active_object
1327 bpy
.ops
.object.mode_set(mode
='EDIT')
1331 def invoke(self
, context
, event
):
1332 global basegeodesic
, geodesic_not_yet_called
1333 if geodesic_not_yet_called
:
1334 geodesic_not_yet_called
= False
1335 bpy
.context
.view_layer
.update()
1336 self
.execute(context
)
1341 def creategeo(polytype
, orientation
, parameters
):
1343 if polytype
== "Tetrahedron":
1344 if orientation
== "PointUp":
1345 geo
= geodesic_classes_271
.tetrahedron(parameters
)
1346 elif orientation
== "EdgeUp":
1347 geo
= geodesic_classes_271
.tetraedge(parameters
)
1348 elif orientation
== "FaceUp":
1349 geo
= geodesic_classes_271
.tetraface(parameters
)
1350 elif polytype
== "Octahedron":
1351 if orientation
== "PointUp":
1352 geo
= geodesic_classes_271
.octahedron(parameters
)
1353 elif orientation
== "EdgeUp":
1354 geo
= geodesic_classes_271
.octaedge(parameters
)
1355 elif orientation
== "FaceUp":
1356 geo
= geodesic_classes_271
.octaface(parameters
)
1357 elif polytype
== "Icosahedron":
1358 if orientation
== "PointUp":
1359 geo
= geodesic_classes_271
.icosahedron(parameters
)
1360 elif orientation
== "EdgeUp":
1361 geo
= geodesic_classes_271
.icoedge(parameters
)
1362 elif orientation
== "FaceUp":
1363 geo
= geodesic_classes_271
.icoface(parameters
)
1367 basegeodesic
, fmeshname
, smeshname
, hmeshname
, outputmeshname
, strutimpmesh
, hubimpmesh
= [None] * 7
1370 def finalfill(source
, target
):
1372 for point
in source
.verts
:
1373 newvert
= vefm_271
.vertex(point
.vector
)
1374 target
.verts
.append(newvert
)
1377 for facey
in source
.faces
:
1378 row
= len(facey
.vertices
)
1380 newvert
= vefm_271
.average(facey
.vertices
).centroid()
1381 centre
= vefm_271
.vertex(newvert
.vector
)
1382 target
.verts
.append(centre
)
1383 for i
in range(row
):
1385 a
= target
.verts
[facey
.vertices
[-1].index
]
1386 b
= target
.verts
[facey
.vertices
[0].index
]
1388 a
= target
.verts
[facey
.vertices
[i
].index
]
1389 b
= target
.verts
[facey
.vertices
[i
+ 1].index
]
1392 target
.faces
.append(f
)
1395 for j
in range(len(facey
.vertices
)):
1397 a
= facey
.vertices
[j
]
1398 f
.append(target
.verts
[a
.index
])
1399 target
.faces
.append(f
)
1402 # for error messages
1403 class DialogOperator(Operator
):
1404 bl_idname
= "object.dialog_operator"
1407 def draw(self
, context
):
1408 layout
= self
.layout
1409 message
= error_message
1410 col
= layout
.column()
1411 tmp
= message
.split("\n")
1413 col
.label(text
= "")
1415 def execute(self
, context
):
1418 def invoke(self
, context
, event
):
1419 wm
= context
.window_manager
1420 return wm
.invoke_props_dialog(self
)
1423 def GeodesicDomeParameters():
1424 GeodesicDomeParameters
= [
1425 "gd_help_text_width",
1429 "face_use_imported_object",
1443 "use_imported_mesh",
1520 "strutimporttoggle",
1543 return GeodesicDomeParameters