jscad-to-step
v0.0.11
Published
Convert [jscad-planner](https://github.com/tscircuit/jscad-planner) operations to STEP files.
Readme
jscad-to-step
Convert jscad-planner operations to STEP files.
Installation
npm install jscad-to-stepUsage
import { jscadPlanner } from "jscad-planner"
import { jscadToStep } from "jscad-to-step"
import fs from "fs"
// Primitives
const cube = jscadPlanner.primitives.cube({ size: 10 })
fs.writeFileSync("cube.step", jscadToStep(cube))
const sphere = jscadPlanner.primitives.sphere({ radius: 5, resolution: 16 })
fs.writeFileSync("sphere.step", jscadToStep(sphere))
const cylinder = jscadPlanner.primitives.cylinder({ radius: 5, height: 10 })
fs.writeFileSync("cylinder.step", jscadToStep(cylinder))
const cuboid = jscadPlanner.primitives.cuboid({ size: [10, 5, 3] })
fs.writeFileSync("cuboid.step", jscadToStep(cuboid))
// Transforms
const translated = jscadPlanner.transforms.translate([5, 5, 5], cube)
fs.writeFileSync("translated.step", jscadToStep(translated))
// Colors
const red = jscadPlanner.colors.colorize([1, 0, 0], cube)
fs.writeFileSync("red-cube.step", jscadToStep(red))
// Boolean operations
const union = jscadPlanner.booleans.union(cube, sphere)
fs.writeFileSync("union.step", jscadToStep(union))
const subtracted = jscadPlanner.booleans.subtract(cube, sphere)
fs.writeFileSync("subtract.step", jscadToStep(subtracted))
const intersected = jscadPlanner.booleans.intersect(cube, sphere)
fs.writeFileSync("intersect.step", jscadToStep(intersected))jscadToStep() also accepts pre-rendered models with the shape { geometries: [{ geom, color }] }.
Adjacent coplanar polygons merge into a single planar STEP face by default. Holes are retained as inner face bounds, and vertices shared with neighboring faces remain in the boundary. Bodies and their colors stay separate. Ambiguous or intersecting trimming boundaries retain the original polygon faces.
To keep individual polygon faces:
jscadToStep(operation, { mergeCoplanarFaces: false })This simplifies flat surfaces; curved surfaces and cylindrical hole walls remain faceted because JSCAD supplies polygon geometry.
