Code: Select all
import FreeCAD as App
doc = App.ActiveDocument
cube = doc.addObject("Mesh::Cube", "Cube")
cube.Length = 10
cube.Width = 10
cube.Height = 10
cube.Placement.Base = App.Vector(50, 50, 0)
doc.recompute()
mesh = cube.Mesh
print(mesh.BoundBox) # BoundBox (45, 45, -5, 55, 55, 5)
result_1 = mesh.nearestFacetOnRay((1, 2, 10), (0, 0, 1))
print(result_1) # {10: (1.0, 2.0, 5.0)}
result_2 = mesh.foraminate((1, 2, 10), (0, 0, 1))
print(result_2) # {8: (1.0, 2.0, -5.0), 10: (1.0, 2.0, 5.0)}