RhinoCommon conversion of OnBinaryFile.Read3dmStartSection

Hi,
We are very busy lately trying to get our apps converted over to work in Rhino 6.0
One of the areas that is causing us most trouble is some file handling/opening code we have.

In our app, we make use of some of the Read3dm… .Net SDK function as part of our own file format.
so the code starts something like this:

  using (OnFileHandle file = OnUtil.OpenFile(filePath, "rb"))
                {
                    if (file != null)
                    {
                        OnBinaryFile bFile = new OnBinaryFile(IOn.archive_mode.read, file);

                        int version3dm = 0;
                        string appName = string.Empty;
                        
                        if (!bFile.Read3dmStartSection(ref version3dm, ref appName))
                        {
                            OnUtil.CloseFile(file);
                            return false;
                        };

                        if (!bFile.Read3dmProperties(ref fileProperties))
                        {
                            OnUtil.CloseFile(file);
                            return false;
                        }

                        On3dmSettings settings = new On3dmSettings();
                        settings.Default();

                        if (!bFile.Read3dmSettings(ref settings))
                        {
                            OnUtil.CloseFile(file);
                            return false;
                        }
...
...
...

So we are trying to get this working now in Rhino 6.0

As of right now the code fails right on the line:
if (!bFile.Read3dmStartSection(ref version3dm, ref appName))

which now returns false.

So I guess I am asking for direction as to either how to get this working in Rhino 6, or is there equivalent code in Rhinocommon I should now be using instead.

Thanks

Hi Gordon,

Can email me your old file reading code along with a test file to read?

Thanks,

– Dale

CSGLoader.zip (272.6 KB)

Here is a little test file loading App.
It is loading enough of one of our .CSG files to demonstrate the problem, we are having.

This command completes correctly with Rhino 5, but fails very early in Rhino 6.

There is a hard coded path to t1.csg which you will have to fix to get this working, I have included the t1.csg file in the solution so that you have it to test with.

Thanks for looking into this for me.

Gordon J.

@gordon

Instead of this:

OnBinaryFile bFile = new OnBinaryFile(IOn.archive_mode.read, file);

Do this:

OnBinaryFile bFile = new OnBinaryFile(IOn.archive_mode.read3dm, file);

Does this help?

– Dale

Hi Dale,

Yep, that totally fixed it,

Thank you again for all your great help.