<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Python Automation that Generates MXD Template Failing after Adding New Layer? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-automation-that-generates-mxd-template/m-p/1092396#M62178</link>
    <description>&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;We are concerned it may be with the top section of the script which can be seen below:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;import os,os.path, math, sys&lt;BR /&gt;import datetime&lt;BR /&gt;import getpass&lt;BR /&gt;import re&lt;BR /&gt;import arcpy&lt;BR /&gt;from arcpy import env&lt;BR /&gt;from arcpy import mapping&lt;/P&gt;&lt;P&gt;arcpy.env.overwriteOutput = True&lt;BR /&gt;arcpy.env.addOutputsToMap = True&lt;/P&gt;&lt;P&gt;#arcpy.GetParameterAsText(1)&lt;BR /&gt;maplayers = [] # ["SGMC_Geology"]&lt;BR /&gt;#arcpy.GetParameterAsText(2)&lt;/P&gt;&lt;P&gt;&lt;EM&gt;But, this other section also looks like it could be causing some trouble:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;def loopThruMapDocs(map_templates_folder, projectnumber,maplayers):&lt;BR /&gt;for root, dirs, files in os.walk(map_templates_folder):&lt;BR /&gt;for mxd in files:&lt;BR /&gt;if mxd.endswith(".mxd"):&lt;BR /&gt;mapdoc = mxd&lt;BR /&gt;filterByProject(projectnumber, mapdoc, map_templates_folder, maplayers)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;def loopThruMapLayers(mapdocument, dataframe, projectnumber):&lt;BR /&gt;try:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;maplayers = arcpy.mapping.ListLayers(mapdocument,"SGMC_Geology*", dataframe)&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Does anyone have any thoughts on this? Any input would be truly helpful.&lt;/EM&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 30 Aug 2021 16:33:41 GMT</pubDate>
    <dc:creator>DS_GIS</dc:creator>
    <dc:date>2021-08-30T16:33:41Z</dc:date>
    <item>
      <title>Python Automation that Generates MXD Template Failing after Adding New Layer?</title>
      <link>https://community.esri.com/t5/python-questions/python-automation-that-generates-mxd-template/m-p/1092396#M62178</link>
      <description>&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;We are concerned it may be with the top section of the script which can be seen below:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;import os,os.path, math, sys&lt;BR /&gt;import datetime&lt;BR /&gt;import getpass&lt;BR /&gt;import re&lt;BR /&gt;import arcpy&lt;BR /&gt;from arcpy import env&lt;BR /&gt;from arcpy import mapping&lt;/P&gt;&lt;P&gt;arcpy.env.overwriteOutput = True&lt;BR /&gt;arcpy.env.addOutputsToMap = True&lt;/P&gt;&lt;P&gt;#arcpy.GetParameterAsText(1)&lt;BR /&gt;maplayers = [] # ["SGMC_Geology"]&lt;BR /&gt;#arcpy.GetParameterAsText(2)&lt;/P&gt;&lt;P&gt;&lt;EM&gt;But, this other section also looks like it could be causing some trouble:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;def loopThruMapDocs(map_templates_folder, projectnumber,maplayers):&lt;BR /&gt;for root, dirs, files in os.walk(map_templates_folder):&lt;BR /&gt;for mxd in files:&lt;BR /&gt;if mxd.endswith(".mxd"):&lt;BR /&gt;mapdoc = mxd&lt;BR /&gt;filterByProject(projectnumber, mapdoc, map_templates_folder, maplayers)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;def loopThruMapLayers(mapdocument, dataframe, projectnumber):&lt;BR /&gt;try:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;maplayers = arcpy.mapping.ListLayers(mapdocument,"SGMC_Geology*", dataframe)&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Does anyone have any thoughts on this? Any input would be truly helpful.&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 16:33:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-automation-that-generates-mxd-template/m-p/1092396#M62178</guid>
      <dc:creator>DS_GIS</dc:creator>
      <dc:date>2021-08-30T16:33:41Z</dc:date>
    </item>
  </channel>
</rss>

