Node Output Example

This example demonstrates how to use template files to generate output files for nodes.

Assume that a particular analysis code requires the nodes in the data deck to appear in the following format:
1      8      16      24      32      40
NODE DATA
NODE        <id>     <x>     <y>     <z>*
.
.
.
END NODES
The following template generates the necessary output:
*text()
  *string("1      8      16      24      32      40")
  *end()
*output()

*nodes()
  *before()
    *string("NODE DATA")
    *end()
  *format()
    *string("NODE    ")
    *field(integer,id,8)
    *field(real,x,8)
    *field(real,y,8)
    *field(real,z,8)
    *string("*")
    *end()
  *after()
    *string("END NODES")
    *end()
*output()

The *text() command indicates the beginning of a simple text block that does not require database access.

The *nodes() command indicates the beginning of a node block. The following commands format all node entities in the HyperWorks Desktop database. The next command, *before(), instructs HyperWorks Desktop to execute the following commands on the before() level. *string() and *end() instruct HyperWorks Desktop to output the string contained in double quotes and perform a carriage return, respectively. The next command informs HyperWorks Desktop to execute the following commands on the format() level, or with each of the entities (nodes in this case). *string() instructs HyperWorks Desktop to place the item in double quotes in the output file. The extra spaces after the word NODE allow you to define a width, since the *string() command does not allow width definition. The next command is the first data request from the database.

The *field() command is how template files communicate with the HyperWorks Desktop database. The *field() command instructs HyperWorks Desktop to scan the database and retrieve the next piece of information for the output file. *field() takes three parameters: the output type, the name of the data accessed, and the width of the generated field. The output type can be integer, real, exponential, string, or hexadecimal. In this case, the data type is an integer. The next parameter is the data name. ID indicates that HyperWorks Desktop places the value of the node ID into this field. The last parameter is the width of the field. In this example, all fields are formatted to eight characters. The next three *field() commands place x, y, and z into the output file formatted as reals. *string() places the trailing asterisk on the end of the line. The *end() command (carriage return) is the last command placed into the format() level.

The *after() command indicates the last process level. This command instructs HyperWorks Desktop to execute the following commands on the after() level. The *string() command places the string contained in double quotes in the output file and the *end() command terminates the current line.

The *output() command processes the node entity output requests made in the preceding block. If the *output() command is missing, HyperWorks Desktop does not print anything to the file.

In addition to this example, the default HyperWorks Desktop templates serve as examples.