<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to Retrieve All Connections from a ufe.Attribute Object in Maya Programming Forum</title>
    <link>https://forums.autodesk.com/t5/maya-programming-forum/how-to-retrieve-all-connections-from-a-ufe-attribute-object/m-p/13352927#M52</link>
    <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I am trying to retrieve all connections from a ufe.Attribute object. Here's what I'm doing:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;I obtain the attrs from a sceneItem using ufe.Attributes.attributes(sceneItem).&lt;/LI&gt;&lt;LI&gt;I iterate over attrs.attributeNames(), and for each attribute name, I retrieve the corresponding ufe.Attribute object using attrs.attribute(attrName).&lt;/LI&gt;&lt;LI&gt;I then attempt to get the connections from the ufe.Attribute object using a ufe.Connections object.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;However, I am encountering the following error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;MyCode :&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;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)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;Error Message :&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Error: Tried to call pure virtual function "Connections::allConnections"
# # Traceback (most recent call last):
# #   File "&amp;lt;maya console&amp;gt;", line 7, in &amp;lt;module&amp;gt;
# # RuntimeError: Tried to call pure virtual function "Connections::allConnections"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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?&lt;/P&gt;&lt;P&gt;Any guidance would be greatly appreciated!&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
    <pubDate>Wed, 05 Mar 2025 06:25:37 GMT</pubDate>
    <dc:creator>tearcandy</dc:creator>
    <dc:date>2025-03-05T06:25:37Z</dc:date>
    <item>
      <title>How to Retrieve All Connections from a ufe.Attribute Object</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/how-to-retrieve-all-connections-from-a-ufe-attribute-object/m-p/13352927#M52</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I am trying to retrieve all connections from a ufe.Attribute object. Here's what I'm doing:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;I obtain the attrs from a sceneItem using ufe.Attributes.attributes(sceneItem).&lt;/LI&gt;&lt;LI&gt;I iterate over attrs.attributeNames(), and for each attribute name, I retrieve the corresponding ufe.Attribute object using attrs.attribute(attrName).&lt;/LI&gt;&lt;LI&gt;I then attempt to get the connections from the ufe.Attribute object using a ufe.Connections object.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;However, I am encountering the following error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;MyCode :&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;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)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;Error Message :&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Error: Tried to call pure virtual function "Connections::allConnections"
# # Traceback (most recent call last):
# #   File "&amp;lt;maya console&amp;gt;", line 7, in &amp;lt;module&amp;gt;
# # RuntimeError: Tried to call pure virtual function "Connections::allConnections"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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?&lt;/P&gt;&lt;P&gt;Any guidance would be greatly appreciated!&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Wed, 05 Mar 2025 06:25:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/how-to-retrieve-all-connections-from-a-ufe-attribute-object/m-p/13352927#M52</guid>
      <dc:creator>tearcandy</dc:creator>
      <dc:date>2025-03-05T06:25:37Z</dc:date>
    </item>
  </channel>
</rss>

