<?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>idea Add function list relationship classes in Python Ideas</title>
    <link>https://community.esri.com/t5/python-ideas/add-function-list-relationship-classes/idi-p/1064766</link>
    <description>&lt;P&gt;Add a function called ListRelationshipClasses().&amp;nbsp; That way, we can grab these objects easier than using a bunch of desc language to get to it.&lt;/P&gt;</description>
    <pubDate>Thu, 03 Jun 2021 17:26:08 GMT</pubDate>
    <dc:creator>SavageTrimble</dc:creator>
    <dc:date>2021-06-03T17:26:08Z</dc:date>
    <item>
      <title>Add function list relationship classes</title>
      <link>https://community.esri.com/t5/python-ideas/add-function-list-relationship-classes/idi-p/1064766</link>
      <description>&lt;P&gt;Add a function called ListRelationshipClasses().&amp;nbsp; That way, we can grab these objects easier than using a bunch of desc language to get to it.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jun 2021 17:26:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-ideas/add-function-list-relationship-classes/idi-p/1064766</guid>
      <dc:creator>SavageTrimble</dc:creator>
      <dc:date>2021-06-03T17:26:08Z</dc:date>
    </item>
    <item>
      <title>Re: Add function list relationship classes</title>
      <link>https://community.esri.com/t5/python-ideas/add-function-list-relationship-classes/idc-p/1064809#M45</link>
      <description>&lt;P&gt;Awesome idea!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jun 2021 18:37:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-ideas/add-function-list-relationship-classes/idc-p/1064809#M45</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-06-03T18:37:03Z</dc:date>
    </item>
    <item>
      <title>Re: Add function list relationship classes</title>
      <link>https://community.esri.com/t5/python-ideas/add-function-list-relationship-classes/idc-p/1066378#M51</link>
      <description>&lt;OL&gt;&lt;LI&gt;good, idea, upvoted.&lt;/LI&gt;&lt;LI&gt;in the meantime, you can do this:&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def listRelationshipClasses(database):
    """Returns a list of dictionaries describing the relationship classes inside the given database.

    Tested with SDE and FGDB

    database: str, path to the database

    """
    desc = arcpy.da.Describe(database)
    parents = [desc] + [c for c in desc["children"] if c["dataElementType"] == "DEFeatureDataset"]
    rs = []
    for p in parents:
        rs += [c for c in p["children"] if c["dataElementType"] == "DERelationshipClass"]
    return rs


listRelationshipClasses("Path\to\your\database.gdb")
listRelationshipClasses("Path\to\your\database.sde")&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;</description>
      <pubDate>Thu, 10 Jun 2021 07:31:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-ideas/add-function-list-relationship-classes/idc-p/1066378#M51</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-06-10T07:31:10Z</dc:date>
    </item>
    <item>
      <title>Re: Add function list relationship classes</title>
      <link>https://community.esri.com/t5/python-ideas/add-function-list-relationship-classes/idc-p/1066392#M52</link>
      <description>&lt;P&gt;Nice&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/294341"&gt;@JohannesLindner&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jun 2021 14:41:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-ideas/add-function-list-relationship-classes/idc-p/1066392#M52</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-06-09T14:41:56Z</dc:date>
    </item>
    <item>
      <title>Re: Add function list relationship classes</title>
      <link>https://community.esri.com/t5/python-ideas/add-function-list-relationship-classes/idc-p/1066424#M53</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/294341"&gt;@JohannesLindner&lt;/a&gt;&amp;nbsp;for the info.&amp;nbsp; I'm having a hard time traversing through a dataset with the script you provided as I've seen examples like that in other blogs.&amp;nbsp; I was posting this for more control over searching in a dataset, or standalone and looping through all of them or specifying specific keywords to choose.&amp;nbsp; This is key to help manage any changes to Utility Networks too as relationships are warehoused within a feature dataset.&amp;nbsp; I'm starting to switch our data over to some of the new models and this function will help manage them with the recreation of relationships when schema changes are massive.&amp;nbsp; Eventually, I'm hopeful that UN will become less strict on how its managed in schema as long as we meet certain criteria.&amp;nbsp; Also, branch versioning has very strict rules before publishing so this function helps in deleting and recreating just in case globalIDs aren't populated correctly even though ArcGIS Pro or Python says, successful.&amp;nbsp; I've had major issues with preparing branch versioning geodatabases because of the massive issues with operations successfully completing when they really haven't.&amp;nbsp; It's just a nice feel good message.&amp;nbsp; Hopefully, esri Fixes these items in future releases because when I run routines, I'd like to think the successful message is accurate.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jun 2021 15:31:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-ideas/add-function-list-relationship-classes/idc-p/1066424#M53</guid>
      <dc:creator>SavageTrimble</dc:creator>
      <dc:date>2021-06-09T15:31:03Z</dc:date>
    </item>
    <item>
      <title>Re: Add function list relationship classes</title>
      <link>https://community.esri.com/t5/python-ideas/add-function-list-relationship-classes/idc-p/1066769#M55</link>
      <description>&lt;P&gt;Updated the code in my comment above: Now it also finds relationship classes in feature datasets, and it returns a list of dicts instead of the old describe objects, so it's easier to read the output.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure if this covers some of what you're looking for:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import os, pprint

all_rs = listRelationshipClasses("path/to/your/database.sde")  # see above

pprint.pprint(all_rs[0])

# filter by name
rs = [r for r in all_rs if r["name"] == "FilterName"]
rs = [r for r in all_rs if "PartOfTheName" in rs["name"]]

# filter by cardinality
rs = [r for r in all_rs if r["cardinality"] == "OneToOne"]

# filter by origin or destination table
rs = [r for r in all_rs if "OriginTableName" in r["originClassNames"]]
rs = [r for r in all_rs if "DestinationTableName" in r["destinationClassNames"]]
rs = [r for r in all_rs if "OriginTableName" in r["originClassNames"] and "DestinationTableName" in r["destinationClassNames"]]

# filter by dataset
rs = [r for r in all_rs if os.path.basename(r["path"]) == "DatasetName"]

# filter by flags
rs = [r for r in all_rs if r["isComposite"]]
rs = [r for r in all_rs if not r["isComposite"]]
# other flags: isAttachmentRelationship, isAttributed, isReflexive, isVersioned, canVersion, changeTracked&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jun 2021 07:57:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-ideas/add-function-list-relationship-classes/idc-p/1066769#M55</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-06-10T07:57:21Z</dc:date>
    </item>
    <item>
      <title>Re: Add function list relationship classes</title>
      <link>https://community.esri.com/t5/python-ideas/add-function-list-relationship-classes/idc-p/1069473#M58</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/294341"&gt;@JohannesLindner&lt;/a&gt;&amp;nbsp;Thank you and will check it out.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jun 2021 16:40:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-ideas/add-function-list-relationship-classes/idc-p/1069473#M58</guid>
      <dc:creator>SavageTrimble</dc:creator>
      <dc:date>2021-06-17T16:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: Add function list relationship classes</title>
      <link>https://community.esri.com/t5/python-ideas/add-function-list-relationship-classes/idc-p/1224755#M156</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;Thank you for the idea and discussion around alternatives!&lt;/P&gt;&lt;P&gt;I wanted to highlight that this can also be done using &lt;FONT face="courier new,courier"&gt;arcpy.da.Walk&lt;/FONT&gt;:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import os

ws = r"C:\&amp;lt;my_path&amp;gt;"
rlclss = []
walk = arcpy.da.Walk(ws, "RelationshipClass")
for dirpath, dirnames, filenames in walk:
    for filename in filenames:
        rlclss.append(os.path.join(dirpath, filename))&lt;/LI-CODE&gt;&lt;P&gt;see&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/data-access/walk.htm" target="_self"&gt;arcpy.da.Walk&lt;/A&gt;&amp;nbsp;for more info.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2022 16:01:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-ideas/add-function-list-relationship-classes/idc-p/1224755#M156</guid>
      <dc:creator>HannesZiegler</dc:creator>
      <dc:date>2022-10-24T16:01:42Z</dc:date>
    </item>
    <item>
      <title>Re: Add function list relationship classes - Status changed to: Open</title>
      <link>https://community.esri.com/t5/python-ideas/add-function-list-relationship-classes/idc-p/1327935#M236</link>
      <description>&lt;P&gt;Reset status to "Open"&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2023 20:05:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-ideas/add-function-list-relationship-classes/idc-p/1327935#M236</guid>
      <dc:creator>HannesZiegler</dc:creator>
      <dc:date>2023-09-12T20:05:42Z</dc:date>
    </item>
  </channel>
</rss>

