I am working with CIM layer definitions a bit. For a layer, I am wanting to get the field that the symbol thematic is based on (layerDefinitions.renderer.fields). However, some renderer types have the fields property while some don't. CIMUniqueValueRenderer has the fields property while CIMSimpleRenderer does not. If I try to access fields on a feature class that uses CIMSimpleRenderer I get an error. However, I cannot access the type property that I can plainly see in the json through the python therefore I cannot create logic around renderer type.
aprx = arcpy.mp.ArcGISProject("CURRENT")
for map in aprx.listMaps():
for layer in map.listLayers():
cim_lyr = layer.getDefinition('V2')
if cim_lyr.renderer.fields is not None: # this is obviously not working
#if cim_lyr.renderer.type == blah: # this is what I would think I should be able to do
print("--- ---Thematic Field: " + str(cim_lyr.renderer.fields[0]))
Error if I plug in a feature class with the wrong type:
AttributeError: 'CIMSimpleRenderer' object has no attribute 'fields'
So, the object obviously knows its type per the error and per the json entry but does not offer me any good way of accessing its type through the CIM object model that I have found. How would I go about this?