HyperMesh Process Automation
HyperMesh Process Automation
HyperMesh Process Automation
Chapter 2
HyperMesh Process
Automation Introduction
In this chapter we will discuss what HyperMesh automation is and the different
levels of automation available within HyperMesh. We will also examine the
HyperMesh Utility menu, the files that are associated with it, and how to run
macros and scripts from it. Finally an example will be given and after which an
exercise will be done.
HyperWorks 12.0
Introduction to HM Customization 27
Proprietary Information of Altair Engineering, Inc
F
!
While macros offer a great deal of flexibility, remember once a macro executes, there
is no way to cancel the execution or reject the results. In addition, a macro may not
be recursive (call itself).
When HyperMesh starts, it looks for a macro file named hm.mac in the current
directory, HOME directory (UNIX only), or the applications base directory. If it
finds this file, HyperMesh runs it automatically to define the attributes and
contents of the Utility Menu.
The default hm.mac file sources the following additional macro files:
disppage.mac
Introduction to HM Customization 28
Proprietary Information of Altair Engineering, Inc.
HyperWorks 12.0
geommeshpage.mac
globalpage.mac
qamodelpage.mac
userpage.mac
Introduction to HM Customization 29
Proprietary Information of Altair Engineering, Inc
In the next Chapter we will go over HyperMesh macros in more detail. Here we
will focus on how to add a button to the Utility menu.
To activate the macro from HyperMesh, you must create a button on the Utility
menu to invoke the macro. Use the *createbutton() command 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:
Row 1
Column 0
Figure: Row and Column Designations
Introduction to HM Customization 30
Proprietary Information of Altair Engineering, Inc.
HyperWorks 12.0
Below are two examples on how to create a button. The first example illustrates
the button calls needed for a user-created HyperMesh macro:
*createbutton(5, Create force, -1, 0, 10, GREEN, Create
force on selected nodes, createForce_macro)
The end of a command is a hard return <cr> (press the ENTER key). In your text
editor, type each command until you get to the end of it, then press ENTER.
The second example shows the button calls for a user created Tcl script using
the EvalTcl command:
*createbutton(5, Create force, -1, 0, 10, GREEN, Create
force on selected nodes, EvalTcl, create_force.tcl)
For each example, 5 refers to the Userpage, Create force is the text on the
button, -1 refers to the row position, 0 is the column number, 10 is the column
width, GREEN is the color of the button, and Create force on selected nodes is
the help string. For the HyperMesh macro example, createForce_macro is
the name of the macro to be evaluated. In the Tcl script example, EvalTcl
needs to be entered before create_force.tcl which is the name of the Tcl
file.
Notice that the full path for create_force.tcl isnt given. A full path can be
specified if the file isnt located in one of the predefined paths that HyperMesh
searches to find scripts. These paths include installation paths as well as the
working directory. Users can add additional search paths using the
TCL_INCLUDE environment variable. Relative paths can also be used from
these search paths.
The only commands used in this example are the menu macro commands, which
called an existing tcl procedure. We have yet to use the macro command to create
our own procedures, tasks or actions.
Online Help
The Online Help for HyperMesh can be accessed by either typing h on your
keyboard or by going to Help in the menu bar and selecting HyperWorks
Desktop. Within the HyperWorks 12.0 Welcome Page there is a HyperWorks
Reference Guides Section. Selecting HyperMesh opens the HyperMesh
Reference Guide in a new tab. If you expand HyperMesh Reference Guide in
HyperWorks 12.0
Introduction to HM Customization 31
Proprietary Information of Altair Engineering, Inc
the navigation area you will find another book named Scripts. This contains all
the commands and functions used in HyperMesh.
Introduction to HM Customization 32
Proprietary Information of Altair Engineering, Inc.
HyperWorks 12.0
Practical Exercises
Exercise 2a
Description
Add a button to the User Page on the Utility Menu that executes the macro
modeltour.tcl. This macro is located in the installation under hm\scripts,
so a path is not needed. The name of the button should be Model Tour.
The help string should be Explore HyperMesh Session. The color and
location are up to you.
HyperMesh commands used
*createbutton()
TCL/TK commands used
none
Hints
On Windows, the working directory is located in the My Documents folder.
Create a new text file called userpage.mac in this location and add the
appropriate commands to make the button evaluate the tcl file.
HyperWorks 12.0
Introduction to HM Customization 33
Proprietary Information of Altair Engineering, Inc
Introduction to HM Customization 34
Proprietary Information of Altair Engineering, Inc.
HyperWorks 12.0