This code works.It will create a table in an SDE database - recreating it each time. Lists all the domains used in the workspace.
import arcpyinWorkspaceString = arcpy.GetParameterAsText(0)arcpy.env.workspace = inWorkspaceStringoutTable = "OTHER_ListDomains_tbl"
# Delete old and Create new output table each timeif 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, "Versioned", "TEXT", "", "", 1, "", "NULLABLE", "NON_REQUIRED") #newRows = arcpy.InsertCursor(outTable, "") # Create cursor to store new rows for output tablearcpy.MakeTableView_management(outTable, "outTableView", "", "", "") # Create table view for output table (for searching for existing records)## Create list of domainsdesc = arcpy.Describe(inWorkspaceString)domains = desc.domainsdomains.sort() # Sorts listfor domain in domains:# Write items from list to output table if they don't already exist there arcpy.SelectLayerByAttribute_management("outTableView", "NEW_SELECTION", "\"DomainName\" = \'" + domain + "\'") if int(arcpy.GetCount_management("outTableView").getOutput(0)) == 0: newRow = newRows.newRow() newRow.DomainName = domain newRows.insertRow(newRow)del newRows # Removes lock on output table
Since this discussion was created in 2011, ListDomains—Help | ArcGIS Desktop is probably the best way to get this information in 2017 using Python.
I realize this is a very old thread, but I can't recommend enough X-ray for ArcCatalog for exactly this.
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.