Newer
Older
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
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
bl_info = {
"name": "Add Symmetrical Empty",
"author": "Pablo Vazquez",
"version": (1,0,2),
"blender": (2, 6, 4),
"location": "View3D > Add > Mesh > Symmetrical Empty",
"description": "Add an empty mesh with a Mirror Modifier for quick symmetrical modeling",
"warning": "",
"wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"\
"Scripts/Add_Mesh/Add_Symmetrical_Empty",
"tracker_url": "",
"category": "Add Mesh"}
'''
Adds an empty mesh with a mirror modifier.
'''
import bpy
from bpy.props import BoolProperty
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')
class AddSymmetricalEmpty(bpy.types.Operator):
bl_idname = "mesh.primitive_symmetrical_empty_add"
bl_label = "Add Symmetrical Empty Mesh"
bl_description = "Add an empty mesh with a Mirror Modifier for quick 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("Mirror Axis")
row = layout.row(align=True)
row.prop(mirror, "use_x")
row.prop(mirror, "use_y")
row.prop(mirror, "use_z")
def execute(self, context):
Add_Symmetrical_Empty()
return {'FINISHED'}
## menu option ##
def menu_item(self, context):
# only in object mode
if bpy.context.mode == "OBJECT":
self.layout.operator("mesh.primitive_symmetrical_empty_add",
text="Symmetrical Empty", icon="EMPTY_DATA")
## register and add it on top of the list ##
def register():
bpy.utils.register_module(__name__)
bpy.types.INFO_MT_mesh_add.prepend(menu_item)
def unregister():
bpy.utils.unregister_module(__name__)
bpy.types.INFO_MT_mesh_add.remove(menu_item)
if __name__ == "__main__":
register()