IGH_TaskCapableComponent
ReferencesGH_Component that can choose to support the use of Tasks to compute solutions When UseTasks returns true, the component has it's SolveInstance enumeration called twice. The first pass (InPreSolve=True) is intended solely for collecting data and starting calculation tasks. The second pass (InPreSolve=False) takes results or the tasks and sets the output.
Properties
Attributes
Gets or sets the attributes that are associated with this object. Only set custom attributes if you know what you are doing.
Category
Gets or sets the Category in which this object belongs. If HasCategory() returns false, this field has no meaning.
ClippingBox
Gets the clipping box for this object. The clipping box is typically the union of the boundingboxes of all the geometry that is drawn by this object.
Returns: The clipping box for this object.
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.
DataComparison
A data combination flag
Description
Gets or sets the description of the object. This field typically remains fixed during the lifetime of an object.
Exposure
Gets the exposure of this object in the Graphical User Interface.
Icon_24x24
Bitmap Icon_24x24 { get; }
The icon associated with this object.
Icon_24x24_Locked
Bitmap Icon_24x24_Locked { get; }
The greyscale icon of this object.
IconDisplayMode
Gets the current display mode of the object.
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.
InPreSolve
#Is set to True by the framework right before a "use tasks" pass is made on SolveIntance calls. When True, SolveInstance should be using Tasks to start calculations on input data. When False, SolveInstance should be setting the output data by either using the result of a task or directly computing the results.
InstanceDescription
Gets a description of the current state of the object. This field is usually the same as the Description() field, but it might be variable when overridden.
IsBakeCapable
Gets a value indicating whether or not the object can potentially Bake data in its current state.
IsDataProvider
Gets whether or not this object is capable of emitting data.
IsPreviewCapable
Gets a value indicating whether or not this object (in its current state) can draw geometric previews at all.
IsValidMasterParameterIndex
Gets whether the MasterParameterIndex property identifies a valid parameter.
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.
Locked
Gets or sets the locked flag of this object. Locked objects are ignored during solutions.
MasterParameterIndex
Gets or sets the master parameter index override. Negative indices or indices larger than or equal to the input parameter count will be ignored and regular master parameter detection will kick in.
Message
Gets or sets a custom message to be displayed underneath the component.
MutableNickName
Gets or sets a value that enables Nick name changes through the menu. The default is TRUE.
Name
Gets or sets the name of the object. This field typically remains fixed during the lifetime of an object.
NickName
Gets or sets the nickname of the object. This field can be changed by the user.
Params
Gets the Params object that managed input and output parameters.
Phase
Gets the solution phase in which this object is currently stuck.
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.
RuntimeMessageLevel
Gets the worst-case level of all messages. I.e. if only warnings have been recorded, the level will be ::warning. If even a single error exists, the level will be ::error.
SubCategory
Gets or sets the SubCategory in which this object belongs. If HasSubCategory() returns false, this field has no meaning.
UseTasks
#Returns True if the component is set to support tasks. Components can have this feature turned on/off. Note that even if UseTasks returns True, there is a chance that a multipass task based solution may not be invoked depending on if multiple calls need to be made during enumeration. You must pay attention to the value of InPreSolve during SolveInstance. The set version of this property can be called by the framework if we want to provide a technique to globally turn on/off task support for all components in a definition.
Methods
AddedToDocument
This method will be called when an object is added to a document.
Parameters:
| document (GH_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.
Parameters:
| Type (GH_RuntimeMessageLevel) | Type of message. Only Warnings and Errors are recorded. |
| Message (string) | Content of message. |
BakeGeometry
Bake all the goemetry in this object in the given Rhino document.
BakeGeometry
Bake all the goemetry in this object in the given Rhino document.
Parameters:
| doc (RhinoDoc) | Document to bake into. |
| att (ObjectAttributes) | Attributes to use for baked geometry. |
| obj_ids (List<Guid>) | All bake objects IDs will be appended to this list. |
ClearData
void ClearData()
This function is called whenever the object needs to clear all solution data. This usually amounts to wiping volatile caches and messages. This function will not affect any other objects, but it will set the Phase flag to Blank
ClearRuntimeMessages
void ClearRuntimeMessages()
Clear all message lists.
CollectData
void CollectData()
This function is called whenever the object is required to collect all data. Either from Persistent records, from source params or whatever. This step is only performed if the phase flag is Blank or Failed. Upon completion, the phase flag will be set to Collected
ComputeData
void ComputeData()
This function is called whenever the object is required to generate new data. This step is only performed by some objects and only when the Phase flag is Collected. Upon completion, the Phase will be Computed. If this object throws exceptions, it is the responsibility of the caller to set the Phase flag to Failed.
CreateAttributes
void CreateAttributes()
Create new default attributes for this object. You should only call this function when the Attributes() field is null.
DependsOn
Solve the inheritance relationship between this object and a potential parental object.
Parameters:
| PotentialSource (IGH_ActiveObject) |
DocumentContextChanged
This method will be called when the document that owns this object moves into a different context.
Parameters:
| document (GH_Document) | Document that owns this object. |
| context (GH_DocumentContext) | The reason for this event. |
DrawViewportMeshes
Implement this function to draw all shaded meshes. If the viewport does not support shading, this function will not be called.
Parameters:
| args (IGH_PreviewArgs) | Draw operation arguments. |
DrawViewportWires
Implement this function to draw all wire and point geometry previews.
Parameters:
| args (IGH_PreviewArgs) | Draw operation arguments. |
ExpirePreview
Call this function when you suspect that the preview has expired for this object. This will cause the display cache to be eradicated.
Parameters:
| redraw (bool) |
ExpireSolution
Call this function whenever you do something which expires the current solution. This will make sure all caches are erased, all downstream objects are expired and that the event is raised. The default implementation merely places a call to OnSolutionExpired(), override this function in derived classes to make sure you clear local data caches and expire downstream objects.
Parameters:
| recompute (bool) | If True, the solution will be recomputed straight away. |
IsolateObject
void IsolateObject()
Destroy all connections to other objects.
MovedBetweenDocuments
This method will be called when an object is moved from one document to another.
Parameters:
| oldDocument (GH_Document) | Document that used to own this object. |
| newDocument (GH_Document) | Document that now owns ths object. |
NewInstanceGuid
void NewInstanceGuid()
Generate a new random instance GUID
NewInstanceGuid
Set the instance ID to be a specific GUID. This is very dangerous, only use this function if you're 6"4' and called David.
Parameters:
| UUID (Guid) |
OnAttributesChanged
void OnAttributesChanged()
Raises the AttributesChanged event on the toplevel object.
OnDisplayExpired
Raises the DisplayExpired event on the toplevel object.
Parameters:
| redraw (bool) | If True, the canvas will be immediately redrawn. |
OnObjectChanged
Raises the ObjectChanged event on the current (!not the top level!) object.
Parameters:
| e (GH_ObjectChangedEventArgs) | Fully constructed event arguments. |
OnObjectChanged
Raises the ObjectChanged event on the current (!not the top level!) object.
Parameters:
| eventType (GH_ObjectEventType) | Type of change. |
| tag (object) | Tag to apply to the event arguments. |
OnObjectChanged
Raises the ObjectChanged event on the current (!not the top level!) object.
Parameters:
| eventType (GH_ObjectEventType) | Type of change. |
OnObjectChanged
Raises the ObjectChanged event on the current (!not the top level!) object.
OnObjectChanged
Raises the ObjectChanged event on the current (!not the top level!) object.
Parameters:
| customEvent (string) | Custom change type name. |
OnPingDocument
Raise the PingDocument Event on the toplevel object and try to find the document which owns this object.
Returns: The document which owns this object if successful, or nothing if no document owns this object.
OnPreviewExpired
Raises the PreviewExpired event on the toplevel object.
Parameters:
| redraw (bool) | If True, the viewports will be immediately redrawn. |
OnSolutionExpired
Raises the SolutionExpired event on the toplevel object.
Parameters:
| recompute (bool) | If True, the solution will be immediately recalculated. |
Read
This method is called whenever the instance is required to deserialize itself.
Parameters:
| reader (GH_IReader) | Reader object to deserialize from. |
Returns: True on success, false on failure.
RecordUndoEvent
Record a specific object change undo event.
Parameters:
| undoName (string) | Name of undo record. |
| action (IGH_UndoAction) | Undo action to record. |
Parameters:
| undoName (string) | Name of undo record. |
Parameters:
| record (GH_UndoRecord) | Record to push. |
RegisterRemoteIDs
If this object depends on Rhino Objects, you must register the UUIDs of those objects. Failure to do so will result in faulty event handling.
Parameters:
| id_list (GH_GuidTable) | The object ID database Grasshopper is responsive to. |
RemovedFromDocument
This method will be called when an object is removed from a document.
Parameters:
| document (GH_Document) | Document that now no longer owns this object. |
RequestTaskCancellation
#void RequestTaskCancellation()
Called by the framework when solving has been interrupted and tasks do not need to complete.
RuntimeMessages
Gets the list of cached runtime messages that were recorded during solver-time processes.
Parameters:
| level (GH_RuntimeMessageLevel) | Runtime message type to retrieve. |
Returns: A list of runtime message strings.
SDKCompliancy
Test whether this object is compliant with a given Rhino version.
TriggerAutoSave
void TriggerAutoSave()
Triggers the AutoSave function on the owner document with the object_changed flag.
TriggerAutoSave
Triggers the AutoSave function on the owner document with a custom flag.
Parameters:
| trigger (GH_AutoSaveTrigger) | 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 (Guid) | ID of autosave event. Consecutive autosave requests with the same ID will be ignored. |
TriggerAutoSave
Triggers the AutoSave function on the owner document with a custom flag.
Parameters:
| trigger (GH_AutoSaveTrigger) | 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. |
TriggerAutoSave
Triggers the AutoSave function on the owner document with the object_changed flag.
Parameters:
| id (Guid) | ID of autosave event. Consecutive autosave requests with the same ID will be ignored. |
Write
This method is called whenever the instance is required to serialize itself.
Parameters:
| writer (GH_IWriter) | Writer object to serialize with. |
Returns: 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.
DisplayExpired
Raised whenever the display (on the Canvas) of a certain object becomes invalid.
ObjectChanged
Raised whenever some property of the object changes that would affect remote instances.
PingDocument
Raised whenever an object needs to know which GH_Document it belongs to.
PreviewExpired
Raised whenever the display (in the Rhino viewports) of a certain object becomes invalid.
SolutionExpired
Raised whenever the solution of a certain object becomes invalid.