I am trying to control the time slider object through my code in the python console. As given in couple of examples, the time property of a data frame could be controlled by Data frame time property. Assuming I have a time aware layer on my current document. I just want to control the time slider by specifying the startTime and End time. I had used the below code to change the data frame time.

mxd= arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd,"*")[0]
df.time.startTime= datetime.datetime.strptime('14-JUL-2010 07:45:00','%d-%b-%Y %H:%M:%S')
df.time.endTime=datetime.datetime.strptime('14-JUL-2010 08:45:00','%d-%b-%Y %H:%M:%S')

But the time slider is still showing the intial time Extent of the layer. Is there a way to atleast restrict the layer below with the time property so that i could display only from one time to other time? Typically I have to get user input and run the time slider from that point the user specifies. Please let me know if it is possible in arcpy

  • Enhancing ArcPy to support control of Time Slider would make a good ArcGIS Idea - if you submit one be sure to add a link to your original Question
    – PolyGeo
    Commented Aug 21, 2012 at 22:47

1 Answer 1


From my experience, you're going to have to do this in ArcObjects. Time-Aware functionality is not fully exposed to ArcPy in 10.0. A solution if you want to continue Python development is to create a time extent-setting executable with ArcObjects and call it from your Python code with time parameters passed into it. See this code example from esri:

      ITime pStartTime = new TimeClass();
      pStartTime.Year = 2000; pStartTime.Month = 9; pStartTime.Day = 25;
      ITime pEndTime = new TimeClass();
      pEndTime.Year = 2000; pEndTime.Month = 9; pEndTime.Day = 30;

      ITimeExtent pTimeExt = new TimeExtentClass();
      pTimeExt.StartTime = pStartTime;
      pTimeExt.EndTime = pEndTime;
      pTimeDisplay.TimeValue = pTimeExt as ITimeValue;

Source for this snippet: http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/Sample_Set_the_time_extents_for_a_layer_then_render_the_layer/0001000002nz000000/

You can call an executable in Python using subprocess.call(myexe.exe) http://docs.python.org/library/subprocess.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.