Skip to content

Fix zero length copper segments#242

Open
mohan-bee wants to merge 4 commits intotscircuit:mainfrom
mohan-bee:fix-zero-len
Open

Fix zero length copper segments#242
mohan-bee wants to merge 4 commits intotscircuit:mainfrom
mohan-bee:fix-zero-len

Conversation

@mohan-bee
Copy link
Copy Markdown
Contributor

Repro:
use this package for the repro: https://tscircuit.com/mohan-bee/soil-moisture-sensor-final

Export to kicad project

Open in kicad PCB > DRC check

you will find a trace crossing error,

image

This fixes a KiCad PCB export bug where duplicate adjacent route points were being written out as real copper segments with zero length.

Motivation

On real boards such as mohan-bee/soil-moisture-sensor-final, this showed up in KiCad DRC as errors like Tracks crossing, where one of the reported tracks had length 0.0000 mm. The visible routing was not the main problem. The exporter was emitting a degenerate ghost segment from a point back to itself, and KiCad then treated that invalid segment as real copper during DRC.

What changed

The PCB trace exporter now skips any segment whose start and end points are identical after coordinate transformation. This keeps duplicate bookkeeping points in route data from becoming invalid KiCad copper.

Result

no more zero-length exported trace segments
no more fake 0.0000 mm tracks in KiCad
fewer downstream false-positive DRC errors such as crossing and clearance violations caused by those ghost segments
A focused repro test was added to confirm that duplicate adjacent route points no longer generate zero-length exported segments.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 24, 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 Apr 24, 2026 10:28am

Request Review

@techmannih
Copy link
Copy Markdown
Member

What are you trying to doing? @mohan-bee

@techmannih
Copy link
Copy Markdown
Member

Screenshot_2026-04-24-19-03-40-31_40deb401b9ffe8e1df2f1cc5ba480b12

@mohan-bee
Copy link
Copy Markdown
Contributor Author

yes I thought that's fixed but it's not, so I accidentally closed the PR I can't able to reopen, so I created the new PR

@mohan-bee
Copy link
Copy Markdown
Contributor Author

What are you trying to doing? @mohan-bee

I have mentioned in the description

@imrishabh18
Copy link
Copy Markdown
Member

So, you mean our autorouter result has these duplicate segments of length 0?

@mohan-bee
Copy link
Copy Markdown
Contributor Author

mohan-bee commented Apr 24, 2026

So, you mean our autorouter result has these duplicate segments of length 0?

@imrishabh18 nice catch, if it is from autorouter this fix is unnecessary, actuallly this needs to fix in autorouter, but before that let me do a repro in the autorouter.

@mohan-bee
Copy link
Copy Markdown
Contributor Author

mohan-bee commented Apr 24, 2026

@imrishabh18 this is from autorouter. yes it is producing duplicate segments of length 0

@imrishabh18
Copy link
Copy Markdown
Member

imrishabh18 commented Apr 24, 2026

@imrishabh18 this is from autorouter. yes it is producing duplicate segments of length 0

Yeah, so this fix is not right. thanks for the investigation. I think I can make a fix for this in the autorouter

@mohan-bee
Copy link
Copy Markdown
Contributor Author

@imrishabh18 this is from autorouter. yes it is producing duplicate segments of length 0

Yeah, so this fix is not right. thanks for the investigation. I think I can make a fix for this in the autorouter

can i work on that ?? @imrishabh18

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