gmlewis/step/cad does not have a README file

    Font

    using @gmlewis/fonts { type Font }

    Font represents an entire font.

    Vec2

    type Vec2 = (Double, Double)

    Vec3

    type Vec3 = (Double, Double, Double)

    CsgEvalError

    pub suberror CsgEvalError {
    CsgEvalError(String)
    }

    CsgEvalError reports why an evaluated CSG export could not be produced.

    LoaderError

    pub suberror LoaderError {
    LoaderError(String)
    } derive(Eq)

    impl Show for LoaderError

    LoaderError::equal

    fn LoaderError::equal(LoaderError, LoaderError) -> Bool

    LoaderError::to_string

    fn LoaderError::to_string(self : LoaderError) -> String

    AcornNut

    pub struct AcornNut {
    across_flats_mm : Double
    body_height_mm : Double
    bore_diameter_mm : Double
    total_height_mm : Double
    dome_diameter_mm : Double
    wall_mm : Double
    face_angle_deg : Double
    rotation_deg : Double
    }

    AcornNut is a DIN 1587 hexagon domed cap nut: the ISO 4032/DIN 934 hexagon body with conical washer faces on both ends, a through bore, and a domed cap. The cap is a spherical cap that starts at the hexagon top rim and reaches total_height_mm; inside it, a concentric spherical cavity leaves wall_mm of cap wall above the bore.

    AcornNut::as_shape

    fn AcornNut::as_shape(self : AcornNut) -> Shape

    AcornNut::as_shape wraps the intent as a Shape.

    AcornNut::centroid

    fn AcornNut::centroid(self : AcornNut) -> (Double, Double, Double)

    AcornNut::centroid returns the exact centroid.

    AcornNut::new

    fn AcornNut::new(across_flats_mm~ : Double, body_height_mm~ : Double, bore_diameter_mm~ : Double, total_height_mm~ : Double, dome_diameter_mm~ : Double, wall_mm? : Double, face_angle_deg? : Double, rotation_deg? : Double) -> AcornNut

    AcornNut::new builds a DIN 1587 cap nut.

    AcornNut::volume

    fn AcornNut::volume(self : AcornNut) -> Double

    AcornNut::volume returns the exact solid volume.

    AnalysisError

    pub(all) enum AnalysisError {
    NotAnalytic(String)
    EmptySection
    UnsupportedTransform(String)
    DegenerateProfile
    }

    AnalysisError reports why an analytic result is unavailable.

    AnalysisError::message

    fn AnalysisError::message(self : AnalysisError) -> String

    AnalysisError::message returns a human-readable diagnostic.

    Angle

    pub struct Angle {
    // private fields
    }

    Angle is an angle in radians, used to make degree/radian mixing explicit.

    Angle::deg

    fn Angle::deg(v : Double) -> Angle

    Angle::rad

    fn Angle::rad(v : Double) -> Angle

    Angle::to_deg

    fn Angle::to_deg(self : Angle) -> Double

    Angle::to_rad

    fn Angle::to_rad(self : Angle) -> Double

    BezierAnchor

    pub struct BezierAnchor {
    position : (Double, Double)
    handle_in : (Double, Double)
    handle_out : (Double, Double)
    }

    BezierAnchor represents a single anchor point in a Bezier curve. The handles are absolute positions (not relative offsets).

    BezierPath

    pub struct BezierPath {
    anchors : Array[BezierAnchor]
    closed : Bool
    clear : Bool
    }

    BezierPath represents a 2D path made of cubic Bezier curves.

    BooleanDifference

    pub struct BooleanDifference {
    base : SceneNode
    cutters : Array[SceneNode]
    }

    BooleanUnion

    pub struct BooleanUnion {
    nodes : Array[SceneNode]
    }

    CalibrationChamferBlock

    pub struct CalibrationChamferBlock {
    length_mm : Double
    width_mm : Double
    height_mm : Double
    chamfer_size_mm : Double
    fillet_radius_mm : Double
    fillet_segments : Int
    }

    CalibrationChamferBlock::new

    fn CalibrationChamferBlock::new(length_mm : Double, width_mm : Double, height_mm : Double, chamfer_size_mm? : Double, fillet_radius_mm? : Double, fillet_segments? : Int) -> Shape

    ChamferedPrism

    pub struct ChamferedPrism {
    base : Array[(Double, Double)]
    levels : Array[(Double, Double)]
    hole : Array[(Double, Double)]?
    hole_levels : Array[(Double, Double)]?
    round_bore : ((Double, Double), Double)?
    }

    ChamferedPrism is a convex prism whose outer boundary is a stack of parallel-inset rings, with an optional prismatic through-hole.

    It is the generalisation of CalibrationChamferBlock needed for real chamfers and fillets on hex nuts, screw heads, washers, and plates: each ring is the base polygon offset inward by inset, placed at z. Consecutive rings are joined by planar ruled quads (edges stay parallel under a uniform parallel offset), and the ends are planar caps. With a through-hole the caps become annuli and the hole gets vertical walls, so a blind socket is built by placing this shape over a solid floor layer.

    ChamferedPrism::as_shape

    fn ChamferedPrism::as_shape(self : ChamferedPrism) -> Shape

    ChamferedPrism::as_shape wraps the prism as a Shape.

    ChamferedPrism::from_chamfer

    fn ChamferedPrism::from_chamfer(base : Array[(Double, Double)], height : Double, bottom_chamfer? : Double, top_chamfer? : Double, chamfer_depth? : Double, hole? : Array[(Double, Double)], round_bore? : ((Double, Double), Double)) -> ChamferedPrism

    ChamferedPrism::from_chamfer builds a prism of height with an optional chamfer at the bottom and top outer edges. chamfer is the parallel inset at each face; chamfer_depth is the axial length of the chamfer.

    ChamferedPrism::new

    fn ChamferedPrism::new(base : Array[(Double, Double)], levels : Array[(Double, Double)], hole? : Array[(Double, Double)], hole_levels? : Array[(Double, Double)], round_bore? : ((Double, Double), Double)) -> ChamferedPrism

    ChamferedPrism::new stores a ring stack without validating it. levels are (z, inset) pairs with strictly increasing z and non-negative insets.

    hole_levels optionally gives a (z, inward_inset) ring stack for the hole; it makes a tapered hole such as a socket lead-in chamfer. Without it the hole has vertical walls.

    ChamferedPrism::section_at

    fn ChamferedPrism::section_at(self : ChamferedPrism, z : Double) -> Result[Section, AnalysisError]

    ChamferedPrism::section_at returns the exact prism section at local z.

    ChamferedPrism::validate

    fn ChamferedPrism::validate(self : ChamferedPrism) -> Result[Unit, PrismError]

    ChamferedPrism::validate checks the ring stack.

    ChamferedPrism::volume

    fn ChamferedPrism::volume(self : ChamferedPrism) -> Double

    ChamferedPrism::volume returns the exact prism volume.

    ConicalNut

    pub struct ConicalNut {
    across_flats_mm : Double
    height_mm : Double
    bore_diameter_mm : Double
    face_angle_deg : Double
    lead_in_mm : Double
    rotation_deg : Double
    }

    ConicalNut is a hexagon nut with a 75/60-degree conical washer face on each bearing face and a circular through bore. The face chamfer is a true CONICAL_SURFACE trimmed by the six flats (hyperbola edges with pcurves), not a parallel-inset ring stack.

    ConicalNut::as_shape

    fn ConicalNut::as_shape(self : ConicalNut) -> Shape

    ConicalNut::as_shape wraps the intent as a Shape.

    ConicalNut::new

    fn ConicalNut::new(across_flats_mm~ : Double, height_mm~ : Double, bore_diameter_mm~ : Double, face_angle_deg~ : Double, lead_in_mm? : Double, rotation_deg? : Double) -> ConicalNut

    ConicalNut::new builds a hexagon nut with conical washer faces.

    Cuboid

    pub struct Cuboid {
    sx : Double
    sy : Double
    sz : Double
    }

    Cuboid::from_lengths

    fn Cuboid::from_lengths(lx~ : Length, ly~ : Length, lz~ : Length) -> Shape

    Cuboid::from_lengths is Cuboid::new with typed dimensions. Mixing a Length with a bare Double is a compile-time error.

    Cuboid::new

    fn Cuboid::new(sx : Double, sy : Double, sz : Double) -> Shape

    Cylinder

    pub struct Cylinder {
    diameter : Double
    height : Double
    }

    Cylinder is a solid right circular cylinder whose base lies on the local Z = 0 plane and whose axis follows +Z through the origin.

    Cylinder::new

    fn Cylinder::new(diameter : Double, height : Double) -> Shape

    Cylinder::new returns a solid right circular cylinder with analytic STEP geometry (a CYLINDRICAL_SURFACE plus two circular PLANE caps), centred on the local Z axis with its base at Z = 0.

    Unlike tube(), which emits a faceted polyhedron, this emits a three-face B-Rep that downstream consumers recognise as a true cylinder.

    Cylinder::section_at

    fn Cylinder::section_at(self : Cylinder, z : Double) -> Result[Section, AnalysisError]

    Cylinder::section_at returns the exact disc section at local z.

    Cylinder::volume

    fn Cylinder::volume(self : Cylinder) -> Double

    Cylinder::volume returns the exact cylinder volume.

    Design

    pub struct Design {
    nodes : Array[SceneNode]
    next_solid_id : Int
    name : String
    description : String
    documentation : String
    snapping : Double?
    }

    Design::add

    fn Design::add(self : Design, node : SceneNode) -> Design

    Design::add_iter

    fn Design::add_iter(self : Design, nodes : Iter[SceneNode]) -> Design

    Design::add_profile_on_face

    fn Design::add_profile_on_face(self : Design, profile : Profile2D, face : FaceInfo, height_mm : Double, into? : Bool, offset? : Double, center? : (Double, Double), name? : String, color? : Rgb) -> Design

    Design::add_profile_on_face adds a profile extruded on face as a node.

    In the flat STEP backend this is a new solid placed relative to the face; combine it with difference() for a nominal cut, or export with write_step_evaluated for real trimming.

    Design::add_text_on_face

    fn Design::add_text_on_face(self : Design, target : SceneNode, text : String, face : Face, font :
    Font
    , font_size? : Double, emboss_depth? : Double, offset_x? : Double, offset_y? : Double, rotation? : Double, margin? : Double, color? : Rgb, emboss? : Bool, segments? : Int) -> Design

    add_text_on_face returns text nodes positioned on a face of the target.

    With the default segments=0 the glyphs are kept as native cubic Beziers (ExtrudedBezierProfile); the STEP compiler flattens those curves when it emits B-Rep entities, while the Blender exporter can still emit true Bezier splines. A positive segments value converts the glyphs to polylines up front with that many segments per curve span.

    Design::create_blender_file

    async fn Design::create_blender_file(self : Design, out_path : String, keep_modifiers? : Bool, segments? : Int) -> Unit

    Design::diagnostics

    fn Design::diagnostics(self : Design) -> Array[Diagnostic]

    Design::diagnostics reports nominal and dropped booleans plus shapes that would compile to nothing. It is a pure observation and does not compile or mutate the design.

    Design::has_errors

    fn Design::has_errors(self : Design) -> Bool

    Design::has_errors reports whether the design has any diagnostic that blocks checked export (nested booleans, empty solids).

    Design::new

    fn Design::new(name? : String, description? : String, documentation? : String, snapping? : Double) -> Design

    Design::planar_faces

    fn Design::planar_faces(self : Design) -> FaceSet

    Design::planar_faces compiles the design and queries its planar faces.

    The returned faces are in world coordinates (node placements already applied). Boolean nodes are compiled nominally, so query the faces of a plain solid rather than of a difference.

    Design::rotate_x

    fn Design::rotate_x(self : Design, angle : Double) -> Design

    Design::rotate_y

    fn Design::rotate_y(self : Design, angle : Double) -> Design

    Design::rotate_z

    fn Design::rotate_z(self : Design, angle : Double) -> Design

    Design::to_assembly_step

    fn Design::to_assembly_step(self : Design, assembly_name~ : String) -> String

    Design::to_assembly_step emits the design as an assembly: one parent product for assembly_name, one child product per node, and a NEXT_ASSEMBLY_USAGE_OCCURRENCE per child. Each child's placement is carried by an ITEM_DEFINED_TRANSFORMATION, linked through a REPRESENTATION_RELATIONSHIP_WITH_TRANSFORMATION and a CONTEXT_DEPENDENT_SHAPE_REPRESENTATION.

    Child geometry is compiled in its own local frame and positioned by the transformation, which is the assembly convention. Composite nodes are not supported here: export them flat with to_step_file() or split them into separate nodes.

    Design::to_blender_python

    fn Design::to_blender_python(self : Design, segments? : Int, keep_modifiers? : Bool) -> String

    Convert the Design to a Blender 5 Python3 script that will recreate the model using the Blender Python3 API. This function keeps the STEP model as high-level as possible, allowing Blender to handle as many modifier operations itself as it can.

    Design::to_csg_step

    fn Design::to_csg_step(self : Design) -> String

    Design::to_csg_step compiles the design to ISO 10303-21 text with real boolean trees.

    Top-level boolean nodes whose root folds to a BOOLEAN_RESULT are wrapped in a CSG_SOLID and referenced by a CSG_SHAPE_REPRESENTATION; leaves and degenerate booleans keep the ordinary flat B-Rep path. Geometry is never evaluated: the consuming kernel computes the boolean.

    The flat export is unchanged; use to_step_file for the portable nominal representation.

    Design::to_gltf

    fn Design::to_gltf(self : Design) -> String

    Design::to_gltf serializes the design as a self-contained glTF 2.0 JSON document with an embedded base64 buffer, one mesh per SceneNode.

    Coordinates are Z-up (STEP convention). Faces that are not PLANE, CYLINDRICAL_SURFACE, or SURFACE_OF_LINEAR_EXTRUSION are rejected rather than emitted as an invalid mesh.

    Design::to_gltf_file

    async fn Design::to_gltf_file(self : Design, out_path : String?) -> Unit

    Design::to_gltf_file writes the design's glTF document to out_path.

    Design::to_step_evaluated

    async fn Design::to_step_evaluated(self : Design, root? : String?) -> String

    Design::to_step_evaluated evaluates the design's boolean tree with OCCT and returns the resulting flat, trimmed B-Rep STEP document.

    It writes to_csg_step() to a temporary file, runs python3 scripts/csg_eval.py with $MOONBIT_STEP_ROOT (or root), and reads back the evaluated STEP. Raises CsgEvalError when the script is missing or OCCT fails.

    Design::to_step_file

    fn Design::to_step_file(self : Design) -> String

    Design::to_step_file compiles the design to ISO 10303-21 text.

    Booleans are nominal: difference()/union_all() concatenate faces rather than trimming or subtracting. Use to_step_file_checked() to refuse designs with error diagnostics.

    Design::to_step_file_checked

    fn Design::to_step_file_checked(self : Design) -> String

    Design::to_step_file_checked compiles the design, aborting with the first error diagnostic instead of emitting plausible-but-wrong geometry.

    Design::to_string

    fn Design::to_string(self : Design) -> String

    Design::translate

    fn Design::translate(self : Design, x? : Double, y? : Double, z? : Double) -> Design

    Design::with_documentation

    fn Design::with_documentation(self : Design, documentation : String) -> Design

    with_documentation sets the self-documentation block written into the STEP header (see @cli.Args::documentation).

    Design::write_blender_python

    async fn Design::write_blender_python(self : Design, out_path : String?, segments? : Int, keep_modifiers? : Bool) -> Unit

    Design::write_csg_step

    async fn Design::write_csg_step(self : Design, out_path : String?) -> Unit

    Design::write_csg_step writes the CSG STEP document to out_path.

    Design::write_step

    async fn Design::write_step(self : Design, out_path : String?, checked? : Bool) -> Unit

    Convenience alias: design.write_step(...). Unchecked by default; pass checked=true to refuse error designs.

    Design::write_step_evaluated

    async fn Design::write_step_evaluated(self : Design, out_path : String?, root? : String?) -> Unit

    Design::write_step_evaluated writes the OCCT-evaluated STEP document to out_path (or stdout). Aborts with the evaluator's message on failure.

    Design::write_step_file

    async fn Design::write_step_file(self : Design, out_path : String?, checked? : Bool) -> Unit

    Design::write_step_file writes the design as STEP. It is unchecked by default (booleans stay nominal); pass checked=true to abort on error diagnostics instead.

    Diagnostic

    pub enum Diagnostic {
    NominalUnion(String)
    NominalDifference(String)
    DroppedNestedBoolean(String)
    EdgeFeatureRequiresKernel(String)
    EmptySolid(String)
    }

    Diagnostic describes something surprising about a Design without compiling it.

    The STEP backend never trims or subtracts: a top-level Union or Difference concatenates its children's faces. Those nodes are reported as nominal (a warning). A boolean nested inside another boolean contributes no faces at all and is reported as an error.

    Diagnostic::is_nominal

    fn Diagnostic::is_nominal(self : Diagnostic) -> Bool

    Diagnostic::is_nominal reports whether the diagnostic describes a nominal (face-concatenating) boolean.

    Diagnostic::message

    fn Diagnostic::message(self : Diagnostic) -> String

    Diagnostic::severity

    fn Diagnostic::severity(self : Diagnostic) -> Severity

    EdgeFeature

    pub(all) struct EdgeFeature {
    base : SceneNode
    selector : EdgeSelector
    size_mm : Double
    angle_deg : Double?
    }

    EdgeFeature is the intent to fillet or chamfer the selected edges of a base solid.

    size_mm is the fillet radius or chamfer distance. angle_deg is an optional chamfer angle; None means an equal-distance chamfer.

    EdgeInfo

    pub(all) struct EdgeInfo {
    start : Int
    end : Int
    edge :
    Ref

    }

    EdgeSelector

    pub(all) enum EdgeSelector {
    AllEdges
    EdgesByDirection((Double, Double, Double), Double)
    EdgesNearPoint((Double, Double, Double), Double)
    EdgeIndices(Array[Int])
    }

    EdgeSelector chooses which edges of a base solid an edge fillet or chamfer applies to.

    The selector is intent, not geometry: the flat STEP writer cannot evaluate it. Only the optional OCCT-backed evaluated export (Design::to_step_evaluated) or the Blender backend can apply the operation. Selectors are evaluated against the base solid's straight/curved edge bounds:

    • AllEdges selects every edge.
    • EdgesByDirection selects edges whose bounding-box diagonal is parallel to dir within tolerance_deg.
    • EdgesNearPoint selects edges whose bounding box is within radius_mm of point.
    • EdgeIndices selects 1-based edge indices in the solid's edge order.

    ExtrudedArcProfile

    pub struct ExtrudedArcProfile {
    segments : Array[ProfileSegment]
    height_mm : Double
    round_bore : ((Double, Double), Double)?
    holes : Array[Array[ProfileSegment]]
    }

    ExtrudedArcProfile is an extruded closed profile whose boundary contains circular arcs, so a genuinely circular side becomes an analytic CYLINDRICAL_SURFACE instead of a polygon of planar facets.

    segments is one closed counter-clockwise outer loop. round_bore is an optional analytic circular through-bore. This is the representation for a keyed shaft (a circular body with a real keyway notch) and for other line-plus-arc sections.

    ExtrudedArcProfile::as_shape

    ExtrudedArcProfile::as_shape wraps the profile as a Shape.

    ExtrudedArcProfile::centroid

    fn ExtrudedArcProfile::centroid(self : ExtrudedArcProfile) -> (Double, Double, Double)

    ExtrudedArcProfile::centroid returns the exact centroid in the local frame.

    ExtrudedArcProfile::new

    fn ExtrudedArcProfile::new(segments : Array[ProfileSegment], height_mm : Double, round_bore? : ((Double, Double), Double), holes? : Array[Array[ProfileSegment]]) -> ExtrudedArcProfile

    ExtrudedArcProfile::new builds an extruded closed line-plus-arc profile.

    ExtrudedArcProfile::validate

    fn ExtrudedArcProfile::validate(self : ExtrudedArcProfile) -> Bool

    ExtrudedArcProfile::validate checks that the outer loop and every hole loop are closed counter-clockwise loops of lines and counter-clockwise minor arcs.

    ExtrudedArcProfile::volume

    fn ExtrudedArcProfile::volume(self : ExtrudedArcProfile) -> Double

    ExtrudedArcProfile::volume returns the exact volume.

    ExtrudedBezierProfile

    pub struct ExtrudedBezierProfile {
    paths : Array[BezierPath]
    height_mm : Double
    }

    ExtrudedBezierProfile represents an extruded shape from Bezier paths.

    ExtrudedBezierProfile::new

    fn ExtrudedBezierProfile::new(paths : Array[BezierPath], height_mm : Double) -> Shape

    ExtrudedProfile

    pub struct ExtrudedProfile {
    profile : Profile2D
    height_mm : Double
    round_bore : ((Double, Double), Double)?
    }

    ExtrudedProfile::new

    fn ExtrudedProfile::new(outer : Array[(Double, Double)], height_mm : Double, holes? : Array[Array[(Double, Double)]], round_bore? : ((Double, Double), Double)) -> Shape

    ExtrudedProfile::on_face

    fn ExtrudedProfile::on_face(self : ExtrudedProfile, face : FaceInfo, into? : Bool, offset? : Double, center? : (Double, Double), name? : String, color? : Rgb) -> SceneNode

    ExtrudedProfile::on_face places an existing extruded profile on a face.

    ExtrudedProfile::section_at

    fn ExtrudedProfile::section_at(self : ExtrudedProfile, z : Double) -> Result[Section, AnalysisError]

    ExtrudedProfile::section_at returns the exact extruded section at local z.

    ExtrudedProfile::volume

    fn ExtrudedProfile::volume(self : ExtrudedProfile) -> Double

    ExtrudedProfile::volume returns the exact extruded volume.

    Face

    pub(all) enum Face {
    Top
    Bottom
    Front
    Back
    Left
    Right
    }

    FaceInfo

    pub struct FaceInfo {
    normal : (Double, Double, Double)
    point : (Double, Double, Double)
    area : Double
    u : (Double, Double, Double)
    v : (Double, Double, Double)
    boundary : Array[(Double, Double, Double)]
    face_id : Int
    surface_id : Int
    }

    FaceInfo describes one planar B-Rep face in world coordinates.

    u/v/normal are orthonormal with u x v = normal. point is the plane placement's origin (a point on the face), and boundary holds the outer loop's vertices in traversal order.

    FaceInfo::center

    fn FaceInfo::center(self : FaceInfo) -> (Double, Double, Double)

    FaceInfo::center returns the average of the outer loop vertices, a point near the middle of the face's boundary.

    FaceInfo::local_xy

    fn FaceInfo::local_xy(self : FaceInfo, p : (Double, Double, Double)) -> (Double, Double)

    FaceInfo::local_xy maps a world point into the face frame's 2D coordinates.

    FaceSet

    pub struct FaceSet {
    faces : Array[FaceInfo]
    }

    FaceSet is a small queryable collection returned by Design::planar_faces.

    FaceSet::aligned_with

    fn FaceSet::aligned_with(self : FaceSet, dir : (Double, Double, Double), tol? : Double) -> FaceSet

    FaceSet::aligned_with keeps faces whose normal points along dir.

    dir need not be normalised. tol is a cosine tolerance: a face is kept when dot(normal, dir) >= 1 - tol (default 1e-6, i.e. exact alignment).

    FaceSet::first_matching

    fn FaceSet::first_matching(self : FaceSet, pred : (FaceInfo) -> Bool) -> FaceInfo?

    FaceSet::first_matching returns the first face satisfying pred.

    FaceSet::is_empty

    fn FaceSet::is_empty(self : FaceSet) -> Bool

    FaceSet::length

    fn FaceSet::length(self : FaceSet) -> Int

    FaceSet::sort_by_z

    fn FaceSet::sort_by_z(self : FaceSet, ascending? : Bool) -> FaceSet

    FaceSet::sort_by_z orders faces by the z coordinate of their plane origin.

    FaceSet::to_array

    fn FaceSet::to_array(self : FaceSet) -> Array[FaceInfo]

    Fit

    pub(all) enum Fit {
    Nominal
    Close
    Free
    Press
    } derive(Eq,
    Debug
    )

    Fit captures the intended clearance of a printed hole as intent rather than as a literal the caller has to compute.

    Clearance is per face, so a hole's diameter grows by 2 * per_face_mm. Only voids grow: material additions (bosses, pins) are out of scope. These values are a starting point for FDM printing, not a universal standard; an explicit number is still allowed wherever a Double is expected.

    STEP export stays nominal: fit changes the modelled void, not a printer compensation layer, so do not treat it as printer calibration.

    Fit::equal

    fn Fit::equal(Fit, Fit) -> Bool

    Fit::not_equal

    fn Fit::not_equal(x : Fit, y : Fit) -> Bool

    Fit::per_face_mm

    fn Fit::per_face_mm(self : Fit) -> Double

    Fit::to_repr

    Fit::per_face_mm returns the radial clearance implied by the fit.

    HexHeadWasherFace

    pub struct HexHeadWasherFace {
    across_flats_mm : Double
    head_height_mm : Double
    face_angle_deg : Double
    shank_diameter_mm : Double
    shank_length_mm : Double
    washer_face_diameter_mm : Double
    washer_face_height_mm : Double
    tip_chamfer_mm : Double
    }

    HexHeadWasherFace is a hexagon head trimmed by a conical washer face: the top is a circle of radius across_flats / 2, the chamfer is a 75-degree cone, and the flat/cone intersections are hyperbolas.

    HexHeadWasherFace::as_shape

    fn HexHeadWasherFace::as_shape(self : HexHeadWasherFace) -> Shape

    HexHeadWasherFace::as_shape wraps the head as a Shape.

    HexHeadWasherFace::new

    fn HexHeadWasherFace::new(across_flats_mm~ : Double, head_height_mm~ : Double, face_angle_deg? : Double, shank_diameter_mm? : Double, shank_length_mm? : Double, washer_face_diameter_mm? : Double, washer_face_height_mm? : Double, tip_chamfer_mm? : Double) -> HexHeadWasherFace

    HexHeadWasherFace::new builds a conical-washer-face hex head.

    Length

    pub struct Length {
    // private fields
    }

    Length is a dimension in millimetres, used to make unit mixing a compile-time error instead of a silent modelling mistake.

    Construct with Length::mm, Length::cm, Length::m, or Length::inches; there is deliberately no conversion from a bare Double, so Length::mm(3.0) + 0.25 does not type-check. Read back with to_mm.
    impl Add for Length
    impl Neg for Length
    impl Sub for Length

    Length::add

    fn Length::add(self : Length, other : Length) -> Length

    Length::cm

    fn Length::cm(v : Double) -> Length

    Length::inches

    fn Length::inches(v : Double) -> Length

    Length::m

    fn Length::m(v : Double) -> Length

    Length::mm

    fn Length::mm(v : Double) -> Length

    Length::neg

    fn Length::neg(self : Length) -> Length

    Length::scale

    fn Length::scale(self : Length, factor : Double) -> Length

    Length::sub

    fn Length::sub(self : Length, other : Length) -> Length

    Length::to_mm

    fn Length::to_mm(self : Length) -> Double

    Matrix3x3

    pub(all) struct Matrix3x3 {
    m00 : Double
    m01 : Double
    m02 : Double
    m10 : Double
    m11 : Double
    m12 : Double
    m20 : Double
    m21 : Double
    m22 : Double
    } derive(Eq,
    Debug
    )

    Matrix3x3::equal

    fn Matrix3x3::equal(Matrix3x3, Matrix3x3) -> Bool

    Matrix3x3::not_equal

    fn Matrix3x3::not_equal(x : Matrix3x3, y : Matrix3x3) -> Bool

    PrismError

    pub(all) enum PrismError {
    PrismTooFewVertices
    PrismBadLevels
    PrismInsetTooLarge(Int)
    PrismSelfIntersection
    PrismBadHole
    }

    PrismError reports why a ChamferedPrism cannot be compiled.

    PrismError::message

    fn PrismError::message(self : PrismError) -> String

    PrismError::message returns a human-readable diagnostic.

    Profile2D

    pub struct Profile2D {
    outer : Array[(Double, Double)]
    holes : Array[Array[(Double, Double)]]
    }

    Profile2D::add_hole

    fn Profile2D::add_hole(self : Profile2D, hole : Array[(Double, Double)]) -> Profile2D

    Profile2D::add_holes_at

    fn Profile2D::add_holes_at(self : Profile2D, locs : Array[(Double, Double)], hole_profile : Array[(Double, Double)]) -> Profile2D

    Profile2D::arc

    fn Profile2D::arc(diameter : Double, start_angle : Double, end_angle : Double, segments? : Int) -> Array[(Double, Double)]

    Profile2D::centered_circle

    fn Profile2D::centered_circle(diameter : Double, segments? : Int) -> Array[(Double, Double)]

    Profile2D::centered_circle is Profile2D::circle with explicit intent: a counter-clockwise circle centered at the origin.

    Profile2D::centered_rect

    fn Profile2D::centered_rect(width : Double, height : Double) -> Array[(Double, Double)]

    Profile2D::chamfer_vertices

    fn Profile2D::chamfer_vertices(profile : Array[(Double, Double)], distance : Double, angle_deg? : Double, which? : VertexSelection) -> Result[Array[(Double, Double)], ProfileOpError]

    Profile2D::chamfer_vertices truncates selected vertices with a straight bevel.

    distance is the leg length measured along the edge toward the previous vertex. When angle_deg is supplied it is the angle between the chamfer line and that incoming edge (measured inside the material); the leg along the outgoing edge then follows from the triangle. Without an angle the chamfer has equal legs.

    The input winding is preserved. Convex vertices are cut; re-entrant vertices have their notch beveled. The result is a simple closed polygon suitable for ExtrudedProfile.

    Profile2D::circle

    fn Profile2D::circle(diameter : Double, segments? : Int) -> Array[(Double, Double)]

    Profile2D::circle_with_fit

    fn Profile2D::circle_with_fit(diameter : Double, fit~ : Fit, segments? : Int) -> Array[(Double, Double)]

    Profile2D::circle_with_fit returns a counter-clockwise circle whose diameter is grown by 2 * fit.per_face_mm() (so the radius grows by the per-face clearance). Voids grow; it never adds material.

    Profile2D::ellipse

    fn Profile2D::ellipse(width : Double, height : Double, segments? : Int) -> Array[(Double, Double)]

    Profile2D::fillet_vertices

    fn Profile2D::fillet_vertices(profile : Array[(Double, Double)], radius : Double, segments? : Int, which? : VertexSelection) -> Result[Array[(Double, Double)], ProfileOpError]

    Profile2D::fillet_vertices rounds selected vertices with a circular arc of radius tangent to both adjacent edges. segments controls the arc subdivisions per corner.

    The input winding is preserved. Convex vertices are rounded (material removed); re-entrant vertices are rounded with the arc filling the notch.

    Profile2D::hole_with_fit

    fn Profile2D::hole_with_fit(diameter : Double, fit~ : Fit, segments? : Int) -> Array[(Double, Double)]

    Profile2D::hole_with_fit returns a clockwise (hole) loop with the same clearance semantics as Profile2D::circle_with_fit.

    Profile2D::is_simple

    fn Profile2D::is_simple(pts : Array[(Double, Double)]) -> Bool

    Profile2D::is_simple reports whether the profile is a simple closed polygon: no zero-length edges and no proper edge crossings between non-adjacent edges.

    Profile2D::new

    fn Profile2D::new(outer : Array[(Double, Double)]) -> Profile2D

    Profile2D::on_face

    fn Profile2D::on_face(self : Profile2D, face : FaceInfo, height_mm : Double, into? : Bool, offset? : Double, center? : (Double, Double), name? : String, color? : Rgb) -> SceneNode

    Profile2D::on_face places the profile on face and extrudes it height_mm along the face normal.

    With into=false the extrusion starts at face.point and grows outward. With into=true it ends at the face and grows inward, which makes a cutter for difference. offset shifts the placement along the normal, and center translates the profile within the face's u/v frame.

    Profile2D::polygon

    fn Profile2D::polygon(sides : Int, diameter : Double, rotation? : Double) -> Array[(Double, Double)]

    Profile2D::polygon returns a regular polygon with the given number of sides, diameter, and optional rotation in degrees.

    Profile2D::rect

    fn Profile2D::rect(width : Double, height : Double) -> Array[(Double, Double)]

    Profile2D::rounded_rect

    fn Profile2D::rounded_rect(width : Double, height : Double, radius : Double, segments? : Int) -> Array[(Double, Double)]

    Profile2D::tangent_rect

    fn Profile2D::tangent_rect(width : Double, height : Double, radius : Double, segments? : Int) -> Array[(Double, Double)]

    Profile2D::tangent_rect returns a rounded rectangle whose corner arcs are tangent to all four sides (the radius is clamped to fit). It is the named form of Profile2D::rounded_rect.

    Profile2D::with_bolt_circle

    fn Profile2D::with_bolt_circle(self : Profile2D, count : Int, radius : Double, hole_diameter : Double, start_angle_deg? : Double, fit? : Fit, segments? : Int) -> Profile2D

    Profile2D::with_bolt_circle adds count evenly spaced holes on radius.

    Profile2D::with_grid_of_holes

    fn Profile2D::with_grid_of_holes(self : Profile2D, cols : Int, rows : Int, pitch_x : Double, pitch_y : Double, hole_diameter : Double, center? : (Double, Double), fit? : Fit, segments? : Int) -> Profile2D

    Profile2D::with_grid_of_holes adds a cols * rows grid of holes.

    Profile2D::with_hole_at

    fn Profile2D::with_hole_at(self : Profile2D, x : Double, y : Double, diameter : Double, fit? : Fit, segments? : Int) -> Profile2D

    Profile2D::with_hole_at adds one clockwise circular hole centered at (x, y). fit grows the hole by its per-face clearance.

    Profile2D::with_holes_at

    fn Profile2D::with_holes_at(self : Profile2D, locs : Array[(Double, Double)], diameter : Double, fit? : Fit, segments? : Int) -> Profile2D

    Profile2D::with_holes_at adds one clockwise circular hole at each location.

    ProfileOpError

    pub(all) enum ProfileOpError {
    TooFewVertices
    NonPositiveSize
    FeatureTooLarge(Int)
    VertexIndexOutOfRange(Int)
    SelfIntersection
    }

    ProfileOpError reports why a 2D profile chamfer or fillet was rejected.

    ProfileOpError::message

    fn ProfileOpError::message(self : ProfileOpError) -> String

    ProfileOpError::message returns a human-readable diagnostic.

    ProfileSegment

    pub(all) enum ProfileSegment {
    SegmentLine((Double, Double), (Double, Double))
    SegmentArc((Double, Double), (Double, Double), (Double, Double))
    }

    ProfileSegment is one boundary segment of a planar profile: a straight line or a counter-clockwise minor circular arc (sweep at most 180 degrees).

    RevCircle

    pub(all) struct RevCircle {
    edge :
    Ref

    vertex :
    Ref

    point :
    Ref

    }

    RevCircle is a cached circular edge at one profile point.

    RevProfileError

    pub(all) enum RevProfileError {
    EmptyProfile
    DiscontinuousChain(Int)
    NegativeRadius(Int)
    ArcEndpointMismatch(Int)
    DegenerateArc(Int)
    NotClosed
    DegenerateArea
    }

    RevProfileError reports why a revolved profile cannot be compiled.

    RevProfileError::message

    fn RevProfileError::message(self : RevProfileError) -> String

    RevProfileError::message returns a human-readable diagnostic.

    RevSegment

    pub(all) enum RevSegment {
    RevLine((Double, Double), (Double, Double))
    RevArc((Double, Double), (Double, Double), (Double, Double))
    }

    RevSegment is one band of a profile in the (r, z) half-plane that is revolved about the Z axis.

    r is the radius (along +X), z is the axial coordinate. RevLine is a straight band; RevArc is a circular arc band defined by its start point, end point, and center. An arc is always the minor arc (sweep at most 180 degrees), which makes the trim unambiguous.

    RevolvedProfile

    pub struct RevolvedProfile {
    segments : Array[RevSegment]
    band_colors : Array[(Int, Rgb)]
    }

    RevolvedProfile is a solid of revolution.

    The profile is a chain of RevSegment values in the (r, z) half-plane with r >= 0. The chain must either begin and end on the axis (r = 0, yielding poles) or close on itself away from the axis (yielding an annular solid such as a washer or a ring). The result is compiled into one closed STEP solid whose lateral faces are true CYLINDRICAL_SURFACE, CONICAL_SURFACE, SPHERICAL_SURFACE, and TOROIDAL_SURFACE bands, with planar caps.

    RevolvedProfile::as_shape

    fn RevolvedProfile::as_shape(self : RevolvedProfile) -> Shape

    RevolvedProfile::as_shape wraps the profile as a Shape so the fluent with_name/translate/rotate_* builder methods apply.

    RevolvedProfile::centroid

    fn RevolvedProfile::centroid(self : RevolvedProfile) -> (Double, Double, Double)

    RevolvedProfile::centroid returns the exact centroid.

    RevolvedProfile::chamfered_cylinder

    fn RevolvedProfile::chamfered_cylinder(diameter : Double, height : Double, bottom_chamfer? : Double, top_chamfer? : Double) -> RevolvedProfile

    RevolvedProfile::chamfered_cylinder builds a solid right circular cylinder of diameter and height whose bottom and/or top rims carry a 45-degree analytic chamfer of the given leg length.

    The result is one CYLINDRICAL_SURFACE, one CONICAL_SURFACE per chamfer, and planar caps. It never degenerates into a prism of planar facets: a circular body's chamfer is a cone, not a ring stack.

    RevolvedProfile::chamfered_tube

    fn RevolvedProfile::chamfered_tube(outer_diameter : Double, inner_diameter : Double, height : Double, outer_bottom_chamfer? : Double, outer_top_chamfer? : Double, inner_bottom_chamfer? : Double, inner_top_chamfer? : Double) -> RevolvedProfile

    RevolvedProfile::chamfered_tube builds an annular solid whose outer and inner rims carry analytic 45-degree chamfers. Every chamfer is a CONICAL_SURFACE, the bores are CYLINDRICAL_SURFACEs, and the ends are annular planes. This is the correct representation of a bearing ring or a chamfered washer.

    RevolvedProfile::cone

    fn RevolvedProfile::cone(radius : Double, height : Double) -> RevolvedProfile

    RevolvedProfile::cone builds a solid cone with base radius radius at z = 0 and apex on the axis at z = height.

    RevolvedProfile::cup

    fn RevolvedProfile::cup(outer_diameter : Double, height : Double, bore_diameter : Double, floor_thickness : Double, top_chamfer? : Double, bore_lead_in? : Double) -> RevolvedProfile

    RevolvedProfile::cup builds a solid circular cup: an outer cylinder of outer_diameter and height height with an optional 45-degree top rim chamfer, a blind cylindrical bore of bore_diameter whose floor sits at floor_thickness above the base, and an optional 45-degree conical lead-in on the bore rim.

    All lateral faces are analytic (CYLINDRICAL_SURFACE and CONICAL_SURFACE); the base, the annular top, and the bore floor are planes. It is the analytic outer shell of a socket-head fastener; the hexagonal socket flats are added by the caller as planar facets over this shell.

    RevolvedProfile::cylinder

    fn RevolvedProfile::cylinder(diameter : Double, height : Double) -> RevolvedProfile

    RevolvedProfile::cylinder builds a solid right circular cylinder with its base at z = 0 and its axis on +Z.

    RevolvedProfile::emission_colors

    fn RevolvedProfile::emission_colors(self : RevolvedProfile) -> Array[Rgb?]

    RevolvedProfile::emission_colors returns the per-face colors in the order the compiler emits the faces. It applies the same winding normalization as compile_revolved_profile, so callers do not have to know whether the profile was reversed.

    RevolvedProfile::frustum

    fn RevolvedProfile::frustum(radius_bottom : Double, radius_top : Double, height : Double) -> RevolvedProfile

    RevolvedProfile::frustum builds a solid frustum between radius_bottom at z = 0 and radius_top at z = height. Either radius may be zero, which makes that end a pole, but not both.

    RevolvedProfile::new

    RevolvedProfile::new stores a chain of segments without validating it.

    RevolvedProfile::polyline

    fn RevolvedProfile::polyline(points : Array[(Double, Double)], closed? : Bool) -> RevolvedProfile

    RevolvedProfile::polyline builds a chain of straight bands through points in the (r, z) half-plane. When closed is true the last point is joined back to the first, which produces an annular solid.

    RevolvedProfile::section_at

    fn RevolvedProfile::section_at(self : RevolvedProfile, z : Double) -> Result[Section, AnalysisError]

    RevolvedProfile::section_at returns the exact section at local z.

    RevolvedProfile::segments

    RevolvedProfile::segments returns the segment chain.

    RevolvedProfile::sphere

    fn RevolvedProfile::sphere(diameter : Double) -> RevolvedProfile

    RevolvedProfile::sphere builds a solid sphere of the given diameter centred on the origin. It is two hemispherical SPHERICAL_SURFACE bands sharing the equator circle.

    RevolvedProfile::sphere_cap

    fn RevolvedProfile::sphere_cap(rim_radius : Double, height : Double) -> RevolvedProfile

    RevolvedProfile::sphere_cap builds a flat-bottomed dome: a disc of radius rim_radius at z = 0 and a spherical cap rising to the axis at z = height. It is the natural representation of a button-head screw top.

    RevolvedProfile::tube

    fn RevolvedProfile::tube(outer_diameter : Double, inner_diameter : Double, height : Double) -> RevolvedProfile

    RevolvedProfile::tube builds an annular solid (washer or plain ring) with the given outside and inside diameters and axial height. Its lateral faces are two analytic CYLINDRICAL_SURFACE bands and its ends are annular PLANE faces. No polygon facets are emitted.

    RevolvedProfile::validate

    fn RevolvedProfile::validate(self : RevolvedProfile) -> Result[Unit, RevProfileError]

    RevolvedProfile::validate checks the segment chain and returns a typed error when it cannot bound a solid.

    RevolvedProfile::volume

    fn RevolvedProfile::volume(self : RevolvedProfile) -> Double

    RevolvedProfile::volume returns the exact volume.

    RevolvedProfile::with_band_color

    fn RevolvedProfile::with_band_color(self : RevolvedProfile, band : Int, color : Rgb) -> RevolvedProfile

    RevolvedProfile::with_band_color returns a copy in which the face emitted for segment band carries color. Band indices follow the segment order passed to new/polyline; the compiler remaps them if it reverses the profile winding. The flat STEP writer emits a face-level STYLED_ITEM for each colored band, so the solid stays one closed B-rep.

    Rgb

    pub struct Rgb {
    r : Double
    g : Double
    b : Double
    } derive(
    Debug
    )

    Rgb::black

    fn Rgb::black() -> Rgb

    Rgb::blue

    fn Rgb::blue() -> Rgb

    Rgb::cyan

    fn Rgb::cyan() -> Rgb

    Rgb::green

    fn Rgb::green() -> Rgb

    Rgb::grey

    fn Rgb::grey() -> Rgb

    Rgb::magenta

    fn Rgb::magenta() -> Rgb

    Rgb::new

    fn Rgb::new(r : Double, g : Double, b : Double) -> Rgb

    Rgb::orange

    fn Rgb::orange() -> Rgb

    Rgb::purple

    fn Rgb::purple() -> Rgb

    Rgb::red

    fn Rgb::red() -> Rgb

    Rgb::to_repr

    Rgb::white

    fn Rgb::white() -> Rgb

    SceneNode

    pub struct SceneNode {
    shape : Shape
    name : String
    color : Rgb
    tx : Double
    ty : Double
    tz : Double
    rx : Double
    ry : Double
    rz : Double
    }

    SceneNode::bounding_box

    fn SceneNode::bounding_box(self : SceneNode) -> (Double, Double, Double, Double, Double, Double)

    SceneNode::repeat_at

    fn SceneNode::repeat_at(self : SceneNode, locs : Array[(Double, Double, Double)]) -> Array[SceneNode]

    SceneNode::rotate_x

    fn SceneNode::rotate_x(self : SceneNode, angle : Double) -> SceneNode

    SceneNode::rotate_y

    fn SceneNode::rotate_y(self : SceneNode, angle : Double) -> SceneNode

    SceneNode::rotate_z

    fn SceneNode::rotate_z(self : SceneNode, angle : Double) -> SceneNode

    rotate_z adds the given angle in degrees to the SceneNode's rotation around the Z-axis.

    SceneNode::translate

    fn SceneNode::translate(self : SceneNode, x? : Double, y? : Double, z? : Double) -> SceneNode

    SceneNode::with_color

    fn SceneNode::with_color(self : SceneNode, color : Rgb) -> SceneNode

    SceneNode::with_name

    fn SceneNode::with_name(self : SceneNode, name : String) -> SceneNode

    Section

    pub(all) struct Section {
    z_mm : Double
    area_mm2 : Double
    perimeter_mm : Double
    outer_radius_mm : Double
    inner_radius_mm : Double
    rings : Array[SectionRing]
    }

    Section is an exact horizontal cross-section of a shape in its local frame.

    SectionRing

    pub(all) struct SectionRing {
    inner_radius_mm : Double
    outer_radius_mm : Double
    }

    SectionRing is one material annulus of a cross-section.

    Severity

    pub enum Severity {
    Info
    Warning
    Error
    }

    Severity classifies a Diagnostic produced by Design::diagnostics.

    Severity::all

    fn Severity::all() -> Array[Severity]

    Severity::all lists the severity levels from least to most urgent.

    Severity::is_error

    fn Severity::is_error(self : Severity) -> Bool

    Severity::is_error reports whether this severity blocks checked export.

    Shape

    pub enum Shape {
    Cuboid(Cuboid)
    Cylinder(Cylinder)
    RevolvedProfile(RevolvedProfile)
    ChamferedPrism(ChamferedPrism)
    SocketedSolid(SocketedSolid)
    ConicalNut(ConicalNut)
    SlitTube(SlitTube)
    AcornNut(AcornNut)
    SquareNut(SquareNut)
    CalibrationChamferBlock(CalibrationChamferBlock)
    ExtrudedProfile(ExtrudedProfile)
    ExtrudedArcProfile(ExtrudedArcProfile)
    SquareHoleWasher(SquareHoleWasher)
    TabWasher(TabWasher)
    HexHeadWasherFace(HexHeadWasherFace)
    ExtrudedBezierProfile(ExtrudedBezierProfile)
    SweptProfile(SweptProfile)
    Fillet(EdgeFeature)
    Chamfer(EdgeFeature)
    Union(BooleanUnion)
    Difference(BooleanDifference)
    }

    Shape::analysis_centroid

    fn Shape::analysis_centroid(self : Shape) -> Result[(Double, Double, Double), AnalysisError]

    Shape::analysis_centroid returns the exact centroid in the shape's local frame, or a typed error when it is not analytically known.

    Shape::analysis_mesh

    fn Shape::analysis_mesh(self : Shape) -> Result[(Array[(Double, Double, Double)], Array[Array[Int]]), AnalysisError]

    Shape::analysis_mesh returns a triangle/quad visualization mesh in the shape's local frame. It is deliberately separate from the analytic API: mesh output is a graphic approximation.

    Shape::analysis_volume

    fn Shape::analysis_volume(self : Shape) -> Result[Double, AnalysisError]

    Shape::analysis_volume returns the exact volume in mm^3, or a typed error when the shape is not analytically analyzable.

    Shape::bounding_box

    fn Shape::bounding_box(self : Shape) -> (Double, Double, Double, Double, Double, Double)

    Shape::section_at_local

    fn Shape::section_at_local(self : Shape, z : Double) -> Result[Section, AnalysisError]

    Shape::section_at_local returns the exact horizontal cross-section at local z.

    Shape::section_at_world_z

    fn Shape::section_at_world_z(self : Shape, rot : Matrix3x3, trans : (Double, Double, Double), z : Double) -> Result[Section, AnalysisError]

    Shape::section_at_world_z applies a rigid placement and returns an exact world-z section. Only translations and rotations that preserve +Z are exact; any other rotation returns UnsupportedTransform instead of a silently approximate section.

    Shape::surface_inventory

    fn Shape::surface_inventory(self : Shape) -> SurfaceInventory

    Shape::surface_inventory returns the analytic face counts the compiler emits for this shape.

    Shape::with_color

    fn Shape::with_color(self : Shape, color : Rgb) -> SceneNode

    Shape::with_name

    fn Shape::with_name(self : Shape, name : String) -> SceneNode

    SlitTube

    pub struct SlitTube {
    outer_diameter_mm : Double
    inner_diameter_mm : Double
    length_mm : Double
    slot_width_mm : Double
    }

    SlitTube is a straight tube with a full-length parallel-sided slot cut through one side (an ISO 8752 slotted spring pin). The outer and inner surfaces are analytic cylinders, the slot walls are planes, and the two end faces are C-shaped planes. The slot is centred on +X with parallel walls at y = +/- slot_width/2.

    SlitTube::as_shape

    fn SlitTube::as_shape(self : SlitTube) -> Shape

    SlitTube::as_shape wraps the intent as a Shape.

    SlitTube::centroid

    fn SlitTube::centroid(self : SlitTube) -> (Double, Double, Double)

    SlitTube::centroid returns the exact centroid.

    SlitTube::new

    fn SlitTube::new(outer_diameter_mm~ : Double, inner_diameter_mm~ : Double, length_mm~ : Double, slot_width_mm~ : Double) -> SlitTube

    SlitTube::new builds a straight slotted tube.

    SlitTube::volume

    fn SlitTube::volume(self : SlitTube) -> Double

    SlitTube::volume returns the exact solid volume.

    SocketGeometry

    pub(all) struct SocketGeometry {
    top_z : Double
    top_radius : Double
    nominal_radius : Double
    top_hex_radius : Double
    mid_z : Double
    floor_z : Double
    lead : Double
    across_flats : Double
    rotation_deg : Double
    }

    SocketGeometry is the resolved geometry of a SocketedSolid pocket.

    SocketedSolid

    pub struct SocketedSolid {
    body : RevolvedProfile
    across_flats_mm : Double
    socket_floor_z_mm : Double
    lead_in_mm : Double
    rotation_deg : Double
    conical : Bool
    rim_angle_deg : Double
    floor_angle_deg : Double
    }

    SocketedSolid is a solid of revolution with a blind vertical hexagonal pocket cut into its flat top face.

    body is a closed RevolvedProfile whose final segment is the radial flat top cap from (top_radius, top_z) to (0, top_z). The compiler suppresses that cap and replaces it with a true single-shell pocket boundary: an annular planar top face, six planar socket walls, an optional ruled 45-degree lead-in, and a planar hexagonal floor. The result is one closed solid, not a stack of layered bodies, and every surface stays analytic (no polygon substitutes for the body's cylinders, cones, spheres, or tori).

    The socket mouth lies on the body's flat top, so top_radius must exceed the socket circumradius. lead_in_mm is a parallel 45-degree break on the six socket flats; it is a ruled approximation of the conical rim and is recorded as such by the caller.

    SocketedSolid::as_shape

    fn SocketedSolid::as_shape(self : SocketedSolid) -> Shape

    SocketedSolid::as_shape wraps the intent as a Shape.

    SocketedSolid::body_segments

    fn SocketedSolid::body_segments(self : SocketedSolid) -> Array[RevSegment]

    SocketedSolid::body_segments returns the revolved body profile chain so callers and tests can verify the underlying solid of revolution.

    SocketedSolid::centroid

    fn SocketedSolid::centroid(self : SocketedSolid) -> (Double, Double, Double)

    SocketedSolid::centroid returns the exact centroid in the local frame.

    SocketedSolid::new

    fn SocketedSolid::new(body : RevolvedProfile, across_flats_mm : Double, socket_floor_z_mm : Double, lead_in_mm? : Double, rotation_deg? : Double, conical? : Bool, rim_angle_deg? : Double, floor_angle_deg? : Double) -> SocketedSolid

    SocketedSolid::new builds a revolved body with a blind hexagonal socket.

    across_flats_mm is the socket width across flats. socket_floor_z_mm is the absolute local height of the socket floor. lead_in_mm is the optional parallel 45-degree break on the six socket flats.

    SocketedSolid::volume

    fn SocketedSolid::volume(self : SocketedSolid) -> Double

    SocketedSolid::volume returns the exact solid volume in the local frame.

    SquareHoleWasher

    pub struct SquareHoleWasher {
    outer_diameter_mm : Double
    square_side_mm : Double
    thickness_mm : Double
    }

    SquareHoleWasher is a plain circular washer with a centered square through hole. The outer surface is one analytic cylinder; the hole walls are four planes and the two end faces are planes with a square hole.

    SquareHoleWasher::as_shape

    fn SquareHoleWasher::as_shape(self : SquareHoleWasher) -> Shape

    SquareHoleWasher::as_shape wraps the washer as a Shape.

    SquareHoleWasher::new

    fn SquareHoleWasher::new(outer_diameter_mm~ : Double, square_side_mm~ : Double, thickness_mm~ : Double) -> SquareHoleWasher

    SquareHoleWasher::new builds a square-hole washer intent.

    SquareNut

    pub struct SquareNut {
    across_flats_mm : Double
    height_mm : Double
    bore_diameter_mm : Double
    face_angle_deg : Double
    rotation_deg : Double
    }

    SquareNut is a DIN 557 square nut: a square prism with a conical washer face on the top bearing face and a circular through bore. The bottom face is flat, as DIN 557 specifies a chamfer on one face only.

    SquareNut::as_shape

    fn SquareNut::as_shape(self : SquareNut) -> Shape

    SquareNut::as_shape wraps the intent as a Shape.

    SquareNut::centroid

    fn SquareNut::centroid(self : SquareNut) -> (Double, Double, Double)

    SquareNut::centroid returns the exact centroid.

    SquareNut::new

    fn SquareNut::new(across_flats_mm~ : Double, height_mm~ : Double, bore_diameter_mm~ : Double, face_angle_deg? : Double, rotation_deg? : Double) -> SquareNut

    SquareNut::new builds a DIN 557 square nut.

    SquareNut::volume

    fn SquareNut::volume(self : SquareNut) -> Double

    SquareNut::volume returns the exact solid volume.

    StepContext

    pub struct StepContext {
    repo :
    Repository

    length_unit_id :
    EntityId

    plane_angle_unit_id :
    EntityId

    solid_angle_unit_id :
    EntityId

    uncertainty_id :
    EntityId

    repo_ctx_id :
    EntityId

    snapping : Double?
    entities : Map[Int,
    AnyEntity
    ]
    directions : Map[String,
    Ref
    ]
    vectors : Map[String,
    Ref
    ]
    cartesian_points : Map[String,
    Ref
    ]
    vertex_points : Map[Int,
    Ref
    ]
    lines : Map[String,
    Ref
    ]
    edge_curves : Map[String,
    Ref
    ]
    axis2_placements : Map[String,
    Ref
    ]
    oriented_edges : Map[String,
    Ref
    ]
    edge_loops : Map[String,
    Ref
    ]
    face_bounds : Map[String,
    Ref
    ]
    advanced_faces : Map[String,
    Ref
    ]
    }

    StepContext::add_product_definition

    fn StepContext::add_product_definition(self : StepContext, name : String) ->
    Ref

    StepContext::advanced_face

    fn StepContext::advanced_face(self : StepContext, bounds : Array[
    Ref
    ], face_geometry :
    Ref
    , same_sense : Bool) ->
    Ref

    StepContext::axis2_placement_3d

    fn StepContext::axis2_placement_3d(self : StepContext, origin :
    Ref
    , axis :
    Ref
    , ref_direction :
    Ref
    ) ->
    Ref

    StepContext::cartesian_point

    fn StepContext::cartesian_point(self : StepContext, x : Double, y : Double, z : Double) ->
    Ref

    StepContext::cartesian_point_2d

    fn StepContext::cartesian_point_2d(self : StepContext, x : Double, y : Double) ->
    Ref

    StepContext::cartesian_point_2d emits a 2D parameter-space point.

    StepContext::context_2d

    fn StepContext::context_2d(self : StepContext) ->
    Ref

    StepContext::context_2d emits the 2D parametric representation context used by pcurve definitional representations.

    StepContext::definitional_representation

    fn StepContext::definitional_representation(self : StepContext, items : Array[
    Ref
    ], context_of_items :
    Ref
    ) ->
    Ref

    StepContext::definitional_representation wraps pcurve 2D items.

    StepContext::direction

    fn StepContext::direction(self : StepContext, x : Double, y : Double, z : Double) ->
    Ref

    StepContext::edge_curve

    fn StepContext::edge_curve(self : StepContext, start :
    Ref
    , end :
    Ref
    , curve :
    Ref
    , same_sense : Bool) ->
    Ref

    StepContext::edge_loop

    StepContext::face_bound

    fn StepContext::face_bound(self : StepContext, bound :
    Ref
    , orientation : Bool) ->
    Ref

    StepContext::face_outer_bound

    fn StepContext::face_outer_bound(self : StepContext, bound :
    Ref
    , orientation : Bool) ->
    Ref

    StepContext::init_standard_context

    fn StepContext::init_standard_context(self : StepContext, name : String) -> Unit

    StepContext::new

    fn StepContext::new(snapping? : Double) -> StepContext

    StepContext::oriented_edge

    fn StepContext::oriented_edge(self : StepContext, edge_element :
    Ref
    , orientation : Bool) ->
    Ref

    StepContext::pcurve

    fn StepContext::pcurve(self : StepContext, basis_surface :
    Ref
    , reference_to_curve :
    Ref
    ) ->
    Ref

    StepContext::pcurve emits a PCURVE relating a 2D representation to a basis surface.

    StepContext::surface_curve

    fn StepContext::surface_curve(self : StepContext, curve_3d :
    Ref
    , associated_geometry : Array[
    Ref
    ]) ->
    Ref

    StepContext::surface_curve emits a 3D curve with its pcurves.

    StepContext::vector

    fn StepContext::vector(self : StepContext, dir :
    Ref
    , magnitude : Double) ->
    Ref

    StepContext::vertex_point

    SurfaceInventory

    pub(all) struct SurfaceInventory {
    plane : Int
    cylinder : Int
    cone : Int
    sphere : Int
    torus : Int
    bspline : Int
    swept : Int
    other : Int
    }

    SurfaceInventory counts the analytic surface faces a shape emits.

    SurfaceInventory::add

    SurfaceInventory::add returns the component-wise sum of two inventories.

    SurfaceInventory::empty

    SurfaceInventory::empty returns a zero inventory.

    SurfaceInventory::total

    fn SurfaceInventory::total(self : SurfaceInventory) -> Int

    SurfaceInventory::total returns the total number of counted faces.

    SweepPath

    pub(all) struct SweepPath {
    points : Array[(Double, Double, Double)]
    normals : Array[(Double, Double, Double)]
    tangents : Array[(Double, Double, Double)]
    }

    SweepPath represents the information needed to sweep a profile along a path.

    SweepProfile

    pub(all) struct SweepProfile {
    center : (Double, Double, Double)
    vertices : Array[(Double, Double, Double)]
    holes : Array[Array[(Double, Double, Double)]]
    normal_dir : (Double, Double, Double)
    right_dir : (Double, Double, Double)
    }

    SweepProfile represents a 2D profile to be swept along a path.

    vertices is the outer boundary of the profile; holes holds optional inner boundaries (e.g. the bore of a ring gear). All loops are given in the same coordinate system as vertices. Loops must be wound so that the outer boundary and every hole have opposite orientation; with the default normal_dir/right_dir the swept side faces then point out of the solid.

    SweepProfile::new

    fn SweepProfile::new(vertices : Array[(Double, Double, Double)], center? : (Double, Double, Double), holes? : Array[Array[(Double, Double, Double)]], normal_dir? : (Double, Double, Double), right_dir? : (Double, Double, Double)) -> SweepProfile

    SweepProfile::new returns a new SweepProfile.

    SweptProfile

    pub struct SweptProfile {
    path : SweepPath
    profile : SweepProfile
    make_start_cap : Bool
    make_end_cap : Bool
    straight_holes : Bool
    straight_outline : Bool
    smooth_helix : Bool
    corner_override : (Array[(Double, Double, Double)], Array[(Double, Double, Double)])?
    }

    SweptProfile::new

    fn SweptProfile::new(path~ : SweepPath, profile~ : SweepProfile, make_start_cap? : Bool, make_end_cap? : Bool, straight_holes? : Bool, straight_outline? : Bool, smooth_helix? : Bool, corner_override? : (Array[(Double, Double, Double)], Array[(Double, Double, Double)])?) -> Shape

    SweptProfile::new generates a new Shape by sweeping a 2D profile along a 3D path. By default, it generates end caps, making it a topologically-closed solid.

    When straight_holes is true the profile's holes keep the orientation of the first path point instead of following the path frame, which gives straight bores through twisted sweeps (e.g. a hex socket in a herringbone gear).

    When straight_outline is true (the default) the outer boundary keeps the orientation of the first path point, which gives a straight outer wall while the holes twist with the path (e.g. a smooth cylindrical shell around a herringbone ring gear). Set it to false when the outer boundary itself must follow the path, such as a thread or a coil wire.

    TabWasher

    pub struct TabWasher {
    outer_diameter_mm : Double
    bore_diameter_mm : Double
    tab_width_mm : Double
    tab_length_mm : Double
    fillet_radius_mm : Double
    thickness_mm : Double
    }

    TabWasher is a plain circular washer with a rectangular external tab. The tab blends into the washer with two concave analytic cylinders; the bore is a cylinder and the tab sides/end and the two faces are planes.

    TabWasher::as_shape

    fn TabWasher::as_shape(self : TabWasher) -> Shape

    TabWasher::as_shape wraps the tab washer as a Shape.

    TabWasher::new

    fn TabWasher::new(outer_diameter_mm~ : Double, bore_diameter_mm~ : Double, tab_width_mm~ : Double, tab_length_mm~ : Double, fillet_radius_mm~ : Double, thickness_mm~ : Double) -> TabWasher

    TabWasher::new builds a tab-washer intent.

    Transform

    pub(all) struct Transform {
    rot : Matrix3x3
    trans : (Double, Double, Double)
    }

    Transform is a rigid affine transform (rotation followed by translation) used to compose a parent SceneNode's placement with a child's own.

    Solid compilers apply a node's own rotate-then-translate to every point. Composite nodes (Union, Difference) have no geometry of their own, so their placement must instead be applied to each compiled child. Threading a Transform down through the compilers keeps that composition in one place and preserves the existing single-node convention.

    Transform::apply

    fn Transform::apply(self : Transform, p : (Double, Double, Double)) -> (Double, Double, Double)

    Transform::apply maps a point through the rotation and translation.

    Transform::apply_dir

    fn Transform::apply_dir(self : Transform, v : (Double, Double, Double)) -> (Double, Double, Double)

    Transform::apply_dir maps a direction through the rotation only.

    Transform::compose

    fn Transform::compose(outer : Transform, inner : Transform) -> Transform

    Transform::compose returns outer applied after inner: compose(outer, inner).apply(p) == outer.apply(inner.apply(p)).

    Transform::from_node

    fn Transform::from_node(node : SceneNode) -> Transform

    Transform::from_node captures a node's rotation (degrees) and translation.

    Transform::identity

    fn Transform::identity() -> Transform

    Transform::identity returns the no-op transform.

    VertexSelection

    pub(all) enum VertexSelection {
    All
    ConvexOnly
    ConcaveOnly
    Indices(Array[Int])
    }

    VertexSelection selects which vertices a 2D chamfer or fillet operation applies to.

    acorn_nut_bounding_box

    fn acorn_nut_bounding_box(n : AcornNut) -> (Double, Double, Double, Double, Double, Double)

    acorn_nut_bounding_box returns the true axis-aligned extent.

    acorn_nut_mesh

    fn acorn_nut_mesh(n : AcornNut, angular_segments? : Int) -> (Array[(Double, Double, Double)], Array[Array[Int]])

    acorn_nut_mesh builds a visualization mesh of the cap nut.

    bolt_circle

    fn bolt_circle(count : Int, radius : Double, start_angle_deg? : Double) -> Array[(Double, Double)]

    bolt_circle returns count hole centers evenly spaced on radius, starting at start_angle_deg (measured counter-clockwise from +X).

    chamfer_edges

    fn chamfer_edges(base : SceneNode, size_mm : Double, angle_deg? : Double, selector? : EdgeSelector, name? : String) -> SceneNode

    chamfer_edges records the intent to bevel the selected edges of base with a chamfer of size_mm (and an optional angle_deg).

    The flat STEP writer cannot trim edges and refuses this node with an error diagnostic. Apply it through Design::to_step_evaluated (OCCT) or the Blender backend.

    chamfered_prism_mesh

    fn chamfered_prism_mesh(prism : ChamferedPrism) -> (Array[(Double, Double, Double)], Array[Array[Int]])

    chamfered_prism_mesh builds a polygonal mesh approximation for the optional Blender export. STEP output uses the analytic compiler, not this mesh.

    compile_acorn_nut

    fn compile_acorn_nut(ctx : StepContext, node : SceneNode, n : AcornNut, reverse? : Bool, parent? : Transform?) -> Array[
    Ref
    ]

    compile_acorn_nut emits the cap nut as one closed STEP shell.

    compile_calibration_chamfer_block

    fn compile_calibration_chamfer_block(ctx : StepContext, node : SceneNode, block : CalibrationChamferBlock, reverse? : Bool, parent? : Transform?) -> Array[
    Ref
    ]

    compile_chamfered_prism

    fn compile_chamfered_prism(ctx : StepContext, node : SceneNode, prism : ChamferedPrism, reverse? : Bool, parent? : Transform?) -> Array[
    Ref
    ]

    compile_chamfered_prism emits the ring-stack prism as one closed solid.

    compile_conical_nut

    fn compile_conical_nut(ctx : StepContext, node : SceneNode, n : ConicalNut, reverse? : Bool, parent? : Transform?) -> Array[
    Ref
    ]

    compile_conical_nut emits the nut as one closed STEP shell.

    compile_conical_socketed_solid

    fn compile_conical_socketed_solid(ctx : StepContext, node : SceneNode, s : SocketedSolid, reverse? : Bool, parent? : Transform?) -> Array[
    Ref
    ]

    compile_conical_socketed_solid emits a revolved body whose flat top cap is replaced by a conical countersink, six hyperbola-trimmed flats, and a conical drill floor. Every shared edge carries a pcurve on both adjacent surfaces.

    compile_cuboid

    fn compile_cuboid(ctx : StepContext, node : SceneNode, cuboid : Cuboid, reverse? : Bool, parent? : Transform?) -> Array[
    Ref
    ]

    compile_cylinder

    fn compile_cylinder(ctx : StepContext, node : SceneNode, cylinder : Cylinder, reverse? : Bool, parent? : Transform?) -> Array[
    Ref
    ]

    compile_cylinder emits a solid right circular cylinder as three analytic faces: one CYLINDRICAL_SURFACE band and two circular PLANE caps.

    Topology: the lateral surface is cut along the seam at +X. The seam edge runs from V0 = (r, 0, 0) to V1 = (r, 0, h); each cap edge is a closed EDGE_CURVE that starts and ends at its own vertex. The lateral loop traverses the seam up, the top circle backwards, the seam down, and the bottom circle forwards, so every edge is used exactly twice with opposite sense (the seam twice within the same face, which is the ISO 10303 seam convention).

    compile_extruded_arc_profile

    fn compile_extruded_arc_profile(ctx : StepContext, node : SceneNode, e : ExtrudedArcProfile, reverse? : Bool, parent? : Transform?) -> Array[
    Ref
    ]

    compile_extruded_arc_profile emits one closed solid with analytic cylindrical faces for every circular arc and planar faces for every line and cap.

    compile_extruded_bezier_profile

    fn compile_extruded_bezier_profile(ctx : StepContext, node : SceneNode, extrusion : ExtrudedBezierProfile, reverse? : Bool, parent? : Transform?) -> Array[
    Ref
    ]

    compile_extruded_bezier_profile writes a B-Rep for an ExtrudedBezierProfile.

    Contours with only straight spans keep the cheap polyline/line path used by compile_extruded_profile. A group with any curved span is emitted with exact B-spline geometry: one closed cubic B_SPLINE_CURVE_WITH_KNOTS per contour, two planar caps, and a SURFACE_OF_LINEAR_EXTRUSION lateral face.

    compile_extruded_profile

    fn compile_extruded_profile(ctx : StepContext, node : SceneNode, extrusion : ExtrudedProfile, reverse? : Bool, parent? : Transform?) -> Array[
    Ref
    ]

    compile_hex_head_pcurves

    fn compile_hex_head_pcurves(ctx : StepContext, node : SceneNode, h : HexHeadWasherFace, reverse? : Bool, parent? : Transform?) -> Array[
    Ref
    ]

    compile_hex_head_pcurves emits the exact conical-washer-face head.

    compile_revolved_profile

    fn compile_revolved_profile(ctx : StepContext, node : SceneNode, rev : RevolvedProfile, reverse? : Bool, parent? : Transform?) -> Array[
    Ref
    ]

    compile_revolved_profile emits a solid of revolution as one closed STEP solid with analytic CYLINDRICAL_SURFACE, CONICAL_SURFACE, SPHERICAL_SURFACE, TOROIDAL_SURFACE, and PLANE faces.

    Line bands are cylinders, cones, or planar radial rings/discs. Arc bands are spherical (arc centred on the axis) or toroidal (arc centred off-axis). Every band uses its start circle with oriented-edge sense .T. and its end circle with .F., so each shared circle is traversed in opposite directions by the two neighbouring faces. Full-period tube bands carry a seam edge (a straight generator for line bands, a trimmed circular arc for arc bands).

    compile_slit_tube

    fn compile_slit_tube(ctx : StepContext, node : SceneNode, t : SlitTube, reverse? : Bool, parent? : Transform?) -> Array[
    Ref
    ]

    compile_slit_tube emits the slotted tube as one closed shell.

    compile_socketed_solid

    fn compile_socketed_solid(ctx : StepContext, node : SceneNode, s : SocketedSolid, reverse? : Bool, parent? : Transform?) -> Array[
    Ref
    ]

    compile_socketed_solid emits one closed solid for a revolved body with a blind hexagonal socket cut into its flat top.

    Every revolved band except the flat top cap is compiled by the analytic revolve compiler, so the body's cylinders, cones, spheres, and tori stay analytic. The top cap is replaced by a planar annular face (outer circle, inner socket rim), six planar socket walls, an optional ruled lead-in, and a planar hexagonal floor. Shared edges are traversed once per adjacent face in opposite directions, so the result is a single watertight shell.

    compile_square_hole_washer

    fn compile_square_hole_washer(ctx : StepContext, node : SceneNode, w : SquareHoleWasher, reverse? : Bool, parent? : Transform?) -> Array[
    Ref
    ]

    compile_square_hole_washer emits one closed solid for a centered square-hole washer.

    compile_square_nut

    fn compile_square_nut(ctx : StepContext, node : SceneNode, n : SquareNut, reverse? : Bool, parent? : Transform?) -> Array[
    Ref
    ]

    compile_square_nut emits the square nut as one closed STEP shell.

    compile_tab_washer

    fn compile_tab_washer(ctx : StepContext, node : SceneNode, w : TabWasher, reverse? : Bool, parent? : Transform?) -> Array[
    Ref
    ]

    compile_tab_washer emits one closed solid for a DIN 93 tab washer.

    conical_nut_bounding_box

    fn conical_nut_bounding_box(n : ConicalNut) -> (Double, Double, Double, Double, Double, Double)

    conical_nut_bounding_box returns the true (trimmed) axis-aligned extent.

    conical_nut_mesh

    fn conical_nut_mesh(n : ConicalNut, angular_segments? : Int) -> (Array[(Double, Double, Double)], Array[Array[Int]])

    conical_nut_mesh builds a visualization mesh of the nut.

    csg_eval_script_path

    fn csg_eval_script_path(root : String?) -> String

    csg_eval_script_path joins a repository root with scripts/csg_eval.py.

    A None root falls back to the current-directory relative path, matching the Blender exporter's script resolution.

    cut_on_face

    fn cut_on_face(base : SceneNode, profile : Profile2D, face : FaceInfo, depth : Double, name? : String, overshoot? : Double, center? : (Double, Double), color? : Rgb) -> SceneNode

    cut_on_face builds a difference that cuts profile depth into base from face.

    The cutter is extended by overshoot past the face so the evaluated boolean does not leave a skin. STEP export remains nominal unless the design is evaluated with OCCT (write_step_evaluated) or Blender.

    cycle_area_3d

    fn cycle_area_3d(pts : Array[(Double, Double, Double)], cycle : Array[Int]) -> (Double, Double, Double)

    difference

    fn difference(base : SceneNode, cutters : Array[SceneNode], name? : String) -> SceneNode

    difference returns a new SceneNode representing a boolean difference between a base node and a set of cutter nodes.

    extruded_arc_mesh

    fn extruded_arc_mesh(e : ExtrudedArcProfile, arc_segments? : Int) -> (Array[(Double, Double, Double)], Array[Array[Int]])

    extruded_arc_mesh builds a visualization mesh by sampling the arcs.

    fillet_edges

    fn fillet_edges(base : SceneNode, radius_mm : Double, selector? : EdgeSelector, name? : String) -> SceneNode

    fillet_edges records the intent to round the selected edges of base with a circular fillet of radius_mm.

    The flat STEP writer cannot trim edges and refuses this node with an error diagnostic. Apply it through Design::to_step_evaluated (OCCT) or the Blender backend. A sharp edge is never emitted and called a fillet.

    find_csg_eval_script

    async fn find_csg_eval_script(root : String?) -> String?

    find_csg_eval_script resolves $MOONBIT_STEP_ROOT (falling back to ./scripts/csg_eval.py) and returns the path only when it exists.

    fmt_double

    fn fmt_double(v : Double, snapping : Double?) -> String

    force_ccw

    fn force_ccw(pts : Array[(Double, Double)]) -> Array[(Double, Double)]

    force_cw

    fn force_cw(pts : Array[(Double, Double)]) -> Array[(Double, Double)]

    grid_of_holes

    fn grid_of_holes(cols : Int, rows : Int, pitch_x : Double, pitch_y : Double, center? : (Double, Double)) -> Array[(Double, Double)]

    grid_of_holes returns cols * rows centers on a rectangular pitch, centered on center and ordered row-major (all columns of row 0, then row 1, ...).

    helix_path

    fn helix_path(pos? : (Double, Double, Double), size_per_turn? : (Double, Double, Double), num_turns? : Double, num_segs_per_turn? : Int, start_angle? : Double, clockwise? : Bool) -> SweepPath

    is_point_in_polygon

    fn is_point_in_polygon(p : (Double, Double), poly : Array[(Double, Double)]) -> Bool

    load_font

    async fn load_font(font_name : String) ->
    Font
    raise LoaderError

    load_font loads a font by its simple name in the compressed JSON format produced by gmlewis/fonts (for example, baloo.json.gz).

    font_name is the short font name (for example, "baloo"), not the full package path. For the baloo font from package gmlewis/fonts-b/baloo, use load_font("baloo"). The examples' baloo font is vendored in assets/fonts/, so a normal checkout needs no environment variable.

    Paths are checked in this order:

    1. ./assets/fonts/{font_name}.json.gz
    2. ./all-fonts/{font_name}.json.gz (legacy working-directory layout)
    3. $MOONBIT_STEP_ROOT/assets/fonts/{font_name}.json.gz
    4. $MOONBIT_FONTS_DIR/all-fonts/{font_name}.json.gz

    If the font is not found, it raises a LoaderError listing every path that was checked, along with instructions on how to generate the font.

    matrix_to_euler

    fn matrix_to_euler(m : Matrix3x3) -> (Double, Double, Double)

    midpoint

    fn midpoint(a : (Double, Double), b : (Double, Double)) -> (Double, Double)

    midpoint returns the center of the segment a-b.

    planar_faces_of

    planar_faces_of returns every planar face of every MANIFOLD_SOLID_BREP in a compiled repository.

    point_on_circle

    fn point_on_circle(radius : Double, angle_deg : Double) -> (Double, Double)

    point_on_circle returns the point at angle_deg on a circle of radius centered at the origin.

    polygon_area_2d

    fn polygon_area_2d(pts : Array[(Double, Double)]) -> Double

    project_point_to_line

    fn project_point_to_line(p : (Double, Double), a : (Double, Double), b : (Double, Double)) -> (Double, Double)

    project_point_to_line returns the perpendicular foot of p on the infinite line through a and b. A degenerate line (a == b) returns a.

    rev_mesh

    fn rev_mesh(rev : RevolvedProfile, angular_segments? : Int, arc_segments? : Int) -> (Array[(Double, Double, Double)], Array[Array[Int]])

    rev_mesh builds a triangle/quad mesh approximation of a revolved profile for the optional Blender export. STEP output uses the analytic compiler, not this mesh.

    rev_profile_polyline

    fn rev_profile_polyline(rev : RevolvedProfile, arc_segments? : Int) -> Array[(Double, Double)]

    rev_profile_polyline samples a revolved profile into a polyline in (r, z).

    rotate_point

    fn rotate_point(p : (Double, Double, Double), rx : Double, ry : Double, rz : Double) -> (Double, Double, Double)

    slit_tube_mesh

    fn slit_tube_mesh(t : SlitTube, arc_segments? : Int) -> (Array[(Double, Double, Double)], Array[Array[Int]])

    slit_tube_mesh builds a visualization mesh of the slotted tube.

    snap_double

    fn snap_double(v : Double, snapping : Double?) -> Double

    socketed_solid_mesh

    fn socketed_solid_mesh(s : SocketedSolid, angular_segments? : Int, arc_segments? : Int) -> (Array[(Double, Double, Double)], Array[Array[Int]])

    socketed_solid_mesh builds a visualization mesh of the revolved body with the blind socket. It samples the socket boundary at the same angular steps as the body so the annulus and walls close without T-junctions.

    square_nut_bounding_box

    fn square_nut_bounding_box(n : SquareNut) -> (Double, Double, Double, Double, Double, Double)

    square_nut_bounding_box returns the true axis-aligned extent.

    square_nut_mesh

    fn square_nut_mesh(n : SquareNut, angular_segments? : Int) -> (Array[(Double, Double, Double)], Array[Array[Int]])

    square_nut_mesh builds a visualization mesh of the square nut.

    text_at

    fn text_at(text : String, x : Double, y : Double, z : Double, font~ :
    Font
    , font_size? : Double, max_width? : Double, emboss_depth? : Double, rx? : Double, ry? : Double, rz? : Double, segments? : Int) -> Array[SceneNode]

    text_at returns an array of SceneNodes representing the given text rendered at the specified position and orientation.

    Note that the 'draw' package represents all glyphs as type CompoundPath where it explicitly labels each included Path as either clear=true (meaning that this represents a cut-out or hole like the two holes in the "8") or clear=false which would represent the outer path, for example. Some glyphs (like "%") have multiple clear=true AND clear=false Paths due to detached geometry. Note that WINDING ORDER IS NOT GUARANTEED in the 'draw' package! So the 'cad' package in THIS repo should understand this critical information, and build proper STEP representations of these extruded CompoundPaths.

    translate_pts

    fn translate_pts(pts : Array[(Double, Double)], x : Double, y : Double) -> Array[(Double, Double)]

    tube

    fn tube(outer_diameter : Double, inner_diameter : Double, height : Double, segments? : Int) -> Shape

    tube returns a Shape representing a hollow (or solid) cylinder. If inner_diameter <= 0, it returns a solid cylinder.

    tube_with_fit

    fn tube_with_fit(outer_diameter : Double, inner_diameter : Double, height : Double, fit? : Fit, segments? : Int) -> Shape

    tube_with_fit is tube() with the bore's clearance captured as a Fit. Only the void grows: the outer diameter is unchanged. Like tube(), it emits a faceted extrusion; use Cylinder for analytic geometry.

    union_all

    fn union_all(nodes : Array[SceneNode], name? : String) -> SceneNode

    union_all returns a new SceneNode representing the grouping of an array of nodes.

    Note that this does not currently perform a formal STEP "union" (which is a CSG operation that many CAD engines struggle to translate), but instead groups the solids together in the same design.

    write_text_file

    async fn write_text_file(text : String, out_path : String?) -> Unit

    Writes text to out_path, or to stdout when out_path is None.

    Existing files are overwritten. I/O errors propagate, so callers (and the process exit code) see a failed write instead of a stale output file.