Cleanup: remove "Tweak" event type
[blender-addons.git] / add_mesh_extra_objects / __init__.py
blob7777ff4527a13c84f9cecb7a19c6ab5bcb07bfc6
1 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Contributed to by:
4 # Pontiac, Fourmadmen, varkenvarken, tuga3d, meta-androcto, metalliandy #
5 # dreampainter, cotejrp1, liero, Kayo Phoenix, sugiany, dommetysk, Jambay #
6 # Phymec, Anthony D'Agostino, Pablo Vazquez, Richard Wilks, lijenstina, #
7 # Sjaak-de-Draak, Phil Cote, cotejrp1, xyz presets by elfnor, revolt_randy, #
8 # Vladimir Spivak (cwolf3d), #
11 bl_info = {
12 "name": "Extra Objects",
13 "author": "Multiple Authors",
14 "version": (0, 3, 7),
15 "blender": (2, 80, 0),
16 "location": "View3D > Add > Mesh",
17 "description": "Add extra mesh object types",
18 "warning": "",
19 "doc_url": "{BLENDER_MANUAL_URL}/addons/add_mesh/mesh_extra_objects.html",
20 "category": "Add Mesh",
23 # Note: Blocks has to be loaded before the WallFactory or the script
24 # will not work properly after (F8) reload
26 if "bpy" in locals():
27 import importlib
28 importlib.reload(add_mesh_star)
29 importlib.reload(add_mesh_twisted_torus)
30 importlib.reload(add_mesh_gemstones)
31 importlib.reload(add_mesh_gears)
32 importlib.reload(add_mesh_3d_function_surface)
33 importlib.reload(add_mesh_round_cube)
34 importlib.reload(add_mesh_supertoroid)
35 importlib.reload(add_mesh_pyramid)
36 importlib.reload(add_mesh_torusknot)
37 importlib.reload(add_mesh_honeycomb)
38 importlib.reload(add_mesh_teapot)
39 importlib.reload(add_mesh_pipe_joint)
40 importlib.reload(add_mesh_solid)
41 importlib.reload(add_mesh_round_brilliant)
42 importlib.reload(add_mesh_menger_sponge)
43 importlib.reload(add_mesh_vertex)
44 importlib.reload(add_empty_as_parent)
45 importlib.reload(add_mesh_beam_builder)
46 importlib.reload(Blocks)
47 importlib.reload(Wallfactory)
48 importlib.reload(add_mesh_triangles)
49 else:
50 from . import add_mesh_star
51 from . import add_mesh_twisted_torus
52 from . import add_mesh_gemstones
53 from . import add_mesh_gears
54 from . import add_mesh_3d_function_surface
55 from . import add_mesh_round_cube
56 from . import add_mesh_supertoroid
57 from . import add_mesh_pyramid
58 from . import add_mesh_torusknot
59 from . import add_mesh_honeycomb
60 from . import add_mesh_teapot
61 from . import add_mesh_pipe_joint
62 from . import add_mesh_solid
63 from . import add_mesh_round_brilliant
64 from . import add_mesh_menger_sponge
65 from . import add_mesh_vertex
66 from . import add_empty_as_parent
67 from . import add_mesh_beam_builder
68 from . import Blocks
69 from . import Wallfactory
70 from . import add_mesh_triangles
72 from .add_mesh_rocks import __init__
73 from .add_mesh_rocks import rockgen
75 import bpy
76 from bpy.types import Menu
78 class VIEW3D_MT_mesh_vert_add(Menu):
79 # Define the "Single Vert" menu
80 bl_idname = "VIEW3D_MT_mesh_vert_add"
81 bl_label = "Single Vert"
83 def draw(self, context):
84 layout = self.layout
85 layout.operator_context = 'INVOKE_REGION_WIN'
86 layout.operator("mesh.primitive_vert_add",
87 text="Add Single Vert")
88 layout.separator()
89 layout.operator("mesh.primitive_emptyvert_add",
90 text="Object Origin Only")
91 layout.operator("mesh.primitive_symmetrical_vert_add",
92 text="Origin & Vert Mirrored")
93 layout.operator("mesh.primitive_symmetrical_empty_add",
94 text="Object Origin Mirrored")
97 class VIEW3D_MT_mesh_gears_add(Menu):
98 # Define the "Gears" menu
99 bl_idname = "VIEW3D_MT_mesh_gears_add"
100 bl_label = "Gears"
102 def draw(self, context):
103 layout = self.layout
104 layout.operator_context = 'INVOKE_REGION_WIN'
105 oper = layout.operator("mesh.primitive_gear", text="Gear")
106 oper.change = False
107 oper = layout.operator("mesh.primitive_worm_gear", text="Worm")
108 oper.change = False
111 class VIEW3D_MT_mesh_diamonds_add(Menu):
112 # Define the "Diamonds" menu
113 bl_idname = "VIEW3D_MT_mesh_diamonds_add"
114 bl_label = "Diamonds"
116 def draw(self, context):
117 layout = self.layout
118 layout.operator_context = 'INVOKE_REGION_WIN'
119 oper = layout.operator("mesh.primitive_brilliant_add", text="Brilliant Diamond")
120 oper.change = False
121 oper = layout.operator("mesh.primitive_diamond_add", text="Diamond")
122 oper.change = False
123 oper = layout.operator("mesh.primitive_gem_add", text="Gem")
124 oper.change = False
127 class VIEW3D_MT_mesh_math_add(Menu):
128 # Define the "Math Function" menu
129 bl_idname = "VIEW3D_MT_mesh_math_add"
130 bl_label = "Math Functions"
132 def draw(self, context):
133 layout = self.layout
134 layout.operator_context = 'INVOKE_REGION_WIN'
135 layout.operator("mesh.primitive_z_function_surface",
136 text="Z Math Surface")
137 layout.operator("mesh.primitive_xyz_function_surface",
138 text="XYZ Math Surface")
139 self.layout.operator("mesh.primitive_solid_add", text="Regular Solid")
140 self.layout.operator("mesh.make_triangle")
143 class VIEW3D_MT_mesh_extras_add(Menu):
144 # Define the "Extra Objects" menu
145 bl_idname = "VIEW3D_MT_mesh_extras_add"
146 bl_label = "Extras"
148 def draw(self, context):
149 layout = self.layout
150 layout.operator_context = 'INVOKE_REGION_WIN'
151 oper = layout.operator("mesh.add_beam", text="Beam Builder")
152 oper.change = False
153 oper = layout.operator("mesh.wall_add", text="Wall Factory")
154 oper.change = False
155 layout.separator()
156 oper = layout.operator("mesh.primitive_star_add", text="Simple Star")
157 oper.change = False
158 oper = layout.operator("mesh.primitive_steppyramid_add", text="Step Pyramid")
159 oper.change = False
160 oper = layout.operator("mesh.honeycomb_add", text="Honeycomb")
161 oper.change = False
162 oper = layout.operator("mesh.primitive_teapot_add", text="Teapot+")
163 oper = layout.operator("mesh.menger_sponge_add", text="Menger Sponge")
166 class VIEW3D_MT_mesh_torus_add(Menu):
167 # Define the "Torus Objects" menu
168 bl_idname = "VIEW3D_MT_mesh_torus_add"
169 bl_label = "Torus Objects"
171 def draw(self, context):
172 layout = self.layout
173 layout.operator_context = 'INVOKE_REGION_WIN'
174 oper = layout.operator("mesh.primitive_twisted_torus_add", text="Twisted Torus")
175 oper.change = False
176 oper = layout.operator("mesh.primitive_supertoroid_add", text="Supertoroid")
177 oper.change = False
178 oper = layout.operator("mesh.primitive_torusknot_add", text="Torus Knot")
179 oper.change = False
182 class VIEW3D_MT_mesh_pipe_joints_add(Menu):
183 # Define the "Pipe Joints" menu
184 bl_idname = "VIEW3D_MT_mesh_pipe_joints_add"
185 bl_label = "Pipe Joints"
187 def draw(self, context):
188 layout = self.layout
189 layout.operator_context = 'INVOKE_REGION_WIN'
190 oper = layout.operator("mesh.primitive_elbow_joint_add", text="Pipe Elbow")
191 oper.change = False
192 oper = layout.operator("mesh.primitive_tee_joint_add", text="Pipe T-Joint")
193 oper.change = False
194 oper = layout.operator("mesh.primitive_wye_joint_add", text="Pipe Y-Joint")
195 oper.change = False
196 oper = layout.operator("mesh.primitive_cross_joint_add", text="Pipe Cross-Joint")
197 oper.change = False
198 oper = layout.operator("mesh.primitive_n_joint_add", text="Pipe N-Joint")
199 oper.change = False
201 # Register all operators and panels
203 # Define "Extras" menu
204 def menu_func(self, context):
205 layout = self.layout
206 layout.operator_context = 'INVOKE_REGION_WIN'
208 layout.separator()
209 layout.menu("VIEW3D_MT_mesh_vert_add",
210 text="Single Vert", icon="DECORATE")
211 oper = layout.operator("mesh.primitive_round_cube_add",
212 text="Round Cube", icon="SPHERE")
213 oper.change = False
214 layout.menu("VIEW3D_MT_mesh_torus_add",
215 text="Torus Objects", icon="MESH_TORUS")
216 layout.separator()
217 layout.menu("VIEW3D_MT_mesh_math_add",
218 text="Math Function", icon="PACKAGE")
219 layout.menu("VIEW3D_MT_mesh_gears_add",
220 text="Gears", icon="PREFERENCES")
221 layout.menu("VIEW3D_MT_mesh_pipe_joints_add",
222 text="Pipe Joints", icon="EMPTY_DATA")
223 layout.separator()
224 layout.menu("VIEW3D_MT_mesh_diamonds_add", text="Diamonds")
225 layout.menu("VIEW3D_MT_mesh_extras_add",
226 text="Extras")
227 layout.separator()
228 layout.operator("object.parent_to_empty",
229 text="Parent To Empty")
231 def Extras_contex_menu(self, context):
232 bl_label = 'Change'
234 obj = context.object
235 layout = self.layout
237 if obj == None or obj.data is None:
238 return
240 if 'Gear' in obj.data.keys():
241 props = layout.operator("mesh.primitive_gear", text="Change Gear")
242 props.change = True
243 for prm in add_mesh_gears.GearParameters():
244 setattr(props, prm, obj.data[prm])
245 layout.separator()
247 if 'WormGear' in obj.data.keys():
248 props = layout.operator("mesh.primitive_worm_gear", text="Change WormGear")
249 props.change = True
250 for prm in add_mesh_gears.WormGearParameters():
251 setattr(props, prm, obj.data[prm])
252 layout.separator()
254 if 'Beam' in obj.data.keys():
255 props = layout.operator("mesh.add_beam", text="Change Beam")
256 props.change = True
257 for prm in add_mesh_beam_builder.BeamParameters():
258 setattr(props, prm, obj.data[prm])
259 layout.separator()
261 if 'Wall' in obj.data.keys():
262 props = layout.operator("mesh.wall_add", text="Change Wall")
263 props.change = True
264 for prm in Wallfactory.WallParameters():
265 setattr(props, prm, obj.data[prm])
266 layout.separator()
268 if 'ElbowJoint' in obj.data.keys():
269 props = layout.operator("mesh.primitive_elbow_joint_add", text="Change ElbowJoint")
270 props.change = True
271 for prm in add_mesh_pipe_joint.ElbowJointParameters():
272 setattr(props, prm, obj.data[prm])
273 layout.separator()
275 if 'TeeJoint' in obj.data.keys():
276 props = layout.operator("mesh.primitive_tee_joint_add", text="Change TeeJoint")
277 props.change = True
278 for prm in add_mesh_pipe_joint.TeeJointParameters():
279 setattr(props, prm, obj.data[prm])
280 layout.separator()
282 if 'WyeJoint' in obj.data.keys():
283 props = layout.operator("mesh.primitive_wye_joint_add", text="Change WyeJoint")
284 props.change = True
285 for prm in add_mesh_pipe_joint.WyeJointParameters():
286 setattr(props, prm, obj.data[prm])
287 layout.separator()
289 if 'CrossJoint' in obj.data.keys():
290 props = layout.operator("mesh.primitive_cross_joint_add", text="Change CrossJoint")
291 props.change = True
292 for prm in add_mesh_pipe_joint.CrossJointParameters():
293 setattr(props, prm, obj.data[prm])
294 layout.separator()
296 if 'NJoint' in obj.data.keys():
297 props = layout.operator("mesh.primitive_n_joint_add", text="Change NJoint")
298 props.change = True
299 for prm in add_mesh_pipe_joint.NJointParameters():
300 setattr(props, prm, obj.data[prm])
301 layout.separator()
303 if 'Diamond' in obj.data.keys():
304 props = layout.operator("mesh.primitive_diamond_add", text="Change Diamond")
305 props.change = True
306 for prm in add_mesh_gemstones.DiamondParameters():
307 setattr(props, prm, obj.data[prm])
308 layout.separator()
310 if 'Gem' in obj.data.keys():
311 props = layout.operator("mesh.primitive_gem_add", text="Change Gem")
312 props.change = True
313 for prm in add_mesh_gemstones.GemParameters():
314 setattr(props, prm, obj.data[prm])
315 layout.separator()
317 if 'Brilliant' in obj.data.keys():
318 props = layout.operator("mesh.primitive_brilliant_add", text="Change Brilliant")
319 props.change = True
320 for prm in add_mesh_round_brilliant.BrilliantParameters():
321 setattr(props, prm, obj.data[prm])
322 layout.separator()
324 if 'Roundcube' in obj.data.keys():
325 props = layout.operator("mesh.primitive_round_cube_add", text="Change Roundcube")
326 props.change = True
327 for prm in add_mesh_round_cube.RoundCubeParameters():
328 setattr(props, prm, obj.data[prm])
329 layout.separator()
331 if 'TorusKnot' in obj.data.keys():
332 props = layout.operator("mesh.primitive_torusknot_add", text="Change TorusKnot")
333 props.change = True
334 for prm in add_mesh_torusknot.TorusKnotParameters():
335 setattr(props, prm, obj.data[prm])
336 layout.separator()
338 if 'SuperToroid' in obj.data.keys():
339 props = layout.operator("mesh.primitive_supertoroid_add", text="Change SuperToroid")
340 props.change = True
341 for prm in add_mesh_supertoroid.SuperToroidParameters():
342 setattr(props, prm, obj.data[prm])
343 layout.separator()
345 if 'TwistedTorus' in obj.data.keys():
346 props = layout.operator("mesh.primitive_twisted_torus_add", text="Change TwistedTorus")
347 props.change = True
348 for prm in add_mesh_twisted_torus.TwistedTorusParameters():
349 setattr(props, prm, obj.data[prm])
350 layout.separator()
352 if 'Star' in obj.data.keys():
353 props = layout.operator("mesh.primitive_star_add", text="Change Star")
354 props.change = True
355 for prm in add_mesh_star.StarParameters():
356 setattr(props, prm, obj.data[prm])
357 layout.separator()
359 if 'Pyramid' in obj.data.keys():
360 props = layout.operator("mesh.primitive_steppyramid_add", text="Change Pyramid")
361 props.change = True
362 for prm in add_mesh_pyramid.PyramidParameters():
363 setattr(props, prm, obj.data[prm])
364 layout.separator()
366 if 'HoneyComb' in obj.data.keys():
367 props = layout.operator("mesh.honeycomb_add", text="Change HoneyComb")
368 props.change = True
369 for prm in add_mesh_honeycomb.HoneyCombParameters():
370 setattr(props, prm, obj.data[prm])
371 layout.separator()
373 # Register
374 classes = [
375 VIEW3D_MT_mesh_vert_add,
376 VIEW3D_MT_mesh_gears_add,
377 VIEW3D_MT_mesh_diamonds_add,
378 VIEW3D_MT_mesh_math_add,
379 VIEW3D_MT_mesh_extras_add,
380 VIEW3D_MT_mesh_torus_add,
381 VIEW3D_MT_mesh_pipe_joints_add,
382 add_mesh_star.AddStar,
383 add_mesh_twisted_torus.AddTwistedTorus,
384 add_mesh_gemstones.AddDiamond,
385 add_mesh_gemstones.AddGem,
386 add_mesh_gears.AddGear,
387 add_mesh_gears.AddWormGear,
388 add_mesh_3d_function_surface.AddZFunctionSurface,
389 add_mesh_3d_function_surface.AddXYZFunctionSurface,
390 add_mesh_round_cube.AddRoundCube,
391 add_mesh_supertoroid.add_supertoroid,
392 add_mesh_pyramid.AddPyramid,
393 add_mesh_torusknot.AddTorusKnot,
394 add_mesh_honeycomb.add_mesh_honeycomb,
395 add_mesh_teapot.AddTeapot,
396 add_mesh_pipe_joint.AddElbowJoint,
397 add_mesh_pipe_joint.AddTeeJoint,
398 add_mesh_pipe_joint.AddWyeJoint,
399 add_mesh_pipe_joint.AddCrossJoint,
400 add_mesh_pipe_joint.AddNJoint,
401 add_mesh_solid.Solids,
402 add_mesh_round_brilliant.MESH_OT_primitive_brilliant_add,
403 add_mesh_menger_sponge.AddMengerSponge,
404 add_mesh_vertex.AddVert,
405 add_mesh_vertex.AddEmptyVert,
406 add_mesh_vertex.AddSymmetricalEmpty,
407 add_mesh_vertex.AddSymmetricalVert,
408 add_empty_as_parent.P2E,
409 add_empty_as_parent.PreFix,
410 add_mesh_beam_builder.addBeam,
411 Wallfactory.add_mesh_wallb,
412 add_mesh_triangles.MakeTriangle,
415 def register():
416 from bpy.utils import register_class
417 for cls in classes:
418 register_class(cls)
420 add_mesh_rocks.register()
422 # Add "Extras" menu to the "Add Mesh" menu and context menu.
423 bpy.types.VIEW3D_MT_mesh_add.append(menu_func)
424 bpy.types.VIEW3D_MT_object_context_menu.prepend(Extras_contex_menu)
427 def unregister():
428 # Remove "Extras" menu from the "Add Mesh" menu and context menu.
429 bpy.types.VIEW3D_MT_object_context_menu.remove(Extras_contex_menu)
430 bpy.types.VIEW3D_MT_mesh_add.remove(menu_func)
432 from bpy.utils import unregister_class
433 for cls in reversed(classes):
434 unregister_class(cls)
436 add_mesh_rocks.unregister()
438 if __name__ == "__main__":
439 register()