Identify features referenced by domain

06-23-2015 07:52 AM
Status: Open
Occasional Contributor
Need to add a tool in ArcToolbox to identify features that use a particular domain.

This is tool would compliment the existing tools: Delete Domain and Remove Domain From Field since this information is required to use these tools.

I was provided with a Python script to accomplish this task:

import arcpy
import string
from arcpy import env 
import os 

#Set workspace environment to geodatabase
arcpy.env.workspace = r"Database Connections\Connecting to database.sde"

#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.domain