How to Retrieve All Connections from a ufe.Attribute Object

How to Retrieve All Connections from a ufe.Attribute Object

tearcandy
Enthusiast Enthusiast
379 Views
0 Replies
Message 1 of 1

How to Retrieve All Connections from a ufe.Attribute Object

tearcandy
Enthusiast
Enthusiast

Hello everyone,

I am trying to retrieve all connections from a ufe.Attribute object. Here's what I'm doing:

  1. I obtain the attrs from a sceneItem using ufe.Attributes.attributes(sceneItem).
  2. I iterate over attrs.attributeNames(), and for each attribute name, I retrieve the corresponding ufe.Attribute object using attrs.attribute(attrName).
  3. I then attempt to get the connections from the ufe.Attribute object using a ufe.Connections object.

However, I am encountering the following error:

 

MyCode : 

 

import maya.internal.common.utils.material as mtl_utils
def getAssignedMtlx(shape):
    mtlxNodes = sorted([x for x in mtl_utils.findRelatedShadingNodesForShape(shape) if "%" in x], key=lambda f:len(f))
    if not mtlxNodes:
        return None
    return mtlxNodes[0]

for sh in mc.listRelatives("Asset", ad=1, type="shape"): 
    surItem = ufe.SceneItem(ufe.PathString.path(getAssignedMtlx(sh)))
    attrs = ufe.Attributes.attributes(surItem)
    for attrName in attrs.attributeNames():
        attr = attrs.attribute(attrName)
        conns = ufe.Connections()
        conns.connections(attr, ufe.Connections.AttributeType.ATTR_ANY)

 

 

 

 Error Message :

 

# Error: Tried to call pure virtual function "Connections::allConnections"
# # Traceback (most recent call last):
# #   File "<maya console>", line 7, in <module>
# # RuntimeError: Tried to call pure virtual function "Connections::allConnections"

 

 

 

Am I using the correct approach to retrieve all connections from a ufe.Attribute object? If not, what is the proper way to achieve this?

Any guidance would be greatly appreciated!

Thanks in advance!

0 Likes
380 Views
0 Replies
Replies (0)