How to fetch current page # from Map Series for la…


We had label scripts in Desktop that called arcpy.mapping.MapDocument(“CURRENT”) and mxd.dataDrivenPages.pageRow.getValue() to populate labels in the map. I have not found any way to recreate this in Pro with Map Series. I don’t want to use Dynamic Text in the layout because the location of the labels may change on every page. The labeling needs to be done in the map, but is dependent on what Map Series page is active. 

Is there a way to do this?

Below is a code snippet of one of our old label scripts from Desktop:

def FindLabel ( [PAGE_INDEX] ):
  result = None
  curIndex = [PAGE_INDEX]

  # current map page info
  mxd = arcpy.mapping.MapDocument("CURRENT")
  PageIndex = mxd.dataDrivenPages.pageRow.getValue('PAGE_INDEX')
  PageBook = long(float(PageIndex[:3]))
  PagePage = long(float(PageIndex[-2:]))

  curBook = long(float(curIndex[:3]))
  curPage = long(float(curIndex[-2:]))

  if curBook != PageBook:
    result="<FNT scale="75">Bk." + str(curBook) + '</FNT>\n' + str(curPage)
  else:
    if curPage != PagePage:
      result="<FNT scale="120">" + str(curPage) + '</FNT>'
  return result
  



Source link

Leave a Comment