Random Multiple Materials in Blender

By Blender Daily

In this tutorial Karim Joseph discusses how we can randomize multiple materials onto the selected objects in Blender. Random materials can be useful in scenes with a lot of objects to assign different materials quickly and get multiple variations.
———————————————————————————————————
Copy this code:
———————————————————————————————————
import random
import bpy

prefix = ‘_’

materials = []
for mat in bpy.data.materials:
if mat.name.startswith(prefix):
materials.append(mat)

for obj in bpy.context.selected_objects:
obj.active_material = random.choice(materials)
———————————————————————————————————
Thanks to:
———————————————————————————————————
Jérôme Belleman:
http://jeromebelleman.gitlab.io/
http://jeromebelleman.gitlab.io/posts/graphics/blenderrand/#randomising-materials

David Mignot :
https://www.idflood.com/
https://knownorigin.io/idflood
https://makersplace.com/idflood/

Video instructor: Karim Joseph
Artstation: https://www.artstation.com/karijoart
Behance: https://www.behance.net/karijoart
YouTube: https://www.youtube.com/channel/UCSRVOY7hRtzUtvEpRznjxhw
Instagram: https://www.instagram.com/karijoart/

Blender Daily on Social Media
Instagram: https://www.instagram.com/blender.daily
Twitter: https://twitter.com/BlenderDaily
Facebook: https://www.facebook.com/blender.daily
TikTok: https://www.tiktok.com/@blender.daily
Website: https://blenderdaily.xyz/