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)
Solved! Go to Solution.
Unfortunate, but understood. Thanks Jeff.
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.
I know this is an older thread, but wondering if someone can help me. I have an existing spatial map series set up in my layout. I created a tool in model builder to re-populate the data for the map series. After this runs, it turns the map series to None type. I can easily just switch it back to spatial, but am hoping to add some code to the tool to eliminate that step. Is there a way to just turn the map series back to Spatial with python? I tried going through the createSpatialMapSeries, which works, but I don't know how to set the group by and page number fields, as well as the extent with python, so it doesn't get set back up how I need it.