Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

share|improve this question
    
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 Aug 21 '12 at 22:47
add comment

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;
      pActiveView.Refresh();

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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