<?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 enableTime() in ArcPy does not work without manually toggling in ArcGIS Pro first in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/enabletime-in-arcpy-does-not-work-without-manually/m-p/1362374#M76523</link>
    <description>&lt;P&gt;enableTime() in ArcPy throws a RuntimeError. But if you manually go to the properties and enable the time filter in ArcGIS Pro, then disable it,&amp;nbsp;enableTime() works.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Open a new ArcGIS Pro project with a new map&lt;/LI&gt;&lt;LI&gt;Add the layer with time data to the map&lt;/LI&gt;&lt;LI&gt;Open a Python window and run the following:&lt;/LI&gt;&lt;/OL&gt;&lt;LI-CODE lang="python"&gt;aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.listMaps()[0]
m.listLayers()[0].enableTime()&lt;/LI-CODE&gt;&lt;P&gt;It gives the following error:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Traceback (most recent call last):
File "&amp;lt;string&amp;gt;", line 1, in &amp;lt;module&amp;gt;
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py", line 992, in enableTime
return convertArcObjectToPythonObject(self._arc_object.enableTime(*gp_fixargs((startTimeField, endTimeField, autoCalculateTimeRange, timeDimension), True)))
RuntimeError&lt;/LI-CODE&gt;&lt;P&gt;In the Contents pane, right click the layer that was added -&amp;gt; Properties -&amp;gt; Time -&amp;gt; Filter layer contents based on attribute values -&amp;gt; OK.&lt;/P&gt;&lt;P&gt;The map refreshes and a time slider is visible. Go to properties and disable the time filter again.&lt;/P&gt;&lt;P&gt;Back in the Python window, run&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;m.listLayers()[0].enableTime()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;It successfully enables the time filter with no errors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Relevant documentation:&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/layertime-class.htm" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/layertime-class.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think this can't be a problem with the data I am using, because clearly it can filter by time when I enable it manually. Is there a step that I missed in ArcPy? Thanks&lt;/P&gt;</description>
    <pubDate>Tue, 19 Dec 2023 02:22:12 GMT</pubDate>
    <dc:creator>Yik-ChingTsui</dc:creator>
    <dc:date>2023-12-19T02:22:12Z</dc:date>
    <item>
      <title>enableTime() in ArcPy does not work without manually toggling in ArcGIS Pro first</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/enabletime-in-arcpy-does-not-work-without-manually/m-p/1362374#M76523</link>
      <description>&lt;P&gt;enableTime() in ArcPy throws a RuntimeError. But if you manually go to the properties and enable the time filter in ArcGIS Pro, then disable it,&amp;nbsp;enableTime() works.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Open a new ArcGIS Pro project with a new map&lt;/LI&gt;&lt;LI&gt;Add the layer with time data to the map&lt;/LI&gt;&lt;LI&gt;Open a Python window and run the following:&lt;/LI&gt;&lt;/OL&gt;&lt;LI-CODE lang="python"&gt;aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.listMaps()[0]
m.listLayers()[0].enableTime()&lt;/LI-CODE&gt;&lt;P&gt;It gives the following error:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Traceback (most recent call last):
File "&amp;lt;string&amp;gt;", line 1, in &amp;lt;module&amp;gt;
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py", line 992, in enableTime
return convertArcObjectToPythonObject(self._arc_object.enableTime(*gp_fixargs((startTimeField, endTimeField, autoCalculateTimeRange, timeDimension), True)))
RuntimeError&lt;/LI-CODE&gt;&lt;P&gt;In the Contents pane, right click the layer that was added -&amp;gt; Properties -&amp;gt; Time -&amp;gt; Filter layer contents based on attribute values -&amp;gt; OK.&lt;/P&gt;&lt;P&gt;The map refreshes and a time slider is visible. Go to properties and disable the time filter again.&lt;/P&gt;&lt;P&gt;Back in the Python window, run&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;m.listLayers()[0].enableTime()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;It successfully enables the time filter with no errors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Relevant documentation:&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/layertime-class.htm" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/layertime-class.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think this can't be a problem with the data I am using, because clearly it can filter by time when I enable it manually. Is there a step that I missed in ArcPy? Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 19 Dec 2023 02:22:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/enabletime-in-arcpy-does-not-work-without-manually/m-p/1362374#M76523</guid>
      <dc:creator>Yik-ChingTsui</dc:creator>
      <dc:date>2023-12-19T02:22:12Z</dc:date>
    </item>
    <item>
      <title>Re: enableTime() in ArcPy does not work without manually toggling in ArcGIS Pro first</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/enabletime-in-arcpy-does-not-work-without-manually/m-p/1362377#M76524</link>
      <description>&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/layertime-class.htm" target="_blank"&gt;LayerTime—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;example 1&lt;/P&gt;&lt;P&gt;I would think that&lt;/P&gt;&lt;P&gt;if lyr.supports('TIME'):&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if lyr.isTimeEnabled:&lt;/P&gt;&lt;P&gt;would be good checks since you have to set time properties somewhere first&lt;/P&gt;</description>
      <pubDate>Tue, 19 Dec 2023 03:02:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/enabletime-in-arcpy-does-not-work-without-manually/m-p/1362377#M76524</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2023-12-19T03:02:23Z</dc:date>
    </item>
    <item>
      <title>Re: enableTime() in ArcPy does not work without manually toggling in ArcGIS Pro first</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/enabletime-in-arcpy-does-not-work-without-manually/m-p/1362380#M76525</link>
      <description>&lt;P&gt;Running this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.listMaps()[0]
m.listLayers()[0].supports('TIME')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;returns True, but&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;m.listLayers()[0].isTimeEnabled&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;returns False.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I manually toggle it,&amp;nbsp;isTimeEnabled is still False, but enableTime() works anyway. I think&amp;nbsp;isTimeEnabled simply reflects the current state, as it becomes True after enableTime(). Assuming we need to make&amp;nbsp;isTimeEnabled True before using enableTime, how would I do that? Where would I "set time properties somewhere" with code?&lt;/P&gt;</description>
      <pubDate>Tue, 19 Dec 2023 03:39:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/enabletime-in-arcpy-does-not-work-without-manually/m-p/1362380#M76525</guid>
      <dc:creator>Yik-ChingTsui</dc:creator>
      <dc:date>2023-12-19T03:39:19Z</dc:date>
    </item>
    <item>
      <title>Re: enableTime() in ArcPy does not work without manually toggling in ArcGIS Pro first</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/enabletime-in-arcpy-does-not-work-without-manually/m-p/1362386#M76526</link>
      <description>&lt;P&gt;The layerTime Properties, for the most part, are read/write so presumably if you know what fields etc you intend to use, you could provide and set that information.&amp;nbsp; I can't find any examples around in Community so you might have to experiment.&amp;nbsp; Good luck&lt;/P&gt;</description>
      <pubDate>Tue, 19 Dec 2023 04:54:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/enabletime-in-arcpy-does-not-work-without-manually/m-p/1362386#M76526</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2023-12-19T04:54:34Z</dc:date>
    </item>
    <item>
      <title>Re: enableTime() in ArcPy does not work without manually toggling in ArcGIS Pro first</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/enabletime-in-arcpy-does-not-work-without-manually/m-p/1388581#M79513</link>
      <description>&lt;P&gt;I stumbled on a solution when working on a different thing. I had to pass in the name of the datetime field to enableTime, for example:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;layer.enableTime('datetime')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Feb 2024 09:13:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/enabletime-in-arcpy-does-not-work-without-manually/m-p/1388581#M79513</guid>
      <dc:creator>Yik-ChingTsui</dc:creator>
      <dc:date>2024-02-29T09:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: enableTime() in ArcPy does not work without manually toggling in ArcGIS Pro first</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/enabletime-in-arcpy-does-not-work-without-manually/m-p/1495240#M84781</link>
      <description>&lt;P&gt;Thanks so much for this, saved me. What I will add is that this didn't work for me at first, but it was because my date field was not actually named what I thought it was. In the attribute table it was called "Date", but when I used python code to display the names of the field , I saw it was actually named "MSA_Date". Just thought I would add to check your field is exactly correct or this fix won't work.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2024 09:02:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/enabletime-in-arcpy-does-not-work-without-manually/m-p/1495240#M84781</guid>
      <dc:creator>NietoLaJ</dc:creator>
      <dc:date>2024-06-20T09:02:08Z</dc:date>
    </item>
    <item>
      <title>Re: enableTime() in ArcPy does not work without manually toggling in ArcGIS Pro first</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/enabletime-in-arcpy-does-not-work-without-manually/m-p/1574028#M91769</link>
      <description>&lt;P&gt;I ran into this error today. While the solution posted above fixed the error, the documentation for layer.enableTime() lists all fields as optional. It seems to me that if the method doesn't work without passing the time field parameter, it should not be listed as optional in the documentation.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/layer-class.htm" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/layer-class.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2025 17:25:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/enabletime-in-arcpy-does-not-work-without-manually/m-p/1574028#M91769</guid>
      <dc:creator>JeffKaplan_Boston</dc:creator>
      <dc:date>2025-01-09T17:25:05Z</dc:date>
    </item>
  </channel>
</rss>

