Getting shortest distance between two set of entities is a frequently asked question. Let's see how it can be done in HyperMesh


Option 1: Interactive measure

From the search bar in HyperWorks, hit Distance to get access to the Find Shortest Distance tool

n

This opens a pop-up where you can define your two groups of entities, among surfaces, solids, nodes, elements, points and lines.

Please note there is an issue in 2022.3 with elements, so use nodes instead if you are dealing with a FE model.

Once you select first and second input, you can Accept for getting min distance information. Also, Create visual checkbox allows you to get a representation in the graphic area.

 

Option 2: tcl commands

The tcl command used behind the scene by the interactive tool is hm_measureshortestdistance. See help here.

An example of use of hm_measureshortestdistance can be found in the macro below:

https://help.altair.com/hwdesktop/hwd/topics/reference/hm/hm_measureshortestdistance2.htm

 

Another tcl command is available, for measuring distance from a reference point: hm_measureshortestdistance2. You can find help here.

Let's say you want to find the minimum distance between a reference point and a surface (both selected interactively). Here's how you can proceed:

*createmarkpanel points 1

set RefPoint [hm_getmark points 1]

set RefX [hm_getvalue points id=$RefPoint dataname=x]

set RefY [hm_getvalue points id=$RefPoint dataname=y]

set RefZ [hm_getvalue points id=$RefPoint dataname=z]

*createmarkpanel surfs 1

set MinDistance [lindex [hm_measureshortestdistance2 $RefX $RefY $RefZ surface 1 0 0] 0]

 

A third command of interst is hm_getclosestnode. It does not return the min distance, but the closer node from a reference coordinate, which can help for some cases. Help for this keyword is available here.