Model.hm_measureshortestdistance#

Model.hm_measureshortestdistance(entityCollection1, reserved1, entityCollection2, reserved2, systemID)#

Measures the shortest distance between two entity selections.

Parameters:
  • entityCollection1 (Collection) – The collection containing the entities on the first collection. Valid entities are nodes, elements, points, lines, surfaces and solids.

  • reserved1 (int) – Reserved for future use. Must be set to 0.

  • entityCollection2 (Collection) – The collection containing the entities on the second collection. Valid entities are nodes, elements, points, lines, surfaces and solids.

  • reserved2 (int) – Reserved for future use. Must be set to 0.

  • systemID (int) – The ID of a local coordinate system to use for reporting the coordinate values dx, dy, dz, x1, y1, z1, x2, y2 and z2. If systemID=0, the global coordinate system is used (default).

Returns:

  • hwReturnStatus - Status object

  • HmQueryResult - Result object containing the output values:

    • distanceTotal (double) - The value of the shortest distance.

    • distanceComponents (numpy.ndarray) - The x, y, and z value of the shortest distance, measured relative to the specified local system.

    • closestEntity1 (Entity) - The closest entity from the entityCollection1.

    • closestCoordinates1 (numpy.ndarray) - The coordinates of the closest location on closestEntity1.

    • closestEntity2 (Entity) - The closest entity from the entityCollection2.

    • closestCoordinates2 (numpy.ndarray) - The coordinates of the closest location on closestEntity2.

Examples#

Get the shortest distance between nodes with IDs 100 - 200 and nodes with IDs 300 - 400#
import hm
import hm.entities as ent

model = hm.Model()

nodes1 = hm.Collection(model, ent.Node, list(range(100, 201)))
nodes2 = hm.Collection(model, ent.Node, list(range(300, 401)))

_,result = model.hm_measureshortestdistance(
    entityCollection1=nodes1, reserved1=0, entityCollection2=nodes2, reserved2=0, systemID=0
)

print("distanceTotal", result.distanceTotal)
print("distanceComponents", result.distanceComponents)
print("closestEntity1", result.closestEntity1)
print("closestCoordinates1", result.closestCoordinates1)
print("closestEntity2", result.closestEntity2)
print("closestCoordinates2", result.closestCoordinates2)
Get the shortest distance between surface with ID 100 and lines with IDs 1 - 10 , with the distance output relative to system with ID 5#
import hm
import hm.entities as ent

model = hm.Model()

surfs = hm.Collection(model, ent.Surface, [100])
lines = hm.Collection(model, ent.Line, list(range(1, 11)))

_,result = model.hm_measureshortestdistance(
    entityCollection1=surfs, reserved1=0, entityCollection2=lines, reserved2=0, systemID=5
)

print("distanceTotal", result.distanceTotal)
print("distanceComponents", result.distanceComponents)
print("closestEntity1", result.closestEntity1)
print("closestCoordinates1", result.closestCoordinates1)
print("closestEntity2", result.closestEntity2)
print("closestCoordinates2", result.closestCoordinates2)