script tool for df.time.currentTime ???

1978
3
03-30-2013 02:49 PM
courtneygarlock
New Contributor II
I'm getting this error when I run my script tool.


Traceback (most recent call last):
  File "C:\Users\Courtney\Desktop\ScriptTool.py", line 233, in <module>
    df.time.currentTime = arcpy.GetParameterAsText(6)          #datetime.datetime(2009, 01, 1, 00, 00)
  File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\arcobjects\_base.py", line 92, in _set
    (attr_name, self.__class__.__name__))
NameError: The attribute 'currentTime' is not supported on this instance of DataFrameTime.

Failed to execute (ScriptTool).

my code is :

df.time.currentTime = arcpy.GetParameterAsText(6)               #datetime.datetime(2009, 01, 1, 00, 00)
endTime = arcpy.GetParameterAsText(7)                              #datetime.datetime(2009, 01, 1, 23, 59)
interval = arcpy.GetParameterAsText(8)                               #arcpy.time.EsriTimeDelta(1, 'hours')
                                                                                    #or #interval = datetime.timedelta(hours=1)

I don't understand why it says "currentTime" is not supported.

Any assistance is appreciated.

Thank you
Tags (2)
0 Kudos
3 Replies
courtneygarlock
New Contributor II
Does anyone have any help for this code? Is there an issue with the "GetParameterAsText" when applying it to the df.time???
0 Kudos
JamesCrandall
MVP Frequent Contributor
Edit: see if the formating of your parameter is correct.  I found a reference that shows it being set like so:

df.time.currentTime = datetime.datetime(2008, 10, 1)

What is df?

If it is reference to the dataframe, then I don't think it supports Time.  From what I can tell, you get the time on the Layer instead.

http://resources.arcgis.com/en/help/main/10.1/index.html#/LayerTime/00s300000063000000/

Sorry if this is incorrect.
0 Kudos
courtneygarlock
New Contributor II
Layer time is only read access. in order to specify the data frame time (ie time slider options) I need to be able to have the user
select the time frame they would like. Data frame time has read and write access bc the funtions are specified via the time slider
window.

my question is not how to change the layer time bc that is not possible. I want the user to select the dataframetime (time slider)
but my GetParameterAsText format is obviously incorrect since I keep getting an error when I run the script.

which is: Traceback (most recent call last):
File "C:\Users\Courtney\Desktop\ScriptTool.py", line 233, in <module>
df.time.currentTime = arcpy.GetParameterAsText(6) #datetime.datetime(2009, 01, 1, 00, 00)
File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\arcobjects\_base.py", line 92, in _set
(attr_name, self.__class__.__name__))
NameError: The attribute 'currentTime' is not supported on this instance of DataFrameTime.

Failed to execute (ScriptTool).
0 Kudos