Select to view content in your preferred language

TypeError: can't compare datetime.datetime to NoneType

1970
0
04-03-2012 07:59 AM
LeilaHashemi
Emerging Contributor
Hello

I am going to add a new layer to my map and then set the appropriate time settings to it, my scripts is similar to the script in ArcGIS (http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00s300000023000000):

import arcpy, datetime
mxd = arcpy.mapping.MapDocument(r"D:\Project.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "New Data Frame")[0]
timeLayer = arcpy.mapping.Layer(r"D:\Proviences.lyr")
arcpy.mapping.AddLayer(df, timeLayer, "AUTO_ARRANGE")
df.time.resetTimeExtent()
df.time.timeWindowUnits = "DAYS"
df.time.timeWindow = 0
df.time.currentTime = datetime.datetime(2010, 07, 1)
df.time.endTime = datetime.datetime(2010, 08, 31)
interval = datetime.timedelta(days=2)
while df.time.currentTime <= df.time.endTime:
    fileName = str(df.time.currentTime).split(" ")[0] + ".png"
    arcpy.mapping.ExportToPNG(mxd, r"C:\Project\Output\\" + fileName)
    df.time.currentTime = df.time.currentTime + interval
del mxd, timeLayer

but I get the below message:
TypeError: can't compare datetime.datetime to NoneType
But both currentTime and endTime (while df.time.currentTime <= df.time.endTime) are datetime.
How can I fix it?

Thank you
Tags (2)
0 Kudos
0 Replies