Presentation is loading. Please wait.

Presentation is loading. Please wait.

Innovation Intelligence ® 1 Chapter 5: Retrieving Data from HyperMesh Entities.

Similar presentations


Presentation on theme: "Innovation Intelligence ® 1 Chapter 5: Retrieving Data from HyperMesh Entities."— Presentation transcript:

1 Innovation Intelligence ® 1 Chapter 5: Retrieving Data from HyperMesh Entities

2 Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved. 22 Retrieving Data from HyperMesh Entities - Overview Topics Presented: HyperMesh Entities and Their Data Names Using the hm_getentityvalue command Pointers and Flags Process for Creating a HyperMesh Tcl Script to Retrieve Data on HyperMesh Entities Example: Automate Computing the Vector Sum of Forces

3 Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved. 3 HyperMesh Entities and Their Data Names What are Data Names? Generic references to the information that physically defines an entity in the HyperMesh environment Example: The x, y, and z coordinates that define a node’s location in three- dimensional space. This information is part of the entity’s definition and is consistent for all solvers. Data Names can change from one HyperMesh version to the next. For this reason, please refer to the online help. Information on the data names can be found in the following location: HyperMesh > Reference Guide > Scripts > Creating Scripts > Tcl > Using Data Names

4 Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved. 4 HyperMesh Entities and Their Data Names nodewhen a load is applied to a node, this serves as a pointer to the node comp1x component of the vector comp2y component of the vector comp3z component of the vector magnitudemagnitude of the load vector collectorcollector that owns the load (load collector pointer) How to access Data Names? hm_getentityvalue command accesses data names and template info associated with an entity Returns a string or floating point value hm_getentityvalue entity_type name_or_id data_name_string flag Example: Set the x component of a force with ID 12 to the variable force_x: set force_x [hm_getentityvalue loads 12 "comp1" 0] Several Data Names available for force loads:

5 Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved. 5 HyperMesh Entities and Their Data Names idThe ID of the node (integer). inputsystemPointer to the node input system (pointer). outputsystemPointer to the node output system (pointer). x The x coordinate of the node in its local system (real). y The y coordinate of the node in its local system (real). z The z coordinate of the node in its local system (real). Example: Tcl script which prompts the user to select several nodes and then displays their x, y, and z coordinates hm_markclear nodes 1 *createmarkpanel nodes 1 set nodes [hm_getmark nodes 1] if { ! [ Null nodes ] } { foreach node $nodes { set xVal [hm_getentityvalue nodes $node "x" 0] set yVal [hm_getentityvalue nodes $node "y" 0] set zVal [hm_getentityvalue nodes $node "z" 0] tk_messageBox -message "Node $node = $xVal $yVal $zVal" } Several Data Names available for nodes:

6 Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved. 6 Pointers and Flags Several of the data names in the two tables are defined as pointers. A pointer is used to directly access another data name. For example, the collector and node data names for force loads are pointers. This means they “point” to data names available for either collectors or nodes. In order to retrieve any data from a pointer, the data name requested for the particular pointer must also be supplied. The additional data names are separated by a period or dot (.).

7 Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved. 7 Pointers and Flags The following are a few examples on how a pointer is used. To retrieve the node id that load 12 is applied to : set node_id [hm_getentityvalue loads 12 "node.id" 0] To retrieve the y coordinate of the node that load 12 is applied to: set node_id [hm_getentityvalue loads 12 "node.y" 0] To retrieve the load collector name that contains load 12: set ld_col [hm_getentityvalue loads 12 "collector.name" 1] For the collector name, notice the flag value is set to 1 as the expected return value is a string value as opposed to a numeric value. In the node example above, the flag value is set to 0, indicating that a floating point number is to be returned.

8 Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved. 8 Pointers and Flags Another example is with component collectors. There is no data name associated with a component collector to get the material name, only the material ID. The following set of commands is used to get the material ID: set matID [hm_getentityvalue comps 12 "materialid" 0] A second set of commands would then be required to get the name of the material with that ID: set matName [hm_getentityvalue mats $matID "name" 1] Alternatively, the component collector has a material pointer data name. From this pointer, any valid material data name can be substituted by separating the pointer and the new data name with a period (.). From the example above the following line can replace the previous two lines: set matName [hm_getentityvalue comps 12 "material.name" 1]

9 Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved. 9 Process for Creating a HyperMesh Tcl Script to Retrieve Data on HyperMesh Entities 1.Define the task to be automated. 2.Write the commands to a user-created *.tcl text file Skip doing the task in HyperMesh as there are likely no commands to capture to the command.cmf file; the task is to retrieve information, not to perform a HyperMesh action. Use HyperMesh Tcl commands to extract data on HyperMesh entities. Use core Tcl commands to store extracted data in variables, retrieve, manipulate, and display it. 3.Test the script from the Command Window. 4.Define the Utility menu button for the macro in userpage.mac file. 5.In the current HyperMesh session, reload the hm.mac file (this also reloads userpage.mac ). 6.Run the script from the Utility menu.

10 Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved. 10 Example: Automate Computing the Vector Sum of Forces 1.Request the user to select forces. 2.If the user does not select loads, display a message stating this. 3.Retrieve the X, Y, and Z component information from the user-selected forces. 4.Sum the X, Y, and Z components. 5.Display the resulting X, Y, and Z components. The following HyperMesh commands are modified in this exercise. *clearmark()*createmarkpanel() The following HyperMesh Tcl commands are used in this exercise. hm_getentityvaluehm_getmark hm_usermessagehm_errormessage The following core Tcl commands are used in this exercise. brackets [ ]expr foreachif setreturn llength

11 Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved. 11 Practical Exercises Exercise 5a Description: Create a HyperMesh Tcl script to automate the following task: Request the user to select a component to be translated. Request the user to select a HyperMesh defined vector along which the component is to be translated. Get the Xcomp Ycomp and Zcomp of the selected vector from the HyperMesh database. Request the user to enter in a translation distance. Use all of the above information to translate the given component. HyperMesh commands used *createmarkpanelhm_getfloat hm_getmarkhm_getentityvalue *createvector*translatemark *clearmark TCL/TK commands used set Hints Use the provided c_channel-tcl_vector.hm file as it has a vector defined in it.

12 Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved. 12 Practical Exercises Exercise 5b Description Create a HyperMesh Tcl script to automate the following task: Request the user to select elements on which to create system. Calculate the centroidal coordinates of each element. Create a node at each of these centroidal locations. Create systems with these nodes as an orientation node. HyperMesh commands used *createmarkpanel*createnode *clearmark*hm_nodelist hm_getmark*systemcreate hm_entityinfo TCL/TK commands used setfor foreacheval lindexllength 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.

13 Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved. 13 Practical Exercises Exercise 5c: Description Starting with the results of Exercise 4b: Create a node at the centroid of the element. Translate the node in the positive direction of the element normal by an amount equal to the shortest diagonal of a quad element and the shortest side of a tria element. Create either a tetra element or a pyramid element using the original element node list and the new node created by the script. HyperMesh commands used *createmark*createvector*translatemark *createnode*createelement*collectorcreate *currentcollectorhm_getmarkhm_nodelist hm_entityinfohm_getentityvalue TCL/TK commands used forforeach setif elseifelse Hints This assignment will require you to think more, but the process is still the same. Pay careful attention to vector directions and look closely at the data you have generated. What are some ways to make this cleaner in the user environment? What are some problems that you might encounter?


Download ppt "Innovation Intelligence ® 1 Chapter 5: Retrieving Data from HyperMesh Entities."

Similar presentations


Ads by Google