hm Module#

Model class#

class Model(name: str = None, *args, **kwargs)#

Class representing a HyperMesh model. A model instance provides access to Model Class Modify Functions and Model Class Query Functions.

Parameters:

name (str) – The name of the HyperMesh model.

Session class#

class Session#

Class representing a HyperMesh session (note this is a different class to hw.Session). It manages all HyperMesh models that exist in the application.

get_all_models()#

Method to return names of all HyperMesh models.

Returns:

List of names of HyperMesh models that exist in the session.

Return type:

list

get_current_model()#

Method to return the name of the current HyperMesh model.

Returns:

The name of the current HyperMesh model.

Return type:

str

model_exists(name: str)#

Method to check if model with specified name exists in the session.

Parameters:

name (str) – The name of the model.

Returns:

Returns True if the model exists, False otherwise.

Return type:

bool

Collection class#

class Collection(model: Model = None, *args*, **kwargs)#

A class that provides a mechanism to create entity collections that can be iterated over or passed to HyperMesh functions as input argument. More information on the creation and usage of collections can be found in Entity Selection via Collections.

The class constructor supports multiple ways of creating a collection object:

Collection(model, type)
Parameters:
  • model (Model) – Instance of the hm.Model class.

  • type (Entity) – HyperMesh entity class from hm.entities.


Collection(model, type, populate = True)
Parameters:
  • model (Model) – Instance of the hm.Model class.

  • type (Entity) – HyperMesh entity class from hm.entities.

  • populate (bool) – Flag to populate the collection. If set to True (default), the collection will contain all entities of the specified class. Set populate=False to create an empty collection.


Collection(model, type, Union[list[int],list[str]])
Parameters:
  • model (Model) – Instance of the hm.Model class.

  • type (Entity) – HyperMesh entity class from hm.entities.

  • list (Union[list[int],list[str]]) – List of integers (IDs) or strings (valid only for hm.entities.Part).


Collection(model, type, list[Entity])
Parameters:
  • model (Model) – Instance of the hm.Model class.

  • type (Entity) – HyperMesh entity class from hm.entities.

  • list (list[Entity]) – List of HyperMesh entity objects.


Collection(model, type, Collection)
Parameters:
  • model (Model) – Instance of the hm.Model class.

  • type (Entity) – HyperMesh entity class from hm.entities.

  • Collection (Collection) – Collection of HyperMesh entities.


Collection(model, EntityList)
Parameters:
  • model (Model) – Instance of the hm.Model class.

  • EntityList (EntityList) – List of HyperMesh entity objects.


Collection(model, Filter)
Parameters:
  • model (Model) – Instance of the hm.Model class.

  • Filter (Filter) – Filter object.


Collection(model, FilterByCollection, Collection)
Parameters:
  • model (Model) – Instance of the hm.Model class.

  • FilterByCollection (FilterByCollection) – FilterByCollection object.

  • Collection (Collection) – Source collection object.


add(rule: CollectionRule, source: Collection = None)#

Method to add entities to the collection.

Parameters:
  • rule (CollectionRule) – Instance of a filter class.

  • source (Collection) – Source collection.

contains(entity: hwdescriptor.Entity)#

Method to check if an entity is contained in the collection.

Parameters:

entity (hwdescriptor.Entity) – HyperMesh entity handle. Can be obtained by querying entity attribute of an entity object.

delete_items()#

Method to delete the entities contained in the collection.

intersect(rule: CollectionRule, source: Collection = None)#

Method to perform a collection intersection.

Parameters:
  • rule (CollectionRule) – Instance of a filter class.

  • source (Collection) – Source collection.

set_items(identifier: str, value)#

Method to set an attribute value to all entities contained in the collection.

Parameters:
  • identifier (str) – The name of the attribute.

  • value – The value of the attribute. The type depends on the specified attribute.

subtract(rule: CollectionRule, source: Collection = None)#

Method to subtract a collection based on a referenced rule.

Parameters:
  • rule (CollectionRule) – Instance of a filter class.

  • source (Collection) – Source collection.

eclass: EntityClass#

The entity class representing the entity type contained in the collection.

Example - Sum of element area values#
import hm
import hm.entities as ent

model = hm.Model()
# A collection of all elements.
col = hm.Collection(model, ent.Element)

total_area = 0
for elem in col:
    total_area += elem.area

    print(f"Total Area: {total_area}")

CollectionByAdjacent function#

CollectionByAdjacent(model: Model, source: Collection)#

Function to create a collection of entities adjacent to the entities in the source collection.

Note

The model object passed to the function has to represent the active model (i.e. HyperMesh model in the active window). If a non-active model is passed to the function, it will return an empty collection.

Parameters:
  • model (Model) – HyperMesh model object.

  • source (Collection) – Source collection object.

Example - Create a collection of adjacent elements and set a property value#
import hm
import hm.entities as ent

model = hm.Model()
# Collection of element ID 579
source_col = hm.Collection(model, ent.Element, "id=579")

# Collection of elements adjacent to element with ID 579 (including the element itself)
adjacent_col = hm.CollectionByAdjacent(model, source_col)

prop = ent.Property(model)
# Highlight the elements in the collection
model.hm_highlightmark(adjacent_col, "h")

for el in adjacent_col:
    el.propertyid = prop

CollectionByAttached function#

CollectionByAttached(model: Model, source: Collection)#

Function to create a collection of entities attached to the entities in the source collection.

Note

The model object passed to the function has to represent the active model (i.e. HyperMesh model in the active window). If a non-active model is passed to the function, it will return an empty collection.

Parameters:
  • model (Model) – HyperMesh model object.

  • source (Collection) – Source collection object.

Example - Remesh a collection of elements attached to selected element#
import hm
import hm.entities as ent

model = hm.Model()
# Collection of element ID 579
source_col = hm.Collection(model, ent.Element, "id=579")

# Collection of elements that attached to element ID 579
attached_col = hm.CollectionByAttached(model, source_col)

# Remesh the collection of elements
model.rebuild_mesh_advanced(
    collection=attached_col, mode="rebuild", keep_selection="failed"
)

CollectionByDisplayed function#

CollectionByDisplayed(model: Model, entity_class: EntityClass)#

Function to create a collection of displayed entities of specified entity class.

Note

The model object passed to the function has to represent the active model (i.e. HyperMesh model in the active window). If a non-active model is passed to the function, it will return an empty collection.

Parameters:
  • model (Model) – HyperMesh model object.

  • entity_class (Entity Class) – HyperMesh entity class.

Example - Create a table of element ID, property ID and property card image for displayed elements#
import hm
import hm.entities as ent

model = hm.Model()

# Collection of displayed elements
col_disp = hm.CollectionByDisplayed(model, ent.Element)

# Create a table with name "table1" with three columns
model.tablecreate("table1", 10, 1, ["element", "properties", "string"], 0)

for elem in col_disp:
    # Property handle for each element
    prop = elem.propertyid
    # Add a row with the element ID, property ID and property cardimage
    model.tableaddrow("table1", [f"{elem.id}", f"{prop.id}", f"{prop.cardimage}"])

CollectionByFace function#

CollectionByFace(model: Model, source: Collection, across_t_junctions: bool = False)#

Function to create a collection of entities on the same face as the entities in the source collection.

Note

The model object passed to the function has to represent the active model (i.e. HyperMesh model in the active window). If a non-active model is passed to the function, it will return an empty collection.

Parameters:
  • model (Model) – HyperMesh model object.

  • source (Collection) – Source collection object.

  • across_t_junctions (bool) – Flag to control the treatment of T-junctions. Set to True to select entities across T-junctions.

Example - Apply constraints to nodes of specific elements belonging to a face#
import hm
import hm.entities as ent

model = hm.Model()

source_col = hm.Collection(model, ent.Element, "id=14")
# Collection of elements on the same face as element ID 14
face_col = hm.CollectionByFace(model, source_col)
# Collection of nodes by elements
node_col = hm.Collection(model, ent.Node, face_col)

for node in node_col:
    loadSPC = ent.LoadConstraint(model)
    loadSPC.entityid = node

CollectionByInteractiveSelection function#

CollectionByInteractiveSelection(model: Model, entity_class: EntityClass, highlight: bool = False)#

Function to create a collection by selecting entities interactively in the graphics window.

Note

The model object passed to the function has to represent the active model (i.e. HyperMesh model in the active window). If a non-active model is passed to the function, the selection widget will not be posted and an empty collection will be returned.

Parameters:
  • model (Model) – HyperMesh model object.

  • entity_class (EntityClass) – HyperMesh entity class.

  • highlight (bool) – Flag to keep the selected entities highlighted after creating the collection.

Example - Hide elements selected interactively#
import hm
import hm.entities as ent

model = hm.Model()

col_elem = hm.CollectionByInteractiveSelection(model, ent.Element)

for elem in col_elem:
    model.hideentity(elem)

CollectionSet class#

class CollectionSet(model: Model = None)#

Class representing a set of collections. Only one collection per entity type can be included in a collection set.

Parameters:

model (Model) – HyperMesh model object.

set(collection: Collection = None)#

Method to add a collection to the collection set.

Parameters:

collection (Collection) – Collection object.

eclasses: list#

List of entity classes contained in the collections inside the collection set.

FilterByAttribute class#

class FilterByAttribute(aclass: EntityClass, expression: str)#

Class representing a filter allowing user to create a collection of entities based on their attribute value.

Parameters:
  • aclass (EntityClass) – HyperMesh entity class.

  • expression (str) – Expression defining the search criteria.

Example - Create a collection of materials with Poisson ratio less than 0.3#
import hm
import hm.entities as ent

model = hm.Model()

filter = hm.FilterByAttribute(ent.Material, "Nu<0.3")
mats = hm.Collection(model, filter)

FilterByBox class#

class FilterByBox(aclass: EntityClass, corner1: List[float] | hwTriple, corner2: List[float] | hwTriple, relative_location: int = 0, containment: int = 0, displayed_only: bool = False, tolerance: float = 0.0)#

Class representing a filter allowing user to create a collection of entities inside a virtual box defined by two opposing corners.

Parameters:
  • aclass (EntityClass) – HyperMesh entity class.

  • corner1 (Union[List[float], hwTriple]) – List of x, y, z coordinates of the first corner.

  • corner2 (Union[List[float], hwTriple]) – List of x, y, z coordinates of the second corner.

  • relative_location (int) – Location of the entities to find, relative to the shape (inside, outside, or on the boundaries). See Enum Table for list of valid values.

  • containment (int) – Flag that indicates whether the entire entity or a part of entity should meet the relative location criteria. See Enum Table for list of valid values.

  • displayed_only (bool) – Flag indicating whether all entities or only displayed entities are considered.

  • tolerance (float) – The tolerance to use. In most cases, this should be set to 0.

Example - Create a collection of elements inside a box#
import hm
import hm.entities as ent

model = hm.Model()

filter = hm.FilterByBox(ent.Element, [30, 23, 45], [58, -18, 45], 0, 0, False, 0.0)
elems = hm.Collection(model, filter)

FilterByCollection class#

class FilterByCollection(aclass: EntityClass, source_class: EntityClass)#

Class representing a filter allowing users to create a collection of entities based on a source collection (e.g. elements by properties, elements by materials, nodes by elements, etc.)

Parameters:
  • aclass (EntityClass) – HyperMesh entity class.

  • source_class (EntityClass) – Source entity class.

Example - Create a collection of nodes by elements with ID 15706, 19751#
import hm
import hm.entities as ent

model = hm.Model()

filter = hm.FilterByCollection(ent.Node, ent.Element)
elems = hm.Collection(model, ent.Element, "id=15706,19751")
nodes = hm.Collection(model, filter, elems)

FilterByCone class#

class FilterByCone(aclass: EntityClass, base: List[float] | hwTriple, normal: List[float] | hwTriple, base_radius: float, top_radius: float, height: float, relative_location: int = 0, containment: int = 0, displayed_only: bool = False, tolerance: float = 0.0)#

Class representing a filter allowing user to create a collection of entities inside a virtual cone defined by the base, normal vector, base radius, top radius, and height.

Parameters:
  • aclass (EntityClass) – HyperMesh entity class.

  • base (Union[List[float], hwTriple]) – List of x, y, z coordinates defining the base center.

  • normal (Union[List[float], hwTriple]) – List of x, y, z coordinates defining a point on the cone axis.

  • base_radius (float) – Radius at the cone base.

  • top_radius (float) – Radius at the cone top.

  • height (float) – Height of the cone.

  • relative_location (int) – Location of the entities to find, relative to the shape (inside, outside, or on the boundaries). See Enum Table for list of valid values.

  • containment (int) – Flag that indicates whether the entire entity or a part of entity should meet the relative location criteria. See Enum Table for list of valid values.

  • displayed_only (bool) – Flag indicating whether all entities or only displayed entities are considered.

  • tolerance (float) – The tolerance to use. In most cases, this should be set to 0.

Example - Create a collection of nodes inside a cone with base center at 25.4, 19.05, 23.83, axis aligned with global y, bottom radius of 10.0, top radius of 5.0 and height of 10.0#
import hm
import hm.entities as ent

model = hm.Model()

filter = hm.FilterByCone(
    ent.Node, [25.4, 19.05, 23.83], [25.4, 20, 23.83], 10.0, 5.0, 10.0, 0, 0, False, 0.0
)
nodes = hm.Collection(model, filter)

FilterByCylinder class#

class FilterByCylinder(aclass: EntityClass, base: List[float] | hwTriple, normal: List[float] | hwTriple, radius: float, height: float, relative_location: int = 0, containment: int = 0, displayed_only: bool = False, tolerance: float = 0.0)#

Class representing a filter allowing user to create a collection of entities inside a virtual cylinder defined by the base, normal vector, radius, and height.

Parameters:
  • aclass (EntityClass) – HyperMesh entity class.

  • base (Union[List[float], hwTriple]) – List of x, y, z coordinates defining the base center.

  • normal (Union[List[float], hwTriple]) – List of x, y, z coordinates defining a point on the cylinder axis.

  • radius (float) – Radius of the cylinder.

  • height (float) – Height of the cylinder.

  • relative_location (int) – Location of the entities to find, relative to the shape (inside, outside, or on the boundaries). See Enum Table for list of valid values.

  • containment (int) – Flag that indicates whether the entire entity or a part of entity should meet the relative location criteria. See Enum Table for list of valid values.

  • displayed_only (bool) – Flag indicating whether all entities or only displayed entities are considered.

  • tolerance (float) – The tolerance to use. In most cases, this should be set to 0.

Example - Create a collection of nodes with the center at 44.45, 0.0, 0.0 along global z-axis, with radius of 20.0 and height of 50.0#
import hm
import hm.entities as ent

model = hm.Model()

filter = hm.FilterByCylinder(ent.Node, [44.45, 0.0, 0.0], [44.45, 0.0, 1.0], 20.0, 50.0)
nodes = hm.Collection(model, filter)

FilterByEnumeration class#

class FilterByEnumeration(aclass: EntityClass, ids: List[str] | List[int])#

Class representing a filter allowing user to create a collection of entities based on a list of identifiers.

Parameters:
  • aclass (EntityClass) – HyperMesh entity class.

  • ids (Union[List[str], List[int]]) – List of integers (IDs) or strings (valid only for hm.entities.Part).

Example - Create a collection of elements with IDs 1-1000#
import hm
import hm.entities as ent

model = hm.Model()

filter = hm.FilterByEnumeration(ent.Element, list(range(1,1001)))
elems = hm.Collection(model, filter)

FilterByInfiniteCylinder class#

class FilterByInfiniteCylinder(aclass: EntityClass, base: List[float] | hwTriple, direction: List[float] | hwTriple, relative_location: int = 0, containment: int = 0, displayed_only: bool = False, tolerance: float = 0.0)#

Class representing a filter allowing user to create a collection of entities inside a virtual infinite cylinder defined by the base point and axis direction.

Parameters:
  • aclass (EntityClass) – HyperMesh entity class.

  • base (Union[List[float], hwTriple]) – List of x, y, z coordinates defining the base center.

  • direction (Union[List[float], hwTriple]) – List of x, y, z coordinates defining the direction of the cylinder axis.

  • relative_location (int) – Location of the entities to find, relative to the shape (inside, outside, or on the boundaries). See Enum Table for list of valid values.

  • containment (int) – Flag that indicates whether the entire entity or a part of entity should meet the relative location criteria. See Enum Table for list of valid values.

  • displayed_only (bool) – Flag indicating whether all entities or only displayed entities are considered.

  • radius (float) – Radius of the cylinder.

Example - Create a collection of nodes inside an infinite cylinder with center at 44.45, 0.0, 0.0, oriented along global z-axis, with radius of 20.0#
import hm
import hm.entities as ent

model = hm.Model()

filter = hm.FilterByInfiniteCylinder(
    ent.Node, [44.45, 0.0, 0.0], [44.45, 0.0, 1.0], 0, 0, False, 20.0
)
nodes = hm.Collection(model, filter)

FilterByPlane class#

class FilterByPlane(aclass: EntityClass, base: List[float] | hwTriple, normal: List[float] | hwTriple, relative_location: int = 0, containment: int = 0, displayed_only: bool = False, tolerance: float = 0.0)#

Class representing a filter allowing user to create a collection of entities within a specified distance of a plane defined by a base point and normal vector.

Parameters:
  • aclass (EntityClass) – HyperMesh entity class.

  • base (Union[List[float], hwTriple]) – List of x, y, z coordinates defining the base center.

  • normal (Union[List[float], hwTriple]) – List of x, y, z coordinates defining the normal direction of the plane.

  • relative_location (int) – Location of the entities to find, relative to the shape (inside, outside, or on the boundaries). See Enum Table for list of valid values.

  • containment (int) – Flag that indicates whether the entire entity or a part of entity should meet the relative location criteria. See Enum Table for list of valid values.

  • displayed_only (bool) – Flag indicating whether all entities or only displayed entities are considered.

  • tolerance (float) – The tolerance to use. In most cases, this should be set to 0.

Example - Create a collection of elements within 1.0 distance away from a plane passing through point 44.45, 0.0, 0.0, with global x-axis as the normal vector#
import hm
import hm.entities as ent

model = hm.Model()

filter = hm.FilterByPlane(
    ent.Element, [44.45, 0.0, 0.0], [1.0, 0.0, 0.0], 0, 0, False, 1.0
)
elems = hm.Collection(model, filter)

FilterBySphere class#

class FilterBySphere(aclass: EntityClass, center: List[float] | hwTriple, radius: float, relative_location: int = 0, containment: int = 0, displayed_only: bool = False, tolerance: float = 0.0)#

Class representing a filter allowing user to create a collection of entities inside a virtual sphere defined by center and radius.

Parameters:
  • aclass (EntityClass) – HyperMesh entity class.

  • center (Union[List[float], hwTriple]) – List of x, y, z coordinates defining the center of the sphere.

  • radius (float) – Radius of the sphere.

  • relative_location (int) – Location of the entities to find, relative to the shape (inside, outside, or on the boundaries). See Enum Table for list of valid values.

  • containment (int) – Flag that indicates whether the entire entity or a part of entity should meet the relative location criteria. See Enum Table for list of valid values.

  • displayed_only (bool) – Flag indicating whether all entities or only displayed entities are considered.

  • tolerance (float) – The tolerance to use. In most cases, this should be set to 0.

Example: Create a collection of points inside a sphere with center at 28.5, 41.0, 73.0 and radius of 20#
import hm
import hm.entities as ent

model = hm.Model()
filter = hm.FilterBySphere(ent.Point, [28.5, 41.0, 73.0], 20.0, 0, 0, False, 0.0)
points = hm.Collection(model, filter)

Enum Table#

This is a table of enums that are used in FilterBy classes of hm module as a value in containment and relative_location arguments. It can be used either the enum directly (i.e., containment = hm.CONTAINMENT_FULL) or the corresponding value.

ENUM

Value

Argument

CONTAINMENT_FULL

0

containment

CONTAINMENT_PARTIAL

1

containment

RELATIVE_LOCATION_INSIDE

0

relative_location

RELATIVE_LOCATION_OUTSIDE

1

relative_location

RELATIVE_LOCATION_ONBOUNDARIES

2

relative_location

EntityList class#

class EntityList(*args)#

Class representing a HyperMesh data type used to define a list of HyperMesh entities.

Note

HyperMesh functions support implicit conversion of EntityList, which means a Python list of HyperMesh entity objects can be passed as argument value instead of an EntityList object.

Example - Create a Python list of entity objects representing nodes ID 5, 6, 7 to be used as an argument of type EntityList#
import hm
import hm.entities as ent

model = hm.Model()

node5 = ent.Node(model, 5)
node6 = ent.Node(model, 6)
node7 = ent.Node(model, 7)
model.linecreatefromnodes([node5, node6, node7], 1, 0.0, 0.0, 0.0)

EntityList2 class#

class EntityList2(*args)#

Class representing a HyperMesh data type used to define a 2D list of HyperMesh entities.

Warning

HyperMesh functions do not support implicit conversion of EntityList2 data type in the 2024.0 release. The Python class in the code snippet below can be used to construct an EntityList2 object from a 2D Python list of entity objects.

Example - Helper class to construct EntityList2#
from hwdescriptor import hwUIntList2
from hm import EntityList2, hwUIntList
from typing import List, Union, Type


class EntityList2Generator:
    def __new__(self, entity_list_2d: Type[List]):

        uids_2d = hwUIntList2()

        for entity_list in entity_list_2d:
            uids_1d = hwUIntList()

            for entity in entity_list:
                uids_1d.push_back(entity.id)

            uids_2d.push_back(uids_1d)

        # pick one entity to define the etype class
        ent = entity_list_2d[0][0]
        elist2 = EntityList2(ent.fulltype, uids_2d)

        return elist2


entlist2_obj = EntityList2Generator([[node1, node2], [node3, node4]])

hwBoolList class#

class hwBoolList(*args)#

Class representing a HyperMesh data type used to define a list of Boolean values.

Parameters:

args – List of bool values.

Example#
bool_list = hm.hwBoolList([True, True, False])

hwCouple class#

class hwCouple(*args)#

Class representing a HyperMesh data type used to define a list of two double values.

Parameters:

args – List of two double values.

Example#
couple = hm.hwCouple(5.5, 6.6)

hwCoupleList class#

class hwCoupleList(*args)#

Class representing a HyperMesh data type used to define a list of hwCouple.

Parameters:

args – List of hwCouple.

Example#
couple_list = hm.hwCoupleList([hm.hwCouple(5.5,6.6),hm.hwCouple(1.2,3.4)])

hwDoubleList class#

class hwDoubleList(*args)#

Class representing a HyperMesh data type used to define a list of double values.

Note

HyperMesh functions support implicit conversion of hwDoubleList, which means a Python list of strings can be passed as argument value instead of a hwDoubleList object.

Parameters:

args – List of double values.

Example#
double_list = hm.hwDoubleList([5.5, 6.6, 7.7, 1.1, 2.2])

hwEntityListList class#

class hwEntityListList(*args)#

Class representing a HyperMesh data type used to define a list of EntityList.

Parameters:

args – List of EntityList.

Example#
import hm
import hm.entities as ent

entitylist_list = hm.hwEntityListList(
    [
        hm.EntityList(ent.Line.fulltype, hm.hwUIntList([334, 40, 35, 335])),
        hm.EntityList(ent.Surface.fulltype, hm.hwUIntList([18, 43])),
    ]
)

hwIntList class#

class hwIntList(*args)#

Class representing a HyperMesh data type used to define a list of integer values.

Parameters:

args – List of integer values.

Example#
int_list = hm.hwIntList([-3, -2, 1, 2, 3, 4, 5, 6])

hwIntListList class#

class hwIntListList(*args)#

Class representing a HyperMesh data type used to define a list of lists of integer values.

Parameters:

args – List of hwIntList.

Example#
intlist_list = hm.hwIntListList(hm.hwIntList([-3, -2, 1]), hm.hwIntList([2, 3, 4]))

hwMatrix44 class#

class hwMatrix44(*args)#

Class representing a HyperMesh data type used to define a 4x4 matrix.

Parameters:

args – List of 16 double values.

Example#
matrix44 = hm.hwMatrix44(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)

hwString class#

class hwString(*args)#

Class representing a HyperMesh data type used to define a string.

Note

HyperMesh functions support implicit conversion of hwString, which means a Python string can be passed as argument value instead of a hwString object.

Parameters:

args – str

hwStringList class#

class hwStringList(*args)#

Class representing a HyperMesh data type used to define a list of strings.

Note

HyperMesh functions support implicit conversion of hwStringList, which means a Python list of strings can be passed as argument value instead of a hwStringList object.

Parameters:

args – List of string values.

Example#
string_list = hm.hwStringList(['aaa', 'bbb', 'ccc'])

hwTriple class#

class hwTriple(*args)#

Class representing a HyperMesh data type used to define a triple of double values.

Note

HyperMesh functions support implicit conversion of hwTriple, which means a Python list of three floats can be passed as argument value instead of a hwTriple object.

Parameters:

args – List of three floats.

Example#
triple = hm.hwTriple([5.5, 6.6, 7.7])

hwTripleI class#

class hwTripleI(*args)#

Class representing a HyperMesh data type used to define a triple of integers values.

Parameters:

args – List of three integers.

Example#
triple_int = hm.hwTripleI([5, 6, 7])

hwTripleIList class#

class hwTripleIList(*args)#

Class representing a HyperMesh data type used to define a list of integer triples.

Parameters:

args – List of hwTripleI objects.

hwTripleList class#

class hwTripleList(*args)#

Class representing a HyperMesh data type used to define a list of float triples.

Parameters:

args – List of hwTriple objects.

hwUIntList class#

class hwUIntList(*args)#

Class representing a HyperMesh data type used to define a list of unsigned integer values.

Parameters:

args – List of unsigned integer values.

Example#
unsigned_int_list = hm.hwUIntList([1, 2, 3, 4, 5])

hm_getcurrentmodel function#

hm_getcurrentmodel(flag: hwString = 'False')#

A function that returns a result object containing the name of the current model loaded in HyperMesh.

Parameters:

flag (hwString) – The parameter flag defining the returned name type. Valid values are ‘False’ (default) and ‘True’.

Returns:

  • hwReturnStatus - The status object.

  • hmQueryResult - The query result object.

hm_getoption function#

hm_getoption(option: hwString, defaultValue: int = 0)#

A function that returns result object containing the current value of a HyperMesh option or its default value. For the full list of available options, please refer to the page setoption.

Note

Options block_error_messages and block_messages are redundant in Python API as their values are handled automatically within the Python API infrastructure.

Parameters:
  • option (hwString) – The name of the option.

  • defaultValue (int) – The default value flag. If set to 1, the function returns the default value of the option instead of the current value.

Returns:

  • hwReturnStatus - The status object.

  • hmQueryResult - The query result object.

Example#
import hm

# Getting the display color on free edges
status, result = hm.hm_getoption("display_color-1")
print(result.value)
# Getting the loads max size
status, result = hm.hm_getoption("load_max_size")
print(result.value)

hm_getoption_cad_reader function#

hm_getoption_cad_reader(cad_reader: hwString, option: hwString = '')#

A function that returns a result object containing the value of a CAD reader option.

Parameters:
  • cad_reader (hwString) – The format of the CAD reader. Valid formats are acis, aveva, catia, catiav6, creo, dxf, iges, inspire, Intergraph, inventor, jt, nx_ct, nx_native, ocx, parasolid, pdgs, rhino, solidworks, step and vdafs.

  • option (hwString) – The name of the option. Valid options for each format can be referred from the cadiooptionname attributes of the respective <format>.xml files in <altair_home>/hm/scripts/ImportExport/xml/geometry/import.

Returns:

  • hwReturnStatus - The status object.

  • hmQueryResult - The query result object.

Example#
import hm

# Getting the type on which components are split in catiav6 reader
status, result = hm.hm_getoption_cad_reader(
cad_reader="catiav6", option="SplitComponents"
)
print(result.option)

hm_getoption_cad_writer function#

hm_getoption_cad_writer(cad_writer: hwString, option: hwString = '')#

A function that returns a result object containing the value of a CAD writer option.

Parameters:
  • cad_writer (hwString) – The format of the CAD writer. Valid formats are iges, inspire, jt, parasolid, and step.

  • option (hwString) – The name of the option. Valid options for each format can be referred from the cadiooptionname attributes of the respective <format>.xml files in <altair_home>/hm/scripts/ImportExport/xml/geometry/export.

Returns:

  • hwReturnStatus - The status object.

  • hmQueryResult - The query result object.

Example#
import hm

# Getting the cuurent type target units for the exporting in a step file
status, result = hm.hm_getoption_cad_writer(
cad_writer="step", option="TargetUnits"
)
print(result.option)

setoption function#

setoption(**kwargs)#

A function to set various HyperMesh option values. For the full list of available options, please refer to the page setoption.

Note

The options using “-” character in the name have been internally remapped to use “_” in Python. For example, to set the option display_color-<config> via Python API user has to define the argument name as display_color_<config>.

Options block_error_messages and block_messages are redundant in Python API as their values are handled automatically within the Python API infrastructure.

Parameters:

kwargs – The list of name-value pair arguments defining the option name and option value (e.g. block_redraw=1).

Note

The argument “1d_at_centroid” (used in Tcl) was renamed to “singledim_at_centroid”

Example#
import hm

# Setting geometry cleanup tolerance to 0.1
hm.setoption(cleanup_tolerance=0.1)
# Setting the order to 2 and the size to 1 of newly created elements
hm.setoption(element_order=2, element_size=1.0)
# Turning on the display of forces (1), constraints (3) and pressure (4) labels
hm.setoption(load_label_1=1, load_label_3=1, load_label_4=1)

setoption_cadreader function#

setoption_cadreader(cad_reader: hwString, option_name: hwString, option_value: hwString)#

A function to set various CAD reader option values.

Parameters:
  • cad_reader (hwString) – The format of the CAD reader. Valid formats are acis, aveva, catia, catiav6, creo, dxf, iges, inspire, Intergraph, inventor, jt, nx_ct, nx_native, ocx, parasolid, pdgs, rhino, solidworks, step and vdafs.

  • option_name – The name of the option. Valid options for each format can be referred from the cadiooptionname attributes of the respective <format>.xml files in <altair_home>/hm/scripts/ImportExport/xml/geometry/import.

  • option_value (hwString) – The value of the option.

Example#
import hm

# Setting import Units and the type which reader use to create the parts for Solidworks
hm.setoption_cadreader(
    cad_reader="solidworks", option_name="TargetUnits", option_value="MMKS (mm kg N s)"
)
hm.setoption_cadreader(
    cad_reader="solidworks", option_name="CreationType", option_value="Parts"
)
# Setting import clean up tolerance for iges files
hm.setoption_cadreader(cad_reader="iges", option_name="CleanupTol", option_value="0.1")

setoption_cadwriter function#

setoption_cadwriter(cad_writer: hwString, option_name: hwString, option_value: hwString)#

A function to set various CAD writer option values.

Parameters:
  • cad_writer (hwString) – The format of the CAD writer. Valid formats are iges, inspire, jt, parasolid, and step.

  • option_name – The name of the option. Valid options for each format can be referred from the cadiooptionname attributes of the respective <format>.xml files in <altair_home>/hm/scripts/ImportExport/xml/geometry/export.

  • option_value (hwString) – The value of the option.

Example#
import hm

# Setting Export option to All for the IGES writer
hm.setoption_cadrwriter(cad_writer="iges", option_name="Export", option_value="All")

# Setting topology and geometry mode to Parasolid writer
hm.setoption_cadrwriter(
    cad_writer="parasolid", option_name="TopologyMode", option_value="Surface"
)
hm.setoption_cadrwriter(
    cad_writer="parasolid", option_name="GeometryMode", option_value="Bspline"
)