File tree Expand file tree Collapse file tree
lib/dsn-pcb/dsn-json-to-circuit-json Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -142,8 +142,10 @@ export function convertDsnSessionToCircuitJson(
142142 const fromLayer = connectingWires [ 0 ] ?. layer || "top"
143143 const toLayer = connectingWires [ 1 ] ?. layer || "bottom"
144144
145- // Add via point to each trace that connects to it
146- sessionElements . forEach ( ( element ) => {
145+ // Add via point to the first trace that connects to it (not all traces)
146+ let viaAdded = false
147+ for ( const element of sessionElements ) {
148+ if ( viaAdded ) break
147149 if ( element . type === "pcb_trace" ) {
148150 const trace = element as PcbTrace
149151 // Check all points in the route, not just the last one
@@ -158,11 +160,12 @@ export function convertDsnSessionToCircuitJson(
158160 from_layer : fromLayer ,
159161 to_layer : toLayer ,
160162 } )
163+ viaAdded = true
161164 break // Found the matching point, no need to continue checking
162165 }
163166 }
164167 }
165- } )
168+ }
166169
167170 sessionElements . push ( {
168171 ...convertViaToPcbVia ( {
Original file line number Diff line number Diff line change @@ -36,12 +36,10 @@ test("Number of vias in the pcb_trace route should match the number of pcb_via e
3636 } )
3737 } )
3838
39- // Each via point is counted twice (once for each layer)
40- routeViaPointsCount /= 2
41-
4239 const outputPcbVias = circuitJsonFromSession . filter (
4340 ( element ) => element . type === "pcb_via" ,
4441 )
4542
43+ // Each via appears once in the route and once as a pcb_via element
4644 expect ( routeViaPointsCount ) . toBe ( outputPcbVias . length )
4745} )
You can’t perform that action at this time.
0 commit comments