I have over 1000 feature classes that I am loading into a map document. I have figured out how to automate this process in using Arcpy. Each feature class has a field with datetime. I can enable time on the layers one by one by right clicking on the layer once it is in arcmap and clicking the box "enable time on this layer". I would like to automate the process using arcpy. Can anyone help?
Ian
Solved! Go to Solution.
Hi Ian
I don't believe there is a direct way to do this with arcpy.mapping.Layer. However, if you have a saved Layer file that does have time enabled, you should be able to use arcpy.mapping.UpdateLayerTime to update the time properties of the layers you are adding from an existing .lyr file.
see:(copy/paste) http://resources.arcgis.com/en/help/main/10.1/index.html#/UpdateLayerTime/00s300000064000000/
I'd test on a single layer first.
Ian M
Hi Ian
I don't believe there is a direct way to do this with arcpy.mapping.Layer. However, if you have a saved Layer file that does have time enabled, you should be able to use arcpy.mapping.UpdateLayerTime to update the time properties of the layers you are adding from an existing .lyr file.
see:(copy/paste) http://resources.arcgis.com/en/help/main/10.1/index.html#/UpdateLayerTime/00s300000064000000/
I'd test on a single layer first.
Ian M
Ian, Thanks very much for the help. This method worked. It might be nice for ESRI to build an arcpy tool in the future but this method works for my purposes. I was able to load all the files via arcpy. Then I enabled time on the 1st layer in the TOC. Then I used arcpy to enable time in all the other layers via code below:
MXD = arcpy.mapping.MapDocument("CURRENT")
DF = arcpy.mapping.ListDataFrames(MXD)[0]
sourceLayer=arcpy.mapping.ListLayers(MXD,"",DF)[0]
updateLayer=arcpy.mapping.ListLayers(MXD,"",DF)
for layers in updateLayer:
arcpy.mapping.UpdateLayerTime (DF,layers, sourceLayer)
They are very hit and miss about what layer properties you can set with arcpy, and which ones you need ArcObjects to directly manipulate. Luckily they had somewhat of a workaround for this particular scenario.
This post is a duplicate of
https://community.esri.com/message/548340#548340
possible links are on that thread. post and/or update in one thread, then share to spaces, don't just try again the next day
There was another duplicate over in python snippets Space. I went ahead and shared with a few other Places
Thanks Ian.
Apologies, I didn't know the protocol.
Ian