Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a geodatabase with many feature classes. Some of the feature classes have subtype fields. Their names vary feature class by feature class. I now want to find the names of those subtype fields. What I have so far is:

for fc in arcpy.ListFeatureClasses("*","",dataset):
    subtypefields = arcpy.da.ListSubtypes(fc)
    for subtype in subtypefields:

Now, I don't know how to continue from here. Any help will be appreciated. Thanks!

share|improve this question

1 Answer 1

up vote 6 down vote accepted

There is a good example in the documentation. Adapted for your purposes:

for fc in arcpy.ListFeatureClasses("*","",dataset):
    subtypes = arcpy.da.ListSubtypes(fc)
    for stcode, stdict in subtypes.iteritems():
        print('Code: {0}'.format(stcode))
        for stkey in stdict.iterkeys():
            if stkey == 'FieldValues':
                print('Fields:')
                fields = stdict[stkey]
                for field, fieldvals in fields.iteritems():                
                    print(' --Field name: {0}'.format(field))
                    print(' --Field default value: {0}'.format(fieldvals[0]))
                    if not fieldvals[1] is None:
                        print(' --Domain name: {0}'.format(fieldvals[1].name))
            else:                    
                print('{0}: {1}'.format(stkey, stdict[stkey]))
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.