Assign Domain to Field (Data Management) |
|
Release 9.2
Last modified November 29, 2010 |
![]() ![]() ![]() Print all topics in : "Tools" |
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
Domain management involves the following steps:
1) Create the domain using the Create Domain tool.
2) Add values to or set the range of values for the domain using the Add Coded Value to Domain tool or Set Value For Range Domain tool.
3) Associate the domain with a feature class using the Assign Domain To Field tool.
When an attribute domain is associated with a table or feature class, an attribute validation rule is created in the database. This attribute validation rule describes and constrains the valid values of a field type.
One attribute domain can be associated with multiple fields in the same table, feature class, or subtype as well as in multiple tables and feature classes.
The environment settings do not have an effect on this tool.
Current map layers may be used to define Input Table.
Workspace domains can also be managed in ArcCatalog. Domains can be created and modified through the Domains tab on the Database Properties dialog box.
The Subtype parameter Add Value button is used only in ModelBuilder. In ModelBuilder, where the preceding tool has not been run, or its derived data does not exist, the Subtype parameter may not be populated with values. The Add Value button allows you to add expected values so you can complete the Assign Domain To Field dialog and continue to build your model.
The environment settings do not have an effect on this tool.
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 |
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 |
# 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()