HyperMesh Process Automation

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Chapter 2: HyperMesh Process Automation Introduction

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.

What is a HyperMesh Macro


A HyperMesh macro functions like a script or command file and is used to
automate a HyperMesh process or execute a series of steps. The HyperMesh
macro language is an extension of the HyperMesh command layer. The types of
macros you can write vary from basic to advanced. Basic types are simple
macros of HyperMesh commands that run a sequential HyperMesh command
file. More advanced macros involve using the Tcl/Tk scripting language to add
additional logic and user interaction such has entity selection. Even more
advanced automation can be done using the Altair Process Manager. The
Process Manager is a programmable personal workflow manager that guides
users through a standard work process. The Process Manager will be addressed
in a different class. Here the focus will be on creating simple HyperMesh macros
and HyperMesh macros with Tcl/Tk.
The HyperMesh Utility Menu commands provide the means to create an interface
in the form of buttons and button groups. For each you specify the following
characteristics:

The macro page it is displayed on


Its label
Its location and size

HyperWorks 12.0

Introduction to HM Customization 27
Proprietary Information of Altair Engineering, Inc

Chapter 2: HyperMesh Process Automation Introduction

Its help message


The macro it calls, and any optional arguments

F
!

The macro command language is an interpreted language. This means each


command executes in the order in which it appears in the macro file.

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).

The HyperMesh Utility Menu


The Utility menu allows you to customize the standard interface to include
function buttons, radio options, and text that have HyperMesh-supplied and userdefined macros associated with them. The Utility menu is located on a tab of the
Tab area pane(s), and can be shown or hidden from within the View > Browsers
> HyperMesh pull-down menu.
The Utility menu includes several pages of its own, each dedicated to different
tasks. Thus it presents groups of functionalities accessible from a set of pages
contained by the Utility tab, although only one set of functions is displayed at a
time. Each page is associated with a button at the bottom of the Utility menu;
clicking one of these buttons accesses the page associated with it. A macro file
(hm.mac) controls the display and available operations of the Utility Menu.
Attributes that you can change include:

The Utility menu page on which the operations appear.


Text to be displayed on each control.
Location and size of the menu.
The help string to be displayed in the bubble as the mouse is hovered
over the button.
The macro to call when each control is used.

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

Populates the Display page of the Utility Menu

Introduction to HM Customization 28
Proprietary Information of Altair Engineering, Inc.

HyperWorks 12.0

Chapter 2: HyperMesh Process Automation Introduction

geommeshpage.mac
globalpage.mac
qamodelpage.mac
userpage.mac

Populates the Geom/Mesh page of the Utility


Menu
Creates the button group that allows you to switch
pages
Populates the QA/Model page of the Utility Menu
Populates the User page of the Utility Menu

A userpage.mac file may exist in the installation directory for HyperMesh or in


the directory from which HyperMesh launches. 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. This file defines the attributes and
contents of the User page of the Utility menu. By default, the Utility menu
displays when HyperMesh starts, but display of the menu can be turned off by
going to the View > Browsers > HyperMesh pull-down menu.

HyperMesh Utility Menu Commands


HyperMesh macro commands reside in the default hm.mac file. When you open
this file, you will see that it defines the Utility menu contents in order by page. To
change a macro on a given page, find that page in the hm.mac file and the
macro name that you wish to modify.
Attributes you can change on a macro page include:
Buttons to display on that macro page
The location and size of the buttons appearing on a macro page
The label for each button
The help string displayed in the bubble as the mouse is hovered over the
button.
The macro called by each button, with optional arguments to pass
HyperMesh macros consist of valid command file or templex commands, and are
enclosed by the *beginmacro(macroname) and *endmacro() commands.
Macros may accept data passed to them using the arguments $1, $2, etc. Each
argument specifies where the values should be substituted. The *callmacro()
command allows you to call a macro from within another one, which allows you
to create groups of standard reusable macros.
The following skeleton shows the format of a macro:
*beginmacro(macroname)
macro command statements go here
*endmacro()
HyperWorks 12.0

Introduction to HM Customization 29
Proprietary Information of Altair Engineering, Inc

Chapter 2: HyperMesh Process Automation Introduction

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:

Indicates the page number on which the button is to appear (values


1 through n; initially there are 5).
name:
The text to display on the button. Enclose the text with quotes ( ).
row:
The row in which to place the button (values 1, 1 - n). The number
of rows visible depends upon the graphics resolution setting of your
hardware. A 0 indicates the next available position, and 1
indicates to skip a row.
column:
The column where the button starts (values 0 - 10 ).
width:
The width of the button ( max 10).
COLOR:
The color of the button. The available button colors are: RED,
BLUE, GREEN, CYAN, BUTTON, GREY, YELLOW and
MAGENTA. The color name must appear in capital letters.
helpString: The string to be displayed in the bubble as the mouse is hovered
over the button. Enclose text of string in quotes ( ).
macroName: The name of the macro to call when the button is selected.
Enclose text of string in quotes ( ).
arg1:
A list of one or more optional arguments passed to the macro. You
may have as many arguments as your computers memory will
allow

Row 1
Column 0
Figure: Row and Column Designations

Introduction to HM Customization 30
Proprietary Information of Altair Engineering, Inc.

HyperWorks 12.0

Chapter 2: HyperMesh Process Automation Introduction

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

Chapter 2: HyperMesh Process Automation Introduction

the navigation area you will find another book named Scripts. This contains all
the commands and functions used in HyperMesh.

Figure: Reference Guide in HyperMesh and BatchMesher Online Help

Introduction to HM Customization 32
Proprietary Information of Altair Engineering, Inc.

HyperWorks 12.0

Chapter 2: HyperMesh Process Automation Introduction

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

Chapter 2: HyperMesh Process Automation Introduction

Introduction to HM Customization 34
Proprietary Information of Altair Engineering, Inc.

HyperWorks 12.0

You might also like