2009-11-26 15:36:23 +00:00
|
|
|
# ##### 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
#
|
|
|
|
# ##### END GPL LICENSE BLOCK #####
|
|
|
|
|
2009-12-05 22:03:07 +00:00
|
|
|
# <pep8 compliant>
|
|
|
|
|
2009-11-26 15:36:23 +00:00
|
|
|
import bpy
|
2009-11-28 23:37:56 +00:00
|
|
|
from bpy.props import *
|
|
|
|
|
|
|
|
|
|
|
|
class SelectPattern(bpy.types.Operator):
|
|
|
|
'''Select object matching a naming pattern.'''
|
|
|
|
bl_idname = "object.select_pattern"
|
|
|
|
bl_label = "Select Pattern"
|
|
|
|
bl_register = True
|
|
|
|
bl_undo = True
|
|
|
|
|
|
|
|
pattern = StringProperty(name="Pattern", description="Name filter using '*' and '?' wildcard chars", maxlen=32, default="*")
|
|
|
|
case_sensitive = BoolProperty(name="Case Sensitive", description="Do a case sensitive compare", default=False)
|
|
|
|
extend = BoolProperty(name="Extend", description="Extend the existing selection", default=True)
|
|
|
|
|
|
|
|
def execute(self, context):
|
|
|
|
|
|
|
|
import fnmatch
|
|
|
|
|
|
|
|
if self.properties.case_sensitive:
|
|
|
|
pattern_match = fnmatch.fnmatchcase
|
|
|
|
else:
|
|
|
|
pattern_match = lambda a, b: fnmatch.fnmatchcase(a.upper(), b.upper())
|
|
|
|
|
2009-12-01 14:48:36 +00:00
|
|
|
obj = context.object
|
|
|
|
if obj and obj.mode == 'POSE':
|
|
|
|
items = obj.data.bones
|
|
|
|
elif obj and obj.type == 'ARMATURE' and obj.mode == 'EDIT':
|
|
|
|
items = obj.data.edit_bones
|
|
|
|
else:
|
|
|
|
items = context.visible_objects
|
|
|
|
|
|
|
|
# Can be pose bones or objects
|
|
|
|
for item in items:
|
|
|
|
if pattern_match(item.name, self.properties.pattern):
|
|
|
|
item.selected = True
|
2009-11-28 23:37:56 +00:00
|
|
|
elif not self.properties.extend:
|
2009-12-01 14:48:36 +00:00
|
|
|
item.selected = False
|
2009-11-28 23:37:56 +00:00
|
|
|
|
|
|
|
return ('FINISHED',)
|
|
|
|
|
|
|
|
def invoke(self, context, event):
|
|
|
|
wm = context.manager
|
2009-12-07 02:20:55 +00:00
|
|
|
# return wm.invoke_props_popup(self, event)
|
|
|
|
wm.invoke_props_popup(self, event)
|
|
|
|
return ('RUNNING_MODAL',)
|
2009-12-05 22:03:07 +00:00
|
|
|
|
2009-11-29 01:49:22 +00:00
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
props = self.properties
|
2009-12-05 22:03:07 +00:00
|
|
|
|
2009-11-29 01:49:22 +00:00
|
|
|
layout.prop(props, "pattern")
|
|
|
|
row = layout.row()
|
|
|
|
row.prop(props, "case_sensitive")
|
|
|
|
row.prop(props, "extend")
|
2009-11-28 23:37:56 +00:00
|
|
|
|
2009-11-26 15:36:23 +00:00
|
|
|
|
2009-12-07 19:56:59 +00:00
|
|
|
class SubdivisionSet(bpy.types.Operator):
|
2009-11-27 18:55:59 +00:00
|
|
|
'''Sets a Subdivision Surface Level (1-5)'''
|
2009-11-26 15:36:23 +00:00
|
|
|
|
2009-12-07 19:56:59 +00:00
|
|
|
bl_idname = "object.subdivision_set"
|
|
|
|
bl_label = "Subdivision Set"
|
2009-11-26 15:36:23 +00:00
|
|
|
bl_register = True
|
|
|
|
bl_undo = True
|
2009-11-28 23:37:56 +00:00
|
|
|
|
|
|
|
level = IntProperty(name="Level",
|
2009-12-07 19:56:59 +00:00
|
|
|
default=1, min=0, max=100, soft_min=0, soft_max=6)
|
2009-11-26 15:36:23 +00:00
|
|
|
|
|
|
|
def poll(self, context):
|
|
|
|
ob = context.active_object
|
|
|
|
return (ob and ob.type == 'MESH')
|
|
|
|
|
|
|
|
def execute(self, context):
|
2009-11-26 16:05:32 +00:00
|
|
|
level = self.properties.level
|
2009-11-26 15:36:23 +00:00
|
|
|
ob = context.active_object
|
|
|
|
for mod in ob.modifiers:
|
2009-12-07 19:56:59 +00:00
|
|
|
if mod.type == 'MULTIRES' and ob.mode == 'SCULPT':
|
|
|
|
if mod.sculpt_levels != level:
|
|
|
|
mod.sculpt_levels = level
|
|
|
|
return ('FINISHED',)
|
|
|
|
elif mod.type == 'SUBSURF' or mod.type == 'MULTIRES':
|
2009-11-26 15:36:23 +00:00
|
|
|
if mod.levels != level:
|
|
|
|
mod.levels = level
|
2009-11-26 16:05:32 +00:00
|
|
|
return ('FINISHED',)
|
2009-11-28 23:37:56 +00:00
|
|
|
|
2009-11-26 15:36:23 +00:00
|
|
|
# adda new modifier
|
2009-11-28 13:33:56 +00:00
|
|
|
mod = ob.modifiers.new("Subsurf", 'SUBSURF')
|
2009-11-26 15:36:23 +00:00
|
|
|
mod.levels = level
|
|
|
|
return ('FINISHED',)
|
|
|
|
|
|
|
|
|
2009-11-30 01:13:46 +00:00
|
|
|
class Retopo(bpy.types.Operator):
|
|
|
|
'''TODO - doc'''
|
|
|
|
|
|
|
|
bl_idname = "object.retopology"
|
|
|
|
bl_label = "Retopology from Grease Pencil"
|
|
|
|
bl_register = True
|
|
|
|
bl_undo = True
|
|
|
|
|
|
|
|
def execute(self, context):
|
|
|
|
import retopo
|
|
|
|
retopo.main()
|
|
|
|
return ('FINISHED',)
|
|
|
|
|
|
|
|
|
2009-11-28 23:37:56 +00:00
|
|
|
bpy.ops.add(SelectPattern)
|
2009-12-07 19:56:59 +00:00
|
|
|
bpy.ops.add(SubdivisionSet)
|
2009-11-30 01:13:46 +00:00
|
|
|
bpy.ops.add(Retopo)
|