Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#
# @author Cindy Jayakumar
# @date 21/07/2018
#
# Extract domains from a field in one feature class, and apply
# it to matching fields in another feature class.
#
import arcpy
source_fc = r'C:\Some\Arb\Folder\test.gdb\source'
target_fc = r'C:\Some\Arb\Folder\test.gdb\target'
# Get field names and domains if applicable
source_fields = {field.name : field.domain for field in arcpy.ListFields(source_fc) if field.domain}
for field in arcpy.ListFields(target_fc):
if field.name in source_fields and field.domain is None:
arcpy.management.AssignDomainToField(target_fc, field.name, source_fields[field.name])
print("Assigned {0} to {1}".format(source_fields[field.name], field.name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.