How to enable map series using python in ArcGIS Pro?

5601
11
Jump to solution
02-26-2019 06:25 AM
AaronLaver
New Contributor II

Hi there, please bear with me as this is my first post and I'm relatively new to Python.

I'm currently constructing a tool which would create and export a map series. So far I've been able to create a strip map index, import a layout, and even export the series to PDF -- but only after I manually enable the mapseries from arcgis pro. How do I go about authoring the map series using python?

Thanks in advance if you're able to help with this. Code can be found below.

#    All of this code works

import arcpy
arcpy.env.workspace = r"somepath"
prodoc = arcpy.mp.ArcGISProject("CURRENT")
prodocmap = prodoc.listMaps("Map")[0]
feature_selection = arcpy.CopyFeatures_management("test_line", r"memory\erased")
scale = 24000 
horiz_line_buffer = "8.5 inches" 
vert_line_buffer = "5.5 inches"
strip_map = arcpy.StripMapIndexFeatures_cartography (feature_selection, "grid1", "USEPAGEUNIT", scale, horiz_line_buffer, vert_line_buffer, "HORIZONTAL", 0, "", "WE_NS")
arcpy.Delete_management ("erased")
prodoc.importDocument(r"layoutpath.pagx")
import arcpy
import os
import sys
relpath = os.path.dirname(sys.argv[0])
p = arcpy.mp.ArcGISProject("CURRENT")
l = p.listLayouts()[0]
mf = l.listElements("MAPFRAME_ELEMENT")[0]
first_map = p.listMaps()[0]

#    Need to inject mapSeries enable or similar here, can't get it to work




#    export mapseries as PDF - This Works
if not l.mapSeries is None:
  ms = l.mapSeries
  if ms.enabled:
    ms.exportToPDF(r"C:\EsriPress\Ex3_SelectedFeatures.pdf", "ALL", "", "PDF_SINGLE_FILE", 150, "BEST", True, "ADAPTIVE", True, "LAYERS_ONLY", True, 80, True, False)
0 Kudos
11 Replies
AaronLaver
New Contributor II

Unfortunate, but understood. Thanks Jeff.

0 Kudos
KoryKramer
Esri Community Moderator

For anybody who runs across this thread, please go to https://community.esri.com/t5/arcgis-pro-ideas/add-python-command-for-create-map-series-and/idi-p/10... to add your support for the idea by giving it a Kudo.  Thank you.

0 Kudos