MustafaMulla29/stride-pedometer

This code defines schematic symbols and 3D footprints for various hardware components such as antennas, sensors, regulators, and connectors used in electronic circuit design.

Version
1.0.4
License
unset
Stars
0

scripts/normalize-through-vias.ts

import { readFileSync, writeFileSync } from 'node:fs'

// tscircuit's router records the layers used by a trace transition in from_layer /
// to_layer, even when the physical via spans all four layers. The Gerber exporter
// uses those two fields for its drill stack. Normalize only vias that are already
// physically specified and clearance-checked on every copper layer.
const file = 'dist/index/circuit.json'
const data = JSON.parse(readFileSync(file, 'utf8')) as any[]
const layers = ['top', 'inner1', 'inner2', 'bottom']
let count = 0
for (const item of data) {
  if (item.type !== 'pcb_via') continue
  if (item.layers?.length !== 4 || !layers.every(layer => item.layers.includes(layer))) {
    throw new Error(`Unexpected non-through via: ${item.pcb_via_id}`)
  }
  item.from_layer = 'top'
  item.to_layer = 'bottom'
  count++
}
writeFileSync(file, JSON.stringify(data, null, 2) + '\n')
console.log(`Confirmed ${count} physical through vias; drill metadata spans L1–L4.`)