Skip To Content

Set Default Subtype

Summary

Sets the default value or code for the input table's subtype.

Usage

  • The input table must contain subtype codes before setting a default code. Use the Add Subtype and Set Subtype Field tools to create subtype codes.

  • You can also view and manage subtypes in Subtypes view which can be opened by clicking the Subtypes button found in the Design section of the Data ribbon, or the by clicking the Subtypes button on the Fields view ribbon.

Syntax

SetDefaultSubtype_management (in_table, subtype_code)
ParameterExplanationData Type
in_table

The input table or feature class whose subtype default value will be set.

Table View
subtype_code

The unique default value for a subtype.

Long

Code sample

Set Default Subtype Example (Python Window)

The following Python window script demonstrates how to use the SetDefaultSubtype function in immediate mode.

import arcpy
arcpy.env.workspace = "C:/data/Montgomery.gdb"
arcpy.SetDefaultSubtype_management("water/fittings", 5)
Set Default Subtype Example 2 (Stand-alone Script)

The following stand-alone script demonstrates how to use the SetDefaultSubtype function as part of a workflow to add subtypes to a field.

#Name: ManageSubtypes.py
# Purpose: Create a subtype definition

# Import system modules
import arcpy
 
try:
    # Set the workspace (to avoid having to type in the full path to the data every time)
    arcpy.env.workspace =  "C:/data/Montgomery.gdb"
    
    # Set local parameters
    inFeatures = "water/fittings"
 
    # Process: Set Subtype Field...
    arcpy.SetSubtypeField_management(inFeatures, "TYPECODE")
     
    # Process: Add Subtypes...
    # Store all the suptype values in a dictionary with the subtype code as the "key" and the 
    # subtype description as the "value" (stypeDict[code])
    stypeDict = {"0": "Unknown", "1": "Bend", "2": "Cap", "3": "Cross", "4": "Coupling",\
                 "5": "Expansion joint", "6": "Offset", "7":"Plug", "8": "Reducer",\
                 "9": "Saddle", "10": "Sleeve", "11": "Tap", "12": "Tee", "13": "Weld", "14": "Riser"} 
    
    # use a for loop to cycle through the dictionary
    for code in stypeDict:
        arcpy.AddSubtype_management(inFeatures, code, stypeDict[code])     
			
    # Process: Set Default Subtype...
    arcpy.SetDefaultSubtype_management(inFeatures, "4")
 
except Exception as err:
    print(err.args[0])

Licensing information

  • ArcGIS Desktop Basic: Yes
  • ArcGIS Desktop Standard: Yes
  • ArcGIS Desktop Advanced: Yes

Related topics