<?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 EsriTimeDelta = a string as GetParameterAsText Please Help, I need this answered ASAP in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/esritimedelta-a-string-as-getparameterastext/m-p/349529#M27412</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm trying to set units to a string and then as a parameter. The EsriTimeDelta syntax is EsriTimeDelta (interval, units)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I run the code below in a script tool I keep getting an error message for the units, it will fail to run the script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If there is an easier way please help! I need this question answered by Monday.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt; df.time.currentTime = datetime.datetime(2009, 01, 1, 00, 00)&amp;nbsp; endTime = datetime.datetime(2009, 01, 1, 23, 59) tsi = arcpy.GetParameterAsText(1) units = "'" + arcpy.GetParameterAsText(2) interval = arcpy.time.EsriTimeDelta(tsi, units)&amp;nbsp; &lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In this code I get an error saying that the interval must be a float. But the interval (double) units (string) according to the help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I also didn't set the units to a string in this instance and the script would actually run. But now I'm getting the error I just mentioned.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt; df.time.currentTime = datetime.datetime(2009, 01, 1, 00, 00)&amp;nbsp; endTime = datetime.datetime(2009, 01, 1, 23, 59) tsi = arcpy.GetParameterAsText(1) units = arcpy.GetParameterAsText(2) interval = arcpy.time.EsriTimeDelta(tsi, units)&amp;nbsp; count = 0&amp;nbsp; while df.time.currentTime &amp;lt;= endTime: &amp;nbsp;&amp;nbsp;&amp;nbsp; fileName = str(df.time.currentTime).split(" ")[0] + str(count) + ".jpg" &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.ExportToJPEG(mxd, os.path.join(inFolder, fileName), data_frame) &amp;nbsp;&amp;nbsp;&amp;nbsp; df.time.currentTime = df.time.currentTime + interval &amp;nbsp;&amp;nbsp;&amp;nbsp; count += 1 &lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 15 Apr 2013 05:07:15 GMT</pubDate>
    <dc:creator>courtneygarlock</dc:creator>
    <dc:date>2013-04-15T05:07:15Z</dc:date>
    <item>
      <title>EsriTimeDelta = a string as GetParameterAsText Please Help, I need this answered ASAP</title>
      <link>https://community.esri.com/t5/python-questions/esritimedelta-a-string-as-getparameterastext/m-p/349529#M27412</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm trying to set units to a string and then as a parameter. The EsriTimeDelta syntax is EsriTimeDelta (interval, units)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I run the code below in a script tool I keep getting an error message for the units, it will fail to run the script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If there is an easier way please help! I need this question answered by Monday.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt; df.time.currentTime = datetime.datetime(2009, 01, 1, 00, 00)&amp;nbsp; endTime = datetime.datetime(2009, 01, 1, 23, 59) tsi = arcpy.GetParameterAsText(1) units = "'" + arcpy.GetParameterAsText(2) interval = arcpy.time.EsriTimeDelta(tsi, units)&amp;nbsp; &lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In this code I get an error saying that the interval must be a float. But the interval (double) units (string) according to the help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I also didn't set the units to a string in this instance and the script would actually run. But now I'm getting the error I just mentioned.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt; df.time.currentTime = datetime.datetime(2009, 01, 1, 00, 00)&amp;nbsp; endTime = datetime.datetime(2009, 01, 1, 23, 59) tsi = arcpy.GetParameterAsText(1) units = arcpy.GetParameterAsText(2) interval = arcpy.time.EsriTimeDelta(tsi, units)&amp;nbsp; count = 0&amp;nbsp; while df.time.currentTime &amp;lt;= endTime: &amp;nbsp;&amp;nbsp;&amp;nbsp; fileName = str(df.time.currentTime).split(" ")[0] + str(count) + ".jpg" &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.ExportToJPEG(mxd, os.path.join(inFolder, fileName), data_frame) &amp;nbsp;&amp;nbsp;&amp;nbsp; df.time.currentTime = df.time.currentTime + interval &amp;nbsp;&amp;nbsp;&amp;nbsp; count += 1 &lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Apr 2013 05:07:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/esritimedelta-a-string-as-getparameterastext/m-p/349529#M27412</guid>
      <dc:creator>courtneygarlock</dc:creator>
      <dc:date>2013-04-15T05:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: EsriTimeDelta = a string as GetParameterAsText Please Help, I need this answered</title>
      <link>https://community.esri.com/t5/python-questions/esritimedelta-a-string-as-getparameterastext/m-p/349530#M27413</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've already answered to your question in previous thread:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A class="jive-link-external-small" href="http://forums.arcgis.com/threads/81296-can-t-export-correct-images-using-script-tool-works-fine-in-regular-script?p=287088#post287088" rel="nofollow" target="_blank"&gt;http://forums.arcgis.com/threads/81296-can-t-export-correct-images-using-script-tool-works-fine-in-regular-script?p=287088#post287088&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;getParameterAsText() does exactly what it sounds, it's getting attribute as text (string if you prefer). So if you need any other type of parameter you need to convert it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;tsi = arcpy.GetParameterAsText(1) units = arcpy.GetParameterAsText(2) interval = arcpy.time.EsriTimeDelta(tsi, units)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;In this code you pass two string variables to arcpy.time.EsriTimeDelta()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;changing line to :&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;tsi = float(arcpy.GetParameterAsText(1))&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;Should resolve issue with interval type.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Best Regards &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Arek&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Apr 2013 11:32:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/esritimedelta-a-string-as-getparameterastext/m-p/349530#M27413</guid>
      <dc:creator>ArkadiuszMatoszka</dc:creator>
      <dc:date>2013-04-15T11:32:43Z</dc:date>
    </item>
    <item>
      <title>Re: EsriTimeDelta = a string as GetParameterAsText Please Help, I need this answered</title>
      <link>https://community.esri.com/t5/python-questions/esritimedelta-a-string-as-getparameterastext/m-p/349531#M27414</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;thank you so much, this works fine!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Apr 2013 13:02:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/esritimedelta-a-string-as-getparameterastext/m-p/349531#M27414</guid>
      <dc:creator>courtneygarlock</dc:creator>
      <dc:date>2013-04-15T13:02:33Z</dc:date>
    </item>
  </channel>
</rss>

