Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

A script I made creates domains within a selected geodatabase.

I need it to not create the domains if they already exist because if they do, it gives an error saying invalid domain name.

Is there anyway around this?

I have overwrite on, but I assume that doesn't have anything to do with domains?

I'm using 10.0


share|improve this question
See this post, might help: gis.stackexchange.com/questions/25129/… –  Chad Cooper Nov 5 '12 at 15:18

1 Answer 1

up vote 3 down vote accepted

arcpy.Exists doesn't handle domains. The ESRI help indicates what it does handle.

So you'll need to get a list of existing domains, and then check your potential new name against the list. What version of ArcGIS are you using? 10.1 introduces a new ListDomains function.

If you're on ArcGIS 10.0, then you don't have this ListDomains. In that case I think you should go with the answer to How to check if domain already exists?, which describes how to use the workspace Describe function to check for existence.

If you're on ArcGIS 10.1, then you can try out the new ListDomains function (data access module) to get a list of existing domain names for a geodatabase, and then compare your potential new name to the list of existing names.

Something like this:

myNewDomains = ['new one', 'new two']
existingDomains = arcpy.da.ListDomains("C:/xyz/xyz.gdb")

for myNewDomain in myNewDomains:
    # check if myNewDomain already exists
    found = False
    for domain in existingDomains: 
        if domain.name == myNewDomain:
            found = True
    # if myNewDomain doesn't already exist, then create it
    if found = False:
        # drop in your domain-creation code
        print "Domain already exists:", myNewDomain
share|improve this answer
Hey how do I view fields instead of domains? To view domain it was *.domains. Is there a way to use Describe to view all the fields within a database? –  ian Nov 5 '12 at 21:11
@I-B: a gdb or workspace has domains, but it doesn't immediately have fields. It can have tables and those tables can have fields. I suggest searching this GIS SE site or ArcGIS help, and then maybe asking a new question here. Try this: help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/… –  andytilia Nov 6 '12 at 16:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.