How to dock more precisely?

Hello guys,

I want to save the dock location of my plugin and restore it when Rhino is opened again. Is there any more information about the position of the plugin besides MRhinoUIDockBar.GetDockLocation()? Because this is not precise enough to restore the exact same position. I tried to look through the class but couldn’t find anything about it.

I am using C# .NET4.0, adding my plugin with MRhinoDockBarManager.CreateRhinoDockBar().

Thanks in advance
Marcel

Hi Marcel,

Rhino’s docking framework is responsible for saving and restoring your dockbar’s size and location. I doubt you will have much luck overriding this behavior.

– Dale

Hey Dale,

thanks for your reply. Well, it just doesn’t work with my plugin. And it somewhat makes sense in my eyes to show the dockbar where I specified by passing a dock location when calling CreateRhinoDockBar. I checked the overloads of the method again and found out that there is only one overload with Rhino.PlugIns.PlugIn which I am using that takes all the parameters like dock location. That means I have to pass a dock location and this might overwrite the saved value by Rhino.

Am I right? What are my options? Is there any other way to install the dock bar or is it advisable to change to MRhinoPlugIn which supports other overloads without passing the dock location?

Thank you very much!

Marcel

Well, there are plenty of members/methods on our dockbar class - you would get one to dock wherever you want. Perhaps I need more information on what you are trying to do.

Also, MRhinoUiDockBar is a wrapper around the C++ SDK’s CRhinoUiDockBar, which is derived from MFC’s CControlBar.

https://msdn.microsoft.com/en-us/library/946eh8h7.aspx

Not sure if this helps or not.

Hey Dale,

I don’t think that it’s such a complicated case. I just want to restore the exact position of my plugin after closing and restarting Rhino. And the question is, does Rhino do it on its own if I don’t pass a DockLocation value through CreateRhinoDockBar or do I have to store the position more exactly than just Top, Right, Bottom, Left? In the first case, I would need to have an alternative how to create the dockbar (and changing the base type to MRhinoPlugIn to use other overloads of CreateRhinoDockBar is not an option). In the second case, I need more information about the positon of the dockbar and where to set it again.

I hope it’s clear what I need.

Marcel

@JohnM can you provide anything here?

Rhino saves state, location and size of all control bars when it shuts down. It does not matter if the control bar is created by a plug-in or by Rhino. When Rhino starts it restores the previous state and position of control bars, if a control bar was visible and created by a plug-in Rhino will do the following:

  1. Load the plug-in
  2. Check for a new control bar with the saved control bar Id
  3. Restore the control bar state and position
    As a general rule your plug-in should always create its control bars in OnLoad and created them as hidden that way you will avoid them flashing the next time Rhino starts and your plug-in is loaded after a user has hidden your control bar. Generally the plug-in will provide a command to show, hide or toggle the state of its control bar(s) or provide some menu interface to show or hide them.

I forgot to mention one thing, if there are no visible control bars associated with a plug-in and the plug-in is not load at start-up then the control bar position information is cached and used when the plug-in is eventually demand loaded, if it does not get loaded during a Rhino session then the cached information is written when Rhino is closed.

In closing, Rhino should take care of this for you as long as you create your control bars when your plug-in loads.

Thank you, it works now. Your explanation helped me understand the workflow of Rhino. I don’t know why but after all these tests it was really easy to implement as Rhino does most of the work on its own.

Again, thank you for your help! :smile: