Model.hm_getorientation#
- Model.hm_getorientation(entityCollection, comparetype=0, samplingFile='')#
Returns a 4x4 matrix (16 values) corresponding to the moment directions of the input.
- Parameters:
entityCollection (Collection) – The collection containing the entities to query. Valid entities are elements, solids, surfaces, nodes, components and parts.
comparetype (int) –
The type of comparison when entity type of
entityCollectionis components or parts:0 - Consider both FE (elements) and CAD (surfaces/solids). Default if not specified.
1 - Prefer CAD. Use FE when there is no CAD.
2 - Only CAD.
3 - Prefer FE. Use CAD when there is no FE.
4 - Only FE.
samplingFile (hwString) – Optional path to a file for saving the sampling data.
- Returns:
hwReturnStatus- Status objectHmQueryResultList- Result list object containingHmQueryResultobjects with the following output data:orientation (numpy.ndarray) - The list of 16 values representing the moment directions of the input
Examples#
Find the difference between the orientation of two selections of surfaces#import hm import hm.entities as ent def matToList(matrix: numpy.ndarray): """ Simple function that converts a numpy array of numpy arrays to list """ converted_list = list() for row in matrix: for col in row: converted_list.append(col) return converted_list model = hm.Model() # Orientation matrix for surfaces with IDs 22-44 on current model surface_collection_1 = hm.Collection(model, ent.Surface, list(range(22, 45))) _, resultlist = model.hm_getorientation(entityCollection=surface_collection_1) result = resultlist[0] # Length of resultlist = 1 in this case m1 = matToList(result.orientation) # Orintation matrix converted to list # Orientation matrix for surfaces with IDs 56-61 on current model surface_collection_2 = hm.Collection(model, ent.Surface, list(range(56, 61))) _, resultlist = model.hm_getorientation(entityCollection=surface_collection_2) result = resultlist[0] # Length of resultlist = 1 in this case m2 = matToList(result.orientation) # Orintation matrix converted to list _, result = model.hm_getmatrixdifference(matrix_1=m1, matrix_2=m2) print("Transformation Matrix:", result.transformationMatrix.reshape(4, 4))
Find the difference between the orientation of two components#import hm import hm.entities as ent def matToList(matrix: numpy.ndarray): """ Simple function that converts a numpy array of numpy arrays to list """ converted_list = list() for row in matrix: for col in row: converted_list.append(col) return converted_list model = hm.Model() # Orientation matrix for components with IDs 44, 45 on current model comps_collection_1 = hm.Collection(model, ent.Component, [44, 45]) _, resultlist = model.hm_getorientation( entityCollection=comps_collection_1, comparetype=1 ) result = resultlist[0] # Length of resultlist = 2 in this case m1 = matToList(result.orientation) # Orintation matrix converted to list result = resultlist[1] m2 = matToList(result.orientation) # Orintation matrix converted to list _, result = model.hm_getmatrixdifference(matrix_1=m1, matrix_2=m2) print("Transformation Matrix:", result.transformationMatrix.reshape(4, 4))