Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bpy
- # Get the active object (the source)
- source = bpy.context.active_object
- if not source:
- print("No active object selected.")
- else:
- # Get the active material from the active slot
- active_mat = source.active_material
- if not active_mat:
- print(f"{source.name} has no active material.")
- else:
- # Apply to all selected objects except the source
- for obj in bpy.context.selected_objects:
- if obj == source:
- continue
- if not obj.material_slots:
- print(f"{obj.name} has no material slots, skipping.")
- continue
- # Assign the same material to all slots, without changing slot count
- for slot in obj.material_slots:
- slot.material = active_mat
- print(f"Applied {active_mat.name} to all slots of {obj.name}.")
Add Comment
Please, Sign In to add comment