myriadbanshee

NOOB - editing part of a definition query using Python script

Discussion created by myriadbanshee on Jun 21, 2011
Latest reply on Jun 21, 2011 by tony.farndon
Hello all,

Forgive me if this is bread and butter to you, but I am struggling my way into programming and need a little guidance.

I have used up as much online resource as I can however I just cannot figure out the next step.

I have a large feature class in a file geodatabase which I then seperate out into different layers (of sequence geology) using a definition query based on a unique field. I am trying to clean up the data and to do this I need to edit the definition query for each layer using python script. This is what I have thus far:-

import arcpy, os
mxd = arcpy.mapping.MapDocument("N:\xxxxxx\KURPM_GDEMAP_pythontest.mxd")
for lyr in arcpy.mapping.ListLayers (mxd, "GDE_KURPM_NOTES"):
    lyr.definitionQuery.replace == ("NOTES", "NOTE")
mxd.save()

GDE_KURPM_NOTES is the feature class in the FGDB that all the layers are pointing to.
i want to change the definition query from
SECTION = 'KURPM_XXXX_NOTES' to 
SECTION = 'KURPM_XXXX_NOTE'

it goes through fine, but nada happens.

Any thoughts - i would be most grateful and will send you virtual cake. It would also give me a base to understand python script and programming a bit better!

Dan.B

Outcomes