Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrendon Murphy <meta.androcto1@gmail.com>2012-06-17 19:15:43 +0400
committerBrendon Murphy <meta.androcto1@gmail.com>2012-06-17 19:15:43 +0400
commit0bc5fba842f9a09e5ffea88c0b5995e664834c18 (patch)
treedb2f0219aa2fa8773a292a3613bba3fdd4c5b290 /space_view3d_materials_utils.py
parent8431ec35b719f304d0697256e5dfe19a376c5b11 (diff)
added function to remove all materials slots from selected objects
Diffstat (limited to 'space_view3d_materials_utils.py')
-rw-r--r--space_view3d_materials_utils.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/space_view3d_materials_utils.py b/space_view3d_materials_utils.py
index e35fcc83..2e8814f9 100644
--- a/space_view3d_materials_utils.py
+++ b/space_view3d_materials_utils.py
@@ -481,7 +481,15 @@ def texface_to_mat():
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,6 +569,20 @@ class VIEW3D_OT_material_to_texface(bpy.types.Operator):
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'''
@@ -632,6 +654,9 @@ class VIEW3D_MT_master_material(bpy.types.Menu):
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')