arcpy find which fields use domain

Solutions on MaxInterview for arcpy find which fields use domain by the best coders in the world

showing results for - "arcpy find which fields use domain"
Matteo
27 Jan 2019
1import arcpy
2
3
4gdb = r'<YOUR GDB HERE>'
5arcpy.env.workspace = gdb
6
7# Update domain search here
8domainList = ['piPipeMaterial', 'piControlValveType']
9
10# Find which fields are using domains in the domainList
11for domain in domainList:
12    print("Looking for '" + domain + "' domain...")
13    fds = arcpy.ListDatasets(feature_type='feature')
14    for fd in fds:
15        print('Searching ' + fd + '...')
16        fcs = arcpy.ListFeatureClasses(feature_dataset=fd)
17        for fc in fcs:
18            fields = arcpy.ListFields(fc)
19            for field in fields:
20                if field.domain == domain:
21                    print('Found field ' + field.name + ' in feature class ' + fc + ' using ' + domain)
22                    print('----')
23        print('----------')
24