Message 1 of 1
How to Retrieve All Connections from a ufe.Attribute Object
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone,
I am trying to retrieve all connections from a ufe.Attribute object. Here's what I'm doing:
- I obtain the attrs from a sceneItem using ufe.Attributes.attributes(sceneItem).
- I iterate over attrs.attributeNames(), and for each attribute name, I retrieve the corresponding ufe.Attribute object using attrs.attribute(attrName).
- 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!