Hi, do you know guys if there’s any method, script or something to delete all the materials in a selected objects? cause usually I can link one material to a whole set of objects but if some of these objects has more than one material then only applies the material I want to the first material, so the sub-materials remains in the objects, I don’t know if you can get my point in this, would be better for me to just delete all the materials first and then create the link to my desired material. Thanks in advance
Select the object you want, then choose the material from the scroll list at the top of the material tab. Next hit the select button just under the tab and choose the material you want to replace it with from the pop up menu. Then hit the assign button. After that just delete the the material from the top menu.
Note: this assumes that you are using 2.5x.
well I was expecting some kind of option like: “delete of the materials from the selected objects” as if I have several objects I should do that for each object and it’s actually a pain in the ass when you work with many objects in a scene.
If you’re not going to be using the material to be deleted anywhere else, and you want that material changed to the same new one in every use of it, then it’s best to edit the material itself. You can either make the adjustments to the existing material or copy and paste one to it (the darker down arrow button in the materials list). That should automatically replace every instance of it.
Alternately, if you do want to save the original, but still replace the current uses of it, you can create a new material slot and copy it to that slot before making the above change.
you could try this one
import bpy for obj in bpy.context.scene.objects: bpy.context.scene.objects.active = obj for x in obj.material_slots: bpy.ops.object.material_slot_remove but this delete all material on all object in scene so may want to change it to select only one object
That’s so great ricky, is it possible to create an script for only delete the materials of the selected objects? then it would be perfect.
import bpy # Deselect eveything bpy.ops.object.select_all(action='DESELECT') # Select ob with given name name ="Cube" obj=bpy.context.scene.objects[name] print ('obj name =', obj.name) print () for x in obj.material_slots: print ('x=',x) bpy.ops.object.material_slot_remove()
The last script only affects the active selected object, not the whole selection, is it possible to have the same action but not only for the active object but for all the selected objects as well? thanks very much Ricky, this feature should be included in Blender already hehehe.
try this one
import bpy # Select ob with given name name ="Cube" print () objselected= bpy.context.selected_objects print ('len ob selected =',len(objselected)) print() jj=0 for i1 in objselected: print ('jj=',jj,'i1=',i1.name,'Type',i1.type) print () bpy.context.scene.objects.active =i1 obj_act = bpy.context.active_object print ('Active object name =',obj_act.name) for x1 in i1.material_slots: print ('mat x =',x1) bpy.ops.object.material_slot_remove() print () jj+=1 print ()
Wow, now it really works, man your script should be included in the official trunk.
That script is soooooooo useful! thanks man!