Layer Page Definition in ArcPy

Idea created by MPCGroup_Admin on Jun 6, 2017
    Reviewed
    Score20
    • Hornbydd
    • MPCGroup_Admin

    Currently there is a gap between what you can do in ArcMap and what you can do with the arcpy mapping module. In particular I would like to see the Layer Class properties to be expanded. Specifically the data driven page properties within a layers definition query. I was thinking along the lines of something like the LabelClass but for definition queries instead.

    Layer—Help | ArcGIS Desktop 

     

    import arcpy
    mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
    for lyr in arcpy.mapping.ListLayers(mxd):
        if lyr.supports("LAYER_DEFINITION"):
            if lyr.layerdefinition is True:
                print "Layer name: " + lyr.name
                print "    Layer Definition:            " + lyr.layerdefinition.expression
                print "    Page Definition Enabled:     " + lyr.layerdefinition.pagedefinition
                print "    Page Definition Expression:  " + lyr.layerdefinition.pagedefinitionexpression
    del mxd

     

    I have just dealt with a data-model change that saw a bunch of fields get consolidated better through out our business and now I am faced with the prospect of changing 100+ mxd's to a new data structure with most having data driven pages driven from one of the fields that was changed. No Drama just script the update however the page definition is the one attribute I am now unable to update and have to now go through manually and correct these.