Has anyone out there used the IMapTimeDisplay.TimeValue to get the current time from the timeslider control? I cannot figure out how to properly use it.
I am writing some code in VB .net that creates a bar graph (in a dockable window in ArcMap) from some of the attribute values in a polygon feature class. My feature class is time-enabled with an attribute called "Year" and the time slider is visible in ArcMap, but the data I send to the bar graph is not filtered by the current year selected on the slider. So, I need the current time to filter my data with.
I have the following which may not be correct, although it does not throw an error:
Dim pMxDoc As IMxDocument = TryCast(My.ArcMap.Application.Document, IMxDocument) Dim pMap As IMap = pMxDoc.FocusMap Dim pMapTimeDisplay As IMapTimeDisplay = pMap Dim pTimeValue As ITimeValue = pMapTimeDisplay.TimeValue Dim pTimeExtent As ITimeExtent = TryCast(pTimeValue, ITimeExtent) 'added
But, I can't figure out what to do from there. Can anyone help me please? I have searched the internet to the best of my ability.
Additional information I tried this, but it caused an error in ArcMap:
Dim currentYear As Integer = pTimeExtent.StartTime.Year
The error is "Unhandled exception has occurred..." and "System.NullReferenceException: Object reference not set to an instance of an object." Yet, I have used pTimeExtent.StartTime.Year successfully in other parts of my code to get the start time of the entire time range using pTimeExtent = pMapTimeDisplay.CurrentTimeExtent.