MeshEditor#
- Usage:
MeshEditor Class API Wrapper
- class MeshEditor[source]#
Bases:
object
Wrapper for MeshEditor class of Moldflow Synergy.
- align_nodes(node1, node2, to_align)[source]#
Aligns a set of nodes so that they are collinear with a given pair of nodes
- Parameters:
- Return type:
bool
- Returns:
True if operation is successful; False otherwise
- align_normals(seed_tri, tris)[source]#
Aligns the normals of a set of triangles to match a seed triangle
- auto_fix()[source]#
Attempts to repair the mesh by automatically removing overlaps and intersections
- Returns:
The number of elements repaired
- Return type:
int
- contact_stitch_interface(merge_tol)[source]#
Stitches contact interface triangles
- Parameters:
merge_tol (float) – Merge tolerance
- Return type:
int
- Returns:
0 if no contact interfaces are found 1 if the operation is successful 2 if the 3D Mold Mesh functionality has not been used to prepare the mold internal surface
- convert_to_beams(start_node, prop, junction, num_branch)[source]#
Converts mesh to beam elements
- Parameters:
- Return type:
int
- Returns:
Number of beams created
- convert_wedges_to_tetras(wedges, num_layer)[source]#
Converts wedges to tetras
- Parameters:
wedges (EntList | None) – EntList object containing the wedges to be converted
num_layer (int) – Number of layers
- Return type:
bool
- Returns:
True if operation is successful; False otherwise
- create_beams(node1, node2, num_beams, prop)[source]#
Creates a beam between two nodes
- Parameters:
- Return type:
- Returns:
The new beam.
- create_beams_by_points(pt1, pt2, num, prop)[source]#
Creates beams between two points
- Parameters:
- Return type:
- Returns:
The new beam.
- create_entity_list()[source]#
Creates a new entity list in the model. When using this function, it will first ask for result invalidation. If you want to select entities without checking result, use study_doc.create_entity_list(). :rtype:
EntList
:returns: The new entity list.
- create_tet(node1, node2, node3, node4, prop)[source]#
Creates a tetrahedron from 4 nodes and a property
- Parameters:
node1 (EntList | None) – EntList object containing the first node
node2 (EntList | None) – EntList object containing the second node
node3 (EntList | None) – EntList object containing the third node
node4 (EntList | None) – EntList object containing the fourth node
prop (Property | None) – Property object containing the property of the tetrahedron
- Return type:
- Returns:
The new tetrahedron.
- create_tri(node1, node2, node3, prop)[source]#
Creates a tetrahedron from 4 nodes and a property
- Parameters:
- Return type:
- Returns:
The new triangle
- create_wedge(node1, node2, node3, node4, node5, node6, prop)[source]#
Creates a wedge from 6 nodes and a property
- Parameters:
node1 (EntList | None) – EntList object containing the first node
node2 (EntList | None) – EntList object containing the second node
node3 (EntList | None) – EntList object containing the third node
node4 (EntList | None) – EntList object containing the fourth node
node5 (EntList | None) – EntList object containing the fifth node
node6 (EntList | None) – EntList object containing the sixth node
prop (Property | None) – Property object containing the property of the wedge
- Return type:
- Returns:
The new wedge.
- cut_triangles_by_plane(plane_normal, ref_point, fill, smooth)[source]#
Cut visible triangles by a plane defined by plane normal and a reference point on the plane
- Parameters:
- Return type:
bool
- Returns:
True if operation is successful; False otherwise
- delete(entities)[source]#
Deletes a set of entities
- Parameters:
entities (EntList | None) – EntList object containing entities to be deleted
- Return type:
- Returns:
EntList object containing entities that were not deleted If you attempt to delete nodes that are referenced by elements or boundary conditions, these will not be deleted. You would need to delete the dependent entities first
- extrude_triangles(offset_tri, dist, scale, smooth_nb, create_new_body, prop)[source]#
Extrude selected triangles in surface normal direction by a specified distance
- Parameters:
offset_tri (EntList | None) – EntList object containing the triangles to be extruded
dist (float) – Extrusion distance
scale (float) – scale selected triangles
smooth_nb (bool) – whether to smooth surrounding triangles after extrusion
create_new_body (bool) – whether to form a separate body with new triangles
prop (Property | None) – Property object containing the property of the extruded mesh
- Return type:
bool
- Returns:
True if operation is successful; False otherwise
- fill_hole(nodes, fill_type=None)[source]#
Fill a “hole” in the mesh by creating triangles between given nodes If fill_type provided, fill a “hole” in the mesh by creating new triangles
- Parameters:
nodes (EntList | None) – EntList ordered sequence of nodes defining the outer boundary of the hole
fill_type (int, optional) – Default is 0, triangles around the hole will be bent.
- Return type:
bool
- Returns:
True if operation is successful; False otherwise
- find_property(prop_type, prop_id)[source]#
Finds a property by type and ID
- Parameters:
prop_type (int) – Property type
prop_id (int) – Property ID
- Return type:
- Returns:
The Property.
- fix_aspect_ratio(target)[source]#
Attempts to reduce triangle aspect ratios in the mesh below a specified value
- Parameters:
target (float) – target aspect ratio
- Return type:
int
- Returns:
number of elements modified to effect aspect ratio reduction
- flip_normals(tris)[source]#
Flips triangle normals
- Parameters:
tris (EntList | None) – EntList object containing the triangles whose normals are to be flipped
- Return type:
bool
- Returns:
True if operation is successful; False otherwise
- global_merge(tolerance, fusion, bad_tri, squeeze=True, remove_dup_elements=True, merge_dup_nodes=True, vis_only=False)[source]#
Merges nodes in the model that are within a specified tolerance
- Parameters:
tolerance (float) – specifies the tolerance for merging nodes
fusion (bool) – specify True to disallow merges between nodes that are not on the same element
bad_tri (bool) – specify True to merge bad triangles
squeeze (bool) – specify True to squeeze the mesh
remove_dup_elements (bool) – specify True to remove duplicate elements
merge_dup_nodes (bool) – specify True to merge duplicate nodes
vis_only (bool) – specify True to only merge visible nodes
- Return type:
int
- Returns:
number of nodes merged
- imprint_selected_triangles(tri)[source]#
Align nodes and triangles in selected areas
- Parameters:
tri (EntList | None) – EntList object containing the triangles to be imprinted
- Return type:
bool
- Returns:
True if operation is successful; False otherwise
- imprint_visible_triangles()[source]#
Align visible nodes and triangles
- Return type:
bool
- Returns:
True if operation is successful; False otherwise
- insert_node(node1, node2)[source]#
Inserts a node between two existing nodes. :type node1:
EntList
|None
:param node1: EntList object containing the first node :type node1: EntList | None :type node2:EntList
|None
:param node2: EntList object containing the second node :type node2: EntList | None- Return type:
- Returns:
The new node.
- insert_node_in_tet(node1, node2=None, node3=None, node4=None)[source]#
Inserts a node in the centroid of a given tetrahedron
Provide 1 Entlist containing 4 nodes or 4 Entlist containing 1 node each.
- Parameters:
- Return type:
- Returns:
The new node at the centroid of tetrahedron.
- insert_node_in_tet_by_nodes(node1, node2, node3, node4)[source]#
DEPRECATED: Use insert_node_in_tet instead. Inserts a node in the centroid of a given tetrahedron
- Parameters:
- Return type:
- Returns:
The new node at the centroid of tetrahedron.
- insert_node_in_tri(node1, node2=None, node3=None)[source]#
Inserts a node in the centroid of a given triangle
Provide 1 Entlist containing 3 nodes or 3 Entlist containing 1 node each.
- insert_node_on_beam(beam, num_div=2)[source]#
Inserts nodes on a beam. :type beam:
EntList
|None
:param beam: EntList object containing the beam :type beam: EntList | None :type num_div:int
:param num_div: Number of divisions to be created along the beam. Default is 2. :type num_div: int- Return type:
- Returns:
Entlist of the new node.
- make_region(tol, is_angular, mesh=True, prop=None)[source]#
Creates geometric regions from mesh triangle or STL
- Parameters:
tol (float) – specifies planar or angular tolerance
is_angular (bool) – specify True to check angular tolerance when merging triangles and False to specify a planar tolerance
mesh (bool) – specify True to convert mesh to regions and False to convert STL
prop (Property) – property to set the region (for STL only)
- Return type:
int
- Returns:
Number of regions created
- match_nodes(nodes, tris, layer)[source]#
Matches the nodes of a set of triangles to a set of nodes
- Parameters:
- Return type:
int
- Returns:
Number of nodes affected
- merge_nodes(target, nodes, fusion, use_mid=False)[source]#
Merges nodes in the model that are within a specified tolerance
- Parameters:
target (EntList | None) – EntList object containing the target node
nodes (EntList | None) – EntList object containing the set of nodes to be merged to the target node
fusion (bool) – specify True to disallow merges between nodes that are not on the same element
use_mid (bool) – specify True to merge nodes to midpoint
- Return type:
int
- Returns:
number of nodes merged
- move_node_to_edge(node, edge_node1, edge_node2, param_loc)[source]#
Moves a node to a triangle edge. It breaks triangles that share the edge and creates new ones if necessary
- Parameters:
node (EntList | None) – EntList object containing the node to be moved
edge_node1 (EntList | None) – EntList object containing the first node of the edge
edge_node2 (EntList | None) – EntList object containing the second node of the edge
param_loc (float) – parameter location along the edge (0.0 to 1.0)
- Return type:
bool
- Returns:
True if operation is successful; False otherwise
- move_nodes(nodes, vector, loc)[source]#
Moves nodes to a new location or by an offset :type nodes:
EntList
|None
:param nodes: EntList object containing the nodes to be moved :type nodes: EntList | None :type vector:Vector
|None
:param vector: Vector object that specifies the destination location or anoffset vector
- Parameters:
loc (bool) – specify True to specify a location and False to to specify an offset vector
- Return type:
bool
- Returns:
True if successful; False otherwise.
- offset_triangles(offset_tri, offset_dist, falloff_dist, smooth_nb)[source]#
Offsets triangles by a given distance
- Parameters:
offset_tri (EntList | None) – EntList object containing the triangles to be offset
offset_dist (float) – Offset distance
falloff_dist (float) – Falloff distance
smooth_nb (bool) – whether to smooth surrounding triangles after offset
- Return type:
bool
- Returns:
True if operation is successful; False otherwise
- orient(fusion)[source]#
Orients the mesh
- Parameters:
fusion (bool) – specify True if the mesh if for a fusion model
- Return type:
bool
- Returns:
True if operation is successful; False otherwise
- project_mesh(tris)[source]#
Project mesh to geometry
- Parameters:
tris (EntList | None) – EntList object containing the triangles to be projected
- Return type:
bool
- Returns:
True if operation is successful; False otherwise
- purge_nodes()[source]#
Deletes nodes in the model that are not connected to any elements
- Returns:
The number of nodes deleted
- Return type:
int
- refine_tetras(tet_ref_layer, num_layer, refine_surface, surface_edge_length)[source]#
Refine selected tetras
- Parameters:
tet_ref_layer (int) – Layer ID
num_layer (int) – Number of layers
refine_surface (bool) – specify True to refine the surface mesh
surface_edge_length (float) – Length of the edge of the surface mesh
- Return type:
bool
- Returns:
True if operation is successful; False otherwise
- refine_tetras_by_labels(nodes, num_layer, isolate_refined_tet, refine_surface, surface_edge_length)[source]#
Refine selected tetras by labels
- Parameters:
nodes (EntList | None) – EntList object containing the nodes to be refined
num_layer (int) – Number of layers
isolate_refined_tet (bool) – specify True to isolate the refined tetras
refine_surface (bool) – specify True to refine the surface mesh
surface_edge_length (float) – Length of the edge of the surface mesh
- Return type:
bool
- Returns:
True if operation is successful; False otherwise
- remesh_area(tris, size, imprint=False, smooth=0.0)[source]#
Remesh a set of triangles
- Parameters:
tris (EntList | None) – EntList object containing the triangles to be remeshed
size (float) – Size of the new mesh
imprint (bool) – specify True to imprint the mesh onto the surface mesh
smooth (float) – smoothing factor (0.0 to 1.0)
- Return type:
bool
- Returns:
True if operation is successful; False otherwise
- smooth_nodes(nodes, feat)[source]#
Performs Laplacian smoothing on a set of nodes
- Parameters:
nodes (EntList | None) – EntList object containing the nodes to be smoothed
feat (bool) – specify True to preserve feature edges during smoothing
- Return type:
bool
- Returns:
True if operation is successful; False otherwise
- stitch_free_edges(nodes, tolerance)[source]#
Stitches free edges within a given tolerance by providing a set of nodes
- Parameters:
nodes (EntList | None) – EntList object containing the nodes
tolerance (float) – float Tolerance
- Return type:
bool
- Returns:
True if successful False otherwise
- swap_edge(tri1, tri2, feat_allow=False)[source]#
Swaps the common edge between two triangles
- Parameters:
- Return type:
bool
- Returns:
True if operation is successful; False otherwise
- view_contact_stitch(merge_tol)[source]#
Preview the contact surface layer created by the stitch operation
- Parameters:
merge_tol (float) – Merge tolerance
- Return type:
int
- Returns:
0 if no contact interfaces are found 1 if the operation is successful 2 if the 3D Mold Mesh funcationality has not been used to prepare the mold internal surface