Hi, I am looking for examples how to use displayfilters in arcpy. Found only answers about definitionqueries...
Thanks for your help, Christoph
Doesn't seem like there is a direct way to control Display Filter from arcpy.
However, you may find this post helpful Solved: Controlling Pro Display Filters with arcpy - Esri Community
Ta,
AB
Hi AB, thanks, but I saw this already. I need the full layer defined and only want to filter the visibility of certan features. With the definitionquery it would be possible with serveral workarounds ... displayfilter would be very usefull to manage by arcpy.
Best Regards, Christoph
You can get and set them via the CIM.
# get the layer
aprx = arcpy.mp.ArcGISProject("current")
layer = aprx.activeMap.listLayers("LayerName")[0]
# get the layer's cim
cim = layer.getDefinition("V3")
# create a new display filter
new_filter = arcpy.cim.CIMVectorLayers.CIMDisplayFilter()
new_filter.whereClause = "Your query here"
# set the CIM's displayFilters attribute and apply the CIM to the layer
cim.displayFilters = [new_filter]
layer.setDefinition(cim)
# to remove all filters:
cim.displayFilters = []
layer.setDefinition(cim)
Prepare a layer with display queries and get it's CIM to play around with the relevant attributes: