i'm working with a large geodatabase, where exists over 50 domains
my goal is to find each field that uses domains (name, type and description of the domain)
i know it is possible using python
however, a new geoprocessing tool would be very useful
Thanks,
Petre Ursaru - Esri Romania
I am trying to write just such a tool in python but it keeps bombing when I do a describe on the fields for the layer. Anyone have any ideas? Code below
import arcpy
#
inWorkspaceString = arcpy.GetParameterAsText(0)
arcpy.env.workspace = inWorkspaceString
outTable = "OTHER_ListDomains_tbl"
# Delete old and Create new output table each time
if arcpy.Exists(outTable):
arcpy.Delete_management(outTable)
#
arcpy.CreateTable_management(inWorkspaceString, outTable)
arcpy.AddField_management(outTable, "DomainName", "TEXT", "", "", 255, "", "NULLABLE", "REQUIRED")
arcpy.AddField_management(outTable, "Feature_Class", "TEXT", "", "", 255, "", "NULLABLE", "NON_REQUIRED")
#
newRows = arcpy.InsertCursor(outTable, "") # Create cursor to store new rows for output table
arcpy.MakeTableView_management(outTable, "outTableView", "", "", "") # Create table view for output table (for searching for existing records)
#
layers = arcpy.ListFeatureClasses() # Adds feature classes to list
for layer in layers:
desc = arcpy.Describe(layer)
if desc.featureType == "Simple":
# Create list of fields
fields = arcpy.ListFields(layer)
for field in fields:
descf = arcpy.Describe(field)
dom = descf.domain
# Write items from list to output table if they don't already exist there
arcpy.SelectLayerByAttribute_management("outTableView", "NEW_SELECTION", "\"DomainName\" = \'" + dom + "\' AND \"Feature_Class\" = \'" + layer + "\'")
if int(arcpy.GetCount_management("outTableView").getOutput(0)) == 0:
newRow = newRows.newRow()
newRow.DomainName = dom
newRow.Feature_Class = layer
newRows.insertRow(newRow)
del newRows # Removes lock on output table
The ability to identify domain usage was added in ArcGIS Pro.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.