I'm rewriting a Python 2.x script so that it can be used in Pro, and I'm stuck on setting a definition query for a layer. Here's what I tried in Pro's Python Window:
aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.listMaps("Map")[0]
for lyr in m.listLayers("Parcel"):
if lyr.supports("DEFINITIONQUERY"):
lyr.definitionQuery = 'JOINPIN = 201-02-0-00-00-012.01-0'
Then I thought maybe the definition query had to be written like a SQL statement, so I tried:
aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.listMaps("Map")[0]
for lyr in m.listLayers("Parcel"):
if lyr.supports("DEFINITIONQUERY"):
lyr.definitionQuery = 'Join Pin is Equal to 201-02-0-00-00-012.01-0'
Neither option generated an error message, but no definition query is set on the Parcel layer.
Appreciate any help I can get! Documentation for moving from 2.x to 3.x for ArcPro doesn't have a lot of code examples that I can copy.