Model.hm_getnearbyentities#

Model.hm_getnearbyentities(input_entity_collection, output_entity_collection, radius, outputentitytypes=List[EntityFullType], nearby_search_method='sphere')#

Finds entities nearby entities on an input collection.

Parameters:
  • input_entity_collection (Collection) – The collection containing the input entities to find nearby entities to. Valid entities are components, elements, equations, loads, nodes, systems, vectors, points, lines, surfs, solids, parts, and connectors.

  • output_entity_collectionset (CollectionSet) – The set of collections containing possibly multiple type of entities to find. Valid entities are components, elements, equations, loads, nodes, systems, vectors, points, lines, surfaces, solids, parts, connectors, and accelerometers.

  • radius (double) – The nearby search radius/size.

  • outputentitytypes (_EntityFullTypeList_vector) – The list of output entity types (classes) to find. Valid entity types are component, element, equation, load, node, system, vector, point, line, surface, solid, part, connector, and accelerometer.

  • nearby_search_method (hwString) – The optional search method, either box or sphere (default).

Returns:

Example#

Query loads and elements nearby components with IDs 301 and 302 use a sphere of size 100#
import hm
import hm.entities as ent

model = hm.Model()

component_collection = hm.Collection(model, ent.Component, [301, 302])
outColSet = hm.CollectionSet(model)

model.hm_getnearbyentities(
    input_entity_collection=component_collection,
    output_entity_collectionset=outColSet,
    outputentitytypes=[
        ent.LoadForce,
        ent.LoadAcceleration,
        ent.LoadConstraint,
        ent.LoadFlux,
        ent.LoadMoment,
        ent.LoadTemperature,
        ent.LoadPressure,
        ent.Element,
    ],
    radius=100,
)

for col in outColSet:
    print("Entity Class", col.eclass.__name__)
    print("Nearby Entities:", [e.id for e in col])