carbonfly.mesh module
Mesh utilities for Rhino-based OpenFOAM workflows.
This module provides helper functions to convert Rhino geometries into triangle meshes and export them in formats suitable for OpenFOAM.
Note
This module depends on the RhinoCommon API and can only be used
inside Rhino / Grasshopper. The Rhino module is provided by Rhino.
- carbonfly.mesh.brep_to_mesh(brep: Rhino.Geometry.Brep) Rhino.Geometry.Mesh[source]
Convert a Rhino Brep into a single unified Mesh.
- Parameters:
brep (Rhino.Geometry.Brep) – Input Brep geometry.
- Returns:
A unified, triangulated mesh, or None if meshing failed.
- Return type:
Rhino.Geometry.Mesh
- carbonfly.mesh.mesh_triangles(mesh)[source]
Iterate over all triangular faces of a Rhino Mesh and yield triangle vertices + normals. If a face is a quad, it will be triangulated using MeshFace.Triangulate().
- Parameters:
mesh (Rhino.Geometry.Mesh) – Input mesh (ideally triangulated).
- Yields:
tuple –
- ((ax,ay,az), (bx,by,bz), (cx,cy,cz), (nx,ny,nz))
where (a,b,c) are vertex coordinates and (n) is the face normal.
- carbonfly.mesh.write_multi_solid_ascii_stl(out_path, named_meshes: Iterable[Tuple[str, Rhino.Geometry.Mesh]], unit: str)[source]
Write a multi-solid ASCII STL file.
Each entry in named_meshes becomes one solid <name> … endsolid <name> block. Geometry is scaled to meters using unit.
- Parameters:
out_path – Output path (Path or str).
named_meshes – Iterable of (name, mesh) pairs.
unit – Unit label for input meshes (“mm” | “cm” | “m”).
- Returns:
Path to the written STL file.