--- name: openscad-parametric description: Algorithmic solid modeling and precise geometry generation for multi-nozzle toolchanging setups (Bambu Lab H2C). disable-model-invocation: false category: CAD risk: safe tags: - openscad - 3d-printing - cad - parametric --- # OpenSCAD Parametric Design ## Purpose To guide the generation of modular, algorithmic, and mathematically precise solid geometry in OpenSCAD, optimized for multi-material toolchanger systems. ## When to Use Use when writing or editing OpenSCAD (`.scad`) code, calculating tolerances/clearances, structuring modular assemblies, or designing fixtures/parts for Bambu Lab H2C toolchanging architectures. ## Core Design Principles ### 1. Parametric Rigidity - Define all key dimensions (lengths, thicknesses, hole diameters, clearances) as variables at the top of the file. - Derive dependent geometry using mathematical relations (e.g., `wall_thickness * 2`) rather than hardcoding numbers. - Use `$fn` selectively to control cylinder resolution; prefer lower `$fn` (e.g., 16-32) during preview and higher (e.g., 64-128) only for final rendering. ### 2. Multi-Nozzle / Multi-Material Design - Organize components into separate modules representing different nozzles/materials. - Avoid geometry overlap (which causes slicing artifacts). Use explicit `difference()` operators to cut channels for different materials to lock into each other mechanically. - Add clearance margins (typically `0.15mm` to `0.3mm`) between interlocking toolchanged parts depending on the printer's dimensional accuracy. ### 3. Bambu Lab H2C Toolchanger Assemblies - Focus on toolchanger mount coordinates, bolt/nut clearances, and alignment pins. - Use standardized alignment pins (`4.0mm` diameter pins with `0.2mm` clearance holes) to locate mating parts securely. - Ensure overhangs respect the 45-degree rule, or design custom print-in-place breakaway supports. ## Math Utilities Library Prefer clean mathematical algorithms for curves and shapes: ```openscad // Parametric ellipse helper module ellipse(rx, ry, h) { scale([1, ry/rx, 1]) cylinder(r=rx, h=h, center=true); } ```