adthewyn

New at Python scripting (Definition query and Looping)

Discussion created by adthewyn on Mar 31, 2011
Latest reply on Mar 31, 2011 by sarebalo
I am trying to create a script that Loops through a layer and creates multiple defintion queries on that layer. The layer is building lines and i want to create multiple definition queries so that each floor can be queried out and then mapped. I am having trouble getting started. I tried creating a script that simply creates a definition query for a layer in a mxd. It says the script is executing but when i open up the project nothing changes. Any help  would be appreciated. Some of my scrip is below.

import arcpy, os

mxd = arcpy.mapping.MapDocument("M:/nih/AsbestosAbatement/Floorplans/BLDG_6A/Floorplanpdf.mxd")

for lyr in arcpy.mapping.ListLayers(mxd):
    if lyr.name == "BuildingFloorLInes":
        layer.definitionQuery =[FLR] = '02'
        layer.update
       
print 2

Outcomes