HG-4000: Create an Export Template
In this tutorial, you will learn how to export template language, register the template, and export plot data to a file.
- Export Template
- A file that contains instructions for exporting curve data into files. The instructions contained in an Export Template file are in an uncompiled type of programming language called Export. An Export Template tells the program in which format the data should be written into the file.
- Templex and Export Template Language Statements:
- The language of Export Templates follows a mixture of Templex commands plus some
additional special statements. For the export of curves only a few
statements are needed, as shown below:
Table 1. Templex Commands indexofmin(i) Index of the minimum of a vector (not the minimum itself). numpts(x) Dimension of the vector X. table() Export of vectors organized in columns. for – endloop Loop if – else – endif Logics Table 2. Special Export Commands cr() New line curvex(i) X vector of curve i. curvey(i) Y vector of curve i. curvelabel(i) Export of the legend of curve i. list Export of vectors in rows. margins(0,30) Length of a line. numcurves() Number of curves in a window. ; End of a command (except loops and logics). - Registering an export template
- The format selection list in the Export Curves... panel contains, by default, ten formats. Via the preferences file, registered templates are added to this list. Registration is done using the preferences file or via the Tools menu.
Create a Template for a MADYMO Function File Format
{ |
|
Row_1="!vehicle acceleration"; |
Set variable for the comment in line1. |
nc = numcurves(); |
Set number of curves |
lc = nc - 1 |
|
for (i = 0; i < nc; i++) |
Loop for the number of curves |
x = curvex(i); |
Set the x-vector of curve i |
y = curvey(i); |
Set the y-vector of curve i |
t = numpts(x); |
Set the number of points |
if (!numpts(x)) |
If curve is switched off don’t export |
else |
|
Row_1; cr(); |
Output for Line 1, label |
t, %5i; cr(); |
Output for Line 2, number of points |
table(x, y, "%10.6f %11.6f", 0, t -
1); |
Output Line 3 to t-1 with the table command |
endif |
|
if (i != lc) |
After every exported curve set an empty line |
cr(); |
|
endif |
|
endloop |
|
} |