/cad-3d-printing:cad-geometry-kernels-formats-and-code-cadfrom cad-3d-printing
Guides on geometry representations (B-rep, mesh, implicit, voxel), kernels, file format conversion losses, and code-CAD scripting including OpenSCAD vs OCCT-based tools and parametric modeling.
Ships in cad-3d-printing. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Part 1 of 5 of the CAD and 3D Printing reference (plugin
cad-3d-printing), covering §0–§4. Sibling skills:cad-slicing-pipeline-and-processes(§5–§6),cad-design-tolerances-and-materials(§7–§9),cad-generative-automation-and-scanning(§10–§12),cad-reference(§13–§18). Section numbers are shared across the set; a reference written as §N →skillpoints into that sibling skill.Currency: The geometry mathematics and process physics are stable; the code-CAD tooling and slicer landscape moved. See §16 →
cad-referencefor both, dated.
Scope. Written for people who write code. §2–§4 are the software engineering (kernels, scripting, formats); §6–§9 →
cad-slicing-pipeline-and-processes,cad-design-tolerances-and-materialsare the manufacturing physics you need for the software to produce parts that work.⚠️ GOTCHA boxes mark what silently produces a bad model or an unprintable part.
The three ideas that organize everything:
- ⚠️ Choose your representation before your tool. B-rep, mesh, and implicit fields are not interchangeable — each makes some operations trivial and others impossible, and most CAD frustration is a representation mismatch (§1).
- ⚠️ Every export loses something. STL loses units, topology, colour, and all parametric intent. STEP keeps the solid but not the feature tree. Know what falls off at each hop (§3).
- ⚠️ The printer does not build your model, it builds your G-code. Slicing is a lossy, opinionated transformation, and the part's real properties — strength, accuracy, surface — are determined there and by the process physics, not by the CAD (§5 →
cad-slicing-pipeline-and-processes, §6 →cad-slicing-pipeline-and-processes).
| You want... | Go to |
|---|---|
| Geometry representations | §1 |
| Kernels and libraries | §2 |
| File formats | §3 |
| Code-CAD and scripting | §4 |
| Mesh processing and repair | §4.5 |
| The slicing pipeline | §5 → cad-slicing-pipeline-and-processes |
| G-code | §5.4 → cad-slicing-pipeline-and-processes |
| Additive processes | §6 → cad-slicing-pipeline-and-processes |
| Design for AM | §7 → cad-design-tolerances-and-materials |
| Tolerances and fits | §8 → cad-design-tolerances-and-materials |
| Materials | §9 → cad-design-tolerances-and-materials |
| Generative design and lattices | §10 → cad-generative-automation-and-scanning |
| Automation pipelines | §11 → cad-generative-automation-and-scanning |
| Scanning and reverse engineering | §12 → cad-generative-automation-and-scanning |
| Anti-patterns | §13 → cad-reference |
| Numbers | §14 → cad-reference |
| Books and tools | §15 → cad-reference |
| What actually moved | §16 → cad-reference |
| Quick reference | §17 → cad-reference |
⚠️ This is the decision everything else follows from.
| Representation | Stores | Good at | ⚠️ Bad at |
|---|---|---|---|
| B-rep | Faces, edges, vertices; each face an exact surface | ⚠️ Exact curves, fillets, chamfers, STEP interchange, machining | Organic shapes; robustness of booleans |
| CSG | A tree of primitives + boolean ops | ⚠️ Parametric intent, compact, always "valid" | Fillets on arbitrary edges; export fidelity |
| Mesh (B-rep's poor cousin) | Triangles | Rendering, printing, scanning, simulation | ⚠️ Approximation only; no exact curves; repair burden |
| Implicit / SDF | A function f(x,y,z) | ⚠️ Booleans are trivial and always valid; lattices, blends, infinite detail | Exact dimensions, sharp features, CAD interchange |
| Voxel | A 3D grid | Simple booleans, topology optimization, medical | Memory (O(n³)), no exact surfaces |
| Point cloud | Points, maybe normals | Scanning output | Not a solid at all until reconstructed |
⚠️ NURBS underpin B-rep surfaces: a rational B-spline with control points, knot vector,
and weights. The rational part is what lets them represent conic sections exactly —
a circle is not a spline approximation in NURBS, it's exact. Degree, continuity (C⁰
positional, C¹ tangent, C² curvature — ⚠️ G² curvature-continuous is what makes a
surface look right in reflection), and knot multiplicity are the parameters that matter.
⚠️ GOTCHA — the representation determines which operations are even possible. "Fillet this edge by 3 mm" is natural in B-rep, awkward in CSG, and meaningless on a mesh (you can only approximate it). "Union these two shapes reliably" is trivial for implicits, routine for meshes, and a well-known source of failure in B-rep. ⚠️ When a CAD operation fails inexplicably, the question is usually whether you're asking the representation to do something it isn't built for.
| Kernel | Type | Used by | ⚠️ Notes |
|---|---|---|---|
| OCCT (Open CASCADE) | B-rep | FreeCAD, CadQuery, build123d | ⚠️ >1M lines of C++; the open B-rep kernel. Steep, and failures are surprising |
| Parasolid | B-rep | SolidWorks, NX, Onshape | Commercial, robust |
| ACIS | B-rep | AutoCAD, others | Commercial |
| CGAL | Exact-arithmetic geometry | OpenSCAD (historically), research | ⚠️ Exact and correct, and slow |
| Manifold | Mesh booleans | OpenSCAD (modern), others | ⚠️ Fast, guarantees manifold output (§16.1 → cad-reference) |
| libigl / Open3D / VTK / trimesh | Mesh processing | Research, pipelines | §4.5 |
| OpenVDB | Sparse voxel/level set | VFX, implicit modelling | Excellent for offsets and thickening |
⚠️ The exact-vs-floating-point trade is the core engineering problem in geometry kernels. Exact arithmetic (CGAL) gives provably correct results and is slow; floating point is fast and produces robustness failures — coincident faces, near-degenerate triangles, and booleans that fail on geometry that "should" work.
⚠️ Which is why coplanar faces are the classic CSG failure: subtracting a box whose face
sits exactly on another face is numerically ambiguous. The universal workaround is to
overlap by a small epsilon — 0.01 mm or so — and it appears in every OpenSCAD codebase
for exactly this reason.
| Format | Carries | ⚠️ Loses |
|---|---|---|
| STL | Triangles only | ⚠️ Units, colour, topology (it's a "triangle soup"), materials, ALL parametric intent |
| OBJ | Triangles, UVs, materials | Solid topology |
| 3MF | ⚠️ Mesh + units + colour + materials + print settings, zipped XML | Parametric history |
| AMF | Similar intent to 3MF | ⚠️ Largely superseded by 3MF |
| STEP (AP203/214/242) | ⚠️ Exact B-rep solids, assemblies; AP242 adds PMI | Feature tree, parametric history |
| IGES | Surfaces | ⚠️ Legacy, often no solid topology. Avoid if STEP is available |
| native (.sldprt, .f3d, .FCStd) | Everything including history | ⚠️ Portability |
| glTF | Rendering-oriented | Engineering data |
⚠️ GOTCHA — STL has no units. The file contains bare numbers. "Is this millimetres or inches?" is resolved by convention and hope, which is why parts occasionally arrive 25.4× wrong. 3MF fixes this and should be your default mesh format — it carries units, and modern slicers all read it.
⚠️ And STL is a triangle soup, not a mesh: each triangle independently lists three vertices with no shared-vertex indexing. Adjacency has to be reconstructed by position-matching, which is where floating-point tolerance decides whether your model is watertight.
⚠️ The pipeline rule: STEP between CAD tools, 3MF to the printer, STL only when something old demands it. Going CAD → STL → CAD is a lossy round trip that leaves you with a mesh you cannot parametrically edit.
| Tool | Language | Kernel | ⚠️ Character |
|---|---|---|---|
| OpenSCAD | Own C-like DSL | CGAL / Manifold | ⚠️ CSG-first, declarative, no fillets on arbitrary edges. Simple and predictable |
| CadQuery | Python | OCCT | ⚠️ Fluent/method-chaining API; exports STEP |
| build123d | Python | OCCT | ⚠️ Successor-in-spirit to CadQuery; context managers instead of chaining, so full Python control flow works naturally |
| FreeCAD scripting | Python | OCCT | Full application automation |
| JSCAD | JavaScript | own | Browser-native |
| Grasshopper | Visual + C#/Python | Rhino | ⚠️ Dominant in architecture and computational design |
| Fusion/SolidWorks/Onshape APIs | Python / VBA / JS | vendor | Automating a commercial tool |
| Blender (bpy) | Python | mesh | ⚠️ Mesh/organic modelling, not engineering CAD |
⚠️ OpenSCAD's language is functional and declarative, and this surprises people: variables are set at compile time, not assignment — ⚠️ assigning twice in the same scope does not do what an imperative programmer expects; the last value wins for the whole scope. There are no loops with mutation; you use recursion and list comprehensions.
The kernel difference is the substantive one:
minkowski, hull, or explicit geometry).fillet() and
chamfer() on selected edges — plus STEP export, which OpenSCAD cannot do.⚠️ The honest counterweight: OCCT's complexity leaks through the Python wrapper. Operations that look simple — "fillet this edge" — fail in surprising ways depending on surrounding geometry, and diagnosing that requires understanding the kernel. OpenSCAD fails more predictably.
⚠️ Parameterize intent, not dimensions: wall_thickness, clearance, screw_size
— not magic numbers scattered through the file
Named constants at the top; derive everything else
⚠️ Build a library of your own fasteners, clearances, and joints — reuse compounds
Assertions on parameters (⚠️ OpenSCAD's assert(); Python's naturally)
⚠️ $fn / tessellation: coarse while iterating, fine only for final export —
this is usually the difference between 2 seconds and 2 minutes
Version-control the source, not the STL ⚠️ this is the whole point of code-CAD
⚠️ The genuine advantage of code-CAD over GUI CAD: diffable, reviewable, version-controlled, and generatable. A single script produces a family of parts. You can put it in CI.
⚠️ The genuine disadvantage: spatial reasoning in text is hard, iteration is slower than direct manipulation for organic shapes, and there is no constraint solver — if you want "this face always tangent to that cylinder," you compute it yourself.
Fusion (Python/C++), SolidWorks (VBA/C#), Onshape (REST + FeatureScript), NX, CATIA. ⚠️ Onshape is architecturally the outlier — a genuine REST API over a cloud document model, which makes it the easiest commercial CAD to automate against and the only one where "CAD in CI" is straightforward.
Common automation tasks: batch parameter sweeps and export, drawing generation, BOM extraction, design-rule checking, and PLM integration.
⚠️ The properties that determine whether a mesh is printable:
Manifold ⚠️ every edge shared by exactly 2 faces
Watertight closed, no holes — encloses a definite volume
Orientable consistent normals (outward)
Non-self-intersecting ⚠️ the one that repair tools handle worst
⚠️ The Euler characteristic V − E + F = 2 − 2g is a fast sanity check — for a closed
surface of genus g. A result that isn't an even integer means the mesh is broken.
Common defects: holes, non-manifold edges (⚠️ 3+ faces on one edge), non-manifold vertices (two shells touching at a point), flipped normals, duplicate/degenerate faces, self-intersection, and internal geometry left inside a solid (⚠️ invisible, and it confuses slicers).
Repair: Meshmixer (legacy but effective), Netfabb, Blender 3D-Print Toolbox, MeshLab, trimesh and pymeshlab in Python, Manifold for guaranteed-valid booleans. ⚠️ Automatic repair is heuristic and can silently change your geometry — inspect the result.
Algorithms worth knowing: marching cubes (implicit → mesh), Poisson surface reconstruction (points → mesh), quadric edge-collapse decimation (⚠️ the standard simplification method), Laplacian smoothing (⚠️ shrinks the model — use taubin smoothing if that matters), voxel remeshing (⚠️ the nuclear option for repair: voxelize and re-surface. Guarantees manifold output, destroys sharp features).
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
5 skills in this plugin
/cad-design-tolerances-and-materialsUse when designing a part that has to work rather than just print: design for additive manufacturing including overhangs, supports, orientation and anisotropy, tolerances and fits and how to achieve them on a printer that does not hold them natively, and materials and their mechanical, thermal and environmental behaviour./cad-generative-automation-and-scanningUse when going beyond hand modelling: generative design and lattice structures and what they are actually good for, automation pipelines for batch generation, headless CAD and build integration, and scanning and reverse engineering including point clouds, registration and getting from a scan back to editable geometry./cad-referenceUse when checking a CAD or printing anti-pattern, looking up a tolerance, temperature or dimensional value, asking what actually moved (OpenSCAD's Manifold backend, the slicer landscape, code-CAD and the LLM angle, verified August 2026), finding the books and tools, or needing a picker and a pre-print checklist. Companion to the other cad-3d-printing skills.npx claudepluginhub the-vibey-project/vibey --plugin cad-3d-printing