Using Plug-ins

Plug-ins Example

In some cases, an algorithm can not be implemented with the provided operators which deal with entire tables as inputs and outputs. A good example of this is the calculation of brittle failure factor of safety that requires logic and control flow for each and every record that is being processed:


Figure 1. Brittle Failure Factor of Safety

This type of calculation is ideally suited for an interpreter, where a user-defined script executes for each input value. Result Math contains an operator library that allows the user to extend it with Tcl, Templex, or even a compiled DLL.

The Tcl procedure that performs this calculation is:


Two functions are added to the Tcl interpreter that allow access to the inputs and a record storage interface:
  • GetRecordInfo – gets information about the current record.
  • AddRecord – stores the calculated value.
The following XML defines the input to this procedure and specifies the Tcl file as well as what procedure to call:


The call to the “TclPlugin” operator requires the following parameters:
  • src – the value table passed to the procedure.
  • ents – the entities that correspond to the source values (for stress, this is elements, for displacements, it would be nodes). This allows the part id attached to the element to be looked up with the GetRecordInfo function.
  • onrecord – this is the name of the procedure in the script file.
  • script – path to the script file that contains the onrecord procedure.
  • answer – the datatype output table.
The “TclPlugin” operator call behaves as any other built-in operator, and is preceded or followed by calls to other operators to leverage the speed of table-based operators along with the flexibility of calling user-defined scripts. The output for this example is:


Figure 2.