Skip to main content
added 65 characters in body
Source Link
Gorgious
  • 31.8k
  • 2
  • 49
  • 106

I don't know if there's a best way to do it since it depends on your file and workflow but :

import bpy

m_source = bpy.data.materials["Material.001"]
m_target = bpy.data.materials["Material.002"]

for obj in (o for o in bpy.data.objects if hasattr(o, "material_slots")):
    for slot in obj.material_slots:
        if slot.material is None:
            continue
        if slot.material.name == m_source.name:
            slot.material = m_target

There actually are material operators to copy/paste material settings but they require a handle on an active object with both materials so it might no be very convenient.

https://docs.blender.org/api/current/bpy.ops.material.html

I don't know if there's a best way to do it since it depends on your file and workflow but :

import bpy

m_source = bpy.data.materials["Material.001"]
m_target = bpy.data.materials["Material.002"]

for obj in (o for o in bpy.data.objects if hasattr(o, "material_slots")):
    for slot in obj.material_slots:
        if slot.material.name == m_source.name:
            slot.material = m_target

There actually are material operators to copy/paste material settings but they require a handle on an active object with both materials so it might no be very convenient.

https://docs.blender.org/api/current/bpy.ops.material.html

I don't know if there's a best way to do it since it depends on your file and workflow but :

import bpy

m_source = bpy.data.materials["Material.001"]
m_target = bpy.data.materials["Material.002"]

for obj in (o for o in bpy.data.objects if hasattr(o, "material_slots")):
    for slot in obj.material_slots:
        if slot.material is None:
            continue
        if slot.material.name == m_source.name:
            slot.material = m_target

There actually are material operators to copy/paste material settings but they require a handle on an active object with both materials so it might no be very convenient.

https://docs.blender.org/api/current/bpy.ops.material.html

Source Link
Gorgious
  • 31.8k
  • 2
  • 49
  • 106

I don't know if there's a best way to do it since it depends on your file and workflow but :

import bpy

m_source = bpy.data.materials["Material.001"]
m_target = bpy.data.materials["Material.002"]

for obj in (o for o in bpy.data.objects if hasattr(o, "material_slots")):
    for slot in obj.material_slots:
        if slot.material.name == m_source.name:
            slot.material = m_target

There actually are material operators to copy/paste material settings but they require a handle on an active object with both materials so it might no be very convenient.

https://docs.blender.org/api/current/bpy.ops.material.html