I have a list of unused/unassigned domains in table format. It's actually a table inside a GDB. I want to build a model that iterates through this table and deletes the domain.

Is this possible with ModelBuilder?

I tried to create a field value iterator, however, it won't let me link it up with the Delete Domain tool.

I know it's possible with python, but has anyone successfully attempted this with ModelBuilder.


I wasn't able to find the Model builder answer, but I managed to create a script in python that did the job.

Here it is:

##domain clean up script
##Created by: Ruchira Welikala
##Date: Aug 27, 2015

import arcpy
from arcpy import env

#Workspace where domains will be deleted from
gdbConnName = "Database Connections\\ProductionDB.sde"

#Workspace/Table where list of unused domains are located
UnusedDmnListTable = "C:\Scratch Workspace\domain_List.gdb\A_UnusedDomains"

#Field name that you're running the cursor on
fieldName = "name"

#Cursor initialization. Set the cursor to the table
cursor = arcpy.SearchCursor(UnusedDmnListTable)
txtfile = open('DomainsNOTDeleted.txt','w')

#Loop through and delete domains from workspace
for row in cursor:
                print "Deleting domain: " + (row.getValue(fieldName))
                arcpy.DeleteDomain_management(gdbConnName, (row.getValue(fieldName)))
                print "Deleted:" + (row.getValue(fieldName))
        except Exception:
                print "Domain " + row.getValue(fieldName) + " was not deleted."
                txtfile.write(row.getValue(fieldName) + "\n")

  • You should delete your cursor (del row, cursor) after you are done using it to ensure proper closure. Or better yet, since you are on 10.1+, use da.SearchCursor with a with statement, which automatically closes and is considerably more robust and efficient. – Paul Aug 28 '15 at 17:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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