3 "author": "YourNameHere",
7 "location": "View3D > Add > Mesh > New Object",
8 "description": "Adds a new Mesh Object",
12 "category": "Add Mesh"}
16 from bpy.props import FloatVectorProperty
17 from add_utils import AddObjectHelper, add_object_data
18 from mathutils import Vector
21 def add_object(self, context):
22 scale_x = self.scale.x
23 scale_y = self.scale.y
25 verts = [Vector((-1 * scale_x, 1 * scale_y, 0)),
26 Vector((1 * scale_x, 1 * scale_y, 0)),
27 Vector((1 * scale_x, -1 * scale_y, 0)),
28 Vector((-1 * scale_x, -1 * scale_y, 0)),
32 faces = [[0, 1, 2, 3]]
34 mesh_data = bpy.data.meshes.new(name='New Object Mesh')
35 mesh_data.from_pydata(verts, edges, faces)
36 add_object_data(context, mesh_data, operator=self)
39 class OBJECT_OT_add_object(bpy.types.Operator, AddObjectHelper):
40 """Add a Mesh Object"""
41 bl_idname = "mesh.add_object"
42 bl_label = "Add Mesh Object"
43 bl_description = "Create a new Mesh Object"
44 bl_options = {'REGISTER', 'UNDO'}
46 scale = FloatVectorProperty(name='scale',
47 default=(1.0, 1.0, 1.0),
48 subtype='TRANSLATION',
49 description='scaling')
51 def execute(self, context):
53 add_object(self, context)
60 def add_object_button(self, context):
62 OBJECT_OT_add_object.bl_idname,
68 bpy.types.INFO_MT_mesh_add.append(add_object_button)
72 bpy.types.INFO_MT_mesh_add.remove(add_object_button)
75 if __name__ == '__main__':