Skip to content

Commit

Permalink
Merge pull request #94 from tscircuit/feat/pcb_group
Browse files Browse the repository at this point in the history
feat: pcb_grouop
  • Loading branch information
imrishabh18 authored Dec 12, 2024
2 parents 946d9da + 995230e commit 3bc58b1
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/any_circuit_element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import * as src from "./source"
import * as cad from "./cad"

export const any_circuit_element = z.union([
// TODO source_group
// TODO source_config
// TODO pcb_group
// TODO pcb_config
// TODO schematic_config
// TODO schematic_group
Expand Down Expand Up @@ -41,6 +39,7 @@ export const any_circuit_element = z.union([
pcb.pcb_smtpad,
pcb.pcb_solder_paste,
pcb.pcb_board,
pcb.pcb_group,
pcb.pcb_trace_hint,
pcb.pcb_silkscreen_line,
pcb.pcb_silkscreen_path,
Expand Down
1 change: 1 addition & 0 deletions src/pcb/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export * from "./pcb_fabrication_note_path"
export * from "./pcb_keepout"
export * from "./pcb_missing_footprint_error"
export * from "./pcb_manual_edit_conflict_error"
export * from "./pcb_group"

import type { PcbComponent } from "./pcb_component"
import type { PcbHole } from "./pcb_hole"
Expand Down
36 changes: 36 additions & 0 deletions src/pcb/pcb_group.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { z } from "zod"
import { point, type Point, getZodPrefixedIdWithDefault } from "src/common"
import { length, type Length } from "src/units"
import { expectTypesMatch } from "src/utils/expect-types-match"

export const pcb_group = z
.object({
type: z.literal("pcb_group"),
pcb_group_id: getZodPrefixedIdWithDefault("pcb_group"),
width: length,
height: length,
center: point,
pcb_component_ids: z.array(z.string()),
name: z.string().optional(),
description: z.string().optional(),
})
.describe("Defines a group of components on the PCB")

export type PcbGroupInput = z.input<typeof pcb_group>
type InferredPcbGroup = z.infer<typeof pcb_group>

/**
* Defines a group of components on the PCB
*/
export interface PcbGroup {
type: "pcb_group"
pcb_group_id: string
width: Length
height: Length
center: Point
pcb_component_ids: string[]
name?: string
description?: string
}

expectTypesMatch<PcbGroup, InferredPcbGroup>(true)

0 comments on commit 3bc58b1

Please sign in to comment.