237702c7a8
- rename every numbered example (04/08/10/11/7ep scripts, 12/16/20/21 dirs) to clean names; each example now writes artifacts to its own out/ folder - examples/README rewritten as a category index (part / assembly / reverse engineering / FEM); stale run_examples.py reference removed - flange_plate gains the quickstart FTC part (model.py + external verify.py + README); u_link/ap242/flange demo builders read the new asset paths - ap242_gmsh_volume_mesh gains render_views.py for the demo gallery fix(artifacts): round-trip-stable geometry fingerprint bounds AddOptimal bounds wobble by one shape-tolerance quantum between a fresh shape and the same shape read back from BRep bytes, so definitions sitting on a quantization cell edge failed every package re-validation. Quantize bounds at a fixed 1e-4 mm grid, far coarser than the wobble; full suite green (1503 passed). Stored packages captured before this change must be recaptured.
86 lines
2.6 KiB
Python
86 lines
2.6 KiB
Python
"""Build the integrated BLDC joint actuator and capture its product package."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
import time
|
|
from pathlib import Path
|
|
|
|
import simplecadapi as scad
|
|
|
|
try:
|
|
from .assembly import build_integrated_bldc_joint_actuator as build_durable_actuator
|
|
from .dimensions import (
|
|
PACKAGE_RADIUS,
|
|
PACKAGE_STRUCTURAL_BOTTOM_Z,
|
|
PACKAGE_TOP_Z,
|
|
TOTAL_REDUCTION,
|
|
validate_design_dimensions,
|
|
)
|
|
except ImportError: # Support direct execution from this example directory.
|
|
from assembly import build_integrated_bldc_joint_actuator as build_durable_actuator
|
|
from dimensions import (
|
|
PACKAGE_RADIUS,
|
|
PACKAGE_STRUCTURAL_BOTTOM_Z,
|
|
PACKAGE_TOP_Z,
|
|
TOTAL_REDUCTION,
|
|
validate_design_dimensions,
|
|
)
|
|
|
|
|
|
sys.setrecursionlimit(30000)
|
|
|
|
OUT_DIR = Path(__file__).resolve().parent / "out"
|
|
|
|
# STEP, MJCF, and FreeCAD exports read meshes and feature graphs from the
|
|
# definition closure, so the tessellated Scene projection is skipped here.
|
|
INCLUDE_SCENE = False
|
|
|
|
|
|
class _StageTimer:
|
|
"""Print one line per pipeline stage with elapsed seconds."""
|
|
|
|
def __init__(self) -> None:
|
|
self._stage_start = time.perf_counter()
|
|
self._run_start = self._stage_start
|
|
|
|
def mark(self, label: str) -> None:
|
|
now = time.perf_counter()
|
|
print(f"[stage] {label}: {now - self._stage_start:.1f}s (total {now - self._run_start:.1f}s)", flush=True)
|
|
self._stage_start = now
|
|
|
|
|
|
def build_integrated_bldc_joint_actuator() -> scad.AssemblyBuildResult:
|
|
"""Build the actuator through durable part and assembly boundaries."""
|
|
|
|
validate_design_dimensions()
|
|
return build_durable_actuator()
|
|
|
|
|
|
def main() -> None:
|
|
"""Build the actuator and capture the durable `.scadpkg`."""
|
|
|
|
timer = _StageTimer()
|
|
OUT_DIR.mkdir(parents=True, exist_ok=True)
|
|
package_path = OUT_DIR / "integrated_bldc_joint_actuator.scadpkg"
|
|
|
|
product_result = build_integrated_bldc_joint_actuator()
|
|
assembly = product_result.value
|
|
timer.mark("build")
|
|
|
|
scad.capture(product_result, package_path, include_scene=INCLUDE_SCENE)
|
|
print(f"[stage] package_bytes={package_path.stat().st_size}", flush=True)
|
|
timer.mark("capture")
|
|
|
|
print(f"envelope_diameter={PACKAGE_RADIUS * 2.0:.1f}")
|
|
print(f"structural_length={PACKAGE_TOP_Z - PACKAGE_STRUCTURAL_BOTTOM_Z:.1f}")
|
|
print(f"total_reduction={TOTAL_REDUCTION:.1f}")
|
|
print(f"assembly={assembly.assembly_id}")
|
|
print(f"components={len(assembly.component_ids())}")
|
|
print(f"constraints={len(assembly.constraint_ids())}")
|
|
print(f"product_package={package_path}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|