Search code examples
pythonmaya

change shader on all assigned meshes, without using hyperShade()


I get all shapes assigned to baseMaterial, select the shapes and then assign the occlusionShader.

for materialClass in materialClassList:
    select(materialClass.baseMaterial)
    hyperShade(objects="")
    hyperShade(a=materialClass.occlusionShader)

works just fine, but if I use it as a pre render script:

  Error: line 0: hyperShade command not supported in batch mode

What can I change the two last lines of my function to to make this work?


Solution

  • i got it to work with:

    for materialClass in materialClassList:
        sets(materialClass.occlusionShadingGroup, e = True, forceElement = materialClass.meshList)
    

    I collect the meshes when I create the materialClass now, which makes much more sense then selecting them for each renderlayer.