<?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 Re: Get Relationship Classes from Table (Not Workspace) in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/get-relationship-classes-from-table-not-workspace/m-p/185368#M14274</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Brett,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you run the code in the Python window it will work. If you use a standalone script, it won't :(. To solve this you should make a Featurelayer of TableView and describe those objects instead:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Feature class&lt;/STRONG&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy fc = r'\\nlbltfs01\Projecten\307103\werkdir\fgb\BLS_Copy_Paste.gdb\Leiding' arcpy.MakeFeatureLayer_management(fc,"myLayer") desc = arcpy.Describe("myLayer") print "myLayer: {0}".format(desc.relationshipClassNames)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Results in:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family:courier new;"&gt;myLayer: [u'ZZRC_Leiding_Afsluiter', u'ZZRC_Leiding_Cap', u'ZZRC_Leiding_Diameterovergang', u'ZZRC_Leiding_Flens', u'ZZRC_Leiding_Isolatiekoppeling', u'ZZRC_Leiding_Las', u'ZZRC_Leiding_Leidingzakbaken', u'ZZRC_Leiding_Wanddikteovergang', u'ZZRC_Leiding_TStuk', u'ZZRC_Leiding_Pigmarker', u'ZZRC_Leiding_Ontluchting', u'ZZRC_Leiding_Mangat', u'ZZRC_Persoon_Leiding']&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Table&lt;/STRONG&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;tbl = r'\\nlbltfs01\Projecten\307103\werkdir\fgb\BLS_Copy_Paste.gdb\Persoon' arcpy.MakeTableView_management(tbl,"myTable") desc = arcpy.Describe("myTable") print "myTable: {0}".format(desc.relationshipClassNames)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Results in:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family:courier new;"&gt;myTable: [u'ZZRC_Persoon_Leiding', u'ZZRC_Eigenaar_Duiker', u'ZZRC_Eigenaar_KruisendeWeg', u'ZZRC_Inspectieweg_Eigenaar', u'ZZRC_Inspectieweg_Onderhoud', u'ZZRC_KruisendeKabel_Persoon', u'ZZRC_KruisendeLeiding_Persoon', u'ZZRC_Onderhoud_Duiker', u'ZZRC_Onderhoud_KruisendeWeg', u'ZZRC_Persoon_Damwandkoker', u'ZZRC_Persoon_Gebouwen', u'ZZRC_Persoon_Gelijkrichter', u'ZZRC_Persoon_Handhole', u'ZZRC_Persoon_KruisendeMantelbuis', u'ZZRC_Persoon_Pachtkavel', u'ZZRC_Persoon_Peilbuis', u'ZZRC_Persoon_Wbe', u'ZZRC_Persoon_Grondzakbaken', u'ZZRC_Persoon_Leidingzakbaken', u'ZZRC_ZakelijkRecht_Persoon']&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Xander&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 22 Nov 2013 06:03:46 GMT</pubDate>
    <dc:creator>XanderBakker</dc:creator>
    <dc:date>2013-11-22T06:03:46Z</dc:date>
    <item>
      <title>Get Relationship Classes from Table (Not Workspace)</title>
      <link>https://community.esri.com/t5/python-questions/get-relationship-classes-from-table-not-workspace/m-p/185367#M14273</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Any ideas on how to do this? Originally, I thought I could use the relationshipClassNames from the GDB Table properties, but I only get empty value back (i.e. []). Anybody know why this does not work or what I'm doing incorrectly? Not much to this and the example is pulled straight from ESRI help documents.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;desc = arcpy.Describe("myTable") print desc.relationshipClassNames&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I found this thread with this code&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy from arcpy import env workspace = env.workspace = r'your_workspace' def detectRelationship(): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rc_list = [c.name for c in arcpy.Describe(workspace).children if c.datatype == "RelationshipClass"] &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for rc in rc_list: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rc_path = workspace + "\\" + rc &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; des_rc = arcpy.Describe(rc_path) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; origin = des_rc.originClassNames &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; destination = des_rc.destinationClassNames &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Relationship Class: %s \n Origin: %s \n Desintation: %s" %(rc, origin, destination)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; detectRelationship()&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;, but I don't need to search the entire DB for all relationships. Only a specific table. I could use this code to ID the table and relationships I want, but would prefer to use the relationshipClassNames from GDB Table to reduce the amount of code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; Any help would be much appreciated.&amp;nbsp; Forgot to add I'm using 10.1.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Nov 2013 19:09:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-relationship-classes-from-table-not-workspace/m-p/185367#M14273</guid>
      <dc:creator>brettangel</dc:creator>
      <dc:date>2013-11-21T19:09:52Z</dc:date>
    </item>
    <item>
      <title>Re: Get Relationship Classes from Table (Not Workspace)</title>
      <link>https://community.esri.com/t5/python-questions/get-relationship-classes-from-table-not-workspace/m-p/185368#M14274</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Brett,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you run the code in the Python window it will work. If you use a standalone script, it won't :(. To solve this you should make a Featurelayer of TableView and describe those objects instead:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Feature class&lt;/STRONG&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy fc = r'\\nlbltfs01\Projecten\307103\werkdir\fgb\BLS_Copy_Paste.gdb\Leiding' arcpy.MakeFeatureLayer_management(fc,"myLayer") desc = arcpy.Describe("myLayer") print "myLayer: {0}".format(desc.relationshipClassNames)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Results in:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family:courier new;"&gt;myLayer: [u'ZZRC_Leiding_Afsluiter', u'ZZRC_Leiding_Cap', u'ZZRC_Leiding_Diameterovergang', u'ZZRC_Leiding_Flens', u'ZZRC_Leiding_Isolatiekoppeling', u'ZZRC_Leiding_Las', u'ZZRC_Leiding_Leidingzakbaken', u'ZZRC_Leiding_Wanddikteovergang', u'ZZRC_Leiding_TStuk', u'ZZRC_Leiding_Pigmarker', u'ZZRC_Leiding_Ontluchting', u'ZZRC_Leiding_Mangat', u'ZZRC_Persoon_Leiding']&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Table&lt;/STRONG&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;tbl = r'\\nlbltfs01\Projecten\307103\werkdir\fgb\BLS_Copy_Paste.gdb\Persoon' arcpy.MakeTableView_management(tbl,"myTable") desc = arcpy.Describe("myTable") print "myTable: {0}".format(desc.relationshipClassNames)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Results in:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family:courier new;"&gt;myTable: [u'ZZRC_Persoon_Leiding', u'ZZRC_Eigenaar_Duiker', u'ZZRC_Eigenaar_KruisendeWeg', u'ZZRC_Inspectieweg_Eigenaar', u'ZZRC_Inspectieweg_Onderhoud', u'ZZRC_KruisendeKabel_Persoon', u'ZZRC_KruisendeLeiding_Persoon', u'ZZRC_Onderhoud_Duiker', u'ZZRC_Onderhoud_KruisendeWeg', u'ZZRC_Persoon_Damwandkoker', u'ZZRC_Persoon_Gebouwen', u'ZZRC_Persoon_Gelijkrichter', u'ZZRC_Persoon_Handhole', u'ZZRC_Persoon_KruisendeMantelbuis', u'ZZRC_Persoon_Pachtkavel', u'ZZRC_Persoon_Peilbuis', u'ZZRC_Persoon_Wbe', u'ZZRC_Persoon_Grondzakbaken', u'ZZRC_Persoon_Leidingzakbaken', u'ZZRC_ZakelijkRecht_Persoon']&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Xander&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Nov 2013 06:03:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-relationship-classes-from-table-not-workspace/m-p/185368#M14274</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2013-11-22T06:03:46Z</dc:date>
    </item>
    <item>
      <title>Re: Get Relationship Classes from Table (Not Workspace)</title>
      <link>https://community.esri.com/t5/python-questions/get-relationship-classes-from-table-not-workspace/m-p/185369#M14275</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Xander, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Making a TableView worked perfectly!&amp;nbsp; Thanks a ton.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Nov 2013 13:19:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-relationship-classes-from-table-not-workspace/m-p/185369#M14275</guid>
      <dc:creator>brettangel</dc:creator>
      <dc:date>2013-11-22T13:19:37Z</dc:date>
    </item>
    <item>
      <title>Re: Get Relationship Classes from Table (Not Workspace)</title>
      <link>https://community.esri.com/t5/python-questions/get-relationship-classes-from-table-not-workspace/m-p/185370#M14276</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If you're following this thread any chance you know how to get the primary and foreign keys from a relationship class?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Nov 2013 19:09:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-relationship-classes-from-table-not-workspace/m-p/185370#M14276</guid>
      <dc:creator>brettangel</dc:creator>
      <dc:date>2013-11-22T19:09:59Z</dc:date>
    </item>
  </channel>
</rss>

