TclPlugin

Plug-in support for the Tcl interpreter.

Inputs

ents
An entity table.
src
A value table.
begin
A procedure to be called on the begin event (optional).
onrecord
A procedure to be called on the onrecord event.
end
A procedure to be called on the end event (optional).
opt_str
Specify to pass a user-defined argument string (optional).
script
The file that contains the event procedure definitions.

Outputs

answer
A value table.

Comments

  • The entities in ents must match the binding of the values in src. For example, if src contains elemental scalars, ents must contain elements from the same pool.
  • The onrecord procedure is mandatory, begin and end procedures are optional.

Syntax

Requires *RegisterResultMathPlugin entry in preference file. See the Configuration section.

XML Example

<call name="TclPlugin" ents="ent_tab" src="src_tab" 
begin="begin_proc" onrecord="record_proc" 
end="end_proc" 
script="tcl_script_filepath" 
answer="answer" />
The query and action events that are added to the Tcl interpreter accept string arguments (case insensitive), and are as follows:
Query/Action Function Description
GetTableInfo Supports table queries and accepts a single argument:
  • label: returns the table label.
  • domain: returns the table domain (“real” or “complex”).

GetTableInfo can be called in the Begin and End events.

GetRecordInfo Supports record queries and accepts the following arguments:
  • id: returns the entity ID attached to the value record.
  • partid: returns the part ID attached to the element (returns 0 for values not bound to elements).
  • config: returns the element configuration number.
  • data: returns the values in the record as a space-separated number.
  • tensor: valid for tensor value records only and accepts a 2nd parameter to extract invariants:
    • p1 – major principal
    • p2 – mid principal
    • p3 – minor principal
    • von – vonMises
  • vector: valid for vector values records only and accepts a 2nd parameter to extract invariants:
    • mag – vector magnitude.

GetRecordInfo can be called in the OnRecord event only.

AddRecord Sends values to the destination table and accepts a string with an ID, followed by a space-separated list of values. For example, when adding a vector value, the call would appear as:

AddRecord “$ent_id $vec_val”

where:

ent_id is a variable that evaluates to the ID.

vec_val is a variable that evaluates to three vector components.

GetOption

GetOption(key)

Returns the string passed in the argument “opt_str” if specified, or the optional argument associated with key.
ThrowException Sends a message to the controlling application and terminates execution of the plug-in operation. The syntax is as follows:

ThrowException $err_string

When a scripted plugin is run from HyperView, the exception string is output in the tk console window.