Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Assign a material to selected objects in Blender
# reference:
# https://blender.stackexchange.com/questions/23433/how-to-assign-a-new-material-to-an-object-in-the-scene-from-python
import bpy
mat = bpy.data.materials.get('my_material')
for o in bpy.context.selected_objects:
if o.data.materials:
ob.data.materials[0] = mat
else:
o.data.materials.append(mat)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.