<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>idea Create Subtypes from a Domain in Data Management Ideas</title>
    <link>https://community.esri.com/t5/data-management-ideas/create-subtypes-from-a-domain/idi-p/1635273</link>
    <description>&lt;P&gt;&lt;STRONG&gt;Problem:&lt;/STRONG&gt; Creating subtypes for feature classes is manual and time-consuming. Doing it for one feature class is annoying, but doing it for multiple feature classes that use the same subtypes is extremely inefficient.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Data Management tool "Add Subtype" only allows the user to add a single subtype at a time. In batch mode, it allows a batch addition of codes, but not descriptions. Subtypes must be integers, so the description is important.&lt;/P&gt;&lt;P&gt;The Manage Subtypes dialog box also only allows you to manually type in one new subtype at a time. The paste option, which would be another great time saver if you could paste in directly from excel or a domain, does not support pasting more than one cell of data at a time.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Existing Idea (Give it a kudo!):&lt;/STRONG&gt;&amp;nbsp;&lt;A href="https://community.esri.com/t5/data-management-ideas/copy-subtype-from-one-feature-class-to-another/idi-p/929083" target="_self"&gt;Allow pasting subtypes from one feature class to another&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;This Idea:&lt;/STRONG&gt; My idea is to allow using a domain stored within the geodatabase to populate the subtype codes and descriptions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 23 Jul 2025 02:43:03 GMT</pubDate>
    <dc:creator>LizAbbey</dc:creator>
    <dc:date>2025-07-23T02:43:03Z</dc:date>
    <item>
      <title>Create Subtypes from a Domain</title>
      <link>https://community.esri.com/t5/data-management-ideas/create-subtypes-from-a-domain/idi-p/1635273</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Problem:&lt;/STRONG&gt; Creating subtypes for feature classes is manual and time-consuming. Doing it for one feature class is annoying, but doing it for multiple feature classes that use the same subtypes is extremely inefficient.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Data Management tool "Add Subtype" only allows the user to add a single subtype at a time. In batch mode, it allows a batch addition of codes, but not descriptions. Subtypes must be integers, so the description is important.&lt;/P&gt;&lt;P&gt;The Manage Subtypes dialog box also only allows you to manually type in one new subtype at a time. The paste option, which would be another great time saver if you could paste in directly from excel or a domain, does not support pasting more than one cell of data at a time.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Existing Idea (Give it a kudo!):&lt;/STRONG&gt;&amp;nbsp;&lt;A href="https://community.esri.com/t5/data-management-ideas/copy-subtype-from-one-feature-class-to-another/idi-p/929083" target="_self"&gt;Allow pasting subtypes from one feature class to another&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;This Idea:&lt;/STRONG&gt; My idea is to allow using a domain stored within the geodatabase to populate the subtype codes and descriptions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jul 2025 02:43:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-ideas/create-subtypes-from-a-domain/idi-p/1635273</guid>
      <dc:creator>LizAbbey</dc:creator>
      <dc:date>2025-07-23T02:43:03Z</dc:date>
    </item>
    <item>
      <title>Re: Create Subtypes from a Domain</title>
      <link>https://community.esri.com/t5/data-management-ideas/create-subtypes-from-a-domain/idc-p/1635392#M2543</link>
      <description>&lt;P&gt;Ngl I kind of assumed this functionality was already there. Weird.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jul 2025 13:03:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-ideas/create-subtypes-from-a-domain/idc-p/1635392#M2543</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2025-07-23T13:03:48Z</dc:date>
    </item>
    <item>
      <title>Re: Create Subtypes from a Domain</title>
      <link>https://community.esri.com/t5/data-management-ideas/create-subtypes-from-a-domain/idc-p/1635631#M2544</link>
      <description>&lt;P&gt;Thanks for this Idea&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/483426"&gt;@LizAbbey&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;This functionality is not available as a single click button or GP tool but can be achieved with a few quick lines of python.&amp;nbsp; Below I've included a sample that will allow you to use any integer domain to create subtypes on a feature class. It could be adapted with minor changes to suit non-integer domains as well.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;workspace: str = "&amp;lt;insert workspace path here&amp;gt;"
domain_name: str = "&amp;lt;inser name of domain in workspace&amp;gt;"
target_table: str = "&amp;lt;path to target table&amp;gt;"
subtype_field: str = "&amp;lt;name of integer subtype field in target_table&amp;gt;"

st_tbl =arcpy.management.DomainToTable(
    workspace, domain_name, 'memory\\temp_out_tbl', 'code', 'desc'
)
arcpy.management.SetSubtypeField(
    target_table, subtype_field
)
with arcpy.da.SearchCursor(st_tbl, ['code', 'desc']) as cursor:
    for row in cursor:
        arcpy.management.AddSubtype(target_table, row[0], row[1])

del cursor
arcpy.management.Delete(st_tbl)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jul 2025 22:50:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-ideas/create-subtypes-from-a-domain/idc-p/1635631#M2544</guid>
      <dc:creator>SSWoodward</dc:creator>
      <dc:date>2025-07-23T22:50:33Z</dc:date>
    </item>
    <item>
      <title>Re: Create Subtypes from a Domain</title>
      <link>https://community.esri.com/t5/data-management-ideas/create-subtypes-from-a-domain/idc-p/1635807#M2545</link>
      <description>&lt;P&gt;Thanks for the code,&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/604859"&gt;@SSWoodward&lt;/a&gt;. As written it doesn't prevent the user from nominating a non-integer domain, or from selecting a subtype field that is not an integer type - both scenarios make the script fail.&lt;/P&gt;&lt;P&gt;I was able to save this as a python script inside a toolbox and added in some validation to only allow selecting an integer field for the target subtype field. I wasn't able to limit the domains to integer domains though (limited python knowledge). My workaround is to prefix subtype domain names with "subtype_" so I know they're formatted correctly.&lt;/P&gt;&lt;P&gt;This is an excellent workaround for me and I have posted the entire script with screenshots below.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Parameters:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LizAbbey_0-1753320886789.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/137112i9FEE02409D329E36/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LizAbbey_0-1753320886789.png" alt="LizAbbey_0-1753320886789.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Execution:&lt;/P&gt;&lt;P&gt;Screenshot&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LizAbbey_0-1753401217843.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/137203i325DB9B8CDC5E435/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LizAbbey_0-1753401217843.png" alt="LizAbbey_0-1753401217843.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

def add_subtypes_from_domain(workspace: str, domain_name: str, target_table: str, subtype_field: str):
    """
    Adds subtypes to a feature class or table based on a coded value domain.

    Parameters:
        workspace (str): Path to the geodatabase containing the domain.
        domain_name (str): Name of the domain to extract codes from.
        target_table (str): Path to the feature class or table to update.
        subtype_field (str): Name of the integer field to use for subtypes.
    """
    arcpy.env.workspace = workspace
    temp_table = "memory\\temp_out_tbl"

    try:
        # Convert domain to table
        st_tbl = arcpy.management.DomainToTable(workspace, domain_name, temp_table, 'code', 'desc')

        # Set the subtype field
        arcpy.management.SetSubtypeField(target_table, subtype_field)

        # Add subtypes from the domain table
        with arcpy.da.SearchCursor(st_tbl, ['code', 'desc']) as cursor:
            for code, desc in cursor:
                arcpy.management.AddSubtype(target_table, code, desc)

    finally:
        # Clean up
        if 'cursor' in locals():
            del cursor
        if arcpy.Exists(temp_table):
            arcpy.management.Delete(temp_table)

if __name__ == "__main__":
    workspace = arcpy.GetParameterAsText(0)
    domain_name = arcpy.GetParameterAsText(1)
    target_table = arcpy.GetParameterAsText(2)
    subtype_field = arcpy.GetParameterAsText(3)

    add_subtypes_from_domain(workspace, domain_name, target_table, subtype_field)&lt;/LI-CODE&gt;&lt;P&gt;Validation:&lt;/P&gt;&lt;P&gt;Screenshot&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LizAbbey_2-1753320978799.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/137114iACB696D757B9574C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LizAbbey_2-1753320978799.png" alt="LizAbbey_2-1753320978799.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

class ToolValidator:
    def __init__(self):
        self.params = arcpy.GetParameterInfo()

    def initializeParameters(self):
        return

    def updateParameters(self):
        # Populate domain names from workspace (no type filtering)
        if self.params[0].altered and self.params[0].value:
            workspace = self.params[0].valueAsText
            arcpy.env.workspace = workspace
            try:
                domains = arcpy.da.ListDomains(workspace)
                domain_names = [d.name for d in domains]
                self.params[1].filter.list = domain_names
            except Exception:
                self.params[1].filter.list = []

        # Populate subtype field list with only Integer or SmallInteger fields
        if self.params[2].altered and self.params[2].value:
            target_table = self.params[2].valueAsText
            try:
                fields = arcpy.ListFields(target_table)
                int_fields = [
                    f.name for f in fields
                    if f.type in ["Integer", "SmallInteger"]
                ]
                self.params[3].filter.list = int_fields
            except Exception:
                self.params[3].filter.list = []

        return

    def updateMessages(self):
        return&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jul 2025 23:54:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-ideas/create-subtypes-from-a-domain/idc-p/1635807#M2545</guid>
      <dc:creator>LizAbbey</dc:creator>
      <dc:date>2025-07-24T23:54:04Z</dc:date>
    </item>
    <item>
      <title>Re: Create Subtypes from a Domain</title>
      <link>https://community.esri.com/t5/data-management-ideas/create-subtypes-from-a-domain/idc-p/1636006#M2546</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/483426"&gt;@LizAbbey&lt;/a&gt;&amp;nbsp;Great improvements!&lt;BR /&gt;&lt;BR /&gt;Adding that validation really takes this to the next level. I'm glad you were able to turn my simple example into a full fledged GP tool.&amp;nbsp; We love to see it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jul 2025 16:27:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-ideas/create-subtypes-from-a-domain/idc-p/1636006#M2546</guid>
      <dc:creator>SSWoodward</dc:creator>
      <dc:date>2025-07-24T16:27:47Z</dc:date>
    </item>
  </channel>
</rss>

