Skip to content

Emit wire harness drawings from TSX - #5792

Merged
seveibar merged 3 commits into
mainfrom
harness-drawing-tsx
Nov 24, 2026
Merged

seveibar merged 3 commits into
mainfrom
harness-drawing-tsx

Conversation

@seveibar

@seveibar seveibar commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Lets a wire harness (cable manufacturing) sheet be defined in TSX. Core now emits the records added in tscircuit/circuit-json#1023 from the props added in tscircuit/props#1030; tscircuit/circuit-json-to-drawing#14 renders them.

[Harness sheet rendered from TSX](https://raw.githubusercontent.com/tscircuit/core/0822b950f28d8830b5384ba60200afcd2f083124/tests/assembly/__snapshots__/assembly-drawing-harness.snap.svg)

<assembly.cable name="MOTOR_CABLE" from=".J1" to=".J2"
  length="50mm" lengthTolerance="3mm"
  fromConnectorName="H1" toConnectorName="H2" wireAwg="22awg">
  <assembly.cablewire fromPin={1} toPin={1} color="black" />
  <assembly.cablewire fromPin={3} toPin={4} color="black" />
  <assembly.cablewire fromPin={4} toPin={3} color="black" />
  <assembly.cablewire fromPin={6} toPin={6} color="black" />
</assembly.cable>

<assembly.drawing.page size="iso_a4" anchorAlignment="bottom_left">
  <assembly.drawing.harnessview name="harness" cableRef="MOTOR_CABLE"
    centerX={148.5} centerY={148} width={230} height={76} showBalloons />
  <assembly.drawing.wiringtable cableRef="MOTOR_CABLE" title="WIRING"
    paperX={212} paperY={98} anchorAlignment="top_left" />
  <assembly.drawing.bomtable partRef="MOTOR_CABLE"
    paperX={5} paperY={5} anchorAlignment="bottom_left" />
</assembly.drawing.page>

What core emits

  • assembly.cable writes nominal_length, length_tolerance, from_connector_name and to_connector_name onto its cad_cable.
  • assembly.cablewire (new) becomes one cad_cable_wire per child, in from-pin order, inheriting wireAwg from the cable. Pins beyond a connector's contact count and two wires on one pin are errors.
  • Cable BOM. A wired cable's cad_assembly_bom_item gains children: wire by gauge and colour (counted in cut pieces), each end's housing, and one crimp contact per wire end. Identical lines merge. An unwired cable stays a single line.
  • assembly.drawing.harnessview (new) becomes a drawing_wiring_harness_view. It takes part in leftOfRef/aboveRef placement with the other views. showBalloons adds three drawing_balloon records whose texts are the item numbers in the cable's parts list on the same page.
  • assembly.drawing.wiringtable and assembly.drawing.bomtable (new) resolve to drawing_table plus drawing_table_cell records with final text, column widths and row heights. The wiring list adds SIGNAL, COLOR and AWG columns only for attributes some wire states. A parts list anchored at its bottom edge lists rows upward from its heading.

A page is still validated completely before any of its records are inserted.

Dependency changes

  • @tscircuit/circuit-json-to-drawing (dev) 0.0.6 → 0.0.7, the release that renders harness views. No existing drawing snapshot changed.
  • DrawingRender now also waits for CadAssemblyBomRender, since parts lists read BOM records.

Notes for review

  • Cables with different contact counts are still not expressible. The motivating PH-6P to PH-4P cable needs adaptercable_a(jst_ph_pins6)_b(jst_ph_pins4), which cableprinter rejects, and core rejects mismatched inferred endpoints. This PR does not change that, so the example uses 6-position housings at both ends.
  • BOM quantities. docs/assembly-bom.md says local quantity is always 1; wired cables now add child lines with larger quantities. Docs are not touched in this PR.
  • Balloon placement is a fixed convention: along the top edge of the viewport, at the left, at 40% across, and at the right. Only the leader tip is resolved by the renderer.
  • cableRef / partRef accept a bare name (MOTOR_CABLE) as well as a selector.
  • Notes inside a harness view resolve to page positions, because drawing_page_note has no harness-view-relative mode.
  • I ran tests/assembly locally (137 files pass; two heavy 3D tests only time out when the whole folder runs in parallel here and pass alone). The rest of the suite is left to CI.

https://claude.ai/code/session_01P5Dw8uDxsoYbX4gqKk2QNf


Generated by Claude Code

- assembly.cable emits its build length, tolerance and connector
  designators, and assembly.cablewire children become cad_cable_wire
  records with pins validated against the cable's connectors.
- A wired cable's BOM line gains children for its wire, housings and
  crimp contacts.
- assembly.drawing.harnessview emits drawing_wiring_harness_view, with
  drawing_balloon callouts when showBalloons is set.
- assembly.drawing.wiringtable and assembly.drawing.bomtable resolve to
  drawing_table and drawing_table_cell records.

Updates circuit-json to 0.0.559 for these elements and the drawing
converter used by tests to 0.0.7, which renders them.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P5Dw8uDxsoYbX4gqKk2QNf
@vercel

vercel Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
tscircuit-core-benchmarks Ready Ready Preview Nov 24, 2026 4:00am UTC

Request Review

Resolves conflicts in package.json (keeps main's dependency versions and
the circuit-json-to-drawing 0.0.7 bump) and resolve-assembly-cable.ts.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P5Dw8uDxsoYbX4gqKk2QNf

Copy link
Copy Markdown
Contributor Author

CI status on the merge commit 0822b95 (merge of main, conflicts in package.json and resolve-assembly-cable.ts): the red shards are not caused by this PR.

  • Four CC2340R5 subcircuit tests fail on main as well (9c4bde6): root-subcircuit-cc2340r5, -collapsed, -exposed-nets and nested-subcircuit-cc2340r5. fix(inductor): emit parsed numeric inductance in source_component (#3111) #5328 makes inductors emit numeric inductance (2.8e-9), while tests/fixtures/cc2340r5-reference/published-electrical-signature.json still expects strings ("2.8nH"). This needs a separate fix against main.
  • bun install hit 504s from api.github.com tarball downloads for the github: dependencies. The failed jobs were re-run once; "Format code" then passed, and six test shards failed again at install on the same 504s. Shards 3 and 4 therefore never ran their tests on this commit.

Typecheck, format check, class exports, smoke test and dependency check pass. Locally, all 137 tests/assembly files pass on the merged tree with no snapshot changes.


Generated by Claude Code

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P5Dw8uDxsoYbX4gqKk2QNf
@seveibar
seveibar merged commit 5a4b352 into main Nov 24, 2026
20 checks passed
@seveibar
seveibar deleted the harness-drawing-tsx branch November 24, 2026 04:06
@tscircuitbot

Copy link
Copy Markdown
Contributor

Thank you for your contribution! 🎉

PR Rating: ⭐⭐⭐
Impact: Major

Track your contributions and see the leaderboard at: tscircuit Contribution Tracker


This branch was successfully deployed

1 active deployment
Preview — 52ade3d0 Deployed Nov 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants