1 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Originals by meta-androcto, Pablo Vazquez, Liero, Richard Wilks
6 from bpy
.types
import Operator
9 def object_origin(width
, height
, depth
):
11 This function takes inputs and returns vertex and face arrays.
12 no actual mesh data creation is done here.
14 verts
= [(+0.0, +0.0, +0.0)]
18 for i
, v
in enumerate(verts
):
19 verts
[i
] = v
[0] * width
, v
[1] * depth
, v
[2] * height
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")
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')
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")
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')
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 not any(mod
.type == 'MIRROR' for mod
in sempty
.modifiers
):
68 bpy
.ops
.object.modifier_add(type='MIRROR')
71 bpy
.ops
.mesh
.select_all(action
='TOGGLE')
72 bpy
.ops
.mesh
.select_all(action
='TOGGLE')
73 bpy
.ops
.mesh
.delete(type='VERT')
76 def Add_Symmetrical_Vert():
78 bpy
.ops
.mesh
.primitive_plane_add(enter_editmode
=True)
80 sempty
= bpy
.context
.object
81 sempty
.name
= "SymmVert"
83 # check if we have a mirror modifier, otherwise add
84 if not any(mod
.type == 'MIRROR' for mod
in sempty
.modifiers
):
85 bpy
.ops
.object.modifier_add(type='MIRROR')
88 bpy
.ops
.mesh
.select_all(action
='TOGGLE')
89 bpy
.ops
.mesh
.select_all(action
='TOGGLE')
90 bpy
.ops
.mesh
.merge(type='CENTER')
93 class AddSymmetricalEmpty(Operator
):
94 bl_idname
= "mesh.primitive_symmetrical_empty_add"
95 bl_label
= "Add Symmetrical Object Origin"
96 bl_description
= "Object Origin with a Mirror Modifier for symmetrical modeling"
97 bl_options
= {'REGISTER', 'UNDO'}
99 def draw(self
, context
):
101 mirror
= next(mod
for mod
in bpy
.context
.object.modifiers
102 if mod
.type == 'MIRROR')
104 layout
.prop(mirror
, "use_clip", text
="Use Clipping")
106 layout
.label(text
="Mirror Axis")
107 row
= layout
.row(align
=True)
108 row
.prop(mirror
, "use_axis")
109 row
.prop(mirror
, "use_axis")
110 row
.prop(mirror
, "use_axis")
112 def execute(self
, context
):
113 Add_Symmetrical_Empty()
118 class AddSymmetricalVert(Operator
):
119 bl_idname
= "mesh.primitive_symmetrical_vert_add"
120 bl_label
= "Add Symmetrical Origin & Vert"
121 bl_description
= "Object Origin with a Mirror Modifier for symmetrical modeling"
122 bl_options
= {'REGISTER', 'UNDO'}
124 def draw(self
, context
):
126 mirror
= next(mod
for mod
in bpy
.context
.object.modifiers
127 if mod
.type == 'MIRROR')
129 layout
.prop(mirror
, "use_clip", text
="Use Clipping")
131 layout
.label(text
="Mirror Axis")
132 row
= layout
.row(align
=True)
133 row
.prop(mirror
, "use_axis")
134 row
.prop(mirror
, "use_axis")
135 row
.prop(mirror
, "use_axis")
137 def execute(self
, context
):
138 Add_Symmetrical_Vert()