A high-level 3D modeling DSL and lossless STEP (ISO 10303-21) parser/serializer in MoonBit.
async fn main {
let design = @cad.Design::new(name="my-model")
.add(
@cad.Cuboid::new(20, 20, 20)
.with_name("base")
.with_color(@cad.Rgb::orange())
)
.add(
@cad.CalibrationChamferBlock::new(10, 10, 5, chamfer_size_mm=1.0)
.with_name("top-part")
.translate(z=20)
)
design.write_step(Some("model.step"))
}| Format | How | Notes |
|---|---|---|
| STEP | ./examples/run-example.sh 12 -o coil.step | Exact B-Rep; opens in any CAD viewer or slicer. |
| STL | ./examples/run-example.sh 12 -o coil.step -stl | OCCT tessellation; STL_DEFLECTION=<mm> (default 0.05). |
| PNG | ./examples/run-example.sh 12 -o coil.step --png=preview.png | Four views; needs OCCT, macOS sips, and optionally Inkscape. |
./examples/run-example.sh <example> --view # opens /tmp/<example>.step in SolidCraftfn parse_example(step_text : String) -> Unit {
match @parse.parse_repository_from_string_result(step_text) {
@parse.ParseRepositoryResult::Ok(repo) => {
let normalized = repo.to_step_file()
println("entities=" + repo.len().to_string())
println(normalized)
}
@parse.ParseRepositoryResult::Err(info) =>
@cli.eprintln(@parse.format_step_parse_error(info))
}
}@cad.bolt_circle(6, 22.0) // hole centers on a bolt circle
@cad.grid_of_holes(3, 2, 20.0, 15.0) // centered, row-major centers
@cad.point_on_circle(10.0, 90.0) // one point at an angle
let profile = @cad.Profile2D::new(@cad.Profile2D::centered_circle(60.0))
.with_hole_at(0.0, 0.0, 20.0) // central bore
.with_bolt_circle(6, 22.0, 5.0, fit=@cad.Fit::Free) // holes grow by the fit
let plate = @cad.ExtrudedProfile::new(profile.outer, 8.0, holes=profile.holes)./test-all.sh
python3 scripts/validate_step.py part.step
python3 scripts/validate_step.py --no-mesh part.step # syntax/topology only
python3 scripts/validate_step.py --gmsh part.step # second mesher| Path | Contents |
|---|---|
| cad/ | Intent-based modeling DSL, shape compilers, STEP writer, analysis, glTF/Blender backends. |
| entities/, parse/, repository/, header/ | STEP entity model, parser, and serializer. |
| cli/ | Command-line argument and error-reporting helpers. |
| components/ | Parametric fasteners, profiles, motion, motors, stock, mechanisms, gears, assemblies, collision, catalogue, and the typed design-family API. |
| examples/ | Runnable example programs (see examples/README.md). |
| tools/ | Inspection and STEP statistics utilities (see tools/README.md). |
| scripts/ | Development validation and rendering harnesses. |
| tests/ | Cross-package integration tests. |
pub struct RawEntity {
name : String
args : String
}Install
Download zipA high-level 3D modeling DSL and lossless STEP (ISO 10303-21) parser/serializer in MoonBit.