shibosoftwaredev/f1c100s-linux-nema8-stepper-controller

Restores component part numbers and CAD models, removes test-point 3D bodies, and validates that solder paste exists only on top-side SMT pads without altering copper or DRC.

Version
0.3.5
License
unset
Stars
0

scripts/render-schematic-sheets.mjs

import fs from "node:fs"
import path from "node:path"
import { Resvg } from "@resvg/resvg-js"
import { convertCircuitJsonToSchematicSvg } from "circuit-to-svg"

const circuitPath = process.argv[2] ?? "dist/index/circuit.json"
const outputDir = process.argv[3] ?? "reports/schematic-sheets"
const circuit = JSON.parse(fs.readFileSync(circuitPath, "utf8"))
const sheets = circuit
  .filter((element) => element.type === "schematic_sheet")
  .sort((a, b) => a.sheet_index - b.sheet_index)

fs.mkdirSync(outputDir, { recursive: true })
for (const sheet of sheets) {
  const basename = `${String(sheet.sheet_index).padStart(2, "0")}-${sheet.name}`
  const svg = convertCircuitJsonToSchematicSvg(circuit, {
    width: 2400,
    height: 1600,
    schematicSheetIndex: sheet.sheet_index,
    showErrorsInTextOverlay: true,
  })
  fs.writeFileSync(path.join(outputDir, `${basename}.svg`), svg)
  const png = new Resvg(svg, { fitTo: { mode: "width", value: 2400 } })
    .render()
    .asPng()
  fs.writeFileSync(path.join(outputDir, `${basename}.png`), png)
}

const outside = circuit.filter((element) =>
  element.type === "schematic_element_outside_sheet_warning"
)
console.log(JSON.stringify({
  sheets: sheets.map(({ name, display_name, sheet_index }) => ({
    name,
    displayName: display_name,
    sheetIndex: sheet_index,
  })),
  outsideSheetWarnings: outside.length,
}, null, 2))