In this tutorial, you will learn about:
• | Export template language |
• | How to register the template |
• | How to export plot data to a file |
Export Template: is 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.
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:
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 |
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) |
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.
1. | Go to <installation directory>\hw\prefinc. |
2. | Open preference_plot.mvw and add the following command that registers an export template with a session. |
*BeginDefaults()
*BeginPlotDefaults()
*AddExportFormat(par1,/homes/.../_madymo_export.tpl,par2)
*EndPlotDefaults()
*EndDefaults()
Above is a small sample of a preference_plot.mvw file that registers a new template (madymo_export.tpl) with a session.
• | This file allows the user to customize sessions by specifying defaults or defining external files that should be able to interact with the user’s session. |
Note: | The content of the parameter par1 is the name that shows up in the selection list. The parameter par2 specifies the extension of the files that is used for exporting the data: export.par2. |
Exercise: Export Template Example for MADYMO
Step 1: Create a Template that makes a file format for a function in MADYMO
1. | Add the commands below to a text file named madymo_export.tpl. |
The statement on the right is an explanation of the command.
{ |
|
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 |
|
} |
Step 2: Register the Export Template.
1. | From Tools menu, select Readers, Writers, and Functions…. |
2. | Go to Export Templates tab. |
3. | Browse the template created for Madymo. |
4. | Give the Template a name. |
5. | Click Register… and OK. |
Step 3: Export plot data:
1. | From the File menu, select Export > Curves. |
2. | Enter a file name for the destination file. |
-Or -
Select an existing file using the file browser.
3. | For Format, select the file you just registered. |
4. | Specify a range of pages. |
5. | Click Apply. |
Plot data from the specified pages are exported to the file.
The below data file is created after exporting curves in this Madymo format:
!vehicle acceleration
151
0.000000 13.591910
1.000000 12.144580
2.000000 10.850770
3.000000 10.180930
4.000000 9.921851
5.000000 9.995111
6.000000 10.342690
7.000000 11.209030
...
...
147.000000 132.563400
148.000000 130.487300
149.000000 129.073800
150.000000 127.332800