Show Navigation | Hide Navigation
You are here:
Geoprocessing tool reference > Data Management toolbox > Domains toolset > Tools

Assign Domain to Field (Data Management)

Release 9.2
Last modified November 29, 2010
E-mail This Topic Printable Version Give Us Feedback

Print all topics in : "Tools"


Related Topics

Sets the domain for a particular field and optionally for a subtype. If no subtype is specified, the domain is only assigned to the specified field.


Usage tips

Command line syntax
An overview of the Command Line window
AssignDomainToField_management <in_table> <field_name> <domain_name> {subtype_code;subtype_code...}

Parameter Explanation Data Type
<in_table>

The name of the table or feature class containing the field that will be assigned a domain.

Table View
<field_name>

The name of the field to be assigned a domain.

Field
<domain_name>

The name of a geodatabase domain to assign to the field name. Available domains will automatically be loaded.

String
{subtype_code;subtype_code...}

The subtype code to be assigned a domain. The Add Value button, which is used only in ModelBuilder, allows you to add expected values so you can complete the dialog and continue to build your model.

String
Data types for geoprocessing tool parameters


Command line example

workspace E:\arcgis\ArcTutor\BuildingaGeodatabase\Montgomery.mdb
AssignDomainToField water\fittings ANGLE RotAngle '2: Tee'

Scripting syntax
About getting started with writing geoprocessing scripts
AssignDomainToField_management (in_table, field_name, domain_name, subtype_code)

Parameter Explanation Data Type
in_table (Required)

The name of the table or feature class containing the field that will be assigned a domain.

Table View
field_name (Required)

The name of the field to be assigned a domain.

Field
domain_name (Required)

The name of a geodatabase domain to assign to the field name. Available domains will automatically be loaded.

String
subtype_code (Optional)

The subtype code to be assigned a domain. The Add Value button, which is used only in ModelBuilder, allows you to add expected values so you can complete the dialog and continue to build your model.

String

Data types for geoprocessing tool parameters


Script example

# Purpose: Create an attribute domain to constrain|material values

# Create the Geoprocessor object
import arcgisscripting
gp = arcgisscripting.create()

try:
    # Set the workspace (to avoid having to type in the full path to the data every time)
    gp.Workspace = "E:/arcgis/ArcTutor/BuildingaGeodatabase"

    # Set variable for domain name
    domname = "Material4"

    # Process: Create the coded value domain
    gp.CreateDomain("montgomery.mdb", domname, "Valid|materials", "TEXT", "CODED")

    # Process: Add valid material types to the domain
    gp.AddCodedValueToDomain("montgomery.mdb", domname, "CI", "Cast iron")
    gp.AddCodedValueToDomain("montgomery.mdb", domname, "DI", "Ductile iron")
    gp.AddCodedValueToDomain("montgomery.mdb", domname, "PVC", "PVC")
    gp.AddCodedValueToDomain("montgomery.mdb", domname, "ACP", "Asbestos concrete")
    gp.AddCodedValueToDomain("montgomery.mdb", domname, "COP", "Copper")

    # Process: Constrain the material value of distribution mains
    gp.AssignDomainToField("Montgomery.mdb/Water/Distribmains", "Material", domname)

except:
    # If an error occurred while running a tool print the messages
    print gp.GetMessages()

Please visit the Feedback page to comment or give suggestions on ArcGIS Desktop Help.
Copyright © Environmental Systems Research Institute, Inc.