Skip to content

Fix NaN KiCad segments from through_obstacle trace route points#291

Open
mohan-bee wants to merge 3 commits intotscircuit:mainfrom
mohan-bee:fix/nan
Open

Fix NaN KiCad segments from through_obstacle trace route points#291
mohan-bee wants to merge 3 commits intotscircuit:mainfrom
mohan-bee:fix/nan

Conversation

@mohan-bee
Copy link
Copy Markdown
Contributor

@mohan-bee mohan-bee commented May 7, 2026

closes #290

This fixes a KiCad export bug where through_obstacle entries in pcb_trace.route could generate invalid segments like (end NaN NaN).

AddTracesStage now reads coordinates from either top-level x/y route points or start/end route points, and skips invalid or zero-length segments.

Also adds a focused regression test for through_obstacle route points to ensure the exporter no longer emits NaN in generated .kicad_pcb output.

Board rendering successfully:

image

@vercel
Copy link
Copy Markdown

vercel Bot commented May 7, 2026

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

Project Deployment Actions Updated (UTC)
circuit-json-to-kicad Ready Ready Preview, Comment May 7, 2026 5:11am

Request Review

this.pcbTraces = this.ctx.db.pcb_trace.list()
}

private getRoutePointPosition(point: any, edge: "start" | "end") {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why any cast?

typeof position?.x !== "number" ||
typeof position?.y !== "number" ||
!Number.isFinite(position.x) ||
!Number.isFinite(position.y)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undo all this typeof nonsense and isFinite etc., use proper imported types- this isn't the right module for this fix as well- the fix should be in core and requires a circuit json spec change CC @AnasSarkiz

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, yes maye be in core let me try to debug there in core also, learning stuffs.. 😄

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.

NaN in place of coordinates is causing it to fail.

2 participants