Cleanup: trailing space
[blender-addons.git] / add_mesh_extra_objects / add_mesh_vertex.py
blob4ee3ad85bfd05d2b48d3d521b2e6bbaaf22f9b2a
1 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Originals by meta-androcto, Pablo Vazquez, Liero, Richard Wilks
5 import bpy
6 from bpy.types import Operator
9 def object_origin(width, height, depth):
10 """
11 This function takes inputs and returns vertex and face arrays.
12 no actual mesh data creation is done here.
13 """
14 verts = [(+0.0, +0.0, +0.0)]
15 faces = []
17 # apply size
18 for i, v in enumerate(verts):
19 verts[i] = v[0] * width, v[1] * depth, v[2] * height
21 return verts, faces
24 class AddVert(Operator):
25 bl_idname = "mesh.primitive_vert_add"
26 bl_label = "Single Vert"
27 bl_description = "Add a Single Vertice to Edit Mode"
28 bl_options = {'REGISTER', 'UNDO'}
30 def execute(self, context):
31 mesh = bpy.data.meshes.new("Vert")
32 mesh.vertices.add(1)
34 from bpy_extras import object_utils
35 object_utils.object_data_add(context, mesh, operator=None)
36 bpy.ops.object.mode_set(mode='EDIT')
38 return {'FINISHED'}
41 class AddEmptyVert(Operator):
42 bl_idname = "mesh.primitive_emptyvert_add"
43 bl_label = "Empty Object Origin"
44 bl_description = "Add an Object Origin to Edit Mode"
45 bl_options = {'REGISTER', 'UNDO'}
47 def execute(self, context):
48 mesh = bpy.data.meshes.new("Vert")
49 mesh.vertices.add(1)
51 from bpy_extras import object_utils
52 object_utils.object_data_add(context, mesh, operator=None)
53 bpy.ops.object.mode_set(mode='EDIT')
54 bpy.ops.mesh.delete(type='VERT')
56 return {'FINISHED'}
59 def Add_Symmetrical_Empty():
61 bpy.ops.mesh.primitive_plane_add(enter_editmode=True)
63 sempty = bpy.context.object
64 sempty.name = "SymmEmpty"
66 # check if we have a mirror modifier, otherwise add
67 if (sempty.modifiers and sempty.modifiers['Mirror']):
68 pass
69 else:
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 (sempty.modifiers and sempty.modifiers['Mirror']):
87 pass
88 else:
89 bpy.ops.object.modifier_add(type='MIRROR')
91 # Delete all!
92 bpy.ops.mesh.select_all(action='TOGGLE')
93 bpy.ops.mesh.select_all(action='TOGGLE')
94 bpy.ops.mesh.merge(type='CENTER')
97 class AddSymmetricalEmpty(Operator):
98 bl_idname = "mesh.primitive_symmetrical_empty_add"
99 bl_label = "Add Symmetrical Object Origin"
100 bl_description = "Object Origin with a Mirror Modifier for symmetrical modeling"
101 bl_options = {'REGISTER', 'UNDO'}
103 def draw(self, context):
104 layout = self.layout
105 mirror = bpy.context.object.modifiers['Mirror']
107 layout.prop(mirror, "use_clip", text="Use Clipping")
109 layout.label(text="Mirror Axis")
110 row = layout.row(align=True)
111 row.prop(mirror, "use_axis")
112 row.prop(mirror, "use_axis")
113 row.prop(mirror, "use_axis")
115 def execute(self, context):
116 Add_Symmetrical_Empty()
118 return {'FINISHED'}
121 class AddSymmetricalVert(Operator):
122 bl_idname = "mesh.primitive_symmetrical_vert_add"
123 bl_label = "Add Symmetrical Origin & Vert"
124 bl_description = "Object Origin with a Mirror Modifier for symmetrical modeling"
125 bl_options = {'REGISTER', 'UNDO'}
127 def draw(self, context):
128 layout = self.layout
129 mirror = bpy.context.object.modifiers['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'}