Hi Steve,
I have a script to create a Map Book that I made a few days ago with the help of Create a map book with Python—ArcGIS Pro | ArcGIS for Desktop . It modifies the text elements and map extent to act like they would with the data driven functionality. Hopefully this post points you or someone else reading this in the right direction if they don't want to wait until the next release. See the attached file for the PDF it outputs.
import arcpy, os
from arcpy import env
# Set input feature class to parameter
fc = arcpy.GetParameterAsText(0)
env.workspace = os.path.dirname(fc)
# Set output PDF location to parameter
pdfOutput = arcpy.GetParameterAsText(1)
# Create the PDF file
pdfPath = os.path.join(pdfOutput,'Inspection.pdf')
pdfDoc = arcpy.mp.PDFDocumentCreate(pdfPath)
# Assign project to parameter
project = arcpy.mp.ArcGISProject("D:\WebSeminars\ProTasks_Demos\Demo2\Data\BuildingTasks\BuildingTasks.aprx")
project.save()
# Select layout and assign to parameter
lyt = project.listLayouts("Layout")[0]
# Set map frame to a parameter and get an extent object
mf = lyt.listElements("MAPFRAME_ELEMENT", "Map Map Frame")[0]
# Set map to a parameter - when importing the layout, it imports the map that was saved with it (ensure this is set correctly)******
map = project.listMaps("Map")[0]
# Set asset layer to a parameter
lyr = map.listLayers(fc)[0]
# Assign Title, Location, Structure, Asset ID, Condition, Last Inspection, and Notes text elements to parameters
titleText = lyt.listElements("TEXT_ELEMENT","Title Text")[0]
locationText = lyt.listElements("TEXT_ELEMENT","Location Text")[0]
structureText = lyt.listElements("TEXT_ELEMENT","Structure Text")[0]
assetText = lyt.listElements("TEXT_ELEMENT","Asset ID Text")[0]
conditionText = lyt.listElements("TEXT_ELEMENT","Condition Text")[0]
lastInspectionText = lyt.listElements("TEXT_ELEMENT","Last Inspection Text")[0]
notesText = lyt.listElements("TEXT_ELEMENT","Notes Text")[0]
# Hide Location, Asset ID, Condition, and Last Inspection text elements for the title page
locationText.text = " "
structureText.text = " "
assetText.text = " "
conditionText.text = " "
lastInspectionText.text = " "
notesText.text = " "
# Zoom to extent of asset layer
###extent = mf.getLayerExtent (lyr,"False","True")
extent = mf.getLayerExtent(lyr)
mf.camera.setExtent(extent)
# Create Title Page for PDF
lyt.exportToPDF(os.path.join(pdfOutput,"TitlePage.pdf"))
pdfDoc.appendPages(os.path.join(pdfOutput,"TitlePage.pdf"))
# Add Length field and calculate values (maintain length in point feature class)
arcpy.AddField_management(fc,"Length","FLOAT")
arcpy.CalculateField_management(fc,"Length","!Shape_Length!","PYTHON")
# Copy selected features to in-memory workspace
arcpy.CopyFeatures_management(fc,"in_memory/SelectedAssets")
# Create center point of assets
arcpy.FeatureToPoint_management("in_memory/SelectedAssets","in_memory/AssetCentroid","CENTROID")
notesText.text = "Notes: _________________________________________________________________________"
# Loop through selected records and create map book
with arcpy.da.SearchCursor("in_memory/AssetCentroid", ['AssetID','CONDITION','LastInspection','DESCRIPTIO','Length','SHAPE@XY','STRUCTURE1']) as cursor:
for row in cursor:
# Get x and y values of centroid
x, y = row[5]
# Set different map extents for different sized features
if row[4] < 70:
# Set smaller extent
left = x - 166
right = x + 166
top = y + 131
bottom = y - 131
else:
# Set larger extent
left = x - 494
right = x + 494
top = y + 390
bottom = y - 390
# Create string from Condition domain value
if str(row[1]) == '1':
conditionValue = 'Bad'
elif str(row[1]) == '2':
conditionValue = 'Poor'
elif str(row[1]) == '3':
conditionValue = 'Fair'
elif str(row[1]) == '4':
conditionValue = 'Good'
elif str(row[1]) == '5':
conditionValue = 'Very Good'
# Update Title, Condition, and Last Inspection text elements
titleText.text = " "
locationText.text = "Location: " + str(row[3])
structureText.text = "Structure: " + str(row[6])
assetText.text = "Asset ID: " + str(row[0])
conditionText.text = "Condition: " + conditionValue
lastInspectionText.text = "Last Inspection Date: " + str(row[2])
# Update map frame extent to the current asset feature
# Assign extent values to parameter
desc = arcpy. Describe(fc)
sr = desc.spatialReference
# Assign extent object new values
extent.XMin = left
extent.XMax = right
extent.YMax = top
extent.YMin = bottom
mf.camera.setExtent(extent)
# Append pages to the PDF
lyt.exportToPDF(os.path.join(pdfOutput,"Asset" + str(row[0]) + ".pdf"))
pdfDoc.appendPages(os.path.join(pdfOutput,"Asset" + str(row[0]) + ".pdf"))
# Set document properties – Change pdf_author to your name or the name of your organization
pdfDoc.updateDocProperties(pdf_title = "Asset Inspection",
pdf_author = "Esri Canada",
pdf_subject = "Asset Inspection",
pdf_keywords = "inspection; asset; condition; last inspection",
pdf_open_view = "USE_THUMBS",
pdf_layout = "SINGLE_PAGE")
pdfDoc.saveAndClose()