Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const stepText = await circuitJsonToStep(circuitJson, {
boardHeight: 15,
boardThickness: 1.6,
productName: "MyPCB",
// Components are included by default
})
await Bun.write("output.step", stepText)
```
Expand Down
8 changes: 5 additions & 3 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export interface CircuitJsonToStepOptions {
boardThickness?: number
/** Product name (default: "PCB") */
productName?: string
/** Include component meshes (default: false) */
/** Include component meshes (default: true) */
includeComponents?: boolean
/** Include external model meshes from model_*_url fields (default: false). Only applicable when includeComponents is true. */
includeExternalMeshes?: boolean
Expand Down Expand Up @@ -565,10 +565,12 @@ export async function circuitJsonToStep(
// Array to hold all solids (board + optional components)
const allSolids: Ref<ManifoldSolidBrep>[] = [solid]

const includeComponents = options.includeComponents ?? true

let handledComponentIds = new Set<string>()
let handledPcbComponentIds = new Set<string>()

if (options.includeComponents && options.includeExternalMeshes) {
if (includeComponents && options.includeExternalMeshes) {
const mergeResult = await mergeExternalStepModels({
repo,
circuitJson,
Expand All @@ -582,7 +584,7 @@ export async function circuitJsonToStep(

// Generate component mesh fallback if requested
// Only call mesh generation if there are components that need it
if (options.includeComponents) {
if (includeComponents) {
// Build set of pcb_component_ids covered by cad_components with model_step_url
const pcbComponentIdsWithStepUrl = new Set<string>()
for (const item of circuitJson) {
Expand Down
2 changes: 1 addition & 1 deletion site/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ <h1>Circuit JSON to STEP Converter</h1>
<div class="options">
<h3>Options</h3>
<div class="option-row">
<input type="checkbox" id="includeComponents">
<input type="checkbox" id="includeComponents" checked>
<label for="includeComponents">Include components</label>
</div>
<div class="option-row">
Expand Down
12 changes: 12 additions & 0 deletions test/repros/kicad-step/kicad-step.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ test("kicad-step: switch fixture renders consistently", async () => {
)
}, 30000)

test("kicad-step: includes component geometry by default", async () => {
const fsMap = await loadStepFilesFromCircuitJson(circuitJson)
const stepText = await circuitJsonToStep(circuitJson as any, {
includeExternalMeshes: true,
productName: "KiCadStepDefaultComponents",
fsMap,
})

const solidCount = (stepText.match(/MANIFOLD_SOLID_BREP/g) || []).length
expect(solidCount).toBeGreaterThanOrEqual(3)
})

test("kicad-step: merges KiCad STEP models referenced via model_step_url", async () => {
const fsMap = await loadStepFilesFromCircuitJson(circuitJson)
const stepText = await circuitJsonToStep(circuitJson as any, {
Expand Down