Select to view content in your preferred language

Allow Add coded values to domain tool to use dictionary in modelbuilder

488
1
01-24-2020 12:19 PM
Status: Open
Labels (1)
MarissaMijal
Occasional Contributor

Currently in modelbuilder you can Add fields (multiple), but you cannot Add Coded Values to Domains (multiple).  You have to add domain values one tool module at a time, which is time consuming.

Create an Add Coded Values to Domains (multiple) tool which allows the user to Paste In multiple formatted domain values, using a json dictionary.  This way the user can format the multiple values in excel and paste it into the tool, not type them into individual fields.

1 Comment
SSWoodward

Thanks for this Idea @MarissaMijal,

It doesn't satisfy your request directly, but using the Table to Domain GP tool  may help you here depending on how your domains are being generated.

Consider writing your domains to a memory table and passing that to the Table to Domain tool all at once.   Here's a bit of sample code that might help.  If you have an existing Excel table, you could also use Excel to Table to get the table directly from your Excel file.  These are python examples below but these tools are also available in Model Builder. 

Example pulling directly from an Excel Workbook

xlsx = <path_to_excel_workbook>
workspace = <path_to_workspace>

tbl = arcpy.conversion.ExcelToTable(
    xlsx, 
    'memory\domain_tbl',
    'Sheet1'
)
arcpy.management.TableToDomain(
    in_table = tbl, 
    code_field = 'code', 
    description_field = 'description', 
    in_workspace = wksp
    domain_name = 'xlsx_domain'
)