1
$\begingroup$

our workflow for a job requires us to import alembic meshes from maya and render them in cycles.

I would like run a script that looks at the scene mesh names and assigns the corresponding material.

If the face sets and corresponding materials import with the alembic, would it be possible to assign materials based on the imported name so that materials can be assigned to groups too?

$\endgroup$

1 Answer 1

2
$\begingroup$

An answer to the first part of the question :

import bpy

# Replace with your materials
mat_a = bpy.data.materials.get('mat_a')
mat_b = bpy.data.materials.get('mat_b')
# etc.

# Link every mesh name to a specific material
mesh_dic = {
    'mesh_a': mat_a,
    'mesh_b': mat_b,
    # etc.
    }

# Circle every mesh and link if need be
for mesh in bpy.data.meshes:
    mat = mesh_dic.get(mesh.name)
    if mat:
        mesh.materials.clear()
        mesh.materials.append(mat)

Unfortunately I don't know the alembic in and outs enough to answer the second part but I guess this would be possible using this kind of script depending on what information you are able to import from the file.

Source

$\endgroup$

You must log in to answer this question.

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