Files
make-cad/examples
NiJingzhe bdee2e16c4 feat(render): opt-in studio style, tubed BRep edges, tessellation and camera-roll controls
Reviewed keep of the BLDC-GIF render pipeline changes (all opt-in; the
default inspection path is byte-identical, verified by A/B render):

- render_screenshot_rpath: + linear_deflection / angular_deflection
  (tighten tessellation for high-res diagnosis), style='studio'
  (product-shot look: black stage, camera-derived three-point lighting,
  metal specular), edge_width_scale (tubed-edge radius as span fraction,
  validated [0, 0.02]), view_up (explicit camera roll for inclined
  orbits)
- BRep edges as vtkTubeFilter geometry in studio style: LineWidth is
  capped ~3px on macOS, so edges must be geometry to stay readable at
  high resolution / for small features
- contracts: unknown style, studio+views grid and out-of-range
  edge_width_scale are rejected with guidance errors
- tests: three rejection contracts + studio/standard divergence smoke
  (size-threshold assertion replaced with a behavioral one: outputs must
  differ); 11/11 pass
- API doc regenerated via tools/auto_docs_gen.py (also picked up the
  view_up parameter the hand edit had missed)
- examples/20 render_showcase.py: four-module axial explode (ESC /
  motor / two-stage reducer / output shaft) with concentric radius-band
  peeling, inclined camera orbit, exploded turntable GIF export
2026-09-06 02:01:27 +08:00
..

SimpleCADAPI Examples

Run examples from the repository root with uv run python <path>. Generated artifacts are written to examples/out/, which is ignored by git.

Every formal single-script example emits three synchronized artifacts under examples/out/: the canonical self-contained .scadpkg, an AP242 .step, and an editable FreeCAD .FCStd. Single-solid products use @scad.part; assemblies use @scad.assemble with explicit immutable definitions for every physical part or nested assembly. Both downstream CAD files are translated from the same product package, so they retain the same definition closure, evaluated geometry, assembly instances, names, solved placements, materials, and available semantic metadata.

tools/run_examples.py requires every formal single-script example to rewrite and validate all three CAD artifacts. The split AP242/Gmsh workflow below is run directly, one script per stage.

Examples

  • 04_dimension_tolerance_chain.py — out/dimension_tolerance_chain/dimension_tolerance_chain.scadpkg
  • 08_constrained_sketch.py — out/constrained_sketch/constrained_sketch.scadpkg
  • 10_part_assembly.py — out/hydraulic_rod_assembly/hydraulic_rod_assembly.scadpkg
  • 11_external_reference_gear_train.py — out/external_reference_gear_train/nested_external_reference_gear_trains.scadpkg
  • 12_ap242_gmsh_volume_mesh/model.py — out/ap242_gmsh_volume_mesh/ap242_gmsh_bracket.scadpkg
  • flange_plate/ — out/flange_plate/flange_plate.scadpkg (session replay: flange_plate/demo/index.html)
  • 7ep_caplcd_enclosure.py — out/7ep_caplcd_enclosure/caplcd_enclosure_7ep.scadpkg
  • 16_compact_two_stage_planetary_reducer/ — out/compact_two_stage_planetary_reducer/compact_two_stage_planetary_reducer.scadpkg
  • 20_integrated_bldc_joint_actuator/ — out/integrated_bldc_joint_actuator/integrated_bldc_joint_actuator.scadpkg

Product Package Exporter And Translator Matrix

Build the canonical package once:

uv run python examples/12_ap242_gmsh_volume_mesh/model.py

Then run any downstream exporter or translator directly:

uv run python examples/12_ap242_gmsh_volume_mesh/export_fcstd.py
uv run python examples/12_ap242_gmsh_volume_mesh/export_step.py
uv run --extra gmsh python examples/12_ap242_gmsh_volume_mesh/export_stl.py
uv run --extra gmsh python examples/12_ap242_gmsh_volume_mesh/export_obj.py
uv run python examples/12_ap242_gmsh_volume_mesh/translate_freecad_script.py
uv run python examples/12_ap242_gmsh_volume_mesh/translate_fusion360_script.py
uv run python examples/12_ap242_gmsh_volume_mesh/translate_solidworks_script.py

The outputs are editable FreeCAD .FCStd, AP242 .step, triangulated .stl, quad-preserving .obj, and standalone Python scripts for FreeCAD, Fusion 360, and SolidWorks. Every command above reads the same .scadpkg directly.

FEM meshing consumes the STEP produced by export_step.py:

uv run --extra gmsh python examples/12_ap242_gmsh_volume_mesh/export_fem_mesh.py

It imports AP242 through Gmsh's OpenCASCADE kernel and writes a 3D .msh.