pcbPath coordinates are measured from the component's center, not from the anchor port as documented

Open
#5,472 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@OLuHneschastniy is already working on this.

Since Nov 13, 2026.

  • #1032 by @aswadi — open
  • #5481 by @OLuHneschastniy — open

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
50/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript
Domain
embedded-iot

Research direction

Start by reading Trace_doInitialPcbManualTraceRender.ts at the transform call cited in the issue, then compare it with the PrimitiveComponent.ts transform implementation and the documented contract in trace.mdx. Reproduce the listed cases with tsci build or getTestFixture(); the work is done when the intended coordinate origin is resolved and the behavior and documentation agree.

Written by the indexing model from the issue text.

Description

What happens

The docs say pcbPath coordinates are relative to the from port (or to pcbPathRelativeTo). In practice, { x, y } points are placed relative to the center of the component that owns that port, and they rotate with the component.

Reproduction

pcbpath.circuit.tsx:

export default () => (
  <board width="20mm" height="10mm">
    <resistor name="R1" resistance="10k" footprint="0402" pcbX={-3} />
    <resistor name="R2" resistance="10k" footprint="0402" pcbX={3} />
    <trace name="T1" from="R1.pin2" to="R2.pin1" pcbPath={[{ x: 0, y: 2 }]} />
  </board>
)
tsci build pcbpath.circuit.tsx --disable-parts-engine

Expected

R1.pin2 is at (-2.49, 0), so the path point should be at (-2.49, 2).

Actual

The point is at (-3, 2), which is R1's center plus (0, 2). pcb_trace.route in circuit.json:

(-2.49, 0) -> (-3, 2) -> (2.49, 0)

With pcbRotation={90} on R1 (R1.pin2 is then at (-3, 0.51)), the same pcbPath gives:

(-3, 0.51) -> (-5, 0) -> (2.49, 0)

(-5, 0) is R1's center plus (0, 2) rotated by 90 degrees.

The example in the docs behaves the same way. With

<trace
  from="R1.pin2"
  to="R2.pin1"
  pcbPathRelativeTo="R1.pin2"
  pcbPath={["R1.pin2", { x: 0, y: 4 }, "R2.pin1"]}
/>

the { x: 0, y: 4 } point ends up at (-3, 4), not (-2.49, 4).

Versions

tscircuit 0.0.3161 (@tscircuit/cli 0.1.2454, @tscircuit/core 0.0.2343), Bun 1.4.4, Linux.

Also on core main (8bb3fef, v0.0.2346), rendering the same three boards with getTestFixture() gives the same routes.

Cause

Docs ("The coordinates are relative to a specific port defined by pcbPathRelativeTo (defaults to the from port)"):
https://github.com/tscircuit/docs/blob/ab0abf51963ab9f1fd28d0b67eb1393d7d30d855/docs/elements/trace.mdx?plain=1#L96

Core transforms the points with anchorPort._computePcbGlobalTransformBeforeLayout():
https://github.com/tscircuit/core/blob/8bb3fefe5f273b9d5ab15a2f33e5aaf1f90b5865/lib/components/primitive-components/Trace/Trace_doInitialPcbManualTraceRender.ts#L389-L391

A port has no pcbX/pcbY of its own, so as far as I can see this is the parent component's transform (position and rotation), not the pad position:
https://github.com/tscircuit/core/blob/8bb3fefe5f273b9d5ab15a2f33e5aaf1f90b5865/lib/components/base-components/PrimitiveComponent/PrimitiveComponent.ts#L517-L556

Question

Which one is intended? If the component frame is intended, the docs could say "relative to the component that owns the port". If the port is intended, the origin is off by the pad offset.


AI-assisted: I used Claude Code to read the source, run the reproduction above and draft this report.

Dominant language
TypeScript
Stars
61
Forks
256
Avg merge
20h 21m
Merged PRs (30d)
289

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from tscircuit/core

All issues in tscircuit/core

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.