Using Recipes

Expressions Example

This example demonstrates the Result Math expression tag. This allows a sequence of calls to be reused across multiple data types, and provides another mechanism for extending the result module. The expression syntax supports parameter passing and nested calls to other expressions in order to maximize reuse and flexibility.
In the example below, a single expression is used by four different data types to calculate area:


The argument list for an expression is a comma-separated variable list. Variables are substituted into the expression during datatype evaluation, and are referenced using the @varname syntax. An expression may be decorated with an optional attribute child element in order to expose it to the HyperView Expression Builder (see the XML Command Reference section under <expression> for details).

The output for total area is:


Figure 1.
Some important points about this example:
  • In the call to the Area operator, the table referenced by the coords argument must override the current subcase with subcase[0] (which is the model subcase). This is because the expression is executed when the datatype is evaluated, which is not at the model step (it is at a step within a subcase). OptiStruct result output contains displacements, not coordinates.
  • The datatypes that are created use a special convention used within HyperWorks applications called scalar groups. The syntax is {group}:{subgroup}. All groups with the same name appear together with the subgroup items in a list box below the datatype selector.


    Figure 2.
  • The parts in the model do not reflect the parts defined in the input deck (using HM_COMMENTS). This model resource is made up of entities from the OP2 file, not the input deck, and has parts defined by property. The .dat file, when organized by HM_COMMENTS, will have nine parts, while the OP2 file has seven parts.