Python Automation that Generates MXD Template Failing after Adding New Layer?

258
0
08-25-2021 11:47 AM
DS_GIS
by
New Contributor III

We have an internal python script that generates MXD and PDF outputs from templates we have created. The original templates were very basic and only featured the World Imagery Basemap and Points that have geometric corrections applied during the script. 

Currently, we are undergoing efforts to improve these templates with additional authoritative layers. Such as: the USGS Geology. We created a new template and added this layer. But, the script is now failing to provide an output. It also doesn't produce an error when run from Idle. 

We are concerned it may be with the top section of the script which can be seen below:

import os,os.path, math, sys
import datetime
import getpass
import re
import arcpy
from arcpy import env
from arcpy import mapping

arcpy.env.overwriteOutput = True
arcpy.env.addOutputsToMap = True

#arcpy.GetParameterAsText(1)
maplayers = [] # ["SGMC_Geology"]
#arcpy.GetParameterAsText(2)

But, this other section also looks like it could be causing some trouble:

def loopThruMapDocs(map_templates_folder, projectnumber,maplayers):
for root, dirs, files in os.walk(map_templates_folder):
for mxd in files:
if mxd.endswith(".mxd"):
mapdoc = mxd
filterByProject(projectnumber, mapdoc, map_templates_folder, maplayers)


def loopThruMapLayers(mapdocument, dataframe, projectnumber):
try:


maplayers = arcpy.mapping.ListLayers(mapdocument,"SGMC_Geology*", dataframe)

Does anyone have any thoughts on this? Any input would be truly helpful.

Tags (2)
0 Kudos
0 Replies