PluginServer

public static class PluginServer
Central repository for all loaded plugins.

Properties

CorePlugins

#
Gets an enumerator for all the core component library assemblies. This property iterates over all RHP files inside the plugin components folder, whether or not they were put there by the Grasshopper installer.
public static IEnumerable<string> CorePlugins { get; }

CustomPlugins

#
Enumerate all custom plugin files.
public static IEnumerable<string> CustomPlugins { get; }

IsLoading

#
Gets whether a plugin is currently in the process of being loaded.

The load lock is held for the entire duration of a plugin load, so a lock which cannot be taken right now means another thread is busy loading. Taking the lock the usual way would block until that load completes, so this probes the lock instead of waiting on it. On the loading thread itself the lock is re-entrant and the loading set is consulted directly.

public static bool IsLoading { get; }

LoadState

#
Gets how far the startup sequence has progressed. Plugins loaded after the startup sequence do not affect this, see PluginLoaded for those.
public static LoadState LoadState { get; }

State

#
Gets the current state of the plugin server. The state is immutable and should never be cached, but always retrieved anew.
public static Plugins State { get; }

YakPlugins

#
Enumerate all 3rd party plugin files.
public static IEnumerable<string> YakPlugins { get; }

Methods

ComponentAssemblies

#
Enumerate over all plugins that Grasshopper would load if it were asked now to do so. This list is not necessarily consistent with the number of plugins that Grasshopper loaded when it started.
public static IEnumerable<string> ComponentAssemblies(
kind
Assembly kinds to include in the enumeration.
)

DescribeUninstall

#
Describe what uninstalling a plugin would actually do, for putting to the user before it happens.

The two kinds of installation carry very different risk. A custom plugin is no more than an entry on a list of files to load, so removing it changes nothing on disk and can be undone by picking the same file again. A Yak package is files, every version of them, and getting them back means downloading them again — assuming the server still has them.

public static string DescribeUninstall(
location
Plugin file which would be uninstalled.
)
A question to put to the user, or null when there is nothing this method knows how to uninstall.

FindPluginForObject

#
Find which plugin provides the given document object. It is possible that an object is not associated with any plugin.
public static Plugin FindPluginForObject()

FindPluginForObject

#
Find which plugin provides the given document object. It is possible that an object is not associated with any plugin.
public static Plugin FindPluginForObject(
objectType
)

ForgetPlugin

#
Forget a scoped potential plugin.
public static bool ForgetPlugin(
location
Location to forget.
)
True if the state of the PluginServer was updated.

InstallCustomPlugin

#
Add a custom component assembly. This is typically used only for those plugins which are not installed through regular channels, such as plugins being locally developed or debugged.
public static FailureKind InstallCustomPlugin(
path
)

LoadAllScopedPlugins

#
Try and load all scoped plugins.
public static (int loaded, int failed) LoadAllScopedPlugins()
A tuple with loaded and failed counts.

LoadPlugin

#
Load a plugin assembly into the framework.
public static bool LoadPlugin(
location,
The location of this assembly. If no file location is associated (for example in the case of assemblies compiled in memory) then the assembly FullName may be used instead.
assembly,
Assembly to load.
failure
Message in case of load failure.
)
True if plugin was loaded successfully.

LoadPlugin

#
Attempt to load a plugin from a file.
public static bool LoadPlugin(
location,
Uri of plugin.
failure
Message in case of load failure.
)
True if plugin was loaded successfully.

RemovePlugin

#
Remove a failed plugin from the list.
public static bool RemovePlugin(
location
Location to remove from failed list.
)

ScopeCustomPlugins

#
Add all custom selected plugin files to the scoped list.
public static int ScopeCustomPlugins()
Number of plugins scoped.

ScopePlugin

#
Scope a potential plugin. This always happens before a plugin is actually loaded.
public static bool ScopePlugin(
location
Location to scope.
)
True if the state of the PluginServer was updated.

ScopeStandardPlugins

#
Add all standard plugins to the scoped list.
public static int ScopeStandardPlugins()
Number of plugins scoped.

ScopeYakPlugins

#
Add all yak package installed plugins to the scoped list.
public static int ScopeYakPlugins()
Number of plugins scoped.

UninstallCustomPlugin

#
Remove a custom component assembly. This is typically used only for those plugins which are not installed through regular channels, such as plugins being locally developed or debugged.
public static bool UninstallCustomPlugin(
path
)

UninstallPlugin

#
Uninstall a plugin, whichever way it was installed.

A custom plugin is only ever an entry on a list of files to load, so removing the entry is the whole job. A Yak plugin is a package on disk, and getting rid of it means deleting that — which Windows will not do while the assembly is loaded, so whatever will not go now is put on FleetingPlugins' removal ledger and dealt with at the next startup.

public static bool UninstallPlugin(
location,
Plugin file to uninstall.
out string
report
A sentence for the user describing what happened.
)
True if the plugin was uninstalled, whether or not the files have gone yet. False if there was nothing this method knows how to remove.

Events

LoadStateChanged

#
Raised once for each stage of the startup sequence, when it is reached. A late subscriber should check LoadState first; both the check and the subscription are safe on the UI thread, which is where the stages are reached.
public static event EventHandler LoadStateChanged

PluginFailed

#
Raised when a plugin fails to load.
public static event EventHandler<PluginEventArgs> PluginFailed

PluginForgotten

#
Raised when a scoped plugin is forgotten during the runtime of Grasshopper.
public static event EventHandler<PluginEventArgs> PluginForgotten

PluginLoaded

#
Raised when a plugin successfully loads.
public static event EventHandler<PluginEventArgs> PluginLoaded

PluginLoading

#
Raised just before a plugin starts getting loaded.
public static event EventHandler<PluginEventArgs> PluginLoading

PluginRemoved

#
Raised when a loaded or failed plugin is removed during the runtime of Grasshopper.
public static event EventHandler<PluginEventArgs> PluginRemoved

PluginScoped

#
Raised when a new plugin is discovered during the runtime of Grasshopper.
public static event EventHandler<PluginEventArgs> PluginScoped