HyperMesh and BatchMesher

HM-8010: Add a Button to the User Page on the Utility Menu

HM-8010: Add a Button to the User Page on the Utility Menu

Previous topic Next topic No expanding text in this topic  

HM-8010: Add a Button to the User Page on the Utility Menu

Previous topic Next topic JavaScript is required for expanding text JavaScript is required for the print function  

In this tutorial you will create a new button on the User page of the Utility menu.

 

Tools


The User page is available on the Utility menu. To access the User page:

1.From the menu bar, click View > Browsers > HyperMesh > Utility.
2.At the bottom of the Utility menu, click the User button

hm-80xx-01

Command files and Tcl/Tk scripts can be added to the userpage.mac file. When HyperMesh starts, it first looks for the userpage.mac file in the directory from which it launches, and then in the installation directory. UNIX users also have the option of putting the userpage.mac file in their home directory.

The userpage.mac file controls the display and available operations on the User page of the HyperMesh Utility menu. In order to invoke a command file or Tcl/Tk script from the User page, a button must be defined inside the userpage.mac file. The *createbutton command is used to define the button and its characteristics. The syntax for this command is:

*createbutton(page, name, row, column, width, COLOR, helpString, macroName [ , arg1 … ])

 

where:

page

The page number on which the button is to appear.  For the User page, this value is 5.

name

The text to display on the button, enclosed in quotes: " ".

row

The row in which to place the button.  The number of visible rows depends on your monitor’s graphics resolution.  A positive value indicates an absolute row number.  A 0 indicates the next highest available row.  A negative value indicates the number of rows to skip.  Rows begin at the bottom of the menu.

column

The column where the button starts (0-10).  Columns begin to the right of the menu.

width

The width of the button (max = 10).

COLOR

The color of the button.  The available button colors are: RED, BLUE, GREEN, CYAN, MAGENTA, YELLOW, GRAY,  and BUTTON (background). The color name must appear in capital letters.

helpString

The string to be displayed in the menu bar when the middle mouse button is pressed and the button is clicked, enclosed in quotes: " ".

macroName

The command to run when the button is pressed, enclosed in quotes: " ".

arg1…

A list of optional arguments passed to the script.

Exercise


In this exercise, you will create a button on the User page that will launch the lighting.tcl dialog from the HyperMesh installation.

Step 1:  Create the userpage.mac file.

 Using a text editor, create a blank userpage.mac file in the appropriate directory.

When HyperMesh starts, it first looks for the userpage.mac file in the directory from which it launches and then in the installation directory. On Windows, the default launch directory is in the My Documents folder. UNIX users also have the option of putting the userpage.mac file in their home directory.  It is not recommended to modify the userpage.mac file in the installation directory.

Step 2:  Add the command to create the button.

1.Add the following text to the userpage.mac file:

*createbutton(5,"Lighting",10,5,5,YELLOW,"Launch the lighting.tcl script","EvalTcl","lighting.tcl")

The EvalTcl macro is defined in the globalpage.mac file in the HyperMesh installation.  It takes a Tcl script as its argument and executes the script.

Notice that the full path is not used to reference the lighting.tcl script.  A full path can be specified if the file is not located in one of the predefined paths that HyperMesh searches to find scripts.  Users can add additional search paths using the TCL_INCLUDE environment variable.  Relative paths can also be used from these search paths.

2.Save the modified userpage.mac file.

Step 3:  Load the updated userpage.mac file.

1.Restart HyperMesh from the working directory or reload the current macro menu .mac file.  This allows the current session to use the modified userpage.mac file.

To reload the current macro menu .mac file while HyperMesh is open, from the menu bar select Preferences > Menu Config and click on retrieve next to macro file.  Make sure to load the proper .mac file from the hm/scripts/<profile name> directory based on the current user profile, or load the default hm.mac in the hm/bin/<platform> directory if no user profile is loaded.

2.Click the User button on the Utility Menu. You will see Lighting, the button defined in Step 2.  Compare this button to its definition.  It is yellow in color, begins in column 5 of row 10, and extends half way across the Utility Menu.

 

 

See Also:

HyperMesh Tutorials