3

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.

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Jul 8, 2014 at 21:35

1 Answer 1

9

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

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.