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.
What's the best way to check if a domain exists?
arcgis-10.0arcpydomains
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.
What's the best way to check if a domain exists?
Best Answer
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 workspaceDescribe
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: