Skip to content

Trimmed Surfaces

Keith Sloan edited this page Oct 6, 2026 · 4 revisions

Trimmed surfaces: trimmed export & the trim3dm extension

Exporting trimmed surfaces

rhino3dm's Python bindings expose no API to author Brep trim topology (rhino3dm #712), so on its own export3DM cannot write a trimmed FreeCAD face as a true trimmed Rhino Brep. The compiled trim3dm extension fills that gap — it builds trimmed Breps directly with OpenNURBS. The preference ExportTrimmedBreps (default on, in BaseApp/Preferences/Mod/ImportExport_3DM) selects the mode:

trim3dm built trim3dm not built
ExportTrimmedBreps on (default) trimmed Breps — each face written as a Brep with its real outer/inner trim loops and 2D pcurves warning in the Report View, then the untrimmed fallback
ExportTrimmedBreps off untrimmed fallback untrimmed fallback
  • Trimmed Breps: holes and non-rectangular boundaries survive, and the file re-imports face-for-face (all 21 AstoCAD Forms export test cases round-trip with exact face counts and areas). Each FreeCAD face is currently written as its own Brep, so a closed solid opens in Rhino as separate surfaces rather than one joined polysurface (use Join in Rhino).
  • Untrimmed fallback: the underlying untrimmed NURBS surface plus its trim boundary as separate NURBS curves. Surface and edges are preserved and the face can be re-trimmed on the Rhino side, but the .3dm contains no trimmed Brep — lossy for any face whose trim is not its full surface rectangle.

One importer with optional enhanced trim support

  • import3DM (pure Python, rhino3dm ≥ 8.32) is the single import type. It reads Rhino trimmed Breps via the official trim-topology API and reconstructs them natively with FreeCAD Part; the OCCT Part.Shell sew is guarded by ImportSewFaceLimit (default 8), so v4_DVDCase_Solid / v5_ring cannot produce invalid solids or hang.

  • trim3dm (the trim3dm C++/OpenNURBS extension) is used automatically by import3DM for any file that contains trimmed Breps whenever a build is present. It reads the real 2D trim data for every Brep face, so complex solids (the whole openNURBS V1–V6 set — TreeFrog, DVDCase, v5_ring, …) import completely with no lost faces; the file's other objects (curves, meshes, points, extrusions) are then imported natively alongside. Files with a trimmed Brep on a hidden Rhino layer use the native path instead, so layer visibility is respected. Without a build the native reconstruction is used and startup reports import 3DM - Trimmed Edges NOT SUPPORTED - Please build Trim3D.

  • Fixed (import3DM 0.6.0): duplicated faces on the trim3dm path. trim3dm reads every Brep face, including untrimmed single-surface Breps, but the native pass that adds the file's other objects also re-imported those single-surface Breps, so they appeared twice. This affected only users with trim3dm built, in files mixing trimmed and untrimmed Breps — 27 of the 138 openNURBS samples (e.g. v1_T-Joint2 read 3,259 instead of 2,257, and the DeformCubes, Lightbulb, Patch and UntrimmedSurfaces files). The native pass now skips all Breps when trim3dm is used. The Serpentine Gallery area cross-check was measured on the native path and was not affected.

Building the trim3dm extension

The compiled extension (trim3dm*.so / .pyd) is not committed — it is platform/Python-specific, so a fresh clone must build it:

brew install cmake          # macOS; needs Xcode CLT for a C++17 compiler
PYTHON=/Applications/FreeCAD_1.1.app/Contents/Resources/bin/python \
  trim3dm/build.sh          # clones OpenNURBS + pybind11, builds, copies the .so next to README

Then copy the resulting trim3dm*.so into the installed module's trim3dm/ folder (or leave it in the repo's trim3dm/) and restart FreeCAD — startup will report Trimmed Edges SUPPORTED, and Brep-only trimmed files are imported with the enhanced reader automatically. If the .so is missing, startup prints import 3DM - Trimmed Edges NOT SUPPORTED - Please build Trim3D and imports use the native reconstruction.

Clone this wiki locally