I'm working on a script to ingest some data, create some data layers with it, and publish that to ArcGIS Server.
Most of that is done with no problem, but I got a new requirement today, time-enabling some of those feature layers. That looks pretty straight-forward, but it isn't working as I'd expect, so I'm hoping someone or some ones here can help.
# dFrame is the data frame, lyrName is the name of the new layer def createLayer (self, dFrame, lyrName): lyrFileName = ... timeLyrFileName = ... arcpy.MakeFeatureLayer_management (lyrName, lyrName + self.lyrSuffix) arcpy.SaveToLayerFile_management (lyrName + self.lyrSuffix, lyrFileName) newLyr = arcpy.mapping.Layer (lyrFileName) ... # set some other layer properties that are working fine arcpy.mapping.AddLayer (dFrame, newLyr) if not os.path.isfile (timeLyrFileName): timeLyr = arcpy.mapping.Layer (timeLyrFileName) if not timeLyr is None: arcpy.mapping.UpdateLayerTime (dFrame, newLyr, timeLyr) return
(The mxd holding the data frame is saved after this method returns.) If I put some print statements after that call to UpdateLayerTime, everything looks good. newLyr.time.isTimeEnabled is True, newLyr.time.timeOffset is the same as timeLyr.time.timeOffset (though, oddly, both show as 0.0 years rather than 1.0 hours. Hoping just a small bug in EsriTimeOffset's toString method (or whatever the python equivalent of that is)), and newLyr.time.timeStartField also looks correct.
The fly in the ointment now is that, when the program finishes, if I open the mxd in Desktop, the layers created are all there, but none of them are time-enabled. (FWIW, we're running the arcpy that came with Server 10.6.)
Anyone got a clue what's going on?