Lua: Mesh Utilities
Description
The Lua API provides helper functions for extending, transforming, saving, inspecting, and visualizing meshes.
Extending a Mesh
Use modalys.extend_mesh to duplicate mesh elements into higher-dimensional structures. It is also available as extend_mesh, duplicate_mesh, and modalys.duplicate_mesh.
local mesh = create_mesh{ kind="single-point", position={ 0, 0.1, 0 } }
mesh = extend_mesh{
method = "translation",
mesh = mesh,
steps = 5,
vector = { 0, 0.1, 0 }
}
Supported methods are:
- translation
- rotation
- helix
- homothety
- reflection
Transforming a Mesh
Use modalys.transform_mesh to transform an existing mesh in place. It is also available as transform_mesh.
transform_mesh{
method = "rotation",
mesh = mesh,
axis = { 0, 0, 1 },
center = { 0, 0, 0 },
angle = 30
}
Supported methods are:
- translation
- rotation
- helix
- homothety
- reflection
Saving and Reading Geometry
save_mesh{
mesh = mesh,
path = "/Users/Shared/test.mesh"
}
local objectMesh = get_mesh(myFiniteElementObject)
modalys.save_mesh is also available as save_mesh. modalys.get_mesh is also available as get_mesh.
Node Coordinates
local xyz = get_node_coordinates(mesh, 7)
local y = get_node_coordinates(mesh, 7, 1)
local same = node_to_coordinates{ object=mesh, node=7 }
modalys.get_node_coordinates returns the full coordinate table when no rank is given. With a rank, it returns one coordinate. Aliases include get_node_coordinates, modalys.get_node_coordinate, modalys.node_to_coordinate, modalys.node_to_coordinates, and node_to_coordinates.
Coordinates to Node
local node = coordinates_to_node{
obj = mesh,
xyz = { 0.75, 0.26, 0 }
}
modalys.coordinates_to_node returns the node number matching the coordinates, or 0 if no node is found. It is also available as coordinates_to_node.
Visualization
view_mesh(mesh)
view_object(myFiniteElementObject)
view{ object=myFiniteElementObject, mode=3, frames=50, amp=0 }
★