Keep instance of a panel when loading files

Hello,
I have noticed that rhino creates a new panel on loading a file, can I prevent that? It breaks my plugin thats keeping track of current objects in the document, my backend code works after loading a file, but the ui is not updating.

You need to give a bit more detail - which panel is newly created upon loading?
What file and file type is being loaded?

my registered eto panel, the OnLoad method is called on loading a 3dm file via the open command

You may want to subscribe to the RhinoApp.Idle event, and handle any necessary UI updates there. Of course you can track the changes in the document in the OnLoad but any changes to the UI must be done in the Idle event. So if you need to change anything, subscribe to RhinoApp.Idle, and if that event handler is triggered, unsubscribe from the event and update your UI as needed. I hope that makes sense :slight_smile:

I might not have explained myself well enough, I am able to track the objects, my ui is updating as expected until I load a new 3dm file into rhino, after that my ui is not updating as if a new panel was created, I believe after the file load there are two instances of my plugin

Hi @Vojta_Hanzlík,

This is how panels behave. Knowing this, your panel’s view model should take this into account.

RhiinoCommon exposes many event related to document activity.

https://developer.rhino3d.com/api/rhinocommon/rhino.rhinodoc#events

Perhaps watching for RhinoDoc.CloseDocument events and taking the required action would help?

– dale