Hey guys,
Current version 0.1.6 Updated on 4th March 2012
http://projects.blender.org/tracker/download.php/153/467/26250/19583/add_mesh_polysphere.py
This is just a preview of my first attempt at making a script!
I thought it would be cool to create a PolySphere for sculpting and because its all quads, you wont get the pinching issue at the poles
I want to go much further with this by enabling the creation of different resolutions of the polysphere and also add some other primitives that are optimised for sculpting.
Im a little stuck with a few errors and if anyone could give me a hand that would be great
If i go through the add menu and add the polysphere I get this error
Traceback (most recent call last):
File "C:\PROGRA~1\BLENDE~1\Blender2.5\2.55\scripts\addons\add_mesh_polysphere.py", line 91, in execute
Add_PolySphere(self, context)
NameError: global name 'Add_PolySphere' is not defined
location:<unknown location>:-1
and if i enable the add on through the prefs, it automatically adds the mesh in the 3d window, which is obviously not very ideal
Here is the code i have so far
# ##### 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_addon_info = {
"name": "Add PolySphere",
"author": "Andy Davies (metalliandy)",
"version": (0,1),
"blender": (2, 5, 5),
"api": 33866,
"location": "View3D > Add > Mesh > PolySphere",
"description": "Adds a PolySphere (all quads) for sculpting",
"warning": "",
"wiki_url": "",
"tracker_url": "",
"category": "Object"}
import bpy
#Add Cube to scene
bpy.ops.mesh.primitive_cube_add(view_align=False, enter_editmode=False, location=(0, 0, 0), rotation=(0, 0, 0), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))
#Changes name of Cube to polysphere adds variable cube
cube = bpy.context.object
cube.name = "PolySphere"
#Positions Cube primitive to scene centre
bpy.context.active_object.location = [0, 0, 0]
#Adds Subsurf Modifier
bpy.ops.object.modifier_add(type='SUBSURF')
#Selects Subsurf Modifier for editing
subsurf = cube.modifiers['Subsurf']
#Changes Subsurf levels
subsurf.levels = 3
#Applys Subsurf Modifier
bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Subsurf")
#Adds smooth shading
bpy.ops.object.shade_smooth()
#Change to Editmode
bpy.ops.object.editmode_toggle()
#Selects cube in Editmode
bpy.ops.mesh.select_all(action='TOGGLE')
#Adds transform "To Sphere"
bpy.ops.transform.tosphere(value=1, 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)
#Change to Objectmode
bpy.ops.object.editmode_toggle()
#makes PolySphere an operator
class AddPolySphere(bpy.types.Operator):
"""Add a PolySphere."""
bl_idname = "mesh.primitive_polysphere_add"
bl_label = "Add PolySphere"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
Add_PolySphere(self, context)
return {'FINISHED'}
# Register the operator
def menu_func(self, context):
self.layout.operator(AddPolySphere.bl_idname, text="PolySphere", icon='PLUGIN')
def register():
# Add "PolySphere" menu to the "Add Mesh" menu.
bpy.types.INFO_MT_mesh_add.append(menu_func)
def unregister():
# Remove "PolySphere" menu from the "Add Mesh" menu.
bpy.types.INFO_MT_mesh_add.remove(menu_func)
if __name__ == "__main__":
register()
Any ideas?
Thanks for looking