1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
20 "name": "Add PolySphere",
21 "author": "Andy Davies (metalliandy)",
23 "blender": (2, 62, 0),
24 "location": "View3D > Add > Mesh > PolySphere",
25 "description": "Adds a PolySphere (all quads) for sculpting",
27 "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/"
28 "Scripts/Add_Mesh/Add_PolySphere",
29 "category": "Add Mesh"}
36 bpy
.ops
.mesh
.primitive_cube_add()
38 #Changes name of Cube to PolySphere adds the variable cube
39 cube
= bpy
.context
.object
40 cube
.name
= "PolySphere"
42 #Positions Cube primitive to scene centre
43 bpy
.context
.active_object
.location
= [0, 0, 0]
45 #Adds Subsurf Modifier
46 bpy
.ops
.object.modifier_add(type='SUBSURF')
48 #Selects Subsurf Modifier for editing
49 subsurf
= cube
.modifiers
['Subsurf']
51 #Changes Subsurf levels
54 #Applys Subsurf Modifier
55 bpy
.ops
.object.modifier_apply(apply_as
='DATA', modifier
="Subsurf")
58 bpy
.ops
.object.shade_smooth()
61 bpy
.ops
.object.editmode_toggle()
63 #Selects cube in Editmode
64 #bpy.ops.mesh.select_all(action='TOGGLE')
66 #Adds transform "To Sphere"
67 bpy
.ops
.transform
.tosphere(value
=1)
70 bpy
.ops
.object.editmode_toggle()
72 #Scales Object to 2.0 Units
73 bpy
.ops
.transform
.resize(value
=(1.15525, 1.15525, 1.15525), constraint_axis
=(False, False, False), constraint_orientation
='GLOBAL', mirror
=False, proportional
='DISABLED', proportional_edit_falloff
='SMOOTH', proportional_size
=1, snap
=False, snap_target
='CLOSEST', snap_point
=(0, 0, 0), snap_align
=False, snap_normal
=(0, 0, 0), release_confirm
=False)
75 #Applys location, rotation and scale data
76 bpy
.ops
.object.transform_apply(location
=True, rotation
=True, scale
=True)
78 #makes PolySphere an operator
79 class AddPolySphere(bpy
.types
.Operator
):
81 bl_idname
= "mesh.primitive_polysphere_add"
82 bl_label
= "Add PolySphere"
83 bl_options
= {'REGISTER', 'UNDO'}
85 def execute(self
, context
):