Fix #105067: Node Wrangler: cannot preview multi-user material group
[blender-addons.git] / add_mesh_extra_objects / add_mesh_vertex.py
blob94912285a646583dcc3e546a91f55ebecd68fc22
1 # SPDX-FileCopyrightText: 2015-2023 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 # Originals by meta-androcto, Pablo Vazquez, Liero, Richard Wilks
7 import bpy
8 from bpy.types import Operator
11 def object_origin(width, height, depth):
12 """
13 This function takes inputs and returns vertex and face arrays.
14 no actual mesh data creation is done here.
15 """
16 verts = [(+0.0, +0.0, +0.0)]
17 faces = []
19 # apply size
20 for i, v in enumerate(verts):
21 verts[i] = v[0] * width, v[1] * depth, v[2] * height
23 return verts, faces
26 class AddVert(Operator):
27 bl_idname = "mesh.primitive_vert_add"
28 bl_label = "Single Vert"
29 bl_description = "Add a Single Vertice to Edit Mode"
30 bl_options = {'REGISTER', 'UNDO'}
32 def execute(self, context):
33 mesh = bpy.data.meshes.new("Vert")
34 mesh.vertices.add(1)
36 from bpy_extras import object_utils
37 object_utils.object_data_add(context, mesh, operator=None)
38 bpy.ops.object.mode_set(mode='EDIT')
40 return {'FINISHED'}
43 class AddEmptyVert(Operator):
44 bl_idname = "mesh.primitive_emptyvert_add"
45 bl_label = "Empty Object Origin"
46 bl_description = "Add an Object Origin to Edit Mode"
47 bl_options = {'REGISTER', 'UNDO'}
49 def execute(self, context):
50 mesh = bpy.data.meshes.new("Vert")
51 mesh.vertices.add(1)
53 from bpy_extras import object_utils
54 object_utils.object_data_add(context, mesh, operator=None)
55 bpy.ops.object.mode_set(mode='EDIT')
56 bpy.ops.mesh.delete(type='VERT')
58 return {'FINISHED'}
61 def Add_Symmetrical_Empty():
63 bpy.ops.mesh.primitive_plane_add(enter_editmode=True)
65 sempty = bpy.context.object
66 sempty.name = "SymmEmpty"
68 # check if we have a mirror modifier, otherwise add
69 if not any(mod.type == 'MIRROR' for mod in sempty.modifiers):
70 bpy.ops.object.modifier_add(type='MIRROR')
72 # Delete all!
73 bpy.ops.mesh.select_all(action='TOGGLE')
74 bpy.ops.mesh.select_all(action='TOGGLE')
75 bpy.ops.mesh.delete(type='VERT')
78 def Add_Symmetrical_Vert():
80 bpy.ops.mesh.primitive_plane_add(enter_editmode=True)
82 sempty = bpy.context.object
83 sempty.name = "SymmVert"
85 # check if we have a mirror modifier, otherwise add
86 if not any(mod.type == 'MIRROR' for mod in sempty.modifiers):
87 bpy.ops.object.modifier_add(type='MIRROR')
89 # Delete all!
90 bpy.ops.mesh.select_all(action='TOGGLE')
91 bpy.ops.mesh.select_all(action='TOGGLE')
92 bpy.ops.mesh.merge(type='CENTER')
95 class AddSymmetricalEmpty(Operator):
96 bl_idname = "mesh.primitive_symmetrical_empty_add"
97 bl_label = "Add Symmetrical Object Origin"
98 bl_description = "Object Origin with a Mirror Modifier for symmetrical modeling"
99 bl_options = {'REGISTER', 'UNDO'}
101 def draw(self, context):
102 layout = self.layout
103 mirror = next(mod for mod in bpy.context.object.modifiers
104 if mod.type == 'MIRROR')
106 layout.prop(mirror, "use_clip", text="Use Clipping")
108 layout.label(text="Mirror Axis")
109 row = layout.row(align=True)
110 row.prop(mirror, "use_axis")
111 row.prop(mirror, "use_axis")
112 row.prop(mirror, "use_axis")
114 def execute(self, context):
115 Add_Symmetrical_Empty()
117 return {'FINISHED'}
120 class AddSymmetricalVert(Operator):
121 bl_idname = "mesh.primitive_symmetrical_vert_add"
122 bl_label = "Add Symmetrical Origin & Vert"
123 bl_description = "Object Origin with a Mirror Modifier for symmetrical modeling"
124 bl_options = {'REGISTER', 'UNDO'}
126 def draw(self, context):
127 layout = self.layout
128 mirror = next(mod for mod in bpy.context.object.modifiers
129 if mod.type == 'MIRROR')
131 layout.prop(mirror, "use_clip", text="Use Clipping")
133 layout.label(text="Mirror Axis")
134 row = layout.row(align=True)
135 row.prop(mirror, "use_axis")
136 row.prop(mirror, "use_axis")
137 row.prop(mirror, "use_axis")
139 def execute(self, context):
140 Add_Symmetrical_Vert()
142 return {'FINISHED'}