<?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 Re: problem with python code exporting to png with time enabled layer in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/problem-with-python-code-exporting-to-png-with/m-p/246308#M19080</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I was able to figure it out.&amp;nbsp; I'm almost positive it was a leap year problem so&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I hard coded a time interval for 5 years using 1826.25 days (365.25 * 5).&amp;nbsp; Now the &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;dynamic text updates correctly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, datetime
mxd = arcpy.mapping.MapDocument(r"C:\GIS_data\mxds\ytf.mxd")
df = arcpy.mapping.ListDataFrames(mxd)[0]
df.time.currentTime = datetime.datetime(1961,01,01)
endTime = datetime.datetime(2010,01,01)
interval&amp;nbsp; = datetime.timedelta(days=1826.25)
#added "+ df.time.timeStepInterval" to the end of the while statement because
#the final year group 2010 was getting cut off
while df.time.currentTime &amp;lt;= df.time.endTime + interval:
&amp;nbsp;&amp;nbsp;&amp;nbsp; #An example str(newTime) would be: "2008-12-29 02:19:59"
&amp;nbsp;&amp;nbsp;&amp;nbsp; #The following line splits the string at the space and takes the first 
&amp;nbsp;&amp;nbsp;&amp;nbsp; #item in the resulting string.&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; fileName = "ytf_fall_" + str(df.time.currentTime).split("-")[0] + ".png"
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.ExportToPNG(mxd, r"C:\GIS_data\media\ytf\\" + fileName)
&amp;nbsp;&amp;nbsp;&amp;nbsp; df.time.currentTime = df.time.currentTime + interval
&amp;nbsp;&amp;nbsp;&amp;nbsp; print fileName
del mxd&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 12:16:04 GMT</pubDate>
    <dc:creator>ChadKeith</dc:creator>
    <dc:date>2021-12-11T12:16:04Z</dc:date>
    <item>
      <title>problem with python code exporting to png with time enabled layer</title>
      <link>https://community.esri.com/t5/python-questions/problem-with-python-code-exporting-to-png-with/m-p/246307#M19079</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi-&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm using the ESRI sample code (modified below) to export a mxd to a series of .PNG files.&amp;nbsp; I'm having problems with the dynamic text associated with the layers.&amp;nbsp; In arcmap I can use the time slider and the text appears correctly - changing by 5 years for each .PNG.&amp;nbsp; But when I export it using the python code it changes the dynamic time text as&amp;nbsp; the time series advances - I think it may have something to do with leap years but I'm not sure.&amp;nbsp; In the .PNG files I'm displaying dynamic text ("time.date" format = "MMM yyyy") and what happens as the time series advances is that at first it shows correctly as Jan 1961 to Jan 1966, Jan 1966 to Jan 1971, Jan 1971 to Jan 1976 but then to Dec 1975 to Dec 1980 - should be Jan 1976 to Jan 1981.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've tried hard coding the py.script using datetime.timedelta(days=1825) but I get similar problems.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I just don't understand why it works in ArcMap but not when exporting.&amp;nbsp; Any help or thoughts would be greatly appreciated.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;here is the code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy, datetime&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument(r"C:\GIS_data\mxds\ytf.mxd")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df = arcpy.mapping.ListDataFrames(mxd)[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df.time.currentTime = datetime.datetime(1961,01,01)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;while df.time.currentTime &amp;lt;= df.time.endTime + df.time.timeStepInterval:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #An example str(newTime) would be: "2008-12-29 02:19:59"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #The following line splits the string at the first - and takes the first &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #item in the resulting string.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fileName = "YF2_" + str(df.time.currentTime).split("-")[0] + ".png"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.ExportToPNG(mxd, r"C:\GIS_data\media\ytf\\" + fileName)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; df.time.currentTime = df.time.currentTime + df.time.timeStepInterval&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print fileName&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;del mxd&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Mar 2011 13:07:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-with-python-code-exporting-to-png-with/m-p/246307#M19079</guid>
      <dc:creator>ChadKeith</dc:creator>
      <dc:date>2011-03-08T13:07:05Z</dc:date>
    </item>
    <item>
      <title>Re: problem with python code exporting to png with time enabled layer</title>
      <link>https://community.esri.com/t5/python-questions/problem-with-python-code-exporting-to-png-with/m-p/246308#M19080</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I was able to figure it out.&amp;nbsp; I'm almost positive it was a leap year problem so&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I hard coded a time interval for 5 years using 1826.25 days (365.25 * 5).&amp;nbsp; Now the &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;dynamic text updates correctly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, datetime
mxd = arcpy.mapping.MapDocument(r"C:\GIS_data\mxds\ytf.mxd")
df = arcpy.mapping.ListDataFrames(mxd)[0]
df.time.currentTime = datetime.datetime(1961,01,01)
endTime = datetime.datetime(2010,01,01)
interval&amp;nbsp; = datetime.timedelta(days=1826.25)
#added "+ df.time.timeStepInterval" to the end of the while statement because
#the final year group 2010 was getting cut off
while df.time.currentTime &amp;lt;= df.time.endTime + interval:
&amp;nbsp;&amp;nbsp;&amp;nbsp; #An example str(newTime) would be: "2008-12-29 02:19:59"
&amp;nbsp;&amp;nbsp;&amp;nbsp; #The following line splits the string at the space and takes the first 
&amp;nbsp;&amp;nbsp;&amp;nbsp; #item in the resulting string.&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; fileName = "ytf_fall_" + str(df.time.currentTime).split("-")[0] + ".png"
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.ExportToPNG(mxd, r"C:\GIS_data\media\ytf\\" + fileName)
&amp;nbsp;&amp;nbsp;&amp;nbsp; df.time.currentTime = df.time.currentTime + interval
&amp;nbsp;&amp;nbsp;&amp;nbsp; print fileName
del mxd&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:16:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-with-python-code-exporting-to-png-with/m-p/246308#M19080</guid>
      <dc:creator>ChadKeith</dc:creator>
      <dc:date>2021-12-11T12:16:04Z</dc:date>
    </item>
  </channel>
</rss>

