Maya command: "cmds.listConnections", behave differently in two classes

Hi,

I have some weird problem with Maya Python cmds library. I need obtain all shading engines in scene, so I list materials then loop thorugh them to get connections. Something like that:

for material in scene_materials:
scene_shading_groups = cmds.listConnections(material, type=‘shadingEngine’)

The problem is that it return different data in two class. In one class it’s work fine and i get all shading engines but when I try to use it in secound class it return onyl deffault shading engines
([u’initialParticleSE’, u’initialShadingGroup’, u’initialParticleSE’]).

Secound class is created in first class but in both I use same cmds command “cmds.listConnections(material, type=‘shadingEngine’)”

It’s working as a Shutgrid hook. Do anybody know what can cause this behavior?

Hey there,
Hard to tell without knowing exactly what are the differences between your two classes.

If you only want the SG and don’t need to check the materiels you can try:

default_sgs = [u’initialParticleSE’, u’initialShadingGroup’, u’initialParticleSE’]
sgs = cmds.ls(type='shadingEngine')
sgs = [i for i in sgs if i not in default_sgs]
1 Like

BenWall,

main difference is that class in which everything works fine is inherite by Shotgrid HookBaseClass.
But when I geting shading engines like you suggest. Just by listing them, everything works fine. It’s looks like in this one class I can list materials, shading engines etc, but it dosent “see” connections between them.

Thanks for your help :slight_smile:

Without more information it would be difficult to pinpoint why the results are different.