By following the given criteria need to get the field values of Assettype and Assetgroup from a feature class.
Check if the feature class have subtypes (Assetgroup assigned as subtype field) and also check if the feature class have both the field names(Assetype and Assetgroup).
If it is true then get the values of both field , the field values are domain coded
I'm using this script but not getting the output
subdict = arcpy.da.ListSubtypes(class_feature)
if len(subdict) > 1:
for stcode in subdict:
if subdict[stcode]['SubtypeField'] != "":
tsubtypefield = subdict[stcode]["SubtypeField"]
subtypenames.append(subdict[stcode]['Name'])
field_name = ["ASSETTYPE", "ASSETGROUP"]
field = [f for f in desc.fields if f.name == field_name][0]
domain = arcpy.da.ListDomains(desc.path)[field.domain]
with arcpy.da.SearchCursor(class_feature, field_name) as cursor:
for row in cursor:
print(row[0],row[1])
This looks an awful lot like a school assignment.
Can you please give me any suggestions how will i achieve the results as specified?
I'm intentionally being vague so as not to deprive you of a learning opportunity. The Esri documentation for arcpy is pretty good. Take a look at the ListSubtypes, ListFields, and ListDomains functions.