I currently have

matName = "Black"

blendfile = addon_dir + "/assets/materials.blend"
selection = "\\Material\\"
material = matName

filepath = blendfile + selection + material
directory = blendfile + selection
filename = material
newMat = bpy.ops.wm.append(filepath=filepath, filename=filename, directory=directory)
mat = bpy.data.materials.get(material)

this appends a material and adds it to the current object. The problem is that it adds a new material slot with the material. How can I make it add the appended material to the active slot?

  • $\begingroup$ Does this post help you LINK? $\endgroup$ – Rick Riggs Jun 22 '16 at 1:27

The list of materials that shows in the material properties comes from


The index for the one that is selected in that list is

idx = obj.active_material_index

using that you assign a material to that slot with

obj.material_slots[idx].material = mat
  • 2
    $\begingroup$ Also equivalent to obj.active_material = mat $\endgroup$ – batFINGER Jun 22 '16 at 7:17
  • $\begingroup$ This works fine! $\endgroup$ – John Roper Jun 22 '16 at 19:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.