0
$\begingroup$

is there a way to automatically create new material into every mesh of a model?

I have this issue with auto-rigging from Mixamo as it removes the existing materials when I download the rigged model. So I have to remake the materials again when importing the auto-rigged model back to Blender.

I don't mind if it assigns only the default Principled BSDF. I just need containers to put the shaders in when I import the model to Unity.

$\endgroup$
2
  • $\begingroup$ i) Do you have the blend with the materials pre-mixamo, and ii) are there more than 1 material per object, iii) if so, does the mesh still have materials assigned to faces? $\endgroup$
    – batFINGER
    May 23, 2021 at 10:54
  • $\begingroup$ No, Each mesh has only material in it. $\endgroup$ May 26, 2021 at 9:05

2 Answers 2

0
$\begingroup$

I am not sure if I understood the question correctly, but If you want to assign the same material to all objects then select all objects, click on the Object you want the materials to copy from (it gets highlighted in yellow) then press "Ctrl L" and choose Materials. All objects should share the same Materialdata then. If you just have one model with different textures on it, go into edit mode select all vertices choose the one material you want to copy in the material bar on the right and press "assign" under the material options.

$\endgroup$
1
  • $\begingroup$ I'm sorry... I think I messed up my terms. What was actually asking is if there is a way to automatically create new materials on every single mesh in a model. $\endgroup$ May 22, 2021 at 11:47
0
$\begingroup$

you can do this via python like this:

  1. move all your objects which should have a new material in the collection named "Automatic" -> or change the python code to the name whatever you want

  2. run the script

     import bpy
    
    
     def create_material(object):
    
         newMat = bpy.data.materials.new(name = 'Material')
         object.data.materials.append(newMat)
    
         newMat.use_nodes = True
    
         nodes = newMat.node_tree.nodes
    
         material_output = nodes.get("Material Output")
    
         node_emission = nodes.new(type='ShaderNodeBsdfDiffuse')
    
         node_emission.inputs[0].default_value = (1,0,0,1) 
    
         links = newMat.node_tree.links
    
         newLink = links.new(node_emission.outputs[0], material_output.inputs[0])
    
     index = bpy.data.collections.find('Automatic')
     coll = bpy.data.collections[index]
    
     for eachObject in coll.objects:
    
         if len(eachObject.data.materials) == 0:
             create_material(eachObject)
    
$\endgroup$
1
  • $\begingroup$ okay, so where do I run this script on? $\endgroup$ May 26, 2021 at 9:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .