Guest User

Untitled

a guest
Jul 21st, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #
  2. # @author Cindy Jayakumar
  3. # @date 21/07/2018
  4. #
  5. # Extract domains from a field in one feature class, and apply
  6. # it to matching fields in another feature class.
  7. #
  8.  
  9. import arcpy
  10.  
  11. source_fc = r'C:\Some\Arb\Folder\test.gdb\source'
  12. target_fc = r'C:\Some\Arb\Folder\test.gdb\target'
  13.  
  14. # Get field names and domains if applicable
  15. source_fields = {field.name : field.domain for field in arcpy.ListFields(source_fc) if field.domain}
  16.  
  17. for field in arcpy.ListFields(target_fc):
  18. if field.name in source_fields and field.domain is None:
  19. arcpy.management.AssignDomainToField(target_fc, field.name, source_fields[field.name])
  20. print("Assigned {0} to {1}".format(source_fields[field.name], field.name)
Add Comment
Please, Sign In to add comment