Select to view content in your preferred language

Script Adding Numbers to End of Domains?

894
2
02-27-2012 12:52 PM
847396730
Frequent Contributor
Hello again!  Until I find a way to return a list of subtype field's domains, I have used this workaround:

1) Import feature class into a fresh file geodatabase
2) Set the default subtype field to "Interstate"
3) Run the script to return the field domains with an "Interstate" subtype
4) Set the default subtype field to "State Route"
5) Run the script to return the field domains with an "Interstate" subtype
repeat, repeat...

Oddly, the output includes the addition of an underscore and a number after some, but not all of the results (see attached).  What could be causing this?

Thank you!

Here's the script:

import arcpy
#Set workspace environment to geodatabase
arcpy.env.workspace = r"\\Gissrv1\017gisdatt\017GISDATA\Geodatabases\NDOT_Transportation.gdb"

#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.name, ",", field.domain

#Get list of feature datasets in geodatabase
FDs = arcpy.ListDatasets("*", "Feature")

#Loop through feature datasets in list
for FD in FDs:

#List fields in feature dataset
fields = arcpy.ListFields(FD)

#Loop through fields
for field in fields:

#Check if field has domain
if field.domain != "":

#Print feature class, field, domain name
print FD, ",", field.name, ",", field.domain
Tags (2)
0 Kudos
2 Replies
DarrenWiens2
MVP Alum
The above script only reads the domains. The domains with underscore numbers seem to be duplicates, which would indicate that there is a problem in how you're writing the domains.

ps - it's much easier to read your code if you wrap them in the provided
 tags, above the post text box.
0 Kudos
847396730
Frequent Contributor
Thank you for your response!  I thought the same thing, so I went into the database and examined the domains.  I can't find any evidence that the ones I marked in red exist.  There aren't any duplicate domains.
0 Kudos