Rhino.Inside Panels not Showing

We are running Rhino.Inside in a .Net 4.8 WPF application. We have taken ownership of the Main Rhino Window and positioned it without our application. When attempting to show any of the Panel UI from Rhino nothing happens.

We are starting the RhinoCore Message Pump on Idle of the WPF Dispatcher, using the ComponentDispatcher.ThreadIdle Event using _rhino_core.Run(); This has fixed our issues with Keyboard Input.

I can manually load a Dockbar, but a DockPanel doesn’t work at all. So we cannot use for instance the Layer command to view the Layer Panel.

Previously we were running two processes, and this worked find when launching Rhino separately, but the Rhino.Inside way really is nice, and we’d like to stick with it, but still want some of the core Rhino functionality to work.

I’m sure there is something I’m missing, or should be doing to make this work. Please let me know if you have any ideas @stevebaer @kike

2 Likes

@Japhy I’ve seen a lot of your posts on Revit, just wondering if you have any insight here that might point me in a direction of something I’m doing wrong. Thanks for any insight you can provide.

Hi JDev, This topic is out of my arena but I can certainly help get it into smaller problems and bring attention to it.

The bulk of the issue seems to be this initialization part. Can you provide a code example or go into more detail on you are doing here? Are you following a particular example? GitHub - mcneel/rhino.inside: Sample Projects for Rhino.Inside

Thank you. I will put together a sample WPF project showing my implementation logic this weekend.

Japhy,

I’ve created a standalone WPF application, bare bones, that is starting Rhino Inside the same way we are, that reproduces the issue with Rhino Panel UI / Layers Menu / etc that we are experiencing in 3 steps:

  1. Click Show Rhino
  2. Click Open Options: you will see that window appear fine.
  3. Click Open Layers: nothing will happen. (the same as typing “Layer”)

And here is the solution:
Rhino Inside Panel Bug.zip (186.8 KB)

Let me know what we are doing wrong, or not doing that we should be to enable the other Rhino UI to work. Thanks!

1 Like

@Japhy let me know if you guys need anything else to diagnose my issue. Looking forward to any help you can provide. We still would like to display some of the UI panels in Rhino within our software, so we need to find a solution.

I love Rhino.Inside and running only a single .exe, really don’t want to go back to the old 2 exe setup…

JDev, I brought this up at the Dev meeting, hopefully Kike can get back to you soon.

1 Like

@kike Is there any more information you need from us on this issue? Or do you have any insight on what we might be doing wrong? Thanks! Have a great weekend you guys!

I think the dialog is shown ouside the screen space.

Try settings the Scaling of your monitor to 100% to confirm.

My guess is Rhino assumes dpiAware entry on the exe manifest is set to true but your exe does not contain this entry.

Look at Application Manifests - Win32 apps | Microsoft Docs.

1 Like

Awesome, I hope it’s that easy. I’ll give it a try today. Thanks again for looking at our issue.

Unfortunately adding the app.manifest and setting the app to either unaware or PerMonitor or PerMonitor2 had no effect.

None of the Rhino Panels from the Panels pull-down menu show anywhere.

I have 2 monitors, one is 1080p and the other is 3440x1440. Both run at 100% dpi scaling in Windows. The test application above behaves the same across multiple PCs/Configs/Display Resolutions.

I’ve also tested added the WinForms scaling switch to the app.config with no effect.

	<appSettings>
		<add key="EnableWindowsFormsHighDpiAutoResizing" value="true" />
	</appSettings>

Any other ideas?

@stevebaer would you be able to help us out at all here Steve? Or do you know someone we can talk to about using the Rhino Panels UI when running Rhino.Inside? I’m available should you guys need any more information, or test projects / code, just let me know.

We are getting pretty far down the development path, and I don’t want to have to give up Rhino.Inside if we can help it, it really helps glue our whole application together.

@dale wrote the layers panel; he may have some idea as to why it is not showing

1 Like

Thanks Steve. Appreciate it, just an FYI it isn’t LAYERS that is the issue. ALL PANEL UI does not work in our solution, or in the test project I sent in this thread.

Anything from the PANEL pull-down menu does not show. Just looking for some insight, as to what we might be doing wrong with Rhino.Inside of our software.

Your project was using an undocumented -appmode flag that I added a while back to experiment with loading as little as possible to start Rhino. I must have left that flag in some example by mistake. If you recall where you found this appmode flag, please let me know so I can adjust the documentation.

Get rid of the “-appmode” start up flag in your code that creates an instance of RhinoCore.

 _rhino_core = new RhinoCore(new[] { "/nosplash" },  
        Rhino.Runtime.InProcess.WindowStyle.Hidden,
       _windowHandle);

I also would recommend getting rid of references to RhinoCommon, RhinoWindows as well as a project reference to Rhino.Inside. You can use a sigle nuget reference to Rhino.Inside and all of these assemblies will be brought into the project.

1 Like

Dang dude! @stevebaer You are the man!! You have made my year! Thank you so very much for taking the time to review this. That definitely solved my issue.

I don’t know if I stole the code from the Revit Project or what, I was looking through a lot of examples, but I’ll have a look at my history and let you know what I found.

Thanks again!

Any idea on why the RhinoApp.Idle event is no longer being raised after I remove that experimental flag?

Also is there any sample documentation for working with the message pump when using Rhino.Inside?

Any best practices. We are just trying to integrate Rhino within our WPF applicaiton, and are having great difficulty.

We had been using that experimental flag of yours, and then just using ComponentDispatcher.Idle event to run the RhinoCore.Run() method. This seemed to fix our input issues, allowing the ENTER / DELETE keys to work.

Without that FLAG, trying to just force it like that, causes Rhino to lock up now… or there is a struggle between our App and Rhino…

If you have any ideas on what we could be doing differently/better please let me know…

As is, I’ve swapped Panels working, for Enter/Delete working now… :frowning:

You definitely don’t want the -appmode flag, I can tell you that. The reason panels didn’t show up with that flag enabled is because none of Rhino’s plug-ins were loaded.

@kike is there anything special you needed to do to get Rhino.Inside Revit to work properly with regards to the message pump?

1 Like

Try adding this to the ComponentDispatcher.ThreadIdle handler.

    OnIdle()
    {
        while(RunModeless()) { }
    }

    static bool idlePending = true;

    static bool RunModeless()
    {
      if (idlePending)
        idlePending = rhino_core.DoIdle();

      var active = rhino_core.DoEvents();
      if (!active)
        idlePending = true;

      return active;
    }

1 Like

@kike Thanks for the help, I had seen that code in the RiR project on Github. But I hadn’t had luck using it. I must have been doing it slightly differently than your code because it was only working for me about 75% of the time.

Dragging the Mouse and other tasks, would lag out / lock up, because all of the idle/window messages weren’t being processed I assume.

With your code above it feels really good and smooth, I was causing a stack overflow entering that method too often, so I modified it some, and that seems to have fixed that issue:

image

image

I only have 1 remaining issue now. Whenever any Modal Dialog is shown by Rhino or you Resize the Rhino Window, I have to Activate another Window, and come back to my application Window and reactivate it in order to get it to respond to my clicks.


(I’ve excluded the filenames from the dialog)

If you have any ideas I would appreciate it. Thankfully the problems are getting smaller, and smaller.

Thank you both for your time, I seriously appreciate your efforts to help me.

– J