Is there any plan to include a Mesh/Plane intersection, similar to what is possible in GH with an output of a polycurve?
there is mesh_cut_by_plane
in the core library (however, this function doesn’t return an intersection polygon), but a more robust and much faster version is available in compas_cgal
. (https://blockresearchgroup.github.io/compas_cgal/)
the new plugin system will soon allow the CGAL based version to be plugged into core COMPAS and use it from there…
1 Like
from compas.datastructures import Mesh
from compas.geometry import Line, Plane, Vector
from compas.geometry import is_point_on_plane
mesh = Mesh.from_polyhedron(8)
normal = Vector(0, 1, 0)
plane = Plane([0,0,0], normal)
# cut mesh by plane
section1, _ = mesh.cut(plane)
# get intersection line
cut = []
for vert1, vert2 in section1.edges():
p1, p2 = section1.vertex_coordinates(vert1), section1.vertex_coordinates(vert2)
if is_point_on_plane(p1, plane) and is_point_on_plane(p2, plane):
cut.append(Line(p1, p2))
section = Mesh.from_lines(cut)