AnsweredAssumed Answered

Testing against current row in DDP

Question asked by anakaine on Sep 26, 2017
Latest reply on Sep 27, 2017 by anakaine

I'm attempting to test against a cell in the current row of Data Driven Pages.
My short script works, however when I start to add things it breaks.

 

For example, the below contains all my variables used to set up the query and should essentially only print whether the value is found, or not. In the python console window within Arcmap 10.3 the script finishes with no feedback at all.

mxd = arcpy.mapping.MapDocument("CURRENT")
ddp = mxd.dataDrivenPages
searchstring = "UBD"
names = ["UBD_2017"]
ddp.currentPageID = ddp.getPageIDFromName("CURRENT")
layers = arcpy.mapping.ListLayers(mxd, "*", df)
row = ddp.pageRow
CurrentRowCell = ddp.pageRow.Basemap
print (ddp.pageRow)
print (CurrentRowCell)
if searchstring == CurrentRowCell:
    print("found in rows.Basemap")
    #df = arcpy.mapping.ListDataFrames(mxd, "Main Map")[0]
    #layers = arcpy.mapping.ListLayers(mxd, "*", df)
    #for layer in layers:
    #    if layer.name in names:
    #        layer.visible = True
else:
    print("not found in rows.basemap")
    #df = arcpy.mapping.ListDataFrames(mxd, "Main Map")[0]
    #layers = arcpy.mapping.ListLayers(mxd, "*", df)
    #for layer in layers:
    #    if layer.name in names:
    #        layer.visible = False

arcpy.RefreshTOC()
arcpy.RefreshActiveView()

 

 

If I shorten my query even further, but paste the below in immediately following the script above I am returned with output "not found in rows.basemap", which is correct. If I change page and present the alternate option it also returns the correct answer.

 

Any ideas on what would stop the first quoted script from at least displaying the output based on whether the desired string is found or not?

Outcomes