1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
# SPDX-License-Identifier: GPL-2.0-or-later
# Originals by meta-androcto, Pablo Vazquez, Liero, Richard Wilks
import bpy
from bpy.types import Operator
def object_origin(width, height, depth):
"""
This function takes inputs and returns vertex and face arrays.
no actual mesh data creation is done here.
"""
verts = [(+0.0, +0.0, +0.0)]
faces = []
# apply size
for i, v in enumerate(verts):
verts[i] = v[0] * width, v[1] * depth, v[2] * height
return verts, faces
class AddVert(Operator):
bl_idname = "mesh.primitive_vert_add"
bl_label = "Single Vert"
bl_description = "Add a Single Vertice to Edit Mode"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
mesh = bpy.data.meshes.new("Vert")
mesh.vertices.add(1)
from bpy_extras import object_utils
object_utils.object_data_add(context, mesh, operator=None)
bpy.ops.object.mode_set(mode='EDIT')
return {'FINISHED'}
class AddEmptyVert(Operator):
bl_idname = "mesh.primitive_emptyvert_add"
bl_label = "Empty Object Origin"
bl_description = "Add an Object Origin to Edit Mode"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
mesh = bpy.data.meshes.new("Vert")
mesh.vertices.add(1)
from bpy_extras import object_utils
object_utils.object_data_add(context, mesh, operator=None)
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.delete(type='VERT')
return {'FINISHED'}
def Add_Symmetrical_Empty():
bpy.ops.mesh.primitive_plane_add(enter_editmode=True)
sempty = bpy.context.object
sempty.name = "SymmEmpty"
# check if we have a mirror modifier, otherwise add
if (sempty.modifiers and sempty.modifiers['Mirror']):
pass
else:
bpy.ops.object.modifier_add(type='MIRROR')
# Delete all!
bpy.ops.mesh.select_all(action='TOGGLE')
bpy.ops.mesh.select_all(action='TOGGLE')
bpy.ops.mesh.delete(type='VERT')
def Add_Symmetrical_Vert():
bpy.ops.mesh.primitive_plane_add(enter_editmode=True)
sempty = bpy.context.object
sempty.name = "SymmVert"
# check if we have a mirror modifier, otherwise add
if (sempty.modifiers and sempty.modifiers['Mirror']):
pass
else:
bpy.ops.object.modifier_add(type='MIRROR')
# Delete all!
bpy.ops.mesh.select_all(action='TOGGLE')
bpy.ops.mesh.select_all(action='TOGGLE')
bpy.ops.mesh.merge(type='CENTER')
class AddSymmetricalEmpty(Operator):
bl_idname = "mesh.primitive_symmetrical_empty_add"
bl_label = "Add Symmetrical Object Origin"
bl_description = "Object Origin with a Mirror Modifier for symmetrical modeling"
bl_options = {'REGISTER', 'UNDO'}
def draw(self, context):
layout = self.layout
mirror = bpy.context.object.modifiers['Mirror']
layout.prop(mirror, "use_clip", text="Use Clipping")
layout.label(text="Mirror Axis")
row = layout.row(align=True)
row.prop(mirror, "use_axis")
row.prop(mirror, "use_axis")
row.prop(mirror, "use_axis")
def execute(self, context):
Add_Symmetrical_Empty()
return {'FINISHED'}
class AddSymmetricalVert(Operator):
bl_idname = "mesh.primitive_symmetrical_vert_add"
bl_label = "Add Symmetrical Origin & Vert"
bl_description = "Object Origin with a Mirror Modifier for symmetrical modeling"
bl_options = {'REGISTER', 'UNDO'}
def draw(self, context):
layout = self.layout
mirror = bpy.context.object.modifiers['Mirror']
layout.prop(mirror, "use_clip", text="Use Clipping")
layout.label(text="Mirror Axis")
row = layout.row(align=True)
row.prop(mirror, "use_axis")
row.prop(mirror, "use_axis")
row.prop(mirror, "use_axis")
def execute(self, context):
Add_Symmetrical_Vert()
return {'FINISHED'}
|