Rhino Inside help

I am testing the Rhino Inside and works fine so far
One issue that I am getting if user exits Rhino on the second call I get a crash in OpenNurbs,dll , to underline that my app is using a custom built opennurbs.dll (opennurbs_public.dll) and maybe this could be the issue.

Well I was thinking to disable the exit option for the user, already done it on the main window and now would like to disable to exit command in the menu any hint ?

thanks
Gerry

I have solved Installing a new windowProc on the main window and changing a WM_CLOSE with a WM_HIDE

gerry

hi gerryark,

There are a lot of addins/plugins that use OpenNurbs, there is a tool that ships with Revit 2025.3 to troubleshoot addins, or the old version here.

Hi Japhy

I am using Rhino Inside to insert Rhino into our app
not Rhino Inside Revit

Gerry

1 Like

Hi @gerryark,

Is there some code that I can look at?
What do you mean by the second call?

I mean the rhino app gets closed. So at the second call to open rhino app (rhino inside) I get this crash reported in opennurbs.dll.
A strange behavior I have noticed is that on this second call rhino ask for the license

Tomorrow will past some code but it’s only c# where I recall the rhino inside startup the app is quite large with more than 60 dll’s

Gerry

Dear Kike
Rhino Startup from my code

public int InvokeRhino()
{
try
{
SplashScreen splash = new SplashScreen();
splash.Show();
splash.Refresh();

            Rhino.Runtime.InProcess.WindowStyle ws = Rhino.Runtime.InProcess.WindowStyle.Normal;
            

            string SchemeName = $"Inside-{"ixCube"}-{"6.0.0"}";
            string[] args = new string[] { "/nosplash" };
            m_rhino_core = new Rhino.Runtime.InProcess.RhinoCore(args,ws);
            gh = (Grasshopper.Plugin.GH_RhinoScriptInterface)RhinoApp.GetPlugInObject("GrassHopper");
            if( gh != null) gh.DisableBanner();

            splash.Close();

            IntPtr MainWindow = RhinoApp.MainWindowHandle();
            IntPtr hMenu = GetSystemMenu(MainWindow, false);
            if (hMenu != IntPtr.Zero)
            {
                // Remove the close button
                RemoveMenu(hMenu, SC_CLOSE, MF_BYCOMMAND);
            }


            newWndProc = new WndProcDelegate(CustomWndProc);
            IntPtr newWndProcPtr = Marshal.GetFunctionPointerForDelegate(newWndProc);
            originalWndProc = SetWindowLongPtr(MainWindow, GWL_WNDPROC, newWndProcPtr);

            RhinoDoc.ActiveDoc.ModelUnitSystem= GetixCubeLengthUnits();


            ixCubeCom.ixComModel.Connect();
            ixCubeCom.ixCubeModel ixModelData = ixCubeCom.ixCubeModel.Instance;
            if (ixModelData != null)
            {
                ixModelData.mBuildMeshParams.LoadTemplateBeforeBuild = false;
                ixModelData.mBuildMeshParams.ResetModelBeforeBuild = true;
                ixModelData.mBuildMeshParams.ReadBackModelAfterBuild = true;
                ixModelData.AutoFillDataDatabase();
                ixModelData.GenerateLayerFromDBItems();
            }
            Initialized = true;
            m_rhino_core.Run();
            return 1;
        }

        catch
        {
            // ignored
            return 0;
        }
    }

I see,

You can only create one instance of RhinoCore per process.

So if you plan to reuse it latter you have to keep a reference to it and use it on your second call.