If you try reading the following files from the Example3DM package:
There might be more of them…
The File3Dm.Created date is invalid : Year, Month, and Day parameters describe an un-representable DateTime.
Maybe this could be avoided in the Created getter?
I just verified that these files don’t have Created or Edited dates - year, month, day, etc. are all Zero. So, yes, this will throw an exception when you try to access. Knowing this, I would put a try-catch block around your code. If you catch an exception, just use the file system date.
The files you mention are fairly old, but I am a bit surprised they don’t have dates.
Yes this is exactly what I did. I just thought it might be a good idea to make the check in the Created getter. It already does a little validation:
public DateTime Created
IntPtr pConstRevisionHistory = UnsafeNativeMethods.ONX_Model_RevisionHistory(this.ConstPointer());
int seconds = 0;
int minutes = 0;
int hours = 0;
int months = 0;
int days = 0;
int years = 0;
if (UnsafeNativeMethods.ON_3dmRevisionHistory_GetDate(pConstRevisionHistory, true, ref seconds, ref minutes, ref hours, ref days, ref months, ref years))
return new DateTime(years, months, days, hours, minutes, seconds);
I’m not expecting a fix, I just thought it was worth mentionning.
I just fixed this on github so DateTime.MinValue is returned when no date information exists in these older files. Please note that we are now using a separate branch for Rhino3dmIo on github if you are building from source.
If you are using the nuget packages, this change will show up in our next nuget release.
Thanks Steve! I’ll wait for the nuget package update.