[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3494] trunk/py/scripts/addons/ space_view3d_materials_utils.py: added function to remove all materials slots from selected objects
Brendon Murphy
meta.androcto1 at gmail.com
Sun Jun 17 17:15:51 CEST 2012
Revision: 3494
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3494
Author: meta-androcto
Date: 2012-06-17 15:15:43 +0000 (Sun, 17 Jun 2012)
Log Message:
-----------
added function to remove all materials slots from selected objects
Modified Paths:
--------------
trunk/py/scripts/addons/space_view3d_materials_utils.py
Modified: trunk/py/scripts/addons/space_view3d_materials_utils.py
===================================================================
--- trunk/py/scripts/addons/space_view3d_materials_utils.py 2012-06-16 23:55:35 UTC (rev 3493)
+++ trunk/py/scripts/addons/space_view3d_materials_utils.py 2012-06-17 15:15:43 UTC (rev 3494)
@@ -481,7 +481,15 @@
if editmode:
bpy.ops.object.mode_set(mode='EDIT')
+def remove_materials():
+ for ob in bpy.data.objects:
+ print (ob.name)
+ try:
+ bpy.ops.object.material_slot_remove()
+ print ("removed material from " + ob.name)
+ except:
+ print (ob.name + " does not have materials.")
# -----------------------------------------------------------------------------
# operator classes:
@@ -561,7 +569,21 @@
mat_to_texface()
return {'FINISHED'}
+class VIEW3D_OT_material_remove(bpy.types.Operator):
+ '''Remove all material slots from active objects'''
+ bl_idname = "view3d.material_remove"
+ bl_label = "Remove All Material Slots"
+ bl_options = {'REGISTER', 'UNDO'}
+ @classmethod
+ def poll(cls, context):
+ return context.active_object != None
+
+ def execute(self, context):
+ remove_materials()
+ return {'FINISHED'}
+
+
class VIEW3D_OT_select_material_by_name(bpy.types.Operator):
'''Select geometry with this material assigned to it'''
bl_idname = "view3d.select_material_by_name"
@@ -632,6 +654,9 @@
layout.operator("view3d.clean_material_slots",
text="Clean Material Slots",
icon='CANCEL')
+ layout.operator("view3d.material_remove",
+ text="Remove Material Slots",
+ icon='CANCEL')
layout.operator("view3d.material_to_texface",
text="Material to Texface",
icon='MATERIAL_DATA')
More information about the Bf-extensions-cvs
mailing list