Cleanup: camera_turnaround (pep8)
[blender-addons.git] / add_mesh_extra_objects / __init__.py
blob14bde07d38976adfd26bab8a1d91e5e08f40c362
1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
18 # Contributed to by:
19 # Pontiac, Fourmadmen, varkenvarken, tuga3d, meta-androcto, metalliandy #
20 # dreampainter, cotejrp1, liero, Kayo Phoenix, sugiany, dommetysk, Jambay #
21 # Phymec, Anthony D'Agostino, Pablo Vazquez, Richard Wilks, lijenstina, #
22 # Sjaak-de-Draak, Phil Cote, cotejrp1, xyz presets by elfnor, revolt_randy, #
23 # Vladimir Spivak (cwolf3d), #
26 bl_info = {
27 "name": "Extra Objects",
28 "author": "Multiple Authors",
29 "version": (0, 3, 6),
30 "blender": (2, 80, 0),
31 "location": "View3D > Add > Mesh",
32 "description": "Add extra mesh object types",
33 "warning": "",
34 "doc_url": "{BLENDER_MANUAL_URL}/addons/add_mesh/mesh_extra_objects.html",
35 "category": "Add Mesh",
38 # Note: Blocks has to be loaded before the WallFactory or the script
39 # will not work properly after (F8) reload
41 if "bpy" in locals():
42 import importlib
43 importlib.reload(add_mesh_star)
44 importlib.reload(add_mesh_twisted_torus)
45 importlib.reload(add_mesh_gemstones)
46 importlib.reload(add_mesh_gears)
47 importlib.reload(add_mesh_3d_function_surface)
48 importlib.reload(add_mesh_round_cube)
49 importlib.reload(add_mesh_supertoroid)
50 importlib.reload(add_mesh_pyramid)
51 importlib.reload(add_mesh_torusknot)
52 importlib.reload(add_mesh_honeycomb)
53 importlib.reload(add_mesh_teapot)
54 importlib.reload(add_mesh_pipe_joint)
55 importlib.reload(add_mesh_solid)
56 importlib.reload(add_mesh_round_brilliant)
57 importlib.reload(add_mesh_menger_sponge)
58 importlib.reload(add_mesh_vertex)
59 importlib.reload(add_empty_as_parent)
60 importlib.reload(add_mesh_beam_builder)
61 importlib.reload(Blocks)
62 importlib.reload(Wallfactory)
63 importlib.reload(add_mesh_triangles)
64 else:
65 from . import add_mesh_star
66 from . import add_mesh_twisted_torus
67 from . import add_mesh_gemstones
68 from . import add_mesh_gears
69 from . import add_mesh_3d_function_surface
70 from . import add_mesh_round_cube
71 from . import add_mesh_supertoroid
72 from . import add_mesh_pyramid
73 from . import add_mesh_torusknot
74 from . import add_mesh_honeycomb
75 from . import add_mesh_teapot
76 from . import add_mesh_pipe_joint
77 from . import add_mesh_solid
78 from . import add_mesh_round_brilliant
79 from . import add_mesh_menger_sponge
80 from . import add_mesh_vertex
81 from . import add_empty_as_parent
82 from . import add_mesh_beam_builder
83 from . import Blocks
84 from . import Wallfactory
85 from . import add_mesh_triangles
87 from .add_mesh_rocks import __init__
88 from .add_mesh_rocks import rockgen
90 import bpy
91 from bpy.types import Menu
93 class VIEW3D_MT_mesh_vert_add(Menu):
94 # Define the "Single Vert" menu
95 bl_idname = "VIEW3D_MT_mesh_vert_add"
96 bl_label = "Single Vert"
98 def draw(self, context):
99 layout = self.layout
100 layout.operator_context = 'INVOKE_REGION_WIN'
101 layout.operator("mesh.primitive_vert_add",
102 text="Add Single Vert")
103 layout.separator()
104 layout.operator("mesh.primitive_emptyvert_add",
105 text="Object Origin Only")
106 layout.operator("mesh.primitive_symmetrical_vert_add",
107 text="Origin & Vert Mirrored")
108 layout.operator("mesh.primitive_symmetrical_empty_add",
109 text="Object Origin Mirrored")
112 class VIEW3D_MT_mesh_gears_add(Menu):
113 # Define the "Gears" menu
114 bl_idname = "VIEW3D_MT_mesh_gears_add"
115 bl_label = "Gears"
117 def draw(self, context):
118 layout = self.layout
119 layout.operator_context = 'INVOKE_REGION_WIN'
120 oper = layout.operator("mesh.primitive_gear", text="Gear")
121 oper.change = False
122 oper = layout.operator("mesh.primitive_worm_gear", text="Worm")
123 oper.change = False
126 class VIEW3D_MT_mesh_diamonds_add(Menu):
127 # Define the "Diamonds" menu
128 bl_idname = "VIEW3D_MT_mesh_diamonds_add"
129 bl_label = "Diamonds"
131 def draw(self, context):
132 layout = self.layout
133 layout.operator_context = 'INVOKE_REGION_WIN'
134 oper = layout.operator("mesh.primitive_brilliant_add", text="Brilliant Diamond")
135 oper.change = False
136 oper = layout.operator("mesh.primitive_diamond_add", text="Diamond")
137 oper.change = False
138 oper = layout.operator("mesh.primitive_gem_add", text="Gem")
139 oper.change = False
142 class VIEW3D_MT_mesh_math_add(Menu):
143 # Define the "Math Function" menu
144 bl_idname = "VIEW3D_MT_mesh_math_add"
145 bl_label = "Math Functions"
147 def draw(self, context):
148 layout = self.layout
149 layout.operator_context = 'INVOKE_REGION_WIN'
150 layout.operator("mesh.primitive_z_function_surface",
151 text="Z Math Surface")
152 layout.operator("mesh.primitive_xyz_function_surface",
153 text="XYZ Math Surface")
154 self.layout.operator("mesh.primitive_solid_add", text="Regular Solid")
155 self.layout.operator("mesh.make_triangle")
158 class VIEW3D_MT_mesh_extras_add(Menu):
159 # Define the "Extra Objects" menu
160 bl_idname = "VIEW3D_MT_mesh_extras_add"
161 bl_label = "Extras"
163 def draw(self, context):
164 layout = self.layout
165 layout.operator_context = 'INVOKE_REGION_WIN'
166 oper = layout.operator("mesh.add_beam", text="Beam Builder")
167 oper.change = False
168 oper = layout.operator("mesh.wall_add", text="Wall Factory")
169 oper.change = False
170 layout.separator()
171 oper = layout.operator("mesh.primitive_star_add", text="Simple Star")
172 oper.change = False
173 oper = layout.operator("mesh.primitive_steppyramid_add", text="Step Pyramid")
174 oper.change = False
175 oper = layout.operator("mesh.honeycomb_add", text="Honeycomb")
176 oper.change = False
177 oper = layout.operator("mesh.primitive_teapot_add", text="Teapot+")
178 oper = layout.operator("mesh.menger_sponge_add", text="Menger Sponge")
181 class VIEW3D_MT_mesh_torus_add(Menu):
182 # Define the "Torus Objects" menu
183 bl_idname = "VIEW3D_MT_mesh_torus_add"
184 bl_label = "Torus Objects"
186 def draw(self, context):
187 layout = self.layout
188 layout.operator_context = 'INVOKE_REGION_WIN'
189 oper = layout.operator("mesh.primitive_twisted_torus_add", text="Twisted Torus")
190 oper.change = False
191 oper = layout.operator("mesh.primitive_supertoroid_add", text="Supertoroid")
192 oper.change = False
193 oper = layout.operator("mesh.primitive_torusknot_add", text="Torus Knot")
194 oper.change = False
197 class VIEW3D_MT_mesh_pipe_joints_add(Menu):
198 # Define the "Pipe Joints" menu
199 bl_idname = "VIEW3D_MT_mesh_pipe_joints_add"
200 bl_label = "Pipe Joints"
202 def draw(self, context):
203 layout = self.layout
204 layout.operator_context = 'INVOKE_REGION_WIN'
205 oper = layout.operator("mesh.primitive_elbow_joint_add", text="Pipe Elbow")
206 oper.change = False
207 oper = layout.operator("mesh.primitive_tee_joint_add", text="Pipe T-Joint")
208 oper.change = False
209 oper = layout.operator("mesh.primitive_wye_joint_add", text="Pipe Y-Joint")
210 oper.change = False
211 oper = layout.operator("mesh.primitive_cross_joint_add", text="Pipe Cross-Joint")
212 oper.change = False
213 oper = layout.operator("mesh.primitive_n_joint_add", text="Pipe N-Joint")
214 oper.change = False
216 # Register all operators and panels
218 # Define "Extras" menu
219 def menu_func(self, context):
220 layout = self.layout
221 layout.operator_context = 'INVOKE_REGION_WIN'
223 layout.separator()
224 layout.menu("VIEW3D_MT_mesh_vert_add",
225 text="Single Vert", icon="DECORATE")
226 oper = layout.operator("mesh.primitive_round_cube_add",
227 text="Round Cube", icon="SPHERE")
228 oper.change = False
229 layout.menu("VIEW3D_MT_mesh_torus_add",
230 text="Torus Objects", icon="MESH_TORUS")
231 layout.separator()
232 layout.menu("VIEW3D_MT_mesh_math_add",
233 text="Math Function", icon="PACKAGE")
234 layout.menu("VIEW3D_MT_mesh_gears_add",
235 text="Gears", icon="PREFERENCES")
236 layout.menu("VIEW3D_MT_mesh_pipe_joints_add",
237 text="Pipe Joints", icon="EMPTY_DATA")
238 layout.separator()
239 layout.menu("VIEW3D_MT_mesh_diamonds_add", text="Diamonds")
240 layout.menu("VIEW3D_MT_mesh_extras_add",
241 text="Extras")
242 layout.separator()
243 layout.operator("object.parent_to_empty",
244 text="Parent To Empty")
246 def Extras_contex_menu(self, context):
247 bl_label = 'Change'
249 obj = context.object
250 layout = self.layout
252 if obj == None:
253 return
255 if 'Gear' in obj.data.keys():
256 props = layout.operator("mesh.primitive_gear", text="Change Gear")
257 props.change = True
258 for prm in add_mesh_gears.GearParameters():
259 setattr(props, prm, obj.data[prm])
260 layout.separator()
262 if 'WormGear' in obj.data.keys():
263 props = layout.operator("mesh.primitive_worm_gear", text="Change WormGear")
264 props.change = True
265 for prm in add_mesh_gears.WormGearParameters():
266 setattr(props, prm, obj.data[prm])
267 layout.separator()
269 if 'Beam' in obj.data.keys():
270 props = layout.operator("mesh.add_beam", text="Change Beam")
271 props.change = True
272 for prm in add_mesh_beam_builder.BeamParameters():
273 setattr(props, prm, obj.data[prm])
274 layout.separator()
276 if 'Wall' in obj.data.keys():
277 props = layout.operator("mesh.wall_add", text="Change Wall")
278 props.change = True
279 for prm in Wallfactory.WallParameters():
280 setattr(props, prm, obj.data[prm])
281 layout.separator()
283 if 'ElbowJoint' in obj.data.keys():
284 props = layout.operator("mesh.primitive_elbow_joint_add", text="Change ElbowJoint")
285 props.change = True
286 for prm in add_mesh_pipe_joint.ElbowJointParameters():
287 setattr(props, prm, obj.data[prm])
288 layout.separator()
290 if 'TeeJoint' in obj.data.keys():
291 props = layout.operator("mesh.primitive_tee_joint_add", text="Change TeeJoint")
292 props.change = True
293 for prm in add_mesh_pipe_joint.TeeJointParameters():
294 setattr(props, prm, obj.data[prm])
295 layout.separator()
297 if 'WyeJoint' in obj.data.keys():
298 props = layout.operator("mesh.primitive_wye_joint_add", text="Change WyeJoint")
299 props.change = True
300 for prm in add_mesh_pipe_joint.WyeJointParameters():
301 setattr(props, prm, obj.data[prm])
302 layout.separator()
304 if 'CrossJoint' in obj.data.keys():
305 props = layout.operator("mesh.primitive_cross_joint_add", text="Change CrossJoint")
306 props.change = True
307 for prm in add_mesh_pipe_joint.CrossJointParameters():
308 setattr(props, prm, obj.data[prm])
309 layout.separator()
311 if 'NJoint' in obj.data.keys():
312 props = layout.operator("mesh.primitive_n_joint_add", text="Change NJoint")
313 props.change = True
314 for prm in add_mesh_pipe_joint.NJointParameters():
315 setattr(props, prm, obj.data[prm])
316 layout.separator()
318 if 'Diamond' in obj.data.keys():
319 props = layout.operator("mesh.primitive_diamond_add", text="Change Diamond")
320 props.change = True
321 for prm in add_mesh_gemstones.DiamondParameters():
322 setattr(props, prm, obj.data[prm])
323 layout.separator()
325 if 'Gem' in obj.data.keys():
326 props = layout.operator("mesh.primitive_gem_add", text="Change Gem")
327 props.change = True
328 for prm in add_mesh_gemstones.GemParameters():
329 setattr(props, prm, obj.data[prm])
330 layout.separator()
332 if 'Brilliant' in obj.data.keys():
333 props = layout.operator("mesh.primitive_brilliant_add", text="Change Brilliant")
334 props.change = True
335 for prm in add_mesh_round_brilliant.BrilliantParameters():
336 setattr(props, prm, obj.data[prm])
337 layout.separator()
339 if 'Roundcube' in obj.data.keys():
340 props = layout.operator("mesh.primitive_round_cube_add", text="Change Roundcube")
341 props.change = True
342 for prm in add_mesh_round_cube.RoundCubeParameters():
343 setattr(props, prm, obj.data[prm])
344 layout.separator()
346 if 'TorusKnot' in obj.data.keys():
347 props = layout.operator("mesh.primitive_torusknot_add", text="Change TorusKnot")
348 props.change = True
349 for prm in add_mesh_torusknot.TorusKnotParameters():
350 setattr(props, prm, obj.data[prm])
351 layout.separator()
353 if 'SuperToroid' in obj.data.keys():
354 props = layout.operator("mesh.primitive_supertoroid_add", text="Change SuperToroid")
355 props.change = True
356 for prm in add_mesh_supertoroid.SuperToroidParameters():
357 setattr(props, prm, obj.data[prm])
358 layout.separator()
360 if 'TwistedTorus' in obj.data.keys():
361 props = layout.operator("mesh.primitive_twisted_torus_add", text="Change TwistedTorus")
362 props.change = True
363 for prm in add_mesh_twisted_torus.TwistedTorusParameters():
364 setattr(props, prm, obj.data[prm])
365 layout.separator()
367 if 'Star' in obj.data.keys():
368 props = layout.operator("mesh.primitive_star_add", text="Change Star")
369 props.change = True
370 for prm in add_mesh_star.StarParameters():
371 setattr(props, prm, obj.data[prm])
372 layout.separator()
374 if 'Pyramid' in obj.data.keys():
375 props = layout.operator("mesh.primitive_steppyramid_add", text="Change Pyramid")
376 props.change = True
377 for prm in add_mesh_pyramid.PyramidParameters():
378 setattr(props, prm, obj.data[prm])
379 layout.separator()
381 if 'HoneyComb' in obj.data.keys():
382 props = layout.operator("mesh.honeycomb_add", text="Change HoneyComb")
383 props.change = True
384 for prm in add_mesh_honeycomb.HoneyCombParameters():
385 setattr(props, prm, obj.data[prm])
386 layout.separator()
388 # Register
389 classes = [
390 VIEW3D_MT_mesh_vert_add,
391 VIEW3D_MT_mesh_gears_add,
392 VIEW3D_MT_mesh_diamonds_add,
393 VIEW3D_MT_mesh_math_add,
394 VIEW3D_MT_mesh_extras_add,
395 VIEW3D_MT_mesh_torus_add,
396 VIEW3D_MT_mesh_pipe_joints_add,
397 add_mesh_star.AddStar,
398 add_mesh_twisted_torus.AddTwistedTorus,
399 add_mesh_gemstones.AddDiamond,
400 add_mesh_gemstones.AddGem,
401 add_mesh_gears.AddGear,
402 add_mesh_gears.AddWormGear,
403 add_mesh_3d_function_surface.AddZFunctionSurface,
404 add_mesh_3d_function_surface.AddXYZFunctionSurface,
405 add_mesh_round_cube.AddRoundCube,
406 add_mesh_supertoroid.add_supertoroid,
407 add_mesh_pyramid.AddPyramid,
408 add_mesh_torusknot.AddTorusKnot,
409 add_mesh_honeycomb.add_mesh_honeycomb,
410 add_mesh_teapot.AddTeapot,
411 add_mesh_pipe_joint.AddElbowJoint,
412 add_mesh_pipe_joint.AddTeeJoint,
413 add_mesh_pipe_joint.AddWyeJoint,
414 add_mesh_pipe_joint.AddCrossJoint,
415 add_mesh_pipe_joint.AddNJoint,
416 add_mesh_solid.Solids,
417 add_mesh_round_brilliant.MESH_OT_primitive_brilliant_add,
418 add_mesh_menger_sponge.AddMengerSponge,
419 add_mesh_vertex.AddVert,
420 add_mesh_vertex.AddEmptyVert,
421 add_mesh_vertex.AddSymmetricalEmpty,
422 add_mesh_vertex.AddSymmetricalVert,
423 add_empty_as_parent.P2E,
424 add_empty_as_parent.PreFix,
425 add_mesh_beam_builder.addBeam,
426 Wallfactory.add_mesh_wallb,
427 add_mesh_triangles.MakeTriangle,
430 def register():
431 from bpy.utils import register_class
432 for cls in classes:
433 register_class(cls)
435 add_mesh_rocks.register()
437 # Add "Extras" menu to the "Add Mesh" menu and context menu.
438 bpy.types.VIEW3D_MT_mesh_add.append(menu_func)
439 bpy.types.VIEW3D_MT_object_context_menu.prepend(Extras_contex_menu)
442 def unregister():
443 # Remove "Extras" menu from the "Add Mesh" menu and context menu.
444 bpy.types.VIEW3D_MT_object_context_menu.remove(Extras_contex_menu)
445 bpy.types.VIEW3D_MT_mesh_add.remove(menu_func)
447 from bpy.utils import unregister_class
448 for cls in reversed(classes):
449 unregister_class(cls)
451 add_mesh_rocks.unregister()
453 if __name__ == "__main__":
454 register()