<?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 How to automate changing Layer properties using python? in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/how-to-automate-changing-layer-properties-using/m-p/1315145#M71706</link>
    <description>&lt;P&gt;I am trying to automate a certain workflow and in the process need to change the layer properties &amp;gt; Time &amp;gt; Layer Time to "Each feature has a single time field". I tried to create a separate python script outside the ArcGIS Pro environment, but failed to import the arcpy module.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have since tried to create a python notebook within ArcGIS Pro to connect to the layer, but I am unsure as to how to write the script to perform the above action.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Additionally, will I be able to run this script from outside the ArcGIS Pro environment without having to open the aprx file?&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my code so far&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;# Setting the workspace (geodatabase or folder containing your data)&lt;/P&gt;&lt;P&gt;arcpy.env.workspace = r"C:\Users\manognat\Documents\ArcGIS\Projects\Workzone-Crash Association\Workzone-Crash Association.gdb"&lt;/P&gt;&lt;P&gt;# Setting the map document&lt;/P&gt;&lt;P&gt;aprx = arcpy.mp.ArcGISProject(r"C:\Users\manognat\Documents\ArcGIS\Projects\WorkZoneTest\WorkZoneTest\WorkZoneTest.aprx")&lt;/P&gt;&lt;P&gt;# Accessing a specific map in the project&lt;/P&gt;&lt;P&gt;map = aprx.listMaps("Map")[0]&lt;/P&gt;&lt;P&gt;# Accessing a specific layer in the map&lt;/P&gt;&lt;P&gt;layer = map.listLayers("LayerName")[0]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I&amp;nbsp; need the script to be able to automate the following functionality:&lt;/P&gt;&lt;P&gt;Right click on the layer –“LayerName”, then select Properties, then select Time, then set “Layer Time” to “Each feature has a single time field” and save. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 03 Aug 2023 16:37:18 GMT</pubDate>
    <dc:creator>ThumukuntaManogna</dc:creator>
    <dc:date>2023-08-03T16:37:18Z</dc:date>
    <item>
      <title>How to automate changing Layer properties using python?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-to-automate-changing-layer-properties-using/m-p/1315145#M71706</link>
      <description>&lt;P&gt;I am trying to automate a certain workflow and in the process need to change the layer properties &amp;gt; Time &amp;gt; Layer Time to "Each feature has a single time field". I tried to create a separate python script outside the ArcGIS Pro environment, but failed to import the arcpy module.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have since tried to create a python notebook within ArcGIS Pro to connect to the layer, but I am unsure as to how to write the script to perform the above action.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Additionally, will I be able to run this script from outside the ArcGIS Pro environment without having to open the aprx file?&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my code so far&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;# Setting the workspace (geodatabase or folder containing your data)&lt;/P&gt;&lt;P&gt;arcpy.env.workspace = r"C:\Users\manognat\Documents\ArcGIS\Projects\Workzone-Crash Association\Workzone-Crash Association.gdb"&lt;/P&gt;&lt;P&gt;# Setting the map document&lt;/P&gt;&lt;P&gt;aprx = arcpy.mp.ArcGISProject(r"C:\Users\manognat\Documents\ArcGIS\Projects\WorkZoneTest\WorkZoneTest\WorkZoneTest.aprx")&lt;/P&gt;&lt;P&gt;# Accessing a specific map in the project&lt;/P&gt;&lt;P&gt;map = aprx.listMaps("Map")[0]&lt;/P&gt;&lt;P&gt;# Accessing a specific layer in the map&lt;/P&gt;&lt;P&gt;layer = map.listLayers("LayerName")[0]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I&amp;nbsp; need the script to be able to automate the following functionality:&lt;/P&gt;&lt;P&gt;Right click on the layer –“LayerName”, then select Properties, then select Time, then set “Layer Time” to “Each feature has a single time field” and save. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Aug 2023 16:37:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-to-automate-changing-layer-properties-using/m-p/1315145#M71706</guid>
      <dc:creator>ThumukuntaManogna</dc:creator>
      <dc:date>2023-08-03T16:37:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to automate changing Layer properties using python?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-to-automate-changing-layer-properties-using/m-p/1315526#M71757</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;You should be able to enable time on a layer with the LayerTime Class. There are some sample scripts at the bottom that give examples:&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/layertime-class.htm" target="_blank" rel="noopener"&gt;https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/layertime-class.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;From the documentation:&amp;nbsp;&lt;SPAN&gt;The&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;enableTime&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;method on the&amp;nbsp;Layer&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;class allows you to enable time on a layer that has time&amp;nbsp;information and therefore making access to&amp;nbsp;&lt;SPAN class=""&gt;LayerTime&lt;/SPAN&gt;&amp;nbsp;properties possible.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2023 14:26:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-to-automate-changing-layer-properties-using/m-p/1315526#M71757</guid>
      <dc:creator>MattSchwartz7</dc:creator>
      <dc:date>2023-08-04T14:26:57Z</dc:date>
    </item>
  </channel>
</rss>

