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.
1 Answer 1
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]))
answered Jul 8, 2014 at 21:39
lang-py