Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Shading Group Callback

Shading Group Callback

KasumiL5x
Participant Participant
747 Views
2 Replies
Message 1 of 3

Shading Group Callback

KasumiL5x
Participant
Participant

Hello,

 

I'm deep in development of a project that relies heavily upon dirtied plugs and attribute events.  I am confused, however, on how to receive callbacks of a shader being applied to a mesh and/or polygon set.  I know I can retrieve the data manually on demand, but I'm hoping there is a way of being told when it changes.  This is all in the latest non-extension C++ API.

 

Is there any way to automatically receive a callback (akin to MNodeMessage style) when a shading group is applied to a mesh or set of polygons?

 

Thanks,

Daniel

0 Likes
Accepted solutions (1)
748 Views
2 Replies
Replies (2)
Message 2 of 3

fowlert
Autodesk
Autodesk
Accepted solution

Hey Daniel,

 

I don't think there is a callback that is specific to shader assignment.  You would probably have to use MDGMessage to track connections, and you would know that it's a shader assignment if it involves a shadingGroup and the dagSetMembers attribute.

 

A bit of Python to print information when there are connections:

import maya.api.OpenMaya as om
def conn_cb(src, dst, made, data):
    print 'src=%s' % (src.name())
    print 'Dst = %s' % (dst.name())
    print 'Made = %d' % (made)
id = om.MDGMessage.addConnectionCallback( conn_cb, None )

Does that help?

0 Likes
Message 3 of 3

KasumiL5x
Participant
Participant

Thanks for getting back so quickly.

 

It's unfortunate that there's no message for this, but I can understand why due to how they are structured.

The Python code helps - this is similar to how I was going to approach it.  I'll implement the detection this way and call my own callbacks.

 

Thanks for the help!

0 Likes