public class PlugIn
A general purpose utility plug-in that can contain one or more commands.

Constructors

PlugIn

#
protected PlugIn()

Properties

AddToHelpMenu

#Since v8.7
Called by Rhino to determine if the plug-in name should be added to the Rhino Help/Plug-ins menu.
public virtual bool AddToHelpMenu { get; }

AskOnLoadProtection

#Since v6.0
If true, Rhino will display a warning dialog when load-protected plug-ins are attempting to load. If false, load-protected plug-ins will silently not load.
public static bool AskOnLoadProtection { get; set; }

Assembly

#Since v5.0
Source assembly for this plug-in.
public Assembly Assembly { get; }

Description

#Since v6.0
Returns the description of the plug-in, as found in the plug-in's assembly attributes.
public string Description { get; }

Id

#Since v5.0
Returns the Guid, or unique Id, of the plug-in.
public Guid Id { get; }

InstalledPlugInCount

#Since v5.0
Returns the number of installed Rhino plug-ins.
public static int InstalledPlugInCount { get; }

LicenseId

#Since v6.0
public Guid LicenseId { get; }

LoadAtStartup

#Since v5.0
public virtual bool LoadAtStartup { get; }
obsoleteUse LoadTime virtual property instead

LoadTime

#Since v5.0
Plug-ins are typically loaded on demand when they are first needed. You can change this behavior to load the plug-in at during different stages in time by overriding this property.
public virtual PlugInLoadTime LoadTime { get; }

LocalPlugInName

#
Optionally override this to provide a localized plug-in name
protected virtual string LocalPlugInName { get; }

Name

#Since v5.0
Returns the name of the plug-in, as found in the plug-in's assembly attributes.
public string Name { get; }

Settings

#Since v5.0
Persistent plug-in settings.
public PersistentSettings Settings { get; }

SettingsDirectory

#Since v5.0
Get the plug-in's settings directory. This is the directory where the plug-in's persistent settings files are saved. This directory will be located in the user's profile folder. Note, this does not verify the directory exists.
public string SettingsDirectory { get; }

SettingsDirectoryAllUsers

#Since v5.0
Get the plug-in's "all users" settings directory. This directory will be located in the system's program data folder. Note, this does not verify the directory exists.
public string SettingsDirectoryAllUsers { get; }

Version

#Since v5.0
Returns the version of the plug-in, as found in the plug-in's assembly attributes.
public string Version { get; }

WindowPositionSettings

#Since v6.0
public PersistentSettings WindowPositionSettings { get; }

Methods

AskUserForLicense

#
protected bool AskUserForLicense(
productBuildType,
standAlone,
textMask,
parentWindow,
validateProductKeyDelegate,
onLeaseChangedDelegate
)

CommandSettings

#Since v5.0
public PersistentSettings CommandSettings(
name
)

CreateCommands

#
Called right after plug-in is created and is responsible for creating all of the commands in a given plug-in. The base class implementation Constructs an instance of every publicly exported command class in your plug-in's assembly.
protected virtual void CreateCommands()

DisplayHelp

#Since v8.7
Called by Rhino if AddToHelpMenu is true and menu item associated with this plug-in is selected.
public virtual bool DisplayHelp(
nint
windowHandle
Native Window handle of the active Rhino interface.
)
true = Help displayed successfully, false = Error displaying help

DocumentPropertiesDialogPages

#
Override this function if you want to extend the document properties sections of the options dialog. This function is called whenever the user brings up the Options dialog.
protected virtual void DocumentPropertiesDialogPages(
doc,
document that the pages are set up for
pages
list of pages to add your custom options dialog page(s) to.
)

Find

#Since v5.0
Finds the plug-in instance that was loaded from a given assembly.
public static PlugIn Find(
pluginAssembly
The plug-in assembly.

You can get the assembly instance at runtime with the Type.Assembly instance property.

)
The assembly plug-in instance if successful. Otherwise, null.

Find

#Since v5.5
Finds the plug-in instance that was loaded from a given plug-in Id.
public static PlugIn Find(
plugInId
The plug-in Id.
)
The plug-in instance if successful. Otherwise, null.

FlushSettingsSavedQueue

#Since v6.0
public static void FlushSettingsSavedQueue()

GetCommands

#Since v5.0
All of the commands associated with this plug-in.
public Command[] GetCommands()

GetEnglishCommandNames

#Since v5.0
Gets names of all "non-test" commands for a given plug-in.
public static string[] GetEnglishCommandNames(
pluginId
The plug-in ID.
)
An array with all plug-in names. This can be empty, but not null.

GetInstalledPlugInFolders

#Since v5.0
public static string[] GetInstalledPlugInFolders()

GetInstalledPlugInNames

#Since v5.0
Returns the names of all installed Rhino plug-ins.
public static string[] GetInstalledPlugInNames()
The names if successful.

GetInstalledPlugInNames

#Since v7.5
Gets a list of installed plug-in names. The list can be restricted by some filters.
public static string[] GetInstalledPlugInNames(
typeFilter,
The enumeration flags that determine which types of plug-ins are included.
loaded,
true if loaded plug-ins are returned.
unloaded,
true if unloaded plug-ins are returned.
localizedPlugInName
If true localized plug-in names are returned otherwise; English names are returned.
)
An array of installed plug-in names. This can be empty, but not null.

GetInstalledPlugInNames

#Since v5.0
Gets a list of installed plug-in names. The list can be restricted by some filters.
public static string[] GetInstalledPlugInNames(
typeFilter,
The enumeration flags that determine which types of plug-ins are included.
loaded,
true if loaded plug-ins are returned.
unloaded
true if unloaded plug-ins are returned.
)
An array of installed plug-in names. This can be empty, but not null.

GetInstalledPlugIns

#Since v5.0
Get a list of all registered plug-in's regardless of if they are loaded or not.
public static Dictionary<Guid, string> GetInstalledPlugIns()
Dictionary with plug-in ID as key and localized plug-in name as value

GetInstalledPlugIns

#Since v7.5
Get a list of all registered plug-in's regardless of if they are loaded or not.
public static Dictionary<Guid, string> GetInstalledPlugIns(
localizedPlugInName
If true then the localize plug-in name is returned otherwise; the English name is used.
)
Dictionary with plug-in ID as key and plug-in name as value

GetLicense

#
Verifies that there is a valid product license for your plug-in, using the Rhino licensing system. If the plug-in is installed as a standalone node, the locally installed license will be validated. If the plug-in is installed as a network node, a loaner license will be requested by the system's assigned Zoo server. If the Zoo server finds and returns a license, then this license will be validated. If no license is found, then the user will be prompted to provide a license key, which will be validated.
protected bool GetLicense(
productBuildType,
The product build contentType required by your plug-in.
validateProductKeyDelegate,
Since the Rhino licensing system knows nothing about your product license, you will need to validate the product license provided by the Rhino licensing system. This is done by supplying a callback function, or delegate, that can be called to perform the validation.
leaseChangedDelegate
Called by the ZooClient when the cloud zoo lease is changed.
)
true if a valid license was found. false otherwise.

GetLicense

#
Verifies that there is a valid product license for your plug-in, using the Rhino licensing system. If the plug-in is installed as a standalone node, the locally installed license will be validated. If the plug-in is installed as a network node, a loaner license will be requested by the system's assigned Zoo server. If the Zoo server finds and returns a license, then this license will be validated. If no license is found, then the user will be prompted to provide a license key, which will be validated.
protected bool GetLicense(
licenseCapabilities,
In the event that a license was not found, or if the user wants to change the way your plug-in is licenses, then provide what capabilities your license has by using this enumeration flag.
textMask,
In the event that the user needs to be asked for a license, then you can provide a text mask, which helps the user to distinguish between proper and improper user input of your license code. Note, if you do not want to use a text mask, then pass in a null value for this parameter. For more information on text masks, search MSDN for the System.Windows.Forms.MaskedTextBox class.
validateProductKeyDelegate,
Since the Rhino licensing system knows nothing about your product license, you will need to validate the product license provided by the Rhino licensing system. This is done by supplying a callback function, or delegate, that can be called to perform the validation.
leaseChangedDelegate
Called by the ZooClient when the cloud zoo lease is changed.
)
true if a valid license was found. false otherwise.

GetLicenseOwner

#Since v5.11
Get the customer name and organization used when entering the product license.
protected bool GetLicenseOwner(
out string
registeredOwner,
out string
registeredOrganization
)

GetLoadProtection

#Since v5.5
Get load protection state for a plug-in
public static bool GetLoadProtection(
pluginId,
out bool
loadSilently
)

GetPlugInInfo

#Since v6.0
Returns detailed information about an installed Rhino plug-in.
public static PlugInInfo GetPlugInInfo(
pluginId
The id of the plug-in.
)
Detailed information about an installed Rhino plug-in if successful, null otherwise.

GetPlugInObject

#Since v5.0
public virtual object GetPlugInObject()

GetPluginSettings

#Since v6.0
public static PersistentSettings GetPluginSettings(
plugInId,
load
)

Icon

#Since v6.0
Returns the plug-in's icon in bitmap form.
public Bitmap Icon(
size
The desired size in pixels.
)
The icon if successful, null otherwise.

IdFromFileName

#Since v8.15
Attempt to get a plugiin id from just the filename of a plug-in
public static Guid IdFromFileName(
filename
plug-in filename
)
id on success; Guid.Empty if no plug-in could be found

IdFromName

#Since v5.5
Gets the id of an installed plug-in giving the plug-in's name.
public static Guid IdFromName(
pluginName
The name of the installed plug-in.
)
The id if successful.

IdFromPath

#Since v5.0
Gets the id of an installed plug-in giving the plug-in's file path.
public static Guid IdFromPath(
pluginPath
The path to the installed plug-in.
)
The id if successful.

IsTextureSupported

#Since v8.6
Returns true if this renderer can render the texture natively without needing it to be baked into a bitmap, false otherwise. By default, returns false for all textures.
public virtual bool IsTextureSupported()

LoadComputeExtensionPlugins

#Since v7.0
Used by compute's startup code to load plug-ins that have registered custom endpoints
public static void LoadComputeExtensionPlugins()

LoadPlugIn

#Since v6.0
Loads an installed plug-in.
public static bool LoadPlugIn(
pluginId,
The id of the installed plug-in.
loadQuietly,
Load the plug-in quietly.
forceLoad
Load plug-in even if previous attempt to load has failed.
)
true if successful, false otherwise.

LoadPlugIn

#Since v5.0
Loads an installed plug-in.
public static bool LoadPlugIn(
pluginId
The id of the installed plug-in.
)
true if successful, false otherwise.

LoadPlugIn

#Since v6.0
Attempt to load a plug-in at a path. Loaded plug-ins are remembered by Rhino between sessions, so this function can also be considered a plug-in installation routine
public static LoadPlugInResult LoadPlugIn(
path,
full path to plug-in to attempt to load
out Guid
plugInId
If successful (or the plug-in is already loaded), the unique id for the plug-in is returned here. Guid.Empty on failure
)

NameFromPath

#Since v5.0
Gets a plug-in name for an installed plug-in given the path to that plug-in.
public static string NameFromPath(
pluginPath
The path of the plug-in.
)
The plug-in name.

ObjectPropertiesPages

#
Override this function is you want to extend the object properties dialog
protected virtual void ObjectPropertiesPages()
obsoleteUse ObjectPropertiesPages(ObjectPropertiesPageCollection collection) instead

ObjectPropertiesPages

#
Override this function is you want to extend the object properties dialog. This method will be called each time a new document is created for each instance of a object properties panel. On Windows there will be a single panel per document but on Mac there may be many properties panel per document.
protected virtual void ObjectPropertiesPages(
collection
Add custom pages by calling collection.Add
)

OnLoad

#
Is called when the plug-in is being loaded.
protected virtual LoadReturnCode OnLoad(
ref string
errorMessage
If a load error is returned and this string is set. This string is the error message that will be reported back to the user.
)
An appropriate load return code.

The default implementation returns LoadReturnCode.Success.

OnShutdown

#
protected virtual void OnShutdown()

OptionsDialogPages

#
Override this function if you want to extend the options dialog. This function is called whenever the user brings up the Options dialog.
protected virtual void OptionsDialogPages(
pages
list of pages to add your custom options dialog page(s) to.
)

PathFromId

#Since v5.9
Gets the path to an installed plug-in given the id of that plug-in
public static string PathFromId(
pluginId
)

PathFromName

#Since v5.9
Gets the path to an installed plug-in given the name of that plug-in
public static string PathFromName(
pluginName
)

PlugInExists

#Since v5.0
Verifies that a Rhino plug-in is installed.
public static bool PlugInExists(
id,
The id of the plug-in.
out bool
loaded,
The loaded state of the plug-in.
out bool
loadProtected
The load protected state of the plug-in.
)
Returns true if the plug-in exists, or is installed.

RaiseOnPlugInSettingsSavedEvent

#Since v6.0
Raise any pending OnPlugInSettingsSaved events, the events are normally queued while a command is running and fired while Rhino is in an idle state. Calling this method will raise any pending changed events regardless of Rhino's current idle state or if a command is running.
public static void RaiseOnPlugInSettingsSavedEvent()

ReadDocument

#
Called whenever a Rhino document is being loaded and plug-in user data was encountered written by a plug-in with this plug-in's GUID.
protected virtual void ReadDocument(
doc,
A Rhino document that is being loaded.
archive,
OpenNURBS file archive object Rhino is using to read this file. Use BinaryArchiveReader.Read*() functions to read plug-in data. If any BinaryArchive.Read*() functions throws an exception then archive.ReadErrorOccurve will be true and you should immediately return.
options
Describes what is being written.
)

RegisterCommand

#
protected bool RegisterCommand(
command
)

ResetMessageBoxes

#
protected virtual void ResetMessageBoxes()

ReturnLicense

#Since v5.0
Returns, or releases, a product license that was obtained from the Rhino licensing system. Note, most plug-ins do not need to call this as the Rhino licensing system will return all licenses when Rhino shuts down.
protected bool ReturnLicense()

SavePluginSettings

#Since v6.0
public static void SavePluginSettings(
plugInId
)

SaveSettings

#Since v6.0
Write settings to disk which will raise a SettingsSaved event.
public void SaveSettings()

SetLicenseCapabilities

#
protected void SetLicenseCapabilities(
textMask,
capabilities,
licenseId
)

SetLoadProtection

#Since v5.5
Set load protection state for a certain plug-in
public static void SetLoadProtection(
pluginId,
loadSilently
)

ShouldCallWriteDocument

#
Called whenever a Rhino is about to save a .3dm file. If you want to save plug-in document data when a model is saved in a version 5 .3dm file, then you must override this function to return true and you must override WriteDocument().
protected virtual bool ShouldCallWriteDocument(
options
The file write options, such as "include preview image" and "include render meshes".
)
true if the plug-in wants to save document user data in the version 5 .3dm file. The default returns false.

WriteDocument

#
Called when Rhino is saving a .3dm file to allow the plug-in to save document user data.
protected virtual void WriteDocument(
doc,
The Rhino document instance that is being saved.
archive,
OpenNURBS file archive object Rhino is using to write the file. Use BinaryArchiveWriter.Write*() functions to write plug-in data. OR use the ArchivableDictionary If any BinaryArchiveWriter.Write*() functions throw an exception, then archive.WriteErrorOccured will be true and you should immediately return. Setting archive.WriteErrorOccured to true will cause Rhino to stop saving the file.
options
The file write options, such as "include preview image" and "include render meshes".
)

Events

SettingsSaved

#Since v6.0
This event is raised when an instance of Rhino has modified the external settings file associated with this plug-in's Settings property.
SaveSettings()

UnknownUserData

#Since v7.17
This event is raised when a 3dm file is loaded with unknown user data, and the plug-in to handle it could not be loaded.
public static event EventHandler<PlugIn.UnknownUserDataEventArgs> UnknownUserData