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
public virtual bool AddToHelpMenu { get; }
Called by Rhino to determine if the plug-in name should be added to the Rhino Help/Plug-ins menu.

AskOnLoadProtection

#Since v6.0
public static bool AskOnLoadProtection { get; set; }
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.

Assembly

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

Description

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

Id

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

InstalledPlugInCount

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

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
public virtual PlugInLoadTime LoadTime { get; }
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.

LocalPlugInName

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

Name

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

Settings

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

SettingsDirectory

#Since v5.0
public string SettingsDirectory { get; }
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.

SettingsDirectoryAllUsers

#Since v5.0
public string SettingsDirectoryAllUsers { get; }
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.

Version

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

WindowPositionSettings

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

Methods

AskUserForLicense

#
protected bool AskUserForLicense(LicenseBuildType productBuildType, bool standAlone, string textMask, object parentWindow, ValidateProductKeyDelegate validateProductKeyDelegate, OnLeaseChangedDelegate onLeaseChangedDelegate)
productBuildType (LicenseBuildType)
standAlone (bool)
textMask (string)
parentWindow (object)
validateProductKeyDelegate (ValidateProductKeyDelegate)
onLeaseChangedDelegate (OnLeaseChangedDelegate)

CommandSettings

#Since v5.0
public PersistentSettings CommandSettings(string name)
name (string)

CreateCommands

#
protected virtual void 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.

DisplayHelp

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

DocumentPropertiesDialogPages

#
protected virtual void DocumentPropertiesDialogPages(RhinoDoc doc, List<OptionsDialogPage> pages)
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.
doc (RhinoDoc)document that the pages are set up for
pages (List<OptionsDialogPage>)list of pages to add your custom options dialog page(s) to.

Find

#Since v5.0
public static PlugIn Find(Assembly pluginAssembly)
Finds the plug-in instance that was loaded from a given assembly.
pluginAssembly (Assembly)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
public static PlugIn Find(Guid plugInId)
Finds the plug-in instance that was loaded from a given plug-in Id.
plugInId (Guid)The plug-in Id.
The plug-in instance if successful. Otherwise, null.

FlushSettingsSavedQueue

#Since v6.0
public static void FlushSettingsSavedQueue()

GetCommands

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

GetEnglishCommandNames

#Since v5.0
public static string[] GetEnglishCommandNames(Guid pluginId)
Gets names of all "non-test" commands for a given plug-in.
pluginId (Guid)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
public static string[] GetInstalledPlugInNames()
Returns the names of all installed Rhino plug-ins.
The names if successful.

GetInstalledPlugInNames

#Since v7.5
public static string[] GetInstalledPlugInNames(PlugInType typeFilter, bool loaded, bool unloaded, bool localizedPlugInName)
Gets a list of installed plug-in names. The list can be restricted by some filters.
typeFilter (PlugInType)The enumeration flags that determine which types of plug-ins are included.
loaded (bool)true if loaded plug-ins are returned.
unloaded (bool)true if unloaded plug-ins are returned.
localizedPlugInName (bool)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
public static string[] GetInstalledPlugInNames(PlugInType typeFilter, bool loaded, bool unloaded)
Gets a list of installed plug-in names. The list can be restricted by some filters.
typeFilter (PlugInType)The enumeration flags that determine which types of plug-ins are included.
loaded (bool)true if loaded plug-ins are returned.
unloaded (bool)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
public static Dictionary<Guid, string> GetInstalledPlugIns()
Get a list of all registered plug-in's regardless of if they are loaded or not.
Dictionary with plug-in ID as key and localized plug-in name as value

GetInstalledPlugIns

#Since v7.5
public static Dictionary<Guid, string> GetInstalledPlugIns(bool localizedPlugInName)
Get a list of all registered plug-in's regardless of if they are loaded or not.
localizedPlugInName (bool)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

#
protected bool GetLicense(LicenseBuildType productBuildType, ValidateProductKeyDelegate validateProductKeyDelegate, OnLeaseChangedDelegate leaseChangedDelegate)
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.
productBuildType (LicenseBuildType)The product build contentType required by your plug-in.
validateProductKeyDelegate (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 (OnLeaseChangedDelegate)Called by the ZooClient when the cloud zoo lease is changed.
true if a valid license was found. false otherwise.

GetLicense

#
protected bool GetLicense(LicenseCapabilities licenseCapabilities, string textMask, ValidateProductKeyDelegate validateProductKeyDelegate, OnLeaseChangedDelegate leaseChangedDelegate)
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.
licenseCapabilities (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 (string)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 (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 (OnLeaseChangedDelegate)Called by the ZooClient when the cloud zoo lease is changed.
true if a valid license was found. false otherwise.

GetLicenseOwner

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

GetLoadProtection

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

GetPlugInInfo

#Since v6.0
public static PlugInInfo GetPlugInInfo(Guid pluginId)
Returns detailed information about an installed Rhino plug-in.
pluginId (Guid)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(Guid plugInId, bool load)
plugInId (Guid)
load (bool)

Icon

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

IdFromFileName

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

IdFromName

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

IdFromPath

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

IsTextureSupported

#Since v8.6
public virtual bool IsTextureSupported(RenderTexture texture)
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.
texture (RenderTexture)

LoadComputeExtensionPlugins

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

LoadPlugIn

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

LoadPlugIn

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

LoadPlugIn

#Since v6.0
public static LoadPlugInResult LoadPlugIn(string path, out Guid plugInId)
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
path (string)full path to plug-in to attempt to load
plugInId (out Guid)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
public static string NameFromPath(string pluginPath)
Gets a plug-in name for an installed plug-in given the path to that plug-in.
pluginPath (string)The path of the plug-in.
The plug-in name.

ObjectPropertiesPages

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

ObjectPropertiesPages

#
protected virtual void ObjectPropertiesPages(ObjectPropertiesPageCollection collection)
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.
collection (ObjectPropertiesPageCollection)Add custom pages by calling collection.Add

OnLoad

#
protected virtual LoadReturnCode OnLoad(ref string errorMessage)
Is called when the plug-in is being loaded.
errorMessage (ref string)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

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

PathFromId

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

PathFromName

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

PlugInExists

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

RaiseOnPlugInSettingsSavedEvent

#Since v6.0
public static void RaiseOnPlugInSettingsSavedEvent()
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.

ReadDocument

#
protected virtual void ReadDocument(RhinoDoc doc, BinaryArchiveReader archive, FileReadOptions options)
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.
doc (RhinoDoc)A Rhino document that is being loaded.
archive (BinaryArchiveReader)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 (FileReadOptions)Describes what is being written.

RegisterCommand

#
protected bool RegisterCommand(Command command)
command (Command)

ResetMessageBoxes

#
protected virtual void ResetMessageBoxes()

ReturnLicense

#Since v5.0
protected bool ReturnLicense()
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.

SavePluginSettings

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

SaveSettings

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

SetLicenseCapabilities

#
protected void SetLicenseCapabilities(string textMask, LicenseCapabilities capabilities, Guid licenseId)
textMask (string)
capabilities (LicenseCapabilities)
licenseId (Guid)

SetLoadProtection

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

ShouldCallWriteDocument

#
protected virtual bool ShouldCallWriteDocument(FileWriteOptions options)
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().
options (FileWriteOptions)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

#
protected virtual void WriteDocument(RhinoDoc doc, BinaryArchiveWriter archive, FileWriteOptions options)
Called when Rhino is saving a .3dm file to allow the plug-in to save document user data.
doc (RhinoDoc)The Rhino document instance that is being saved.
archive (BinaryArchiveWriter)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 (FileWriteOptions)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.

UnknownUserData

#Since v7.17
public static event EventHandler<PlugIn.UnknownUserDataEventArgs> UnknownUserData
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.