Created
July 3, 2021 19:21
-
-
Save aaronjolson/10d86bbae14e58842ba303c13693d8c3 to your computer and use it in GitHub Desktop.
remove extra materials from all objects in a scene
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import bpy | |
| for obj in bpy.context.selected_editable_objects: | |
| obj.active_material_index = 1 | |
| for i in range(1, len(obj.material_slots)): | |
| bpy.ops.object.material_slot_remove({'object': obj}) | |
| for block in bpy.data.materials: | |
| if block.users == 0: | |
| bpy.data.materials.remove(block) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment