Model.hm_measureshortestdistance2#

Model.hm_measureshortestdistance2(x, y, z, collection, reserved, systemCoord)#

Measures the shortest distance between a coordinate location and an entity selection.

Parameters:
  • x (double) – The x input coordinate location.

  • y (double) – The y input coordinate location.

  • z (double) – The z input coordinate location.

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

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

  • systemCoord (int) – The ID of a local coordinate system to use for reporting the distance values dx, dy, dz, x, y and z. If systemCoord=0, the global coordinate system is used (default).

Returns:

  • hwReturnStatus - Status object

  • HmQueryResult - Result object containing the output values:

    • minDist (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.

    • closestEntity (int) - The ID of the closest entity from the collection.

    • closestCoordinates (numpy.ndarray) - The coordinates of the closest location on closestEntity.

Examples#

Get the shortest distance between (0, 10, 0) and nodes with IDs 100-200#
import hm
import hm.entities as ent

model = hm.Model()

nodes = hm.Collection(model, ent.Node, list(range(100, 201)))

_, result = model.hm_measureshortestdistance2(
    x=0.0, y=10.0, z=0.0, collection=nodes, reserved=0, systemCoord=0
)

print("minDist", result.minDist)
print("distanceComponents", result.distanceComponents)
print("closestEntity", result.closestEntity)
print("closestCoordinates", result.closestCoordinates)
Get the shortest distance between (5, 0, 1) and lines with IDs 1-10, with the distance output relative to system ID 5#
import hm
import hm.entities as ent

model = hm.Model()

lines = hm.Collection(model, ent.Line, list(range(1, 11)))

_, result = model.hm_measureshortestdistance2(
    x=5.0, y=0.0, z=1.0, collection=lines, reserved=0, systemCoord=5
)

print("minDist", result.minDist)
print("distanceComponents", result.distanceComponents)
print("closestEntity", result.closestEntity)
print("closestCoordinates", result.closestCoordinates)