49f142a434
Each example is now a project directory of notebooks: - one part notebook per part; part families (four-bar links, planetary and BLDC gears, l-link adapter presets) are one notebook used under several ids with scad.use(path, id=..., **overrides) - assembly and sub-assembly notebooks compose children with scad.use - shared parameters and helpers stay in plain modules (dimensions, common, materials, bearings, FEM steps) - export and acceptance scripts load products with run_notebook and capture one .scadpkg per product, then translate from it main.py side-effect entry points become export.py; intermediate hypothesis/probe/diag/archive verify scripts are deleted, and only the final acceptance checks are kept. l_link_motor_mount and pcg_attractor_canopy join the index. histcad_demo stays translator output and demo_kit is unchanged. examples/SDK_DEFECTS.md records the SDK defects found along the way. test_example_model_contract now checks that every example model is a notebook with a unique id; the ap242 and phase-A scene tests load the notebooks. Co-Authored-By: Claude Code <noreply@anthropic.com>
45 lines
1.4 KiB
Python
45 lines
1.4 KiB
Python
"""Export the four-bar linkage: product package and STEP.
|
|
|
|
uv run python examples/four_bar_linkage/export.py
|
|
|
|
The model is the ``four_bar_linkage.py`` notebook; this script loads its
|
|
product, reports the constraint residuals and writes the exchange files to
|
|
``out/``.
|
|
"""
|
|
|
|
from pathlib import Path
|
|
|
|
import simplecadapi as scad
|
|
from simplecadapi.runtime import run_notebook
|
|
|
|
HERE = Path(__file__).resolve().parent
|
|
OUT_DIR = HERE / "out"
|
|
PACKAGE_PATH = OUT_DIR / "four_bar_linkage.scadpkg"
|
|
|
|
|
|
def capture_package() -> scad.Assembly:
|
|
"""Run the notebook and write its product package; returns the assembly."""
|
|
OUT_DIR.mkdir(parents=True, exist_ok=True)
|
|
run = run_notebook(HERE / "four_bar_linkage.py")
|
|
scad.capture(run.definition, PACKAGE_PATH)
|
|
return run.product
|
|
|
|
|
|
def main() -> None:
|
|
linkage = capture_package()
|
|
report = scad.inspect_assembly_constraints_rconstraintreport(assembly=linkage)
|
|
step_report = scad.exporter.export_product_package_to_step(
|
|
PACKAGE_PATH, OUT_DIR / "four_bar_linkage.step"
|
|
)
|
|
print(
|
|
f"four_bar_solved: components={len(linkage.component_ids())} "
|
|
f"constraints={len(linkage.constraint_ids())} "
|
|
f"residuals_ok={all(r.within_tolerance for r in report.residuals)}"
|
|
)
|
|
print("product package", PACKAGE_PATH)
|
|
print("step", step_report.output_path)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|