From 0bfb71cee9c5df721f5cdd257127da529a8b2a6e Mon Sep 17 00:00:00 2001 From: seveibar Date: Fri, 25 Oct 2024 14:32:55 -0700 Subject: [PATCH] library and cli usage in readme --- README.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/README.md b/README.md index 21cdcf5..04a930c 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,13 @@ Convert a [Circuit JSON](https://github.com/tscircuit/circuit-json) to Gerber/Excellon files. +## Installation + +```bash +# Global installation for CLI usage +npm install -g circuit-json-to-gerber +``` + ## CLI Usage Convert a circuit JSON file to Gerber/Excellon files: @@ -20,6 +27,38 @@ The output ZIP file will contain: - Plated drill file (plated.drl) - Unplated drill file (unplated.drl) +## Library Usage + +```typescript +import { + convertSoupToGerberCommands, + stringifyGerberCommandLayers, +} from "circuit-json-to-gerber" +import { + convertSoupToExcellonDrillCommands, + stringifyExcellonDrill, +} from "circuit-json-to-gerber" + +// Convert Circuit JSON to Gerber commands +const gerberCommands = convertSoupToGerberCommands(circuitJson) + +// Convert to Gerber file content +const gerberOutput = stringifyGerberCommandLayers(gerberCommands) + +// Generate drill files +const platedDrillCommands = convertSoupToExcellonDrillCommands({ + circuitJson, + is_plated: true, +}) +const unplatedDrillCommands = convertSoupToExcellonDrillCommands({ + circuitJson, + is_plated: false, +}) + +const platedDrillOutput = stringifyExcellonDrill(platedDrillCommands) +const unplatedDrillOutput = stringifyExcellonDrill(unplatedDrillCommands) +``` + ## References - [Gerber Format Specification (2022)](https://www.ucamco.com/files/downloads/file_en/456/gerber-layer-format-specification-revision-2022-02_en.pdf?7b3ca7f0753aa2d77f5f9afe31b9f826)