Hello fellow Maya heads,
Can anyone point me to an working example how to connect a material override to a shadingEngine?
Right now, my code looks like this(method of a class creating a render setup):
@staticmethod
def create_material_override(collection, shading_group, name):
"""
Creates a material override for the provided collection and
assigns it to the provided shadingEngine.
"""
# Create material override
__ovr = collection.createOverride(name, typeIDs.materialOverride)
# Connect shadingEngine to override
try:
# Maya 2017 Update 4
__ovr.setOverrideConnection(shading_group.name() + '.message', applyIt=True)
except Exception as e:
# Pre Maya 2017 Update 4
# 2017 Update 3 also has a setMaterial method
LOGGER.debug(e)
__ovr.setSource(shading_group.name() + '.message')
return __ovr
This is working in Maya 2017 Update 4 but throws all kind of "Python Callback failed" errors on Maya 2016.5 (Extension 2 SP2).
Is there a better way to connect the override? I -think- I can not simply connect it via cmds or OpenMaya API2 since the render setup objects are only available thru the render setup API.
Cheers, Stefan