Change domains for subtype features

627
5
Jump to solution
04-26-2018 10:20 AM
forestknutsen1
MVP Regular Contributor

Is there a way to change the domains on a feature class that has sybtypes with arcpy?

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RandyBurton
MVP Regular Contributor

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.

View solution in original post

5 Replies
RandyBurton
MVP Regular Contributor

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.

forestknutsen1
MVP Regular Contributor

I don't see anything in them that will let me set the domain on a field by subtype... unless I am missing something...

0 Kudos
RandyBurton
MVP Regular Contributor

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.

0 Kudos
forestknutsen1
MVP Regular Contributor

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...  

0 Kudos
forestknutsen1
MVP Regular Contributor

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)