How can I add a domain to a field for all subtypes?

2908
2
07-15-2015 12:23 PM
RobBlash
Occasional Contributor III

I want to automate adding a domain to a field. I need to do this a bunch of times with multiple feature classes that have multiple subtypes. Is there a wildcard I can use for the subtype parameter to grab all of them? Another method I'm not thinking of?

Assign Domain To Field (Data Management)

0 Kudos
2 Replies
RebeccaStrauch__GISP
MVP Emeritus

If you are willing to look thru my script, and ignore all the stuff that is strictly for my project, I can send you the .py script I use.  I will follow you, and if you follow my I can send it email.  Too busy to clean it up for general use.  But I routinely run a set of scripts to copy my master SDE to a fgdb and pre-process it for Server.  One of the steps is reapplying domains and subtypes.  It might give you all the info you need.  (ig nore this message if someone gives you are cleaner answer).

0 Kudos
FreddieGibson
Occasional Contributor III

Have you tried using the ListSubtypes function of the data access module to gather the subtypes for the needed table or feature class?

List Subtypes

http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-data-access/listsubtypes.htm

The describe objects may also be useful for this workflow. You should be able to compile a tool that can parse out the subtype names needed and implement your workflow to process them.

GDB Table Properties

http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-functions/gdb-table-properties.htm