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.

Constructors

GH_Component

#
Custom blank constructor for naughty components.
protected internal GH_Component()

GH_Component

#
Constructor for this component. This function will call the PostConstructor which will initialize the parameters
protected GH_Component(
name,
The name of this component. Keep it short, single words are best.
nickname,
The abbreviation of this component. Keep it short, 1~5 character words are best.
description,
The description of this component. Be succinct but clear. You can supply whole sentences.
category,
The category of this component. The category controls in which tab the component will end up.
subCategory
the SubCategory for this component. The SubCategory controls in which panel the component will end up.
)

Fields

m_attributes

protected IGH_Attributes m_attributes
inherited fromGH_DocumentObject

Properties

Attributes

Gets or sets the attributes that are associated with this object. Only set custom attributes if you know what you are doing.
public IGH_Attributes Attributes { get; set; }
inherited fromGH_DocumentObject
Attributes

Category

Gets or sets the Category in which this object belongs. If HasCategory() returns false, this field has no meaning.
public virtual string Category { get; set; }
inherited fromGH_InstanceDescription
Category

ClippingBox

#
Gets the clipping box for all preview geometry drawn by this component and all associated parameters.
public virtual BoundingBox ClippingBox { get; }
ClippingBox

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.
public abstract Guid ComponentGuid { get; }
inherited fromGH_DocumentObject
ComponentGuid

DataComparison

#
Gets or sets the data matching algorithm for this component
[EditorBrowsable(EditorBrowsableState.Never)] public GH_DataComparison DataComparison { get; set; }
DataComparison

Description

Gets or sets the description of the object. This field typically remains fixed during the lifetime of an object.
public virtual string Description { get; set; }
inherited fromGH_InstanceDescription
Description

Exposure

Gets the exposure of this object in the Graphical User Interface. The default is to expose everywhere.
public virtual GH_Exposure Exposure { get; }
inherited fromGH_DocumentObject
Exposure

HasCategory

Gets whether or not the Category field has been set.
public bool HasCategory { get; }
inherited fromGH_InstanceDescription
HasCategory

HasSubCategory

Gets whether or not the SubCategory field has been set.
public bool HasSubCategory { get; }
inherited fromGH_InstanceDescription
HasSubCategory

HelpDescription

#
Override this method if you want the help topic content to be more than the Component description.
protected virtual string HelpDescription { get; }

Hidden

#
Gets or sets the hidden flag for this component. Does not affect Hidden flags on parameters associated with this component.
public bool Hidden { get; set; }
Hidden

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.
protected virtual Bitmap Icon { get; }
inherited fromGH_DocumentObject

Icon_24x24

The icon associated with this object.
public Bitmap Icon_24x24 { get; }
inherited fromGH_DocumentObject
Icon_24x24

Icon_24x24_Locked

The greyscale icon of this object.
public Bitmap Icon_24x24_Locked { get; }
inherited fromGH_DocumentObject
Icon_24x24_Locked

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.
public virtual bool IconCapableUI { get; }
inherited fromGH_ActiveObject

IconDisplayMode

Gets the current display mode of the object.
public GH_IconDisplayMode IconDisplayMode { get; set; }
inherited fromGH_DocumentObject
IconDisplayMode

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 bool InConstructor { get; }
InConstructor

InstanceDescription

#
public override string InstanceDescription { get; }

InstanceGuid

Gets the ID of this runtime instance.
public Guid InstanceGuid { get; }
inherited fromGH_InstanceDescription
InstanceGuid

Internal_Icon_24x24

Override this function to supply a custom icon. The result of this property is cached, so don't worry if icon retrieval is not very fast.
[EditorBrowsable(EditorBrowsableState.Never)] [Browsable(false)] protected virtual Bitmap Internal_Icon_24x24 { get; }
inherited fromGH_DocumentObject

IsBakeCapable

#
public virtual bool IsBakeCapable { get; }
IsBakeCapable

IsDataProvider

#
Components are never Data providers. Only the output parameters can be considered to be providers.
public sealed override bool IsDataProvider { get; }

IsPreviewCapable

#
If a single parameter is PreviewCapable, so is the component. Override this property if you need special Preview flags.
public virtual bool IsPreviewCapable { get; }
IsPreviewCapable

IsValidPrincipalParameterIndex

#
Gets whether the MasterParameterIndex property identifies a valid parameter.
public bool IsValidPrincipalParameterIndex { get; }

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.
public virtual IEnumerable<string> Keywords { get; }
inherited fromGH_InstanceDescription
Keywords

Locked

#
Gets or sets the Locked state for this Component. This also sets locked states for all input and output parameters.
public override bool Locked { get; set; }

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 string Message { get; set; }
Message

MutableNickName

Gets or sets a value that enables Nick name changes through the menu. The default is TRUE.
public bool MutableNickName { get; set; }
inherited fromGH_ActiveObject
MutableNickName

Name

Gets or sets the name of the object. This field typically remains fixed during the lifetime of an object.
public virtual string Name { get; set; }
inherited fromGH_InstanceDescription
Name

NickName

Gets or sets the nickname of the object. This field can be changed by the user.
public virtual string NickName { get; set; }
inherited fromGH_InstanceDescription
NickName

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.
public virtual bool Obsolete { get; }
inherited fromGH_DocumentObject
Obsolete

Params

#
Gets the parameter manager object for this component.
public GH_ComponentParamServer Params { get; }
Params

Phase

Gets or sets the solution phase this object is currenly in.
public GH_SolutionPhase Phase { get; set; }
inherited fromGH_ActiveObject
Phase

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 int PrincipalParameterIndex { get; set; }

ProcessorTime

#
Gets the total processor time (profiler) spend by this component and all input parameters.
public override TimeSpan ProcessorTime { get; }

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 int RunCount { get; }
RunCount

RuntimeMessageLevel

#
Returns the worst case runtime warning level of me and all my parameters
public sealed override GH_RuntimeMessageLevel RuntimeMessageLevel { get; }

SubCategory

Gets or sets the SubCategory in which this object belongs. If HasSubCategory() returns false, this field has no meaning.
public virtual string SubCategory { get; set; }
inherited fromGH_InstanceDescription
SubCategory

Methods

AddedToDocument

#
Overrides the AddedToDocument method and delegates the call to all parameters.
public override void AddedToDocument(
document
Document that now owns this object.
)

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.
public virtual void AddRuntimeMessage(
level,
Type of message. Only Warnings and Errors are recorded.
text
Content of message.
)
inherited fromGH_ActiveObject
AddRuntimeMessage

AfterSolveInstance

#
Override this method if you want to be called after the last call to SolveInstance.
protected virtual void AfterSolveInstance()

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.
protected virtual void AppendAdditionalComponentMenuItems()

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
public override void AppendAdditionalMenuItems()

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.
public override bool AppendMenuItems(
menu
Menu object to populate.
)
inherited fromGH_ActiveObject
If true, the menu will be displayed, if false the menu will be supressed.

AppendRenderGeometry

#
Append all geometry associated with this component to a render queue.
[EditorBrowsable(EditorBrowsableState.Never)] public virtual void AppendRenderGeometry()

AssignInitCodeToInputParameter

#
Utility function for parsing and assigning init codes. This only works for standard parameter types.
protected bool AssignInitCodeToInputParameter(
paramIndex,
Index of input parameter to assign.
code
Code to parse and assign.
)
True if the code was assigned, false if otherwise.

BakeGeometry

#
public virtual void BakeGeometry(
doc,
obj_ids
)
BakeGeometry

BakeGeometry

#
public virtual void BakeGeometry()
BakeGeometry

BeforeSolveInstance

#
Override this method if you want to be called before the first call to SolveInstance.
protected virtual void BeforeSolveInstance()

ClearData

#
Clear the data inside this component and all output parameters.
public override void ClearData()

ClearRuntimeMessages

#
Clears all runtime messages in me and my parameters
public sealed override void ClearRuntimeMessages()

CollectData

#
Calls CollectData on all input parameters and makes sure the Component and all associated parameters are left in a valid state.
public override void CollectData()

ComputeData

#
Compute all data and fill out all output parameters.
public override void ComputeData()

CopyFrom

Copy all fields (except the instance ID) from another instance description.
public void CopyFrom(
other
Object to mimic.
)
inherited fromGH_InstanceDescription

CreateAttributes

#
Create new attributes.
public override void CreateAttributes()
Remarks: Typically you do not have to override this.

DependsOn

#
Returns True is any one of my input parameters depends on the source.
public sealed override bool DependsOn(
potentialSource
Source to test for dependency.
)

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.
protected void DestroyIconCache()
inherited fromGH_DocumentObject

DocumentAngleTolerance

#
Gets the Angle tolerance (in radians) for the currently active Rhino document.
protected static double DocumentAngleTolerance()

DocumentContextChanged

#
Overrides the DocumentContextChanged method and delegates the call to all parameters.
public override void DocumentContextChanged(
document,
Document that owns this object.
context
The reason for this event.
)

DocumentTolerance

#
Gets the Absolute tolerance for the currently active Rhino document.
protected static double DocumentTolerance()

DrawViewportMeshes

#
Draw preview meshes for this component and all associated parameters.
public virtual void DrawViewportMeshes(
args
Display data used during preview drawing.
)
DrawViewportMeshes

DrawViewportWires

#
Draw preview wires for this component and all associated parameters.
public virtual void DrawViewportWires(
args
Display data used during preview drawing.
)
DrawViewportWires

ExpireDownStreamObjects

#
Expire all objects that depend on any of the output parameters.
protected override void ExpireDownStreamObjects()

ExpirePreview

Call this function when you suspect that the preview has expired for this object. This will cause the display cache to be eradicated.
public virtual void ExpirePreview(
redraw
)
inherited fromGH_DocumentObject
ExpirePreview

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.
public override void ExpireSolution(
recompute
If True, the document will be instructed to solve the new state.
)
inherited fromGH_ActiveObject

GenerateDefaultHTML

#
Creates the default component help topic, including all parameter lists.
protected GH_HtmlFormatter GenerateDefaultHTML()
Remarks: This formatter does not include the this-is-an-autogenerated-topic message

GenerateParameterHelp

#
Create an HTML string that lists names and descriptions for input and output parameters.
protected string GenerateParameterHelp()

GenerateParameterHelp

#
Generate HTML string for a single parameter.
protected string GenerateParameterHelp(
param
)

GetValue

Get a boolean value from the component value table.
protected bool GetValue(
valueName,
Name of boolean to retrieve.
default
Default value to return in case of missing named value.
)
inherited fromGH_DocumentObject
The boolean value with the given name of the default value.

GetValue

Get a color value from the component value table.
protected Color GetValue(
valueName,
Name of color to retrieve.
Color
default
Default value to return in case of missing named value.
)
inherited fromGH_DocumentObject
The color value with the given name of the default value.

GetValue

Get a double value from the component value table.
protected double GetValue(
valueName,
Name of double to retrieve.
default
Default value to return in case of missing named value.
)
inherited fromGH_DocumentObject
The double value with the given name of the default value.

GetValue

Get an integer value from the component value table.
protected int GetValue(
valueName,
Name of integer to retrieve.
default
Default value to return in case of missing named value.
)
inherited fromGH_DocumentObject
The integer value with the given name of the default value.

GetValue

Get a string value from the component value table.
protected string GetValue(
valueName,
Name of string to retrieve.
default
Default value to return in case of missing named value.
)
inherited fromGH_DocumentObject
The string value with the given name of the default value.

HtmlHelp_Source

#
Return 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
protected internal override string HtmlHelp_Source()
Remarks: You can use the GUI.GH_HtmlFormatter class to generate an HTML page which conforms to Grasshopper Help standards
The HTML default help topic for this component including all parameters

IsolateObject

#
Sever the connections of all input and output parameters.
public override void IsolateObject()

MovedBetweenDocuments

#
Overrides the MovedBetweenDocuments method and delegates the call to all parameters.
public override void MovedBetweenDocuments(
oldDocument,
Document that used to own this object.
newDocument
Document that now owns ths object.
)

NewInstanceGuid

Generate a new random instance GUID
public void NewInstanceGuid()
inherited fromGH_InstanceDescription
NewInstanceGuid

NewInstanceGuid

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.
public void NewInstanceGuid(
UUID
)
inherited fromGH_InstanceDescription
NewInstanceGuid

OnAttributesChanged

Raises the AttributesChanged event on the toplevel object.
public void OnAttributesChanged()
inherited fromGH_DocumentObject

OnDisplayExpired

Raises the DisplayExpired event on the toplevel object.
public void OnDisplayExpired(
redraw
If True, the canvas will be immediately redrawn.
)
inherited fromGH_DocumentObject
OnDisplayExpired

OnObjectChanged

public void OnObjectChanged()
inherited fromGH_DocumentObject
OnObjectChanged

OnObjectChanged

public void OnObjectChanged()
inherited fromGH_DocumentObject
OnObjectChanged

OnObjectChanged

public void OnObjectChanged()
inherited fromGH_DocumentObject
OnObjectChanged

OnObjectChanged

public void OnObjectChanged(
customEvent,
tag
)
inherited fromGH_DocumentObject
OnObjectChanged

OnObjectChanged

public void OnObjectChanged(
customEvent
)
inherited fromGH_DocumentObject
OnObjectChanged

OnPingDocument

Raise the PingDocument Event on the toplevel object and try to find the document which owns this object.
public GH_Document OnPingDocument()
inherited fromGH_DocumentObject
The document which owns this object if successful, or nothing if no document owns this object.
OnPingDocument

OnPreviewExpired

Raises the PreviewExpired event on the toplevel object.
public void OnPreviewExpired(
redraw
If True, the viewports will be immediately redrawn.
)
inherited fromGH_DocumentObject
OnPreviewExpired

OnSolutionExpired

Raises the SolutionExpired event on the toplevel object. You probably want to call ExpireSolution() instead of this method directly.
public void OnSolutionExpired(
recompute
If True, the solution will be immediately recalculated.
)
inherited fromGH_DocumentObject
OnSolutionExpired

PostConstructor

#
The PostConstructor is called from within each constructor. DO NOT OVERRIDE THIS unless you know what you are doing.
protected virtual void PostConstructor()

Read

#
Read all required data for deserialization from an IO archive.
public override bool Read(
reader
Object to read with.
)
True on success, false on failure.

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.
public virtual bool ReadFull(
reader
Writer for deserialization.
)
inherited fromGH_InstanceDescription
True on success, false on failure.

RecordUndoEvent

Record a specific object change undo event.
public Guid RecordUndoEvent(
undoName,
Name of undo record.
action
Undo action to record.
)
inherited fromGH_DocumentObject
The ID of the newly added record or Guid.Empty on failure.
RecordUndoEvent

RecordUndoEvent

Record a generic object change undo event.
public Guid RecordUndoEvent(
undoName
Name of undo record.
)
inherited fromGH_DocumentObject
The ID of the newly added record or Guid.Empty on failure.
RecordUndoEvent

RecordUndoEvent

Record an entire undo record.
public void RecordUndoEvent(
record
Record to push.
)
inherited fromGH_DocumentObject
RecordUndoEvent

RegisterInputParams

#
Declare all your input parameters here.
protected abstract void RegisterInputParams(
pManager
Use the pManager to register new parameters. pManager is never null.
)

RegisterOutputParams

#
Declare all your output parameters here.
protected abstract void RegisterOutputParams(
pManager
Use the pManager to register new parameters. pManager is never null.
)

RegisterRemoteIDs

#
Registers all my input parameters with the UUID_LookUpTable
public override void RegisterRemoteIDs()

RemovedFromDocument

#
Overrides the RemovedFromDocument method and delegates the call to all parameters.
public override void RemovedFromDocument(
document
Document that now no longer owns this object.
)

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.
public override IList<string> RuntimeMessages(
level
Runtime message type to retrieve.
)
A list of runtime message strings.

SDKCompliancy

Test whether this object is compliant with a given Rhino version.
public virtual bool SDKCompliancy(
exeVersion,
Rhino major release (4, 5, ...).
exeServiceRelease
Rhino minor (service) release.
)
inherited fromGH_ActiveObject
True if this object is compliant with the given Rhino release.
SDKCompliancy

SetIconOverride

Set a new custom icon override for this object.
public void SetIconOverride(
Bitmap
customIcon
Icon override. Should be a 24x24 image.
)
inherited fromGH_DocumentObject

SetValue

Set a named value. This value will be serialized with the component.
protected void SetValue(
valueName,
Name of value.
value
Value itself.
)
inherited fromGH_DocumentObject

SetValue

Set a named value. This value will be serialized with the component.
protected void SetValue(
valueName,
Name of value.
Color
value
Value itself.
)
inherited fromGH_DocumentObject

SetValue

Set a named value. This value will be serialized with the component.
protected void SetValue(
valueName,
Name of value.
value
Value itself.
)
inherited fromGH_DocumentObject

SetValue

Set a named value. This value will be serialized with the component.
protected void SetValue(
valueName,
Name of value.
value
Value itself.
)
inherited fromGH_DocumentObject

SetValue

Set a named value. This value will be serialized with the component.
protected void SetValue(
valueName,
Name of value.
value
Value itself.
)
inherited fromGH_DocumentObject

SolveInstance

#
This function will be called (successively) from within the ComputeData method of this component.
protected abstract void SolveInstance(
DA
Data Access object. Use this object to retrieve data from input parameters and assign data to output parameters.
)

TriggerAutoSave

Triggers the AutoSave function on the owner document with the object_changed flag.
public void TriggerAutoSave()
inherited fromGH_DocumentObject
TriggerAutoSave

TriggerAutoSave

Triggers the AutoSave function on the owner document with a custom flag.
public void TriggerAutoSave(
trigger,
Reason for the autosave operation. It is possible that a user has decided to avoid autosave events for specific types, so if you can, try and provide a correct trigger flag.
id
ID of autosave event. Consecutive autosave requests with the same ID will be ignored.
)
inherited fromGH_DocumentObject
TriggerAutoSave

TriggerAutoSave

Triggers the AutoSave function on the owner document with a custom flag.
public void TriggerAutoSave(
trigger
Reason for the autosave operation. It is possible that a user has decided to avoid autosave events for specific types, so if you can, try and provide a correct trigger flag.
)
inherited fromGH_DocumentObject
TriggerAutoSave

TriggerAutoSave

Triggers the AutoSave function on the owner document with the object_changed flag.
public void TriggerAutoSave(
id
ID of autosave event. Consecutive autosave requests with the same ID will be ignored.
)
inherited fromGH_DocumentObject
TriggerAutoSave

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.
protected virtual void ValuesChanged()
inherited fromGH_DocumentObject

Write

#
Write all required data for deserialization to an IO archive.
public override bool Write(
writer
Object to write with.
)
True on success, false on failure.

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.
public virtual bool WriteFull(
writer
Writer for serialization.
)
inherited fromGH_InstanceDescription
True on success, false on failure.

Events

AttributesChanged

Raised whenever the number or kind of attributes changes. This event is handled by GH_Documents who subsequently wipe their attribute caches.
public event IGH_DocumentObject.AttributesChangedEventHandler AttributesChanged
inherited fromGH_DocumentObject
AttributesChanged

DisplayExpired

Raised whenever the display (on the Canvas) of a certain object becomes invalid.
inherited fromGH_DocumentObject
DisplayExpired

PingDocument

Raised whenever an object needs to know which GH_Document it belongs to.
inherited fromGH_DocumentObject
PingDocument

PreviewExpired

Raised whenever the display (in the Rhino viewports) of a certain object becomes invalid.
inherited fromGH_DocumentObject
PreviewExpired

SolutionExpired

Raised whenever the solution of a certain object becomes invalid.
public event IGH_DocumentObject.SolutionExpiredEventHandler SolutionExpired
inherited fromGH_DocumentObject
SolutionExpired