Customize the Environment
In this tutorial, you will learn how to customize the program using the preference file.
The Preference File:
A preference file is a script file that is read each time the program is started. It specifies default user settings such as the order in which colors are assigned, the default printer, default page layout, the auto save interval, and so on. A standard preference file can be created in the program installation directory which is executed every time a license is activated. An additional preference file can be created in your working directory that contains personal settings that either overwrite the standard preference file or are added to the existing settings in the standard preference file.
- All products, except HyperStudy: preferences.mvw
- HyperStudy only: preferences_hst.mvw
Seven include preference files are contained in the installation. These include preference files must be included in the main preference file, as they cannot be used as independent preference files. They are located under $ALTAIR_HOME/hwdesktop/hw/prefinc.
Organization of the Preference File:
*BeginDefaults()
*EndDefefaults()
*BeginDefinitions()
*EndDefinitions()
*BeginStatsTemplates()
*EndStatsTemplates()
*BeginPlotMacros()
*EndPlotMacros()
*BeginTemplexFunctions()
*EndTemplexFunctions()
The *BeginDefaults() block is unique to a preference file while the *BeginDefintions(), *BeginStatsTemplates(), *BeginPlotMacros(), and *BeginTemplexFunctions() blocks are the same as those found in script files.
- *Id statement
- The syntax for the *Id statement is: *Id("Release") where the release gives the program name and version.
- The *BeginDefaults - *EndDefaults block
- The *BeginDefaults() block is comprised of general defaults and seven subordinate statement blocks. The general defaults are declared first, and then as many sub-blocks as required. Each sub-block has the same structure as the main block. This means there is a *Begin statement, followed by the necessary statements, and closing the block with an *End statement.
- General defaults
- General defaults include the autosave interval, bubble help status, and
default printer settings. The block is delimited by these
statements:
*BeginDefaults() *EndDefaults()
- Model defaults
- Model defaults are used to customize the model tool bar and to add MDL
defaults for submitting mechanical system models to a solver. The block
is delimited by these
statements:
*BeginModelDefaults() *EndModelDefaults()
- Graphic defaults
- Graphic preferences such as model orientation and the part attributes
are specified in the graphics default block. The block is delimited by
these
statements:
*BeginGraphicDefaults() *EndGraphicDefaults()
- Plot defaults
- Plotting preferences for curves including colors, fonts, and note
defaults are specified in the plotting defaults block. The block is
delimited by these
statements:
*BeginPlotDefaults() *EndPlotDefaults()
- TextEditor defaults
- TextEditor preferences including text and background color and font
settings are specified in the text editor defaults block. The block is
delimited by these
statements:
*BeginTextEditorDefaults() *EndTextEditorDefaults()
- Page header defaults
- Page headers are specified in the page header block. The block is
delimited by these
statements:
*BeginHeader() *EndHeader()
- Page footer defaults
- Page footers are specified in the page footer block. The block is
delimited by these
statements:
*BeginFooter() *EndFooter()
To help you avoid compile problems, when you begin each block, start with the *Begin and *End block statements, then enter the remaining statements between the block delimiters.
Set the Auto Save Default
- Open TextView.
- From the menu bar, select autosave_bubble_help.mvw file, located in the preferences folder. and open the
-
After the *BeginDefaults() line, add the following
preference statement: *SetAutoSaveInterval(2)
This sets the autosave interval to two minutes. If this statement does not appear in the preferences.mvw file, the program sets the autosave interval to 10 minutes.
- Save the new preference file to your home directory as new_autosave_bubble_help.mvw by selecting from the menu bar.
Observe the Updated AutoSave Default
- Start the program.
-
Set the preference file by selecting
. This opens a window which lists all the registered preference files.
- Click Register and then browse for the file new_autosave_bubble_help.mvw.
-
Select new_autosave_bubble_help.mvw from the list of
Registered Preferences and then click Load to load the
preference file.
- Click the red X in the upper right corner to close the window
-
Wait for approximately two minutes and then list the contents of your working
directory.
A new file, autosave.mvw, will be present and contain a back up of the current session.
Set the Curve Defaults
- Open TextView.
- From the menu bar, select curve_defaults.mvw file, located in the preferences folder. and open the
- After the *BeginPlotDefaults() line, add the *ResetCurveDefaults() statement to ignore all previous *SetCurveDefaults() statements.
-
After the *ResetCurveDefaults() line, add the following
preference statements to set the curve defaults:
*SetCurveDefaults(1, 7, 0, 0, 0) *SetCurveDefaults(3, 16, 1, 0, 0) *SetCurveDefaults(5, 24, 2, 0, 0) *SetCurveDefaults(2, 32, 3, 0, 0) *SetCurveDefaults(4, 40, 0, 0, 0) *SetCurveDefaults(5, 48, 1, 0, 0)
A plotting preference block can contain several *SetCurveDefaults() statements. The program assigns curve attributes sequentially.
- Save the new preference file to your home directory as new_curve_defaults.mvw by selecting from the menu bar.
Observe the Updated Curve Default Settings
-
Create a page to add to the session using the page navigation tools in the
upper right corner.
- In the new window, click the Change Type icon () above the plot window and select HyperGraph.
- Change the page window layout to two windows per page, .
- Click Create Curves by File dialog. to open the
-
Open a plotting file:
- Click the file browser.
- Select the file ANGACC, located in the plotting folder.
- Click Open.
-
Select the data components and channels to plot:
- Select Angular Acceleration from the Y Type list.
- Select 50th% Hybrid3 – LOWER TORSO from the Y Component list.
- Select the All button from the Y Channel list.
- Click Apply and leave the dialog open.
- Set the file new_curve_defaults.mvw as the preference file by selecting .
-
Select Register and then browse for the file
new_curve_defaults.mvw.
This automatically loads new_curve_defaults.mvw file as the preference file.
-
Select new_curve_defaults.mvw from the list and click
Load.
- Click the red X in the upper right corner to close the window.
- If prompted to “Update all plots current default colors”, select No.
- Click on the second plot window on this page.
- Return to the Create Curves by File dialog.
-
Click Apply.
The color and line styles follow the defaults defined in the new_curve_defaults.mvw file instead of the program system defaults.
Set the Default Plot Colors
-
Create a page to add to the session using the page navigation tools in the
upper right corner.
- In the new window, click the Change Type icon () above the plot window and select TextView.
- From the menu bar, select plot_colors.mvw file, located in the preferences folder. and open the
-
After the *BeginPlotDefaults() line, add the following
preference statements to set the default plot colors:
*SetBackgroundColor(9) *SetGridlineColor(6) *SetZerolineColor(2) *SetFrameColor(7) *SetAxisColor(4) *SetHeaderColor(0) *SetFooterColor(3)
- Save the new preference file as new_plot_colors.mvw in your working directory. You cannot save files back to the default directory.
Observe the Updated Default Plot Colors
- Add a new page and select the HyperGraph.
- Create header and footer text.
- Register and Load the preference file new_plot_colors.mvw. If prompted to "Update all plots current default colors", click No.
- Add a new page, which will activate the new settings.
-
Create header and footer text.
Note: The colors of the various areas of the plot window reflect the defaults defined in the file new_plot_color.mvw rather than the program system defaults.
Set the Default Fonts for the Plot Area
- Add a new page and select the TextView.
- From the file browser on the toolbar, open the file font_defaults.mvw, located in the preferences folder.
-
After the *BeginPlotDefaults() line, add the following
preference statements:
*SetAxisLabelFont("Times New Roman", 1, 0, 8) *SetAxisTicFont("Times New Roman", 0, 1, 18)
The first placeholder sets the font name.
The second placeholder sets the font weight. 0 = normal (default), 1 = bold.
The third placeholder sets the slant, or font style. 0 = normal (default), 1 = italic.
The fourth placeholder sets the font size, 8, 10, 12, 14, 18, or 24 points.
Note: If the suggested font is not available on your system, use the name of a font available on your system. -
After the *SetAxisTicFont() line, add the following
preference statements to set the font defaults for the header and footer
text:
*SetLine1HeaderFont("Verdana",0,0,8) *SetLine2HeaderFont("Verdana",1,0,10) *SetLine3HeaderFont("Verdana",0,1,12) *SetLine1FooterFont("Tahoma",0,0,8) *SetLine2FooterFont("Tahoma",0,1,10) *SetLine3FooterFont("Tahoma",1,0,12)
Note: If the suggested font is not available on your system, use the name of a font available on your system. - Save the new preference file as new_font_defaults.mvw.
Observe the Updated Default Plot Fonts
- Add a new page and select the HyperGraph.
- Create a three line header and footer on the plot.
- Register and Load the file new_font_defaults.mvw. If prompted to update to the current defaults, select No.
- Change Page Layout to two windows per page.
- Click on the second plot window on the current page.
-
Create a three line header and footer on the plot.
The fonts in the plot window reflect the defaults defined in the new_font_defaults.mvw file, including each line of the header and footer area, rather than the program system defaults.
Set the Note Defaults
- Add a new page and select TextView.
- From the file browser on toolbar, select the file notes_legends.mvw, located in the preferences folder.
-
After the *BeginPlotDefaults() line, add the following
preference statement to set the default font type, style and size for
notes:
*SetNoteFont("Tahoma", 1, 1, 10)
-
After the *SetNoteFont() line, add the following preference
statements to set the default for note attachment, text alignment, and
color:
*SetNoteAttachment(View) *SetNoteAlignment(Left) *SetNoteColor(5)
- Save the new preferences file as new_notes_legends.mvw.
Set the Legend Defaults
- Select the file new_notes_legends.mvw from the file browser in TextView window mode.
-
After the *SetNoteColor() line, add the following preference
statements to set the defaults for legend font and legend placement:
*SetLegendFont("Tahoma",1,1,24) *SetLegendPlacement(TopRight)
- Save the new preference file as new_notes_legends.mvw.
Observe the Updated Default Plot Fonts
-
Create a page to add to the session using the page navigation tools in the
upper right corner.
- In the new window, click the Change Type icon () above the plot window and select HyperGraph.
- Change page layout to two windows per page.
- Add a curve to the current plot.
- Add a note to the current plot.
- Register and Load the file new_notes_legends.mvw. If prompted to update to current defaults, select No.
- Click on the second plot window on the current page.
- Add a curve to the current plot.
-
Add a note to the current plot.
The note and legend displayed on the plot reflects the defaults defined in the new_notes_legends.mvw file. To view the note attachment update, translate the curves using the view control arrows located in the lower left of the program window.
Update Note and Legend Defaults
- Add a page and select TextView.
- From the file browser on the toolbar, open file headers_footers.mvw, located in the preferences folder.
-
After the *BeginDefaults() line, add the following
preference statements to define the *BeginHeader()
block:
*BeginHeader() *EndHeader()
-
After the *BeginHeader() line, add the following preference
statements to define portion of the available header area:
*BeginRegion(400, 0, 600, 300) *EndRegion()
-
Region descriptions use a coordinate system. The arguments in the region
statement represent: the minimum X coordinate, the minimum Y coordinate, the
maximum X coordinate and the maximum Y coordinate.
If the region you were describing was the entire header area your *BeginRegion statement would be: *BeginRegion(0,0,1000,1000).
-
After the *BeginRegion() line, add the following preference
statements to set the text font, alignment and border for the region (update the
path below to reflect where your installation is located):
*Font("Times",0,1,12) *Alignment(Center) *BorderWidth(1,1,1,1)
-
After the *BorderWidth() line, add the following preference
statement to define the text in the header region:
*Text("Project Title")
- Save the new preference file as new_headers_footers.mvw.
Add a Page Footer
- Your file should be new_headers_footers.mvw. If not, open the file new_headers_footers.mvw from TextView window mode.
-
After the *EndHeader() line, add the following preference
statements to define the *BeginFooter() block:
*BeginFooter() *EndFooter()
-
After the *BeginFooter() line, add the following preference
statements to define and set up one region in the footer:
*BeginRegion(700, 0, 1000, 1000) *Font("Times",0,1,12) *Alignment(Center) *BorderWidth(1,1,1,1) *EndRegion()
The footer region’s coordinate system is similar to the header region: minimum X coordinate is 0 at the left and maximum X coordinate is 1000 at the right. The minimum Y coordinate is 0 at the base of the footer and its maximum coordinate is 1000.
-
After the *BorderWidth() line, add the following preference
statement to place text in the region:
*Text("Your Name") *Text("{time()} on {date()}") *Text("Page: {pagenum}/{numpages}")
-
After the *EndRegion() line, add the following preference
statements to define and set up a second region within the page footer:
*BeginRegion(700, 0, 1000, 1000) *BorderWidth(1,1,1,1) *EndRegion()
-
After the *BorderWidth() line, add the following preference
statement to put an image in the region:
*Image("<install_directory>/tutorials/mv_hv_hg/preferences/Altair_logo.gif")
Images, such as company logos, can be added to any region within the header or footer of a plot. The image type must be either GIF (format 87), JPG or BMP. Images are fitted vertically and centered horizontally.
- Save the new preference file as new_headers_footers.mvw.
Observe the New Page Header and Footer
- Register and Load the preference file new_headers_footers.mvw.
- If a printer is installed, you can select Print and then click OK. These headers and footers will be seen when the session or page is printed.
Set the Text Editor Defaults
- Add a page and select TextView.
- From file browser on the toolbar, select the file text_editor.mvw, located in the preferences folder.
-
After the *BeginTextEditorDefaults() line, add the following
preference statement to set the default font type, style, and size for the text
editor:
*Font("Times", 0, 1, 12)
-
After the *Font() line, add the following preference
statement to set the default text color for the text editor window:
*TextColor(6)
-
After the *TextColor() line, add the following preference
statement to set the default background color for the text editor window:
*BackGroundColor(23)
- Save the new preference file as new_text_editor.mvw.
Observe the Updated Default Plot Fonts
- Register and Load the file new_text_editor.mvw.
-
Click the Add Page icon on the toolbar to add a new page
to the current session.
The updated default for the background color is displayed.
-
Click in the text window and enter text to view changes to text defaults.