Solved! Go to Solution.
import arcpy mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd") df = arcpy.mapping.ListDataFrames(mxd)[0] # first data frame lyrs = arcpy.mapping.ListLayers(mxd, "" , df) fixLayers = ["Test1 polygon","Test2 polygon"] newParcel = 5 for lyr in lyrs: if lyr.name in fixLayers: lyr.definitionQuery = "parcel_no = {0}".format(newParcel) arcpy.RefreshActiveView() del mxd # release the object (the map will not be deleted)import arcpy
import pythonaddins
class ComboBoxClass1(object):
"""Implementation for Query_addin.combobox (ComboBox)"""
def __init__(self):
self.items = ['"parcel_no" = 1', '"parcel_no" = 2', '"parcel_no" = 3', '"parcel_no" = 4', '"parcel_no" = 5']
self.editable = False
self.enabled = True
self.dropdownWidth = 'WWWWWWWWWW'
self.width = 'WWWWWWWWWW'
def onSelChange(self, selection):
self.mxd = arcpy.mapping.MapDocument("CURRENT")
for lyr in arcpy.mapping.ListLayers(self.mxd):
if lyr.name.lower() == "parcels1":
lyr.definitionQuery = selection
if lyr.name.lower() == "parcels2":
lyr.definitionQuery = selection
if lyr.name.lower() == "parcels3":
lyr.definitionQuery = selection
arcpy.RefreshTOC()
arcpy.RefreshActiveView()
import arcpy mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd") df = arcpy.mapping.ListDataFrames(mxd)[0] # first data frame lyrs = arcpy.mapping.ListLayers(mxd, "" , df) fixLayers = ["Test1 polygon","Test2 polygon"] newParcel = 5 for lyr in lyrs: if lyr.name in fixLayers: lyr.definitionQuery = "parcel_no = {0}".format(newParcel) arcpy.RefreshActiveView() del mxd # release the object (the map will not be deleted)