Is there a way to change the domains on a feature class that has sybtypes with arcpy?
Solved! Go to Solution.
Check out:
An overview of the Domains toolset
An overview of the Subtypes toolset
You should be able to use these tools to do what you need.
My solution:
ListSubtypes—Data Access module | ArcGIS Desktop
Assign Domain To Field—Data Management toolbox | ArcGIS Desktop
import arcpy sde_path = r"xxxx" arcpy.env.workspace = sde_path domain = "T_LineSegment" domain_feature_classes = {"feature_class": "domain_field", ....} for feature, domain_field in domain_feature_classes.items(): print "updating domains by subtype on " + feature subtypes = arcpy.da.ListSubtypes(feature) for k, v in subtypes.items(): print "\tsetting domain for subtype code: " + str(k) arcpy.AssignDomainToField_management(feature, domain_field, domain, k)
Check out:
An overview of the Domains toolset
An overview of the Subtypes toolset
You should be able to use these tools to do what you need.
I don't see anything in them that will let me set the domain on a field by subtype... unless I am missing something...
If you are using Pro, there's this:
Create, modify, and delete subtypes
With Desktop, I believe it is a Delete and Add instead of Modify.
No we are still on desktop. But I did judge your last post to fast. It is part of the solution I think for sure. I was just being foolish. I am testing now...
My solution:
ListSubtypes—Data Access module | ArcGIS Desktop
Assign Domain To Field—Data Management toolbox | ArcGIS Desktop
import arcpy sde_path = r"xxxx" arcpy.env.workspace = sde_path domain = "T_LineSegment" domain_feature_classes = {"feature_class": "domain_field", ....} for feature, domain_field in domain_feature_classes.items(): print "updating domains by subtype on " + feature subtypes = arcpy.da.ListSubtypes(feature) for k, v in subtypes.items(): print "\tsetting domain for subtype code: " + str(k) arcpy.AssignDomainToField_management(feature, domain_field, domain, k)
This should be marked as the solution.