List Domains by Subtype?

3435
1
02-27-2012 11:43 AM
847396730
Occasional Contributor III
Hello!  I have a script which combs a geodatabase and returns each feature class and feature dataset which uses a domain, the name of the domain, and to which field the domain is applied.  When it hits a feature dataset with a subtype, it only lists the domains in use by the default subtype value, not the domains associated with the other subtype values.  How can I write a script which will list the domains set for each individual subtype in a feature dataset?  Thank you!

import arcpy
#Set workspace environment to geodatabase
arcpy.env.workspace = r"\\Gissrv1\017gisdatt\017GISDATA\Geodatabases\NDOT_Transportation.gdb"

#Get list of feature classes in geodatabase
FCs = arcpy.ListFeatureClasses()

#Loop through feature classes in list
for FC in FCs:

        #List fields in feature class
        fields = arcpy.ListFields(FC)

        #Loop through fields
        for field in fields:

            #Check if field has domain
            if field.domain != "":

                #Print feature class, field, domain name
                print FC, ",", field.name, ",", field.domain
               
#Get list of feature datasets in geodatabase
FDs = arcpy.ListDatasets("*", "Feature")

#Loop through feature datasets in list
for FD in FDs:

        #List fields in feature dataset
        fields = arcpy.ListFields(FD)

        #Loop through fields
        for field in fields:

            #Check if field has domain
            if field.domain != "":

                #Print feature class, field, domain name
                print FD, ",", field.name, ",", field.domain
Tags (2)
0 Kudos
1 Reply
NathanLebel
New Contributor
Outside of just getting the default subtype for a feature class in python against a file geodatabase there really isn't anything else you can do in python. The only way I've been able to do it is to connect to the data in SDE and run arcsdesqlexecute on the some of the system tables that have all of that info to build the results, or if you are using a personal geodatabase you could connect to it as an access database using win32comm and basically do the same thing by accessing the system tables and building a list from there. I can post up a couple of examples if you'd like.
0 Kudos