Skip to main content
Built-in Elements

<assembly.cable />

assembly.cable connects two endpoints inside an assembly.device. Give it a name, from, and to. Core infers a compatible cable and its route from the connectors' positions and orientations, then renders its wires and plugs in 3D.

Connect a motor to its controller​

Use wireConnection="jst-ph-6" on assembly.motor to expose the wireside connector. Match it with a six-pin JST PH connector on the board. The cable standard is inferred, so this example does not need a standard prop:

import { assembly } from "tscircuit"

export default () => (
<assembly.device>
<assembly.motor name="MOTOR" standard="nema17"
wireConnection="jst-ph-6" />
<board name="CONTROLLER" width={44} height={34}
pcbX={85} routingDisabled>
<connector name="J_MOTOR" standard="jst_ph" pinCount={6}
footprint="jst6_ph" pcbX={-18} pcbRotation={90} />
</board>
<assembly.cable name="MOTOR_CABLE"
from="MOTOR.wireside" to=".CONTROLLER > .J_MOTOR" />
</assembly.device>
)

The board connector sits at the edge facing the motor, so the cable approaches outside the PCB instead of passing through it.

JST PH and SH plugs seat inside their sockets. Each plug's pin 1 follows its header's footprint rotation and PCB layer; motor plugs follow the motor's orientation automatically.

MOTOR.wireside is the named motor endpoint. .CONTROLLER > .J_MOTOR selects the connector inside that board. Mounting and cabling are independent: use mountedTo to place parts, and keep the same cable references when their positions change. See the printed spacer and bracket-mounted controller examples.

The six-pin PH termination is a supported model configuration, not a requirement for every NEMA17 motor. Choose the connector and winding pinout for your actual motor. A physical cable does not create electrical traces or map pins.

Connect two boards with USB-C​

Place each USB-C port on its own board and select each endpoint through its board name. standard="usb_c" explicitly requests a USB-C-to-USB-C cable. It can also be omitted when both endpoints use standard="usb_c":

import { assembly } from "tscircuit"

export default () => (
<assembly.device>
<board name="HOST" width={32} height={28} pcbX={-60}
routingDisabled>
<connector name="J_USB" standard="usb_c" footprint="usbcmidmount"
pcbX={13} pcbRotation={90} />
</board>
<board name="CONTROLLER" width={32} height={28} pcbX={60}
routingDisabled>
<connector name="J_USB" standard="usb_c" footprint="usbcmidmount"
pcbX={-13} pcbRotation={270} />
</board>
<assembly.cable name="USB" standard="usb_c"
from=".HOST > .J_USB" to=".CONTROLLER > .J_USB" />
</assembly.device>
)

Connect different cable ends​

Set model to an explicit cable model string when the ends differ. The adaptercable_a(...)_b(...) form specifies end A at from and end B at to. This example connects three 3.5 mm female contacts to three 4 mm female contacts:

import { assembly } from "tscircuit"
import { Fragment } from "react"

const contactFootprint = (pitch: number) => (
<footprint>
{[0, 1, 2].map((pin) => (
<Fragment key={pin}>
<platedhole pcbX={(pin - 1) * pitch}
portHints={[`pin${pin + 1}`]}
holeDiameter={0.5} outerDiameter={0.8} shape="circle" />
</Fragment>
))}
</footprint>
)

export default () => (
<assembly.device>
<board width={65} height={30} routingDisabled>
<connector name="J1" pinCount={3} pcbX={-20}
footprint={contactFootprint(5.5)} />
<connector name="J2" pinCount={3} pcbX={20}
footprint={contactFootprint(6)} />
</board>
<assembly.cable name="ADAPTER" from=".J1" to=".J2"
model="adaptercable_a(bullet3_d3.5mm_gfemale)_b(bullet3_d4mm_gfemale)" />
</assembly.device>
)

bullet3 groups three contacts at each end, d3.5mm and d4mm set their diameters, and gfemale selects female contacts. Choose genders that mate with your hardware; three male 3.5 mm outputs would mate with the female A end.

The board connectors here are generic endpoint anchors with three plated holes each. The cable's model determines the plugs; the board footprints do not define a bullet connector model. The two cable ends must have the same contact count. An explicit model also supports other combinations, such as adaptercable_a(jst_sh_pins4)_b(jst_ph_pins4).

State the wiring and length​

Add one assembly.cablewire child per conductor, a length, and names for the two ends to describe how the cable is built. An assembly.drawing.harnessview then draws it for manufacturing:

import { assembly } from "tscircuit"

export default () => (
<assembly.device>
<board width={40} height={20} routingDisabled>
<connector name="J1" standard="jst_sh" pinCount={4}
footprint="jst4_sh" pcbX={-12} />
<connector name="J2" standard="jst_ph" pinCount={4}
footprint="jst4_ph" pcbX={12} />
</board>
<assembly.cable name="SENSOR" from=".J1" to=".J2"
model="adaptercable_a(jst_sh_pins4)_b(jst_ph_pins4)"
length="100mm" lengthTolerance="5mm" wireAwg={28}
fromConnectorName="SH" toConnectorName="PH">
<assembly.cablewire name="GND" fromPin={1} toPin={2} color="black" />
<assembly.cablewire name="3V3" fromPin={2} toPin={1} color="red" />
<assembly.cablewire name="SDA" fromPin={3} toPin={3} color="blue" />
<assembly.cablewire name="SCL" fromPin={4} toPin={4} color="yellow" />
</assembly.cable>
<assembly.drawing.page name="sensor-adapter" width={200} height={125}>
<assembly.drawing.harnessview cableRef="SENSOR"
width={180} height={60} centerY={28} />
<assembly.drawing.wiringtable cableRef="SENSOR" title="WIRING"
paperX={0} paperY={-12} anchorAlignment="top_center" />
</assembly.drawing.page>
</assembly.device>
)
Drawing 1 of 1: sensor-adapter

length is a build specification. It is never measured from the 3D route, and the route does not change to match it. See the wire harness drawings guide for wiring lists, parts lists and complete sheets.

Cable properties​

PropertyTypeDescription
namestringRequired cable name. Use a different name for each cable.
fromstringRequired starting endpoint: a connector selector or a motor's wireside reference.
tostringRequired ending endpoint, distinct from from.
modelstringOptional explicit cable model, including different-ended adapter cables. Omit to infer the model from the endpoints.
standard"usb_c"Optional USB-C preset. Omit to infer USB-C, JST SH (1 mm pitch), or JST PH (2 mm pitch) from the endpoints.
lengthnumber | stringOptional manufactured length between the two connectors' wire exits, such as "50mm".
lengthTolerancenumber | stringOptional symmetric plus/minus tolerance on length. Requires length.
fromConnectorName, toConnectorNamestringOptional designators for the connectors at the from and to ends on drawings, such as "H1" and "H2".
wireAwgnumber | stringOptional conductor gauge inherited by the cable's wires: 22 or "22awg".
childrenOptional assembly.cablewire elements stating the pin-to-pin wiring.

When model is omitted, both JST connectors must have the same standard and pinCount. Select a matching footprint, such as jst6_ph for a six-pin PH header. Inferred cables reject incompatible standards or pin counts. Missing or ambiguous endpoints report errors with either mode. Endpoints resolve within the nearest assembly.device, including components declared later.

Add one assembly.cable for each physical cable; several cables can share a device. Each creates an independent cable path. The initial route includes connector exit directions and a clearance arch. It does not perform obstacle avoidance or calculate gravity sag, so inspect the rendered path when placing enclosures and nearby parts. There are no route-hint props, and length does not affect the route.