Top Banner
Innovation Intelligence ® 1 Chapter 3: HyperMesh Automation with HyperMesh Macros
16

Innovation Intelligence ® 1 Chapter 3: HyperMesh Automation with HyperMesh Macros.

Dec 21, 2015

Download

Documents

Stella Stanley
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Innovation Intelligence ® 1 Chapter 3: HyperMesh Automation with HyperMesh Macros.

Innovation Intelligence®

1

Chapter 3: HyperMesh Automation

with HyperMesh Macros

Page 2: Innovation Intelligence ® 1 Chapter 3: HyperMesh Automation with HyperMesh Macros.

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

2

Overview

Topics Presented:

• HyperMesh Commands• Command Files• Entity Types, Marks, Planes and Vectors• Common Command File Commands

• HyperMesh Macro Structure• Process to Create HyperMesh Macros• Example: Automate Creating a Load Collector• Modifying Commands to Create Generalized Macros

Page 3: Innovation Intelligence ® 1 Chapter 3: HyperMesh Automation with HyperMesh Macros.

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

3

HyperMesh Commands

• HyperMesh command macros make use of only HyperMesh commands.

• HyperMesh writes all commands used in a session to the command.cmf file.

• The command.cmf file is an ASCII file that HyperMesh can read or write.

• If this file doesn't already exist, then HyperMesh creates it at the start of a session.  

• If the file does already exist, HyperMesh adds the commands for the new session to the end of the original file.

• You can use command files in applications that rely on repetitive or iterative steps, or to create demonstrations.

Page 4: Innovation Intelligence ® 1 Chapter 3: HyperMesh Automation with HyperMesh Macros.

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

4

HyperMesh Commands

• Command files follow this syntax:• A command begins with an asterisk (*).• A command ends with the left parenthesis.• The parameters for a command are separated by commas, ending with the

right parenthesis.

• Command syntax example:*shrink(.2)

• Commands executed in an active HyperMesh session are not immediately written to the command files.  

• They are stored in memory and are written to the command file during idle time (when HyperMesh is not busy performing user operations).

Page 5: Innovation Intelligence ® 1 Chapter 3: HyperMesh Automation with HyperMesh Macros.

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

5

HyperMesh Commands

• Entity Types • Used as string parameters in commands that act directly on entities in some

fashion, such as creating filtered sets that contain only a specific entity type.

• Examples of entity types are elements, line, groups, sets, and loads.

• Marks• Marks specify groups of entities that are transferred to the command

processor. • Marks can be created for most entities, and commands are then issued to

perform operations on the entities on the mark.  • HyperMesh allows for two standard marks and a user mark.

• Standard marks are referenced by the mark IDs 1 and 2.  

Page 6: Innovation Intelligence ® 1 Chapter 3: HyperMesh Automation with HyperMesh Macros.

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

6

HyperMesh Commands

• Example of how to delete elements using the standard mark:

*createmark(elements, 1) 50 51 52*deletemark(elements, 1)

• This *createmark command populates mark 1 with elements 50, 51, and 52.

• The *deletemark command deletes the elements contained on mark 1.

• Element ids will not be consistent from model to model. In order to make a macro useful for multiple models, we can change the selection method.

Page 7: Innovation Intelligence ® 1 Chapter 3: HyperMesh Automation with HyperMesh Macros.

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

7

HyperMesh Commands

• Using Selection Methods with a Mark – several options exist to make the *createmark command more general

• “all”, “by displayed“, “by config”, etc

• Use the *appendmark() command to add entities to a mark.

• *createmark(elements, 1) 50 51 52• *appendmark(elements, 1) “by adjacent”• *deletemark(elements, 1)

• Another option is to replace the *createmark command with *createmarkpanel.

• When executed, this command presents the user with a selection panel in the entity specified in the command can be selected.

Page 8: Innovation Intelligence ® 1 Chapter 3: HyperMesh Automation with HyperMesh Macros.

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

8

HyperMesh Commands

• At times, it is necessary to define a vector or plane for a command.  

• HyperMesh allocates two vectors and two planes with the IDs 1 and 2.  • The vectors and planes can be defined at any time during the processing of a

command file or Tcl script.

• The following example translates node 10 along the x axis by 5 units:

*createvector(1, 1.0, 0.0, 0.0)*createmark(nodes, 1) 10*translatemark(nodes, 1, 1, 5.0)

• Additionally, a normal and base point are required to define a plane.   

*createplane(1, 1.0, 0.0, 0.0, 5.0, 0.0, 0.0)*createmark(elements, 1) “displayed”*reflectmark(elements, 1, 1)

Page 9: Innovation Intelligence ® 1 Chapter 3: HyperMesh Automation with HyperMesh Macros.

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

9

HyperMesh Commands

Command Name Description

*appendmark() Add additional entities to a mark

*beginmacro(name) Start the definition of a Utility Menu macro

*callmacro() Call a macro from within another macro

*createbutton() Add a button to the Utility Menu

*createbuttongroup()

Add a button group to the Utility Menu

*createlistpanel() Allow you to interactively select a list of entities

*createmarklast() Place the entities from the last operation into a mark

*createmarkpanel() Allow you to interactively select entities

*createtext() Add text to the Utility Menu

Command Name Description

*endmacro()

End the definition of a macro started with the beginmacro command

*enterpanel() Enter the passed HyperMesh panel

*includemacrofile() Include the contents of the passed macro file

*insertbutton() Insert a button into the Utility Menu

*inserttext() Insert text into the Utility Menu

*setactivegroup() Set the default selection for a button group

*setactivepage() Set the current displayed Utility Menu page

*setbuttongroupactivecolor()

Set the color for the Utility Menu button group’s current selection indicator

Common Command File Commands

Page 10: Innovation Intelligence ® 1 Chapter 3: HyperMesh Automation with HyperMesh Macros.

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

10

HyperMesh Macro Structure

• HyperMesh macro commands are enclosed by the *beginmacro() and *endmacro() commands.

*beginmacro(macroName)[commands]

*endmacro()

• Macros may accept data passed to them using the arguments $1, $2, etc.

• Each argument specifies where the values should be substituted.

*beginmacro(ToggleGeom_macro)*displaycollectorwithfilter(comps,$1,””,0,1)*plot()

*endmacro()

*createbutton(5, “Turn off all geometry”, -1, 0, 10, GREEN, “Turn off the display of all geometry”, “ToggleGeom_macro”, “none”)

Page 11: Innovation Intelligence ® 1 Chapter 3: HyperMesh Automation with HyperMesh Macros.

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

11

Process to Create HyperMesh Macros

1. Define the task to be automated.

2. Delete the existing command.cmf file. This file is located in either the start-in directory or the current working directory.

3. Perform the operations in HyperMesh that the script should run.

4. Extract the commands from the command.cmf file.

5. Add the commands to the userpage.mac file.

6. Modify the commands as necessary and add macro wrapper commands *beginmacro() and *endmacro().

7. Add the macro button using the *createbutton() command that will call the new macro defined in Step 6.

8. Reload the current .mac file into HyperMesh to load the modified userpage.mac.

9. Test the macro.

Page 12: Innovation Intelligence ® 1 Chapter 3: HyperMesh Automation with HyperMesh Macros.

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

12

Example: Automate Creating a Load Collector

• The purpose of this example is to become familiar with the general process for creating a HyperMesh macro.

• This example will use the process described above for creating a HyperMesh macro.

Page 13: Innovation Intelligence ® 1 Chapter 3: HyperMesh Automation with HyperMesh Macros.

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

13

Example 1: Automate Creating a Load Collector

Summary

• Followed the process for creating a HyperMesh macro.

• Creating a macro will not always be as simple as cutting and pasting commands from the command.cmf file.

• Sometimes macros will have to use extended selection options in order to be general enough to be used on multiple models.

• Other times the user will need to interactively select entities as well.

• The next example will explore these options.

Page 14: Innovation Intelligence ® 1 Chapter 3: HyperMesh Automation with HyperMesh Macros.

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

14

Modifying Commands to Create Generalized Macros

• Simply copying commands from the command.cmf can result in macros being too restrictive.

• To generalize the macros so that they can be used on multiple models, the *createmark() command will need to be modified.

• When HyperMesh writes the *createmark() command to the command.cmf file, it operates on entity ids making it very restrictive.

• Even if a selection method such as “displayed” is used, entity ids are listed in the command.cmf file.

• As a result, we need to modify the command so that it is less restrictive.

• We can do this by replacing the *createmark() command with the *createmarkpanel() command.

• The *createmarkpanel() command allows users to interactively select the entities.

Page 15: Innovation Intelligence ® 1 Chapter 3: HyperMesh Automation with HyperMesh Macros.

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

15

Modifying Commands to Create Generalized Macros

• The syntax for the *createmarkpanel() command is:

*createmarkpanel(entity_type, mark_id, message)

entity_type: Type of entity to be placed on the markmark_id: ID of the mark to be created, 1 or 2message: Message to display to the user

• Example: Allow the user to select the elements and then delete the elements

*createmarkpanel(elements, 1, “Select elements to delete”)*deletemark(elements, 1)

Page 16: Innovation Intelligence ® 1 Chapter 3: HyperMesh Automation with HyperMesh Macros.

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

16

Practical Exercises

Exercise 3aDescription

Add a button to the Utility Menu which allows elements on the top of the channel to be translated in the z-direction. Give the users the option of selecting which elements to translate.

HyperMesh commands used*createbutton() *beginmacro()*createmarkpanel() *endmacro()*translatemark()

TCL/TK commands usednone

HintsFollow the Process to Create HyperMesh Macros presented in this Chapter. Do all the steps in HyperMesh and extract the appropriate commands from the command.cmf file.