Author Topic: Maya Arnold 5 to Substance Export script  (Read 851 times)


a friend of mine worked on a pymel-script, which I requested and I want to share it with you.

Its for working with lots of assets in a scene, which you want to give a Arnold Standard-Surface Shader with the name of the geo.

All you need to do is, select the geo (generally transform-nodes) you want to export and execute the script.
Also it will apply a random color, which helps with indicating which geo is already shaded.

hope, that helps  ;)

I never found a other way. If there is an easier method - let me know  ;D I really haven't found one...

import pymel.core as pm
import random

def create_random_material(obj_list, shader_type="aiStandardSurface", suffix="mat"):
    material_list = []
    for obj in obj_list:
        mat_name = "{}{}".format(obj.getParent().nodeName(), suffix)
        mat_name = mat_name.replace("_GEO", "")
        material = pm.shadingNode(shader_type, asShader=True, name=mat_name)
        print pm.nodeType(material)
        color_r = random.uniform(0, 1)
        color_g = random.uniform(0, 1)
        color_b = random.uniform(0, 1)
        print material
        # "aiStandardSurface"
        material.baseColor.set((color_r, color_g, color_b))
        # "lambert"
        #material.color.set(color_r, color_g, color_b)

        sg_name = "{}_{}".format(obj.getParent().nodeName(), "SG")
        sg_name = sg_name.replace("_GEO", "")

        shading_group = pm.sets(renderable=True,noSurfaceShader=True,empty=True, name=sg_name)
        pm.sets(shading_group, forceElement=obj)
    return material_list   

selected_transforms =, type="transform")
meshes = []
for transform in selected_transforms:
    shapes = transform.getShapes()
    for shape in shapes:
        if pm.nodeType(shape) == "mesh":
            print shape

create_random_material(meshes, suffix="")