1 # SPDX-License-Identifier: GPL-2.0-or-later
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), #
12 "name": "Extra Objects",
13 "author": "Multiple Authors",
15 "blender": (2, 80, 0),
16 "location": "View3D > Add > Mesh",
17 "description": "Add extra mesh object types",
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
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
)
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
69 from . import Wallfactory
70 from . import add_mesh_triangles
72 from .add_mesh_rocks
import __init__
73 from .add_mesh_rocks
import rockgen
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
):
85 layout
.operator_context
= 'INVOKE_REGION_WIN'
86 layout
.operator("mesh.primitive_vert_add",
87 text
="Add Single Vert")
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"
102 def draw(self
, context
):
104 layout
.operator_context
= 'INVOKE_REGION_WIN'
105 oper
= layout
.operator("mesh.primitive_gear", text
="Gear")
107 oper
= layout
.operator("mesh.primitive_worm_gear", text
="Worm")
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
):
118 layout
.operator_context
= 'INVOKE_REGION_WIN'
119 oper
= layout
.operator("mesh.primitive_brilliant_add", text
="Brilliant Diamond")
121 oper
= layout
.operator("mesh.primitive_diamond_add", text
="Diamond")
123 oper
= layout
.operator("mesh.primitive_gem_add", text
="Gem")
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
):
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"
148 def draw(self
, context
):
150 layout
.operator_context
= 'INVOKE_REGION_WIN'
151 oper
= layout
.operator("mesh.add_beam", text
="Beam Builder")
153 oper
= layout
.operator("mesh.wall_add", text
="Wall Factory")
156 oper
= layout
.operator("mesh.primitive_star_add", text
="Simple Star")
158 oper
= layout
.operator("mesh.primitive_steppyramid_add", text
="Step Pyramid")
160 oper
= layout
.operator("mesh.honeycomb_add", text
="Honeycomb")
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
):
173 layout
.operator_context
= 'INVOKE_REGION_WIN'
174 oper
= layout
.operator("mesh.primitive_twisted_torus_add", text
="Twisted Torus")
176 oper
= layout
.operator("mesh.primitive_supertoroid_add", text
="Supertoroid")
178 oper
= layout
.operator("mesh.primitive_torusknot_add", text
="Torus Knot")
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
):
189 layout
.operator_context
= 'INVOKE_REGION_WIN'
190 oper
= layout
.operator("mesh.primitive_elbow_joint_add", text
="Pipe Elbow")
192 oper
= layout
.operator("mesh.primitive_tee_joint_add", text
="Pipe T-Joint")
194 oper
= layout
.operator("mesh.primitive_wye_joint_add", text
="Pipe Y-Joint")
196 oper
= layout
.operator("mesh.primitive_cross_joint_add", text
="Pipe Cross-Joint")
198 oper
= layout
.operator("mesh.primitive_n_joint_add", text
="Pipe N-Joint")
201 # Register all operators and panels
203 # Define "Extras" menu
204 def menu_func(self
, context
):
206 layout
.operator_context
= 'INVOKE_REGION_WIN'
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")
214 layout
.menu("VIEW3D_MT_mesh_torus_add",
215 text
="Torus Objects", icon
="MESH_TORUS")
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")
224 layout
.menu("VIEW3D_MT_mesh_diamonds_add", text
="Diamonds")
225 layout
.menu("VIEW3D_MT_mesh_extras_add",
228 layout
.operator("object.parent_to_empty",
229 text
="Parent To Empty")
231 def Extras_contex_menu(self
, context
):
237 if obj
== None or obj
.data
is None:
240 if 'Gear' in obj
.data
.keys():
241 props
= layout
.operator("mesh.primitive_gear", text
="Change Gear")
243 for prm
in add_mesh_gears
.GearParameters():
244 setattr(props
, prm
, obj
.data
[prm
])
247 if 'WormGear' in obj
.data
.keys():
248 props
= layout
.operator("mesh.primitive_worm_gear", text
="Change WormGear")
250 for prm
in add_mesh_gears
.WormGearParameters():
251 setattr(props
, prm
, obj
.data
[prm
])
254 if 'Beam' in obj
.data
.keys():
255 props
= layout
.operator("mesh.add_beam", text
="Change Beam")
257 for prm
in add_mesh_beam_builder
.BeamParameters():
258 setattr(props
, prm
, obj
.data
[prm
])
261 if 'Wall' in obj
.data
.keys():
262 props
= layout
.operator("mesh.wall_add", text
="Change Wall")
264 for prm
in Wallfactory
.WallParameters():
265 setattr(props
, prm
, obj
.data
[prm
])
268 if 'ElbowJoint' in obj
.data
.keys():
269 props
= layout
.operator("mesh.primitive_elbow_joint_add", text
="Change ElbowJoint")
271 for prm
in add_mesh_pipe_joint
.ElbowJointParameters():
272 setattr(props
, prm
, obj
.data
[prm
])
275 if 'TeeJoint' in obj
.data
.keys():
276 props
= layout
.operator("mesh.primitive_tee_joint_add", text
="Change TeeJoint")
278 for prm
in add_mesh_pipe_joint
.TeeJointParameters():
279 setattr(props
, prm
, obj
.data
[prm
])
282 if 'WyeJoint' in obj
.data
.keys():
283 props
= layout
.operator("mesh.primitive_wye_joint_add", text
="Change WyeJoint")
285 for prm
in add_mesh_pipe_joint
.WyeJointParameters():
286 setattr(props
, prm
, obj
.data
[prm
])
289 if 'CrossJoint' in obj
.data
.keys():
290 props
= layout
.operator("mesh.primitive_cross_joint_add", text
="Change CrossJoint")
292 for prm
in add_mesh_pipe_joint
.CrossJointParameters():
293 setattr(props
, prm
, obj
.data
[prm
])
296 if 'NJoint' in obj
.data
.keys():
297 props
= layout
.operator("mesh.primitive_n_joint_add", text
="Change NJoint")
299 for prm
in add_mesh_pipe_joint
.NJointParameters():
300 setattr(props
, prm
, obj
.data
[prm
])
303 if 'Diamond' in obj
.data
.keys():
304 props
= layout
.operator("mesh.primitive_diamond_add", text
="Change Diamond")
306 for prm
in add_mesh_gemstones
.DiamondParameters():
307 setattr(props
, prm
, obj
.data
[prm
])
310 if 'Gem' in obj
.data
.keys():
311 props
= layout
.operator("mesh.primitive_gem_add", text
="Change Gem")
313 for prm
in add_mesh_gemstones
.GemParameters():
314 setattr(props
, prm
, obj
.data
[prm
])
317 if 'Brilliant' in obj
.data
.keys():
318 props
= layout
.operator("mesh.primitive_brilliant_add", text
="Change Brilliant")
320 for prm
in add_mesh_round_brilliant
.BrilliantParameters():
321 setattr(props
, prm
, obj
.data
[prm
])
324 if 'Roundcube' in obj
.data
.keys():
325 props
= layout
.operator("mesh.primitive_round_cube_add", text
="Change Roundcube")
327 for prm
in add_mesh_round_cube
.RoundCubeParameters():
328 setattr(props
, prm
, obj
.data
[prm
])
331 if 'TorusKnot' in obj
.data
.keys():
332 props
= layout
.operator("mesh.primitive_torusknot_add", text
="Change TorusKnot")
334 for prm
in add_mesh_torusknot
.TorusKnotParameters():
335 setattr(props
, prm
, obj
.data
[prm
])
338 if 'SuperToroid' in obj
.data
.keys():
339 props
= layout
.operator("mesh.primitive_supertoroid_add", text
="Change SuperToroid")
341 for prm
in add_mesh_supertoroid
.SuperToroidParameters():
342 setattr(props
, prm
, obj
.data
[prm
])
345 if 'TwistedTorus' in obj
.data
.keys():
346 props
= layout
.operator("mesh.primitive_twisted_torus_add", text
="Change TwistedTorus")
348 for prm
in add_mesh_twisted_torus
.TwistedTorusParameters():
349 setattr(props
, prm
, obj
.data
[prm
])
352 if 'Star' in obj
.data
.keys():
353 props
= layout
.operator("mesh.primitive_star_add", text
="Change Star")
355 for prm
in add_mesh_star
.StarParameters():
356 setattr(props
, prm
, obj
.data
[prm
])
359 if 'Pyramid' in obj
.data
.keys():
360 props
= layout
.operator("mesh.primitive_steppyramid_add", text
="Change Pyramid")
362 for prm
in add_mesh_pyramid
.PyramidParameters():
363 setattr(props
, prm
, obj
.data
[prm
])
366 if 'HoneyComb' in obj
.data
.keys():
367 props
= layout
.operator("mesh.honeycomb_add", text
="Change HoneyComb")
369 for prm
in add_mesh_honeycomb
.HoneyCombParameters():
370 setattr(props
, prm
, obj
.data
[prm
])
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
,
416 from bpy
.utils
import register_class
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
)
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__":