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