Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Get Relationship Classes from Table (Not Workspace)

$
0
0
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.

Code:

desc = arcpy.Describe("myTable")
print desc.relationshipClassNames

I found this thread with this code

Code:

import arcpy
from arcpy import env
workspace = env.workspace = r'your_workspace'
def detectRelationship():
    rc_list = [c.name for c in arcpy.Describe(workspace).children if c.datatype == "RelationshipClass"]
    for rc in rc_list:
        rc_path = workspace + "\\" + rc
        des_rc = arcpy.Describe(rc_path)
        origin = des_rc.originClassNames
        destination = des_rc.destinationClassNames
        print "Relationship Class: %s \n Origin: %s \n Desintation: %s" %(rc, origin, destination)       
detectRelationship()

, 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.

Any help would be much appreciated. Forgot to add I'm using 10.1.

Viewing all articles
Browse latest Browse all 2485

Latest Images

Trending Articles



Latest Images