List Domains

746
3
02-27-2015 09:34 AM
Status: Implemented
PetreUrsaru
New Contributor II
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


 
Tags (2)
3 Comments
RobertBorchert
ArcGisDiagrammer will show you these things.

It is not a terribly friendly program but it does this.

There used to be a database reporter tool for 9.3 that was the cats meow. It would list each feature class and the attributes and each domain for those attributes.

It was replaced by ArcGisDiagrammer.  Yes it was a step backwards
KarenFolger

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

KoryKramer
Status changed to: Implemented