Skip to content

Commit

Permalink
Merge pull request #25 from tscircuit/pill2
Browse files Browse the repository at this point in the history
Pill Implementation
  • Loading branch information
seveibar authored Oct 25, 2024
2 parents 394033b + 4a06ea9 commit 6c7bcba
Show file tree
Hide file tree
Showing 30 changed files with 807 additions and 117 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,6 @@ dist
yalc.lock

gerber-output
gerber-output.zip
gerber-output.zip
.aider*
*.diff.png
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ Some components of this gerber system:
## References

- [Gerber Format Specification (2022)](https://www.ucamco.com/files/downloads/file_en/456/gerber-layer-format-specification-revision-2022-02_en.pdf?7b3ca7f0753aa2d77f5f9afe31b9f826)
- [Excellon Drill Format Specification](https://gist.github.com/katyo/5692b935abc085b1037e)
Binary file modified bun.lockb
Binary file not shown.
340 changes: 340 additions & 0 deletions docs/CIRCUIT_JSON_PCB_OVERVIEW.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,340 @@
# Circuit JSON Specification: PCB Component Overview

> Created at 2024-10-23T22:17:25.274Z
> Latest Version: https://github.com/tscircuit/circuit-json/blob/main/docs/PCB_COMPONENT_OVERVIEW.md
Any type below can be imported from `circuit-json`. Every type has a corresponding
snake_case version which is a zod type that can be used to parse unknown json,
for example `PcbComponent` has a `pcb_component.parse` function that you
can also import.

```ts
export interface PcbFabricationNotePath {
type: "pcb_fabrication_note_path"
pcb_fabrication_note_path_id: string
pcb_component_id: string
layer: LayerRef
route: Point[]
stroke_width: Length
color?: string
}

export interface PcbComponent {
type: "pcb_component"
pcb_component_id: string
source_component_id: string
center: Point
layer: LayerRef
rotation: Rotation
width: Length
height: Length
}

export interface PcbPortNotMatchedError {
type: "pcb_port_not_matched_error"
pcb_error_id: string
message: string
pcb_component_ids: string[]
}

export interface PcbSolderPasteCircle {
type: "pcb_solder_paste"
shape: "circle"
pcb_solder_paste_id: string
x: Distance
y: Distance
radius: number
layer: LayerRef
pcb_component_id?: string
pcb_smtpad_id?: string
}

export interface PcbSolderPasteRect {
type: "pcb_solder_paste"
shape: "rect"
pcb_solder_paste_id: string
x: Distance
y: Distance
width: number
height: number
layer: LayerRef
pcb_component_id?: string
pcb_smtpad_id?: string
}

export type PcbSolderPaste = PcbSolderPasteCircle | PcbSolderPasteRect

export interface PcbSilkscreenText {
type: "pcb_silkscreen_text"
pcb_silkscreen_text_id: string
font: "tscircuit2024"
font_size: Length
pcb_component_id: string
text: string
layer: LayerRef
is_mirrored?: boolean
anchor_position: Point
anchor_alignment:
| "center"
| "top_left"
| "top_right"
| "bottom_left"
| "bottom_right"
}

export interface PcbTraceError {
type: "pcb_trace_error"
pcb_trace_error_id: string
error_type: "pcb_trace_error"
message: string
center?: Point
pcb_trace_id: string
source_trace_id: string
pcb_component_ids: string[]
pcb_port_ids: string[]
}

export interface PcbSilkscreenPill {
type: "pcb_silkscreen_pill"
pcb_silkscreen_pill_id: string
pcb_component_id: string
center: Point
width: Length
height: Length
layer: LayerRef
}

export interface PcbPlatedHoleCircle {
type: "pcb_plated_hole"
shape: "circle"
outer_diameter: number
hole_diameter: number
x: Distance
y: Distance
layers: LayerRef[]
port_hints?: string[]
pcb_component_id?: string
pcb_port_id?: string
pcb_plated_hole_id: string
}

export interface PcbPlatedHoleOval {
type: "pcb_plated_hole"
shape: "oval" | "pill"
outer_width: number
outer_height: number
hole_width: number
hole_height: number
x: Distance
y: Distance
layers: LayerRef[]
port_hints?: string[]
pcb_component_id?: string
pcb_port_id?: string
pcb_plated_hole_id: string
}

export type PcbPlatedHole = PcbPlatedHoleCircle | PcbPlatedHoleOval

export interface PcbFabricationNoteText {
type: "pcb_fabrication_note_text"
pcb_fabrication_note_text_id: string
font: "tscircuit2024"
font_size: Length
pcb_component_id: string
text: string
layer: VisibleLayer
anchor_position: Point
anchor_alignment:
| "center"
| "top_left"
| "top_right"
| "bottom_left"
| "bottom_right"
color?: string
}

export interface PcbSilkscreenCircle {
type: "pcb_silkscreen_circle"
pcb_silkscreen_circle_id: string
pcb_component_id: string
center: Point
radius: Length
layer: VisibleLayer
}

export interface PcbSilkscreenPath {
type: "pcb_silkscreen_path"
pcb_silkscreen_path_id: string
pcb_component_id: string
layer: VisibleLayerRef
route: Point[]
stroke_width: Length
}

export interface PcbText {
type: "pcb_text"
pcb_text_id: string
text: string
center: Point
layer: LayerRef
width: Length
height: Length
lines: number
align: "bottom-left"
}

export interface PCBKeepout {
type: "pcb_keepout"
shape: "rect" | "circle"
center: Point
width?: Distance
height?: Distance
radius?: Distance
pcb_keepout_id: string
layers: string[]
description?: string
}

export interface PcbVia {
type: "pcb_via"
pcb_via_id: string
x: Distance
y: Distance
outer_diameter: Distance
hole_diameter: Distance
layers: LayerRef[]
pcb_trace_id?: string
}

export interface PcbSilkscreenOval {
type: "pcb_silkscreen_oval"
pcb_silkscreen_oval_id: string
pcb_component_id: string
center: Point
radius_x: Distance
radius_y: Distance
layer: VisibleLayer
}

export interface PcbPlacementError {
type: "pcb_placement_error"
pcb_placement_error_id: string
message: string
}

export interface PcbPort {
type: "pcb_port"
pcb_port_id: string
source_port_id: string
pcb_component_id: string
x: Distance
y: Distance
layers: LayerRef[]
}

export interface PcbSmtPadCircle {
type: "pcb_smtpad"
shape: "circle"
pcb_smtpad_id: string
x: Distance
y: Distance
radius: number
layer: LayerRef
port_hints?: string[]
pcb_component_id?: string
pcb_port_id?: string
}

export interface PcbSmtPadRect {
type: "pcb_smtpad"
shape: "rect"
pcb_smtpad_id: string
x: Distance
y: Distance
width: number
height: number
layer: LayerRef
port_hints?: string[]
pcb_component_id?: string
pcb_port_id?: string
}

export type PcbSmtPad = PcbSmtPadCircle | PcbSmtPadRect

export interface PcbSilkscreenLine {
type: "pcb_silkscreen_line"
pcb_silkscreen_line_id: string
pcb_component_id: string
stroke_width: Distance
x1: Distance
y1: Distance
x2: Distance
y2: Distance
layer: VisibleLayer
}

export interface PcbHoleCircleOrSquare {
type: "pcb_hole"
pcb_hole_id: string
hole_shape: "circle" | "square"
hole_diameter: number
x: Distance
y: Distance
}

export interface PcbHoleOval {
type: "pcb_hole"
pcb_hole_id: string
hole_shape: "oval"
hole_width: number
hole_height: number
x: Distance
y: Distance
}

export type PcbHole = PcbHoleCircleOrSquare | PcbHoleOval

export interface PcbTraceRoutePointWire {
route_type: "wire"
x: Distance
y: Distance
width: Distance
start_pcb_port_id?: string
end_pcb_port_id?: string
layer: LayerRef
}

export interface PcbTraceRoutePointVia {
route_type: "via"
x: Distance
y: Distance
from_layer: string
to_layer: string
}

export type PcbTraceRoutePoint = PcbTraceRoutePointWire | PcbTraceRoutePointVia

export interface PcbTrace {
type: "pcb_trace"
source_trace_id?: string
pcb_component_id?: string
pcb_trace_id: string
route_order_index?: number
route_thickness_mode?: "constant" | "interpolated"
should_round_corners?: boolean
route: Array<PcbTraceRoutePoint>
}

export interface PcbBoard {
type: "pcb_board"
pcb_board_id: string
width: Length
height: Length
thickness: Length
num_layers: number
center: Point
outline?: Point[]
}

```
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,21 @@
],
"devDependencies": {
"@biomejs/biome": "^1.8.3",
"@tscircuit/core": "^0.0.102",
"@tscircuit/core": "^0.0.131",
"@types/bun": "^1.1.8",
"@types/node": "^22.5.2",
"@types/react": "^18.3.11",
"@types/react": "^18.3.12",
"bun-match-svg": "^0.0.3",
"gerber-to-svg": "^4.2.8",
"pcb-stackup": "^4.2.8",
"react": "^18.3.1",
"tsup": "^8.2.4"
},
"peerDependencies": {
"typescript": "^5.0.0"
"typescript": "^5.0.0",
"circuit-json": "*"
},
"dependencies": {
"circuit-json": "^0.0.83",
"fast-json-stable-stringify": "^2.1.0"
}
}
2 changes: 2 additions & 0 deletions src/excellon-drill/any-excellon-drill-command-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import type { ExcellonDrillCommandDef } from "./define-excellon-drill-command"
import * as EDCMD from "./commands"

export const excellon_drill_command_map = {
G01: EDCMD.G01,
G85: EDCMD.G85,
M48: EDCMD.M48,
M95: EDCMD.M95,
FMAT: EDCMD.FMAT,
Expand Down
Loading

0 comments on commit 6c7bcba

Please sign in to comment.