Skip to content

Commit

Permalink
cad components initial
Browse files Browse the repository at this point in the history
  • Loading branch information
seveibar committed Jun 29, 2024
1 parent 6c64da1 commit 9c5e477
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 2 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/any_soup_element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { z } from "zod"
import * as pcb from "./pcb"
import * as sch from "./schematic"
import * as src from "./source"
import * as cad from "./cad"

export const any_soup_element = z.union([
// TODO source_group
Expand Down Expand Up @@ -50,6 +51,7 @@ export const any_soup_element = z.union([
sch.schematic_path,
sch.schematic_error,
sch.schematic_net_label,
cad.cad_component,
])

export type AnySoupElement = z.infer<typeof any_soup_element>
Expand Down
27 changes: 27 additions & 0 deletions src/cad/cad_component_model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { z } from "zod"
import { point3 } from "../common"
import { rotation, length } from "../units"
import { layer_ref } from "src/pcb"

export const cad_component = z
.object({
type: z.literal("cad_component"),
cad_component_id: z.string(),
pcb_component_id: z.string(),
source_component_id: z.string(),
position: point3,
rotation: point3.optional(),
size: point3.optional(),
layer: layer_ref.optional(),

// These are all ways to generate/load the 3d model
footprinter_string: z.string().optional(),
model_obj_url: z.string().optional(),
model_stl_url: z.string().optional(),
model_3mf_url: z.string().optional(),
model_jscad: z.array(z.any()).optional(),
})
.describe("Defines a component on the PCB")

export type CadComponentInput = z.input<typeof cad_component>
export type CadComponent = z.infer<typeof cad_component>
1 change: 1 addition & 0 deletions src/cad/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./cad_component_model"
1 change: 1 addition & 0 deletions src/common/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from "./point"
export * from "./point3"
export * from "./size"
12 changes: 12 additions & 0 deletions src/common/point3.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { z } from "zod"
import { distance } from "../units"

export const point3 = z.object({
x: distance,
y: distance,
z: distance,
})

export const position3 = point3

export type Point3 = z.infer<typeof point3>
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ export * from "./common"
export * from "./source"
export * from "./schematic"
export * from "./pcb"
export * from "./cad"
export * from "./any_soup_element"

0 comments on commit 9c5e477

Please sign in to comment.