Capture Animation
capture_animationUse this when you need to render a script's animation timeline to a video. Capture a kernelCAD script's animationView({...}) timeline to an MP4 (ffmpeg) or a PNG frame sequence, verifying the sampled poses for part interference. FILE ONLY: pass { file } (a .kcad.ts path) — there is no { code } mode, because the capture engine renders from a file on disk (its relative lib.fromSTEP imports resolve against the script directory). MP4 by default; pass { frames_dir } to write frame-0000.png... and skip ffmpeg entirely (mutually exclusive with output_path). Animation-pose interference verification runs by default (keyframe times + segment midpoints) BEFORE any browser/ffmpeg cost; { no_verify: true } skips it and { verify_every: n } additionally samples every n-th frame time. Pass { focus } or { hide } (arrays of feature ids or assembly part names, mutually exclusive) to isolate parts in the rendered frames — same semantics as kernelcad render --focus/--hide; visibility is render-only and does NOT affect the pose verification. Collisions DO NOT fail the call — the artifact is still written as evidence with ok: true; read verified: false + the collisions[] array. ENVIRONMENT REQUIREMENT (identical to kernelcad render): capture drives a headless browser against a running studio dev server reachable at http://localhost:5173 (or the VITE_PORT override); there is no bundled-static serving mode yet, so the same dev-server precondition applies in a production MCP install. Returns { ok, output_path, frame_count, duration_ms, fps, verified, verify_skipped?, collisions: [{ t_ms, a, b, volume_mm3 }], diagnostics }.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fps | No | Override the animationView record's fps. | |
| file | Yes | Path to a .kcad.ts script with an animationView({...}) record. Required (no inline { code } mode). | |
| hide | No | Hide matching feature ids / assembly part names in the rendered frames. Mutually exclusive with focus. Render-only; does not affect pose verification. | |
| focus | No | Show only matching feature ids / assembly part names in the rendered frames. Mutually exclusive with hide. Render-only; does not affect pose verification. | |
| no_verify | No | Skip the animation-pose interference verification (default: verify on). | |
| frames_dir | No | PNG-sequence mode directory: write frame-0000.png... and skip ffmpeg. Mutually exclusive with output_path. | |
| output_path | No | MP4 output path; default <scriptDir>/<basename>-animation.mp4. Mutually exclusive with frames_dir. | |
| verify_every | No | Additionally verify at every n-th frame time of the fps schedule (unioned with the keyframe sample set). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | Yes | ||
| fps | No | ||
| error | No | ||
| verified | No | Whether pose-interference verification passed. | |
| errorCode | No | ||
| errorHint | No | ||
| collisions | No | Colliding poses { t_ms, a, b, volume_mm3 }. | |
| diagnostics | Yes | ||
| duration_ms | No | ||
| frame_count | No | ||
| output_path | No | Written MP4 path (MP4 mode). | |
| failure_kind | No | ||
| verify_skipped | No |