Presentation is loading. Please wait.

Presentation is loading. Please wait.

Innovation Intelligence ® 1 Chapter 4: Using TCL to Control the HyperMesh Session.

Similar presentations


Presentation on theme: "Innovation Intelligence ® 1 Chapter 4: Using TCL to Control the HyperMesh Session."— Presentation transcript:

1 Innovation Intelligence ® 1 Chapter 4: Using TCL to Control the HyperMesh Session

2 Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved. 2 Using Tcl to Control the HyperMesh Session - Overview Topics Presented: HyperMesh commands vs. Tcl Modify Commands Tcl GUI Commands and Tcl Query Commands Basic HyperMesh Input Widgets Common HyperMesh Tcl Commands Using the Command Window Example: Using the Command Window Process to Create a Tcl HyperMesh macro Example: Automate Creating Forces with a User Specified Magnitude

3 Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved. 3 Using Tcl to Control the HyperMesh Session - Overview The macros that have been created thus far are very powerful in their automation of repetitive tasks. However, there are limitations. The Tcl scripting language can be utilized to provide support for more advanced tasks. Using the previous example, Tcl could be used to request a name for the load collector from the user and use that information to tell the HyperMesh session to create a load collector with the user provided name.

4 Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved. 4 The HyperMesh commands which were presented in the previous chapter are also available through their Tcl Modify commands Notice that while the parentheses and commas have been removed, each of the commands still begin with an asterisk (*) and that the command name hasn’t changed. In addition to the syntax change, Tcl core commands can also be used. HyperMesh commands vs. Tcl Modify Commands Macro in userpage.mac fileTcl Script *beginmacro("macroJpeg")Not used in Tcl *setbackgroundcolor(255,255,255) *setbackgroundcolor 255 255 255 *setmeshlinecolor(6)*setmeshlinecolor 6 *jpegfile()*jpegfile *setbackgroundcolor(0,0,0)*setbackgroundcolor 0 0 0 *setmeshlinecolor(0)*setmeshlinecolor 0 *endmacro()Not used in Tcl

5 Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved. 5 Tcl GUI Commands and Tcl Query Commands HyperMesh Tcl GUI commands make changes/updates in the HyperMesh GUI HyperMesh Tcl Query Commands query the HyperMesh database for information. These commands have the prefix “hm_”. We will go over two basic HyperMesh input widgets and a table of common commands.

6 Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved. 6 Basic HyperMesh Input Widgets hm_getstring passes a string value entered by the user: hm_getstring ?option? ?message? hm_getstring “Load collector name” “Enter a name for the load collector” This command can be used with the set Tcl command to assign the string entered in the panel to a variable: set loadname [hm_getstring “Load collector name” “Enter name for load collector”]

7 Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved. 7 Basic HyperMesh Input Widgets hm_getint and hm_getfloat passes values entered by the user. hm_getint returns a user input integer value. hm_getfloat returns a user input floating point value. Both these commands have the same options as the hm_getstring command. set force [hm_getfloat “Force” “Enter force value”]

8 Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved. 8 Common HyperMesh Tcl Commands hm_answernext Force an answer to the next *command hm_answernext "yes" *deletemodel hm_blockmessages Inform HyperMesh whether or not messages should be displayed in header message bar hm_elemlist Return list of element ids for passed component id hm_entityinfo Get information about entities in current model hm_entitylist Get list of names or IDs of all entities of the requested type in current model hm_entitymaxid Return maximum ID in use for an entity type hm_errormessage Display error message in header message bar hm_getclosestnode Return ID of closest node to point x y z hm_getentityvalue Get information for an entity using the HyperMesh template interface hm_getfilename Get filename from user using HyperMesh file panel hm_getfloat Get floating point value from user using HyperMesh panel hm_getint Get integer value from user using HyperMesh panel hm_getmark Get ids for passed entity type on passed mark mask hm_getstring Get text string from user using HyperMesh panel hm_info Get general information about HyperMesh hm_markclear Clear IDs for entity type from passed mark mask hm_nodelistGet list of node IDs for passed element hm_nodevalueGet XYZ values for passed node ID hm_usermessage Display message in HyperMesh header message bar

9 Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved. 9 Using the Command Window An interactive Command Window is provided and can be access through the View menu. This launches the Tk Console (TkCon) which is an interactive console which comes with Tk. In the Command Window, users can evaluate any command that can be issued in Tcl or in HyperMesh through Tcl. Such as ls, pwd, and cd can be used within the Command Window.

10 Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved. 10 Using the Command Window General Tcl and HyperMesh specific Tcl commands can also be entered. For example, let’s use the HyperMesh specific Tcl command hm_info with the following options: hm_info –appinfo SPECIFIEDPATH TEMPLATES_DIR This returns the current template directory. Using the Command Window provides the automation tool developer an easy means of testing a concept before writing the full procedure. In the Command Window you can… Evaluate any command that can be issued to Tcl or to HyperMesh through Tcl Run scripts using the source command, i.e. source test.tcl, or, run scripts using the File >> Load menu option Save the session’s command history using the File >> Save menu option

11 Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved. 11 Example: Using the Command Window The purpose of this example is to become familiar with using the Command Window for developing in Tcl. HyperMesh Tcl and core Tcl commands will be used in the Command Window to determine the number of elements in a component collector for a pre-defined HyperMesh model. The following commands are used in this exercise: Modified HyperMesh commands: *createmark() HyperMesh Tcl commands hm_info hm_getmark Core Tcl commands list llength set source

12 Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved. 12 Process to Create a Tcl HyperMesh macro This process is nearly identical to developing a HyperMesh Basic macro except: The HyperMesh commands must be converted to Tcl format Tcl core commands are allowed to introduce control logic to the automation tools. 1.Define the task. 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. 5.Create a Tcl script by converting the commands to Tcl format and modifying as necessary (this includes adding additional Tcl commands) 6.Create a new Utility menu macro that runs a Tcl script. 7.Add macro button using *createbutton that calls the macro created in Step 6 with the appropriate Tcl script filename. 8.Reload the current.mac file into HyperMesh to load the modified userpage.mac. 9.Test the macro.

13 Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved. 13 Example: Automate Creating Forces with a User Specified Magnitude In this example, we will go through the general process for creating HyperMesh Tcl scripts. The script will automate the creating of forces with a user defined magnitude. The following commands are used in this example: Modified and added HyperMesh commands: *createmark *clearmark HyperMesh Tcl commands: hm_getfloat Core Tcl commands: set

14 Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved. 14 Practical Exercises Exercise 4a Description Create a HyperMesh Tcl script to automate the following task Create a component collector with a user specified name Select elements and move those elements into the new component collector. Translate the elements in the new component collector a user specified distance in the z direction. HyperMesh commands used hm_getstring *collectorcreateonly *createmarkpanel*movemark *clearmark*createvector hm_getfloat*translatemark TCL/TK commands used set Hints Be sure to do the steps in HyperMesh and then extract the appropriate commands from the command.cmf file. Modify the commands as necessary and be sure to clear the mark when needed.

15 Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved. 15 Practical Exercises Exercise 4b Description For each element in a HyperMesh model, build a list where the contents of the list are as follows ELEMID {NODE1 NODE2 …} These lists should then be included in a list of lists: {{ELEMID1 {NODE1 NODE2 …} {ELEMID2 {NODE1 NODE2 …} … HyperMesh commands used *createmarkhm_getmark hm_nodelist TCL/TK commands used forforeachlist lappendsetincr ifelseifelse Hints The majority of this assignment will be discovering where to find information about commands and how to apply the information you find. Be patient and use the resources available to you, including the HyperWorks online help.


Download ppt "Innovation Intelligence ® 1 Chapter 4: Using TCL to Control the HyperMesh Session."

Similar presentations


Ads by Google