Open a 3dm file with the corresponding application version

Hello!

I work at a company that uses different versions of Rhino.
Rhino 5 is used for machine tools (CNC) and Rhino 5 or 7 for modeling.

I wrote a small script to save a version 5 when the document is saved in Rhino 7.

For those who are interested:
using System;
using System.Runtime.InteropServices;
using System.IO;
using Rhino;
using Rhino.PlugIns;

public class RhinoPlugIn : PlugIn
{
    public override PlugInLoadTime LoadTime => PlugInLoadTime.AtStartup;

    public RhinoPlugIn ()
    {
        RhinoDoc.EndSaveDocument += RhinoDoc_EndSaveDocument;
    }

    bool _islock;

    private void RhinoDoc_EndSaveDocument (object sender, DocumentSaveEventArgs e)
    {
        // Recurrence due to _SaveVersion5
        if (_islock) return;
        _islock = true;

        var extension = Path.GetExtension (e.FileName);
        if (extension != ".3dm") return;

        var filename = Path.ChangeExtension (e.FileName, " (V5).3dm");
        var cmd =  "-_SaveAs _Version=5 \"" + filename + "\"";
        
        // Executes the second save command after saving the file
        // Other methods do not work. Call `RhinoApp.RunScript` directly here or use `RhinoApp.InvokeOnUiThread`
        RhinoApp.Idle += _SaveVersion5;
        void _SaveVersion5 (object sender, EventArgs e) {
            RhinoApp.Idle -= _SaveVersion5;
            RhinoApp.RunScript (cmd, echo: true);
            _islock = false;
        }
    }
}

Now I would like to know if there is a possibility for Windows to open version 5 of the file with Rhino 5 and version 7 with Rhino 7?

I tried changing the version 5 file extension to “.3dm5” and then setting the default app for that file type.
Unfortunately, there are 2 big problems.

  • Rhino 5 does not want to open the file it indicates a dialog box File not managed by Rhino
  • File explorer can no longer display previews and notes, which is essential especially when searching for files from a project done last month or done by someone else.

I also imagined writing a standalone application to open all .3dm files, use rhino3dm to read File3dm.ApplicationName and then launch the corresponding application. again I would lose the previews of the file, which will not be accepted.

Does anyone have a solution or a way forward?

merci,
jmv

Yes, this would be extremely handy if it worked.
As it is I manually add a pre-suffix to the file (rh5, rh6, rh7, rh8) and use the “open with…”-dialogue in windows explorer

1 Like

Hi @kitjmv, @norbert_geelen,

See here: Open Rhino 8 files - open with problem - #5 by jeremy5

Regards
Jeremy

2 Likes

Thanks Jeremy, I’m going to have a look at this.
Seems like a nifty solution.

Wow!!! Thank you @jeremy5 !!!
This is exactly the last option that I had imagined ready-made!!
And I was wrong. This method preserves the preview of thumbnails and details in File Explorer.
I have nothing to do !! MERCI !! :slight_smile:
jmv

1 Like

I will probably rewrite the code (or more precisely copy it from ILSpy) to look for a solution to hide the console display when double-clicking a file.
If I remember correctly, just replace OutputType with WinExe in the project file .csproj
Do you have a GitHub or other repository for this project?
jmv

No, no Github repository. It was just something I knocked up for my own convenience a while back, which I’ve subsequently shared with one or two people.

1 Like