I have an object with hundreds of materials, and I want to change the blend mode on all of them to opaque. I do not want to go through them individually, so I was wondering if there was a way through the console or somewhere else. I saw this page which was doing a similar things, but it id only changing the nodes. (Automatically change the properties of multiple materials) Thank you!
What to Do
You can do this in Python with a loop, but what you loop on depends on what materials you want to change. The key is that eventually you want to set
material.blend_method = 'OPAQUE' and the problem becomes how you pick
If, for instance, you wanted to change the mode for every material:
for material in bpy.data.materials: material.blend_method = 'OPAQUE'
Or you might want to change the mode for the active object:
object = bpy.context.active_object for slot in object.material_slots: if slot.material: slot.material.blend_method = 'OPAQUE'
or if you wanted to change the mode on the selected objects, you would use the loop in this answer
How to Do it
There are two easy ways you can go about doing this.
- Open a Python Console window and paste the code directly into the window.
- As a text:
- Open a text editor
- click 'New' to create a new text
- Insert the line
- Paste the text
- Click the run button (looks like the 'play' button in the time line.
The first approach is immediate. The second takes a little more time, but then you can save the text as a Python file and load it again later.