Disable plugin after loading

Hi,

Is it possible to disable my plugin after loading?
I start running a background worker in the OnLoad to speed up the login.
But after the background worker ends and the result is out of date I want to disable the plugin.

Is there an easier way than add a line in each command that the plugin is disabled?

Thanks.

What I now tried is to make a public variable that says true or false and when a command runs check if it is a command from my plugin, but cant figure out how to cancel the command from continueing.

 Private Sub StartOfCommand(ByVal sender As Object, ByVal e As Rhino.Commands.CommandEventArgs)
        If Definitions.PluginEnabled = False Then
            If e.CommandPluginName = MyPlugin.MyPlugin.Instance.Name Then
                            'concel command from continueing here'
            End If
        End If
    End Sub

You mean something like this?

Protected Overrides Function RunCommand(ByVal doc As RhinoDoc, ByVal mode As RunMode) As Result

  If Not MyPlugIn.Instance().IsEnabled Then
    RhinoApp.WriteLine("Plug-in disabled.")
    Return Result.Failure
  End If

  ' TODO...

  Return Result.Success

End Function

Not really. This way I have to add this to every command. Is it possible to
disable the plugin entirely? Or in the begincommand handler?

Why don’t you just have an abstract base command class that all your other commands derive from? Then you can have this same functionality implemented in all of your commands.

1 Like

Dale,

Can this be hooked up to a toolbar button and if so are there any examples?

Since Rhino toolbar buttons mostly just run Rhino command, this is “hooked up” by default. Make sense?

I understand - mostly.

I took a look at the button editor (per a previous question/answer [ here ]) and I now understand how to produce a button that launches a plugin.

I see that there is a left and right mouse button option and would like the right click to trigger an ‘end’ process. So the question is really: How can one stop a plugin in a similar way to the English language method provided many of the development examples. Is there a way to do this?

I would like to tie an enlgish language ‘stop’ command to the right mouse button.

Dale,

I’ve sucessfully produced the RHI file and I believe that it’s being installed correctly via your installer. Inside the RHI I’ve produced the specified document structure which includes a custom toolbar (RUI) for the plugin.

Two brief follow-up questions:

  1. I notice that the toolbar icon doesn’t load - rather I see a : ) instead of my own icon. Do I need to place the icon file in any particular location? I was thinking that it would be wrapped by the RUI automatically.

  2. Is there a way for me to unload the plugin that I just installed in order to retest it cleanly? I’ve tried to do the remove manually by deleting the installed plugin file but the plugin still lists in my rhino preferences. If possible I’d like to completely remove the plugin so that I can faithfully test the install process as a new user would…

1.) I am confused by your first question. But basically you use Rhino to create toolbars and toolbar buttons. The Toolbar command had a button editor that allows you to assign images to buttons, which are then embedded in RUI files. RUI files do not reference external icon files. Does this help?

2.) Not really. To really uninstall a plug-in, you must remove its entry from the Windows Registry.