GH_Component
Inherit from this class if you wish to create a custom component. Note that you must provide a public, empty constructor which calls the base class constructor.
Inheritance Hierarchy
System.Object
Grasshopper.Kernel.GH_InstanceDescription
Grasshopper.Kernel.GH_DocumentObject
Grasshopper.Kernel.GH_ActiveObject
Grasshopper.Kernel.GH_Component
Grasshopper.Kernel.GH_TaskCapableComponent.T.
Namespace: Grasshopper.Kernel
Assembly: Grasshopper (in Grasshopper.dll)
Syntax
public abstract class GH_Component : GH_ActiveObject, IGH_Component, IGH_RenderAwareObject
The GH_Component type exposes the following members.
Properties
Name
Description
Public Property
Attributes
Gets or sets the attributes that are associated with this object. Only set custom attributes if you know what you are doing.
(Inherited from GH_DocumentObject.)
Public Property
Category
Gets or sets the Category in which this object belongs. If HasCategory() returns false, this field has no meaning.
(Inherited from GH_InstanceDescription.)
Public Property
ClippingBox
Gets the clipping box for all preview geometry drawn by this component and all associated parameters.
Public Property
ComponentGuid
Returns a consistent ID for this object type. Every object must supply a unique and unchanging ID that is used to identify objects of the same type.
(Inherited from GH_DocumentObject.)
Public Property
Description
Gets or sets the description of the object. This field typically remains fixed during the lifetime of an object.
(Inherited from GH_InstanceDescription.)
Public Property
Exposure
Gets the exposure of this object in the Graphical User Interface. The default is to expose everywhere.
(Inherited from GH_DocumentObject.)
Public Property
HasCategory
Gets whether or not the Category field has been set.
(Inherited from GH_InstanceDescription.)
Public Property
HasSubCategory
Gets whether or not the SubCategory field has been set.
(Inherited from GH_InstanceDescription.)
Protected property
HelpDescription
Override this method if you want the help topic content to be more than the Component description.
Public Property
Hidden
Gets or sets the hidden flag for this component. Does not affect Hidden flags on parameters associated with this component.
Protected property
Icon
Override this function to supply a custom icon (24x24 pixels). The result of this property is cached, so don’t worry if icon retrieval is not very fast.
(Inherited from GH_DocumentObject.)
Public Property
Icon_24x24
The icon associated with this object.
(Inherited from GH_DocumentObject.)
Public Property
Icon_24x24_Locked
The greyscale icon of this object.
(Inherited from GH_DocumentObject.)
Public Property
IconCapableUI
By default the NickName menu item supports the Icon Mode override toggle. If your UI is not capable of displaying icons, then override this property and return False.
(Inherited from GH_ActiveObject.)
Public Property
IconDisplayMode
Gets the current display mode of the object.
(Inherited from GH_DocumentObject.)
Public Property
InConstructor
Gets the constructor flag for this instance. If InConstructor = True, it means the component is still registering parameters and the layout is not yet complete.
Public Property
InstanceDescription
(Overrides
GH_InstanceDescription.InstanceDescription
.)Public Property
InstanceGuid
Gets the ID of this runtime instance.
(Inherited from GH_InstanceDescription.)
Public Property
IsBakeCapable
Public Property
IsDataProvider
Components are never Data providers. Only the output parameters can be considered to be providers.
(Overrides
GH_ActiveObject.IsDataProvider
.)Public Property
IsPreviewCapable
If a single parameter is PreviewCapable, so is the component. Override this property if you need special Preview flags.
Public Property
IsValidPrincipalParameterIndex
Gets whether the MasterParameterIndex property identifies a valid parameter.
Public Property
Keywords
Gets a list of additional keywords that describe the object. Typically this list is empty but you can override this property to aid in object searches.
(Inherited from GH_InstanceDescription.)
Public Property
Locked
Gets or sets the Locked state for this Component. This also sets locked states for all input and output parameters.
(Overrides
GH_ActiveObject.Locked
.)Public Property
Message
Gets or sets a custom message to be displayed underneath the component. This message is not serialized and should be assigned on every solution anew.
Public Property
MutableNickName
Gets or sets a value that enables Nick name changes through the menu. The default is TRUE.
(Inherited from GH_ActiveObject.)
Public Property
Name
Gets or sets the name of the object. This field typically remains fixed during the lifetime of an object.
(Inherited from GH_InstanceDescription.)
Public Property
NickName
Gets or sets the nickname of the object. This field can be changed by the user.
(Inherited from GH_InstanceDescription.)
Public Property
Obsolete
Gets whether this object is obsolete. Default implementation returns true if the class name contains the string “OBSOLETE” or if this class has been decorated with the ObsoleteAttribute. You are free to override this if you want, but I suggest adding the ObsoleteAttribute instead.
(Inherited from GH_DocumentObject.)
Public Property
Params
Gets the parameter manager object for this component.
Public Property
Phase
Gets or sets the solution phase this object is currenly in.
(Inherited from GH_ActiveObject.)
Public Property
PrincipalParameterIndex
Gets or sets the principal parameter index override. Negative indices or indices larger than or equal to the input parameter count will be ignored and regular principal parameter detection will kick in.
Public Property
ProcessorTime
Gets the total processor time (profiler) spend by this component and all input parameters.
(Overrides
GH_ActiveObject.ProcessorTime
.)Public Property
RunCount
Gets a value indicating how many times the SolveInstance method was called on this component during the last solution. This property will return -1 if no valid runcount is available.
Public Property
RuntimeMessageLevel
Returns the worst case runtime warning level of me and all my parameters
(Overrides
GH_ActiveObject.RuntimeMessageLevel
.)Public Property
SubCategory
Gets or sets the SubCategory in which this object belongs. If HasSubCategory() returns false, this field has no meaning.
(Inherited from GH_InstanceDescription.)
Methods
Name
Description
Public Method
AddedToDocument
Overrides the AddedToDocument method and delegates the call to all parameters.
(Overrides
GH_DocumentObject.AddedToDocument(GH_Document)
.)Public Method
AddRuntimeMessage
Add a new message to this object. Valid message type flags are Warning and Error. If the Message string is empty or zero-length no message is added.
(Inherited from GH_ActiveObject.)
Protected method
AfterSolveInstance
Override this method if you want to be called after the last call to SolveInstance.
Protected method
AppendAdditionalComponentMenuItems
Override this function if you want to insert some custom menu items in your derived Component class. Items will be added between List Matching items and parameter menus.
Public Method
AppendAdditionalMenuItems
Adds typical component type items to the context menu: 1. Data comparison types 2. Custom (overridden) items 3. Nested input parameter context menu items 4. Nested output parameter context menu items
(Overrides
GH_ActiveObject.AppendAdditionalMenuItems(ToolStripDropDown)
.)Public Method
AppendMenuItems
This function is called when a context menu is about to be displayed. Override it to set custom items. GH_ActiveObject will already populate the menu with default items, if you merely wish to insert object-specific menu item, consider overriding AppendAdditionalMenuItems instead.
(Inherited from GH_ActiveObject.)
Protected method
AssignInitCodeToInputParameter
Utility function for parsing and assigning init codes. This only works for standard parameter types.
Public Method
BakeGeometry(RhinoDoc, List.Guid.)
Public Method
BakeGeometry(RhinoDoc, ObjectAttributes, List.Guid.)
Protected method
BeforeSolveInstance
Override this method if you want to be called before the first call to SolveInstance.
Public Method
ClearData
Clear the data inside this component and all output parameters.
(Overrides
GH_ActiveObject.ClearData.
.)Public Method
ClearRuntimeMessages
Clears all runtime messages in me and my parameters
(Overrides
GH_ActiveObject.ClearRuntimeMessages.
.)Public Method
CollectData
Calls CollectData on all input parameters and makes sure the Component and all associated parameters are left in a valid state.
(Overrides
GH_ActiveObject.CollectData.
.)Public Method
ComputeData
Compute all data and fill out all output parameters.
(Overrides
GH_ActiveObject.ComputeData.
.)Public Method
CopyFrom
Copy all fields (except the instance ID) from another instance description.
(Inherited from GH_InstanceDescription.)
Public Method
CreateAttributes
Create new attributes.
(Overrides
GH_DocumentObject.CreateAttributes.
.)Public Method
DependsOn
Returns True is any one of my input parameters depends on the source.
(Overrides
GH_ActiveObject.DependsOn(IGH_ActiveObject)
.)Protected method
DestroyIconCache
Call this method to erase the existing icon cache. You must call this if you want to change the display icon of an object.
(Inherited from GH_DocumentObject.)
Protected methodStatic Member
DocumentAngleTolerance
Gets the Angle tolerance (in radians) for the currently active Rhino document.
Public Method
DocumentContextChanged
Overrides the DocumentContextChanged method and delegates the call to all parameters.
(Overrides
GH_DocumentObject.DocumentContextChanged(GH_Document, GH_DocumentContext)
.)Protected methodStatic Member
DocumentTolerance
Gets the Absolute tolerance for the currently active Rhino document.
Public Method
DrawViewportMeshes
Draw preview meshes for this component and all associated parameters.
Public Method
DrawViewportWires
Draw preview wires for this component and all associated parameters.
Protected method
ExpireDownStreamObjects
Expire all objects that depend on any of the output parameters.
(Overrides
GH_ActiveObject.ExpireDownStreamObjects.
.)Public Method
ExpirePreview
Call this function when you suspect that the preview has expired for this object. This will cause the display cache to be eradicated.
(Inherited from GH_DocumentObject.)
Public Method
ExpireSolution
Informs the document that owns this object that the solution has expired. The current object will be set to BLANK as a result. This method is recursive, it will also expire any and all objects which depend on this object. If you want a less destructive expiration, consider using ClearData(). If this object is already Blank, you should consider not expiring it.
(Inherited from GH_ActiveObject.)
Protected method
GenerateDefaultHTMLCreates the default component help topic, including all parameter lists.
Protected method
GenerateParameterHelp.
Create an HTML string that lists names and descriptions for input and output parameters.
Protected method
GenerateParameterHelp(IGH_Param)
Generate HTML string for a single parameter.
Protected method
GetValue(String, Boolean)
Get a boolean value from the component value table.
(Inherited from GH_DocumentObject.)
Protected method
GetValue(String, Double)
Get a double value from the component value table.
(Inherited from GH_DocumentObject.)
Protected method
GetValue(String, Color)
Get a color value from the component value table.
(Inherited from GH_DocumentObject.)
Protected method
GetValue(String, Int32)
Get an integer value from the component value table.
(Inherited from GH_DocumentObject.)
Protected method
GetValue(String, String)
Get a string value from the component value table.
(Inherited from GH_DocumentObject.)
Protected method
HtmlHelp_SourceReturn a String which contains HTML formatted source for the help topic. If you want to pass a URL that points to a remote page, then prefix the URL with a GOTO: tag, like so: GOTO:http://www.YourWebAddressHere.com
(Overrides GH_DocumentObject.HtmlHelp_Source..)
Public Method
IsolateObject
Sever the connections of all input and output parameters.
(Overrides
GH_DocumentObject.IsolateObject.
.)Protected method
Menu_AppendBakeItem
Append the default Bake menu item.
(Inherited from GH_ActiveObject.)
Protected method
Menu_AppendEnableItem
Append the default Enable/Disable menu item.
(Inherited from GH_ActiveObject.)
Protected method
Menu_AppendObjectHelp
Appends the default object Help menu item.
(Inherited from GH_DocumentObject.)
Protected method
Menu_AppendObjectName
Appends the old-fashioned object name menu item. If you also want the Display mode toggle then use Menu_AppendObjectNameEx()
(Inherited from GH_DocumentObject.)
Protected method
Menu_AppendObjectNameEx
Appends the default object name + display mode menu item.
(Inherited from GH_DocumentObject.)
Protected method
Menu_AppendPreviewItem
Append the default Show/Hide preview menu item.
(Inherited from GH_ActiveObject.)
Protected method
Menu_AppendPublish
Appends the default item for publishing to RCP. This menu will only appear if the current class implement IRcpAwareObject
(Inherited from GH_DocumentObject.)
Protected method
Menu_AppendRuntimeMessages
Append the default warnings and errors menu items.
(Inherited from GH_ActiveObject.)
Public Method
MovedBetweenDocuments
Overrides the MovedBetweenDocuments method and delegates the call to all parameters.
(Overrides
GH_DocumentObject.MovedBetweenDocuments(GH_Document, GH_Document)
.)Public Method
NewInstanceGuid.
Generate a new random instance GUID
(Inherited from GH_InstanceDescription.)
Public Method
NewInstanceGuid(Guid)
Set the instance ID to be a specific GUID. This is very dangerous, only use this function if you’re 6”4’ and your first name is David.
(Inherited from GH_InstanceDescription.)
Public Method
OnAttributesChanged
Raises the AttributesChanged event on the toplevel object.
(Inherited from GH_DocumentObject.)
Public Method
OnDisplayExpired
Raises the DisplayExpired event on the toplevel object.
(Inherited from GH_DocumentObject.)
Public Method
OnObjectChanged(GH_ObjectChangedEventArgs)
(Inherited from GH_DocumentObject.)
Public Method
OnObjectChanged(GH_ObjectEventType)
(Inherited from GH_DocumentObject.)
Public Method
OnObjectChanged(String)
(Inherited from GH_DocumentObject.)
Public Method
OnObjectChanged(GH_ObjectEventType, Object)
(Inherited from GH_DocumentObject.)
Public Method
OnObjectChanged(String, Object)
(Inherited from GH_DocumentObject.)
Public Method
OnPingDocument
Raise the PingDocument Event on the toplevel object and try to find the document which owns this object.
(Inherited from GH_DocumentObject.)
Public Method
OnPreviewExpired
Raises the PreviewExpired event on the toplevel object.
(Inherited from GH_DocumentObject.)
Public Method
OnSolutionExpired
Raises the SolutionExpired event on the toplevel object. You probably want to call ExpireSolution() instead of this method directly.
(Inherited from GH_DocumentObject.)
Protected method
PostConstructor
The PostConstructor is called from within each constructor. DO NOT OVERRIDE THIS unless you know what you are doing.
Public Method
Read
Read all required data for deserialization from an IO archive.
(Overrides
GH_ActiveObject.Read(GH_IReader)
.)Public Method
ReadFull
GH_InstanceDescription does not by default serialize all fields. Use this function to read all fields from the archive. This method is compatible with the default Write()/Read() operations.
(Inherited from GH_InstanceDescription.)
Public Method
RecordUndoEvent(GH_UndoRecord)
Record an entire undo record.
(Inherited from GH_DocumentObject.)
Public Method
RecordUndoEvent(String)
Record a generic object change undo event.
(Inherited from GH_DocumentObject.)
Public Method
RecordUndoEvent(String, IGH_UndoAction)
Record a specific object change undo event.
(Inherited from GH_DocumentObject.)
Protected method
RegisterInputParams
Declare all your input parameters here.
Protected method
RegisterOutputParams
Declare all your output parameters here.
Public Method
RegisterRemoteIDs
Registers all my input parameters with the UUID_LookUpTable
(Overrides
GH_ActiveObject.RegisterRemoteIDs(GH_GuidTable)
.)Public Method
RemovedFromDocument
Overrides the RemovedFromDocument method and delegates the call to all parameters.
(Overrides
GH_DocumentObject.RemovedFromDocument(GH_Document)
.)Public Method
RuntimeMessages
Gets the list of cached runtime messages that were recorded during solver-time processes. For components, the set of runtime messages also includes input and output parameters.
(Overrides
GH_ActiveObject.RuntimeMessages(GH_RuntimeMessageLevel)
.)Public Method
SDKCompliancy
Test whether this object is compliant with a given Rhino version.
(Inherited from GH_ActiveObject.)
Public Method
SetIconOverride
Set a new custom icon override for this object.
(Inherited from GH_DocumentObject.)
Protected method
SetValue(String, Boolean)
Set a named value. This value will be serialized with the component.
(Inherited from GH_DocumentObject.)
Protected method
SetValue(String, Double)
Set a named value. This value will be serialized with the component.
(Inherited from GH_DocumentObject.)
Protected method
SetValue(String, Color)
Set a named value. This value will be serialized with the component.
(Inherited from GH_DocumentObject.)
Protected method
SetValue(String, Int32)
Set a named value. This value will be serialized with the component.
(Inherited from GH_DocumentObject.)
Protected method
SetValue(String, String)
Set a named value. This value will be serialized with the component.
(Inherited from GH_DocumentObject.)
Protected method
SolveInstance
This function will be called (successively) from within the ComputeData method of this component.
Public Method
TriggerAutoSave.
Triggers the AutoSave function on the owner document with the object_changed flag.
(Inherited from GH_DocumentObject.)
Public Method
TriggerAutoSave(GH_AutoSaveTrigger)
Triggers the AutoSave function on the owner document with a custom flag.
(Inherited from GH_DocumentObject.)
Public Method
TriggerAutoSave(Guid)
Triggers the AutoSave function on the owner document with the object_changed flag.
(Inherited from GH_DocumentObject.)
Public Method
TriggerAutoSave(GH_AutoSaveTrigger, Guid)
Triggers the AutoSave function on the owner document with a custom flag.
(Inherited from GH_DocumentObject.)
Protected method
ValuesChanged
Override this method if you want to respond to changes to the value table. The base implementation is empty, so you don’t have to call it.
(Inherited from GH_DocumentObject.)
Public Method
Write
Write all required data for deserialization to an IO archive.
(Overrides
GH_ActiveObject.Write(GH_IWriter)
.)Public Method
WriteFull
GH_InstanceDescription does not by default serialize all fields. Use this function to write all fields to the archive. This method is compatible with the default Write()/Read() operations.
(Inherited from GH_InstanceDescription.)
Events
Name
Description
Public Event
AttributesChanged
Raised whenever the number or kind of attributes changes. This event is handled by GH_Documents who subsequently wipe their attribute caches.
(Inherited from GH_DocumentObject.)
Public Event
DisplayExpired
Raised whenever the display (on the Canvas) of a certain object becomes invalid.
(Inherited from GH_DocumentObject.)
Public Event
ObjectChanged
(Inherited from GH_DocumentObject.)
Public Event
PingDocument
Raised whenever an object needs to know which GH_Document it belongs to.
(Inherited from GH_DocumentObject.)
Public Event
PreviewExpired
Raised whenever the display (in the Rhino viewports) of a certain object becomes invalid.
(Inherited from GH_DocumentObject.)
Public Event
SolutionExpired
Raised whenever the solution of a certain object becomes invalid.
(Inherited from GH_DocumentObject.)
Fields
Name
Description
Protected field
m_attributes(Inherited from GH_DocumentObject.)