AnsweredAssumed Answered

Setting a definition query

Question asked by emilharold on Jan 4, 2014
Hi gang,

For some reason I can't get this code to work. I'm simply trying to set a definition query on a layer. The pertinent code is:

mxd = arcpy.mapping.MapDocument("CURRENT")  theProj = arcpy.GetParameter(1)  for lyr in arcpy.mapping.ListLayers(mxd):     if lyr.name == theProj:         lyr.definitionQuery = '"PROJ_TYPE" = \'C\' OR "PROJ_TYPE" = \'VC\''


The script runs fine, but no definition query is applied to the layer once it has completed.

Any help?


EDIT: I figured it out :D

mxd = arcpy.mapping.MapDocument("CURRENT")  theProj = arcpy.GetParameter(1)  for lyr in arcpy.mapping.ListLayers(mxd):     if lyr.name == str(theProj):         lyr.definitionQuery = '"PROJ_TYPE" = \'C\' OR "PROJ_TYPE" = \'VC\''



I had to add str() is all.

Outcomes