Example #1
0
def updtDomain(domTable, codeField, descField, wrkspc, domName, domDesc,
               updateOp, TbleText):
    # Count the rows in the table to make sure there is something to update
    cSub = arcpy.GetCount_management(domTable)
    if int(cSub.getOutput(0)) > 0:
        # Update the attribute table with the GlobalID before updating the domain
        with arcpy.da.SearchCursor(domTable, ['GlobalID']) as cursor:
            for row in cursor:
                RowID = str(row[0])
            del row
        del cursor
        cursor = arcpy.da.UpdateCursor(domTable, [codeField])
        for row in cursor:
            row[0] = RowID
            cursor.updateRow(row)
        del cursor, row

        # Process: Create a domain from an existing table
        msg = "Update {} domain".format(TbleText)
        arcpy.AddMessage(msg)
        try:
            arcpy.TableToDomain_management(domTable, codeField, descField,
                                           wrkspc, domName, domDesc, updateOp)
            arcpy.SortCodedValueDomain_management(wrkspc, domName,
                                                  "DESCRIPTION", "ASCENDING")
        except:
            msg = "Unable to update {} domain".format(TbleText)
            arcpy.AddWarning(msg)
            pass
    else:
        msg = "No {} to update".format(TbleText)
        arcpy.AddMessage(msg)
Example #2
0
def updateAssignmentDomain():
    # Process: Table To Domain (10)
    Assignments = "Assignments"
    try:
        cAssign = arcpy.GetCount_management(Assignments)
        if int(cAssign.getOutput(0)) > 0:
            arcpy.AddMessage("\nUpdate Assignment Numbers domain\n")
            arcpy.TableToDomain_management(Assignments, "Assignment_Number",
                                           "Assignment_Number", wrkspc,
                                           "Assignment_Number",
                                           "Assignment_Number", "REPLACE")
            try:
                arcpy.SortCodedValueDomain_management(wrkspc,
                                                      "Assignment_Number",
                                                      "DESCRIPTION",
                                                      "ASCENDING")
            except:
                pass
        else:
            arcpy.AddMessage("No Assignment Numbers to update")
    except:
        arcpy.AddMessage(
            "Error in Assignment Numbers update: may be two Assignments with same number or multiple blanks"
        )
    return
Example #3
0
def updtDomain2(domTable, codeField, descField, wrkspc, domName, domDesc,
                updateOp, TbleText):
    # Count the rows in the table to make sure there is something to update
    cSub = arcpy.GetCount_management(domTable)
    if int(cSub.getOutput(0)) > 0:
        # Process: Create a domain from an existing table
        msg = "Update {} domain".format(TbleText)
        arcpy.AddMessage(msg)
        try:
            arcpy.TableToDomain_management(domTable, codeField, descField,
                                           wrkspc, domName, domDesc, updateOp)
            arcpy.SortCodedValueDomain_management(wrkspc, domName,
                                                  "DESCRIPTION", "ASCENDING")
        except:
            msg = "Unable to update {} domain".format(TbleText)
            arcpy.AddWarning(msg)
            pass
    else:
        msg = "No {} to update".format(TbleText)
        arcpy.AddMessage(msg)
Example #4
0
#-------------------------------------------------------------------------------
# Name:        module1
# Purpose:
#
# Author:      chrism
#
# Created:     20/11/2017
# Copyright:   (c) chrism 2017
# Licence:     <your licence>
#-------------------------------------------------------------------------------

import arcpy
schema_workspace = arcpy.GetParameter(0)
domain_name = arcpy.GetParameter(1)
sort_by = arcpy.GetParameter(2)
if sort_by = '#' or not sort_by:
    sort_by = "CODE"
sort_order = arcpy.GetParameterAsText(3)
if sort_order = '#' or not sort_order:
    sort_order = "ASCENDING"

arcpy.SortCodedValueDomain_management(schema_workspace, domain_name, sort_by, sort_order)

                "Ulmus_rubra": "Ulmus rubra", \
                "Ulmus_thomasii": "Ulmus thomasii", \
                "Viburnum_acerifolia": "Viburnum acerifolia", \
                "Viburnum_alnifolia": "Viburnum alnifolia", \
                "Viburnum_lentago": "Viburnum lentago", \
                "Viburnum_trilobum": "Viburnum trilobum", \
                "Vitis_riparia": "Vitis riparia", \
                "Xanthocyparis_nootkatensis": "Xanthocyparis nootkatensis", \
                "Zanthoxylum_americanum": "Zanthoxylum americanum", \
                "Zelkova_serrata": "Zelkova serrata", }

    for code in domDict:
        arcpy.AddCodedValueToDomain_management(gdb, domName, code,
                                               domDict[code])

        arcpy.SortCodedValueDomain_management(gdb, domName, "CODE",
                                              "ASCENDING")


    domDict2 = {"02": "02", \
                "04": "04", \
                "06": "06", \
                "08": "08", \
                "10": "10", \
                "12": "12", \
                "14": "14", \
                "16": "16", \
                "18": "18", \
                "20": "20", \
                "22": "22", \
                "24": "24", \
                "26": "26", \
Example #6
0
TeamMemb = "Team_Members"
Subject_Information = "Subject_Information"
Scenarios = "Scenarios"
Probability_Regions = "Probability_Regions"
Assignments = "Assignments"
Clues_Point = "Clues_Point"

# Process: Table To Domain (1)
cLead = arcpy.GetCount_management(Lead_Agency)
if int(cLead.getOutput(0)) > 0:
    arcpy.AddMessage("update Lead Agency domain")
    arcpy.TableToDomain_management(Lead_Agency, "Lead_Agency", "Lead_Agency",
                                   Workspace, "Lead_Agency", "Lead_Agency",
                                   "REPLACE")
    try:
        arcpy.SortCodedValueDomain_management(Workspace, "Lead_Agency",
                                              "DESCRIPTION", "ASCENDING")
    except:
        pass
else:
    arcpy.AddMessage("No Lead Agency information to update")

# Process: Table To Domain (2)
cIncident = arcpy.GetCount_management(Incident_Information)
if int(cIncident.getOutput(0)) > 0:
    arcpy.AddMessage("update Incident Information domain")
    arcpy.TableToDomain_management(Incident_Information, "Incident_Name",
                                   "Incident_Name", Workspace, "Incident_Name",
                                   "Incident_Name", "REPLACE")
    try:
        arcpy.SortCodedValueDomain_management(Workspace, "Incident_Name",
                                              "DESCRIPTION", "ASCENDING")
Example #7
0
except arcpy.ExecuteError:
    if arcpy.GetMessages(2)[0:12] == 'ERROR 000464':
        if DeleteSharedLocksOnDomains(inDomain) is True:
            print "Shared locks deleted, trying again"
            try:
                arcpy.AddCodedValueToDomain_management(inWS, inDomain, addCode, addDesc)
                print 'Domain value: ' + str(addCode) + ' - ' + str(addDesc) + " added to domain: " + str(inDomain)
            except:
                print 'Adding domain failed'
except Exception, e:
    print e

##Sort domain if specified-----------------------------
if sortVal is True:
    try:
        arcpy.SortCodedValueDomain_management(inWS, inDomain, optSortBy, optSortOrder)
        print 'Domain: ' + str(inDomain) + ' sorted by ' + str(optSortBy) + ' ' + str(optSortOrder)
    except arcpy.ExecuteError:
        if arcpy.GetMessages(2)[0:12] == 'ERROR 000464':
            if DeleteSharedLocksOnDomains(inDomain) is True:
                print "Shared locks deleted, trying again"
                try:
                    arcpy.AddCodedValueToDomain_management(inWS, inDomain, addCode, addDesc)
                    print 'Domain value: ' + str(addCode) + ' - ' + str(addDesc) + " added to domain: " + str(inDomain)
                except:
                    print 'Adding domain failed'
    except Exception, e:
        print e


Example #8
0
            with arcpy.da.SearchCursor(domTable, ['GlobalID']) as cursor:
                for row in cursor:
                    RowID = str(row[0])
                del row
            del cursor
            cursor = arcpy.da.UpdateCursor(domTable,[codeField])
            for row in cursor:
                row[0]=RowID
                cursor.updateRow(row)
            del cursor, row
        
            msg="Update {} domain".format(TbleText)
            arcpy.AddMessage(msg)
            try:
                arcpy.TableToDomain_management(domTable, codeField, descField, wrkspc, domName, domDesc, updateOp)
                arcpy.SortCodedValueDomain_management(wrkspc, domName, "DESCRIPTION", "ASCENDING")
            except:
                msg="Unable to update {} domain".format(TbleText)
                arcpy.AddWarning(msg)
                pass  
        else:
            msg="No {} to update".format(TbleText)
            arcpy.AddMessage(msg)
    else:
        arcpy.AddMessage("You have not provided a valid Subject Name")


    if LeadAgency: 
        #Set local parameters
        LeadInfo = path.join(wrkspc,"Lead_Agency")
        TbleText = "Lead Agency Information"