RhinoIO.Net invalid DateTime on sample 3DM files


#1

Hello,

If you try reading the following files from the Example3DM package:
v2_my_mesh.3dm
v2_my_surfaces.3dm
v2_my_trimmed_surface.3dm

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?

Thanks

Alex


(Dale Fugier) #2

Hi Alex,

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.

– Dale


#3

Hello Dale,

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
{
  get
  {
    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);
    return DateTime.MinValue;
  }
}

I’m not expecting a fix, I just thought it was worth mentionning.

Alex


(Steve Baer) #4

Hi Alex,
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


#5

Thanks Steve! I’ll wait for the nuget package update.

Alex