You know you want to use them

Script parts

Write a part in JavaScript or TypeScript; the numbers and toggles you expose become editable settings.

A script part is a part you build with code instead of by dragging shapes. You write a short ManifoldCAD-style ES module that returns a solid, and CubbyCAD runs it to produce real geometry. Any parameters you declare — sizes, counts, angles, on/off toggles — show up as ordinary sliders, number fields, and switches, so you (or anyone who uses your part) can dial it in without touching the code.

Reach for a script part when a shape is fundamentally parametric or repetitive: gears, lattices, pegboard/Gridfinity-style grids, threads, or anything you'd rather express as a loop and a formula than place by hand. Because the part stays live, changing a parameter rebuilds the geometry instantly.

Script parts: the code editor with live preview
Overview. A script part with its code, parameters, and live preview.

How to use it

  1. Create the part

    Open the Parts panel and click the New script part tile (you can also run File ▸ New script part… from the File menu or command palette). Give the part a name and click Create.

  2. Open the editor

    The script editor opens as a docked panel. The left side holds the part's Label, Icon, Shape ID, Description, Tags, and a Parameters list. The right side is the code editor with a Live preview underneath.

  3. Start from an example

    To start from something that already works, switch to the Examples tab and pick a template (Centered cube, Rounded box, Polygon prism, Revolved vase, Pegboard tile, Spur gear, Gridfinity bin, and more).

  4. Write the module

    Write your module in the editor. Import the geometry API and your parameters, then export default a solid. For example:

    import { Manifold } from 'manifold-3d/manifoldCAD';
    import params from 'cubbycad:params';
    const size = Number(params.size) || 10;
    export default Manifold.cube([size, size, size], true);

  5. Define parameters

    Define your editable settings under Parameters: click Add parameter and fill in a Key (e.g. radius), a Label, a Type (Number, Integer, String, Boolean, or Enum), and a Default. Numeric types also take Min, Max, Step, and Unit. Read each value in code via params.<key>.

  6. Watch the preview

    Watch the Live preview as you edit — it shows building… then ready, and prints any build or validation errors in red.

  7. Save the part

    Click Create script (or Save changes when editing) to save the part to your workspace. Click Close to leave the editor.

  8. Place an instance

    Back in the scene, drag the part's tile from the Parts panel into the viewport to place an instance. Select the instance to adjust its parameters in the properties panel.

Parameters becoming editable sliders
In the editor. Declared parameters surfaced as sliders on the placed part.

Tips

  • Scripts use the same dialect as manifoldcad.org, so scripts written there usually paste in with little or no change. Build with Manifold for 3D primitives and booleans (subtract, add, hull), and CrossSection for 2D profiles you extrude or revolve.
  • You can export default a single solid or an array of solids — an array is merged with a boolean union, handy for building assemblies in a loop.
  • TypeScript is fine: type annotations are stripped before the script runs. Top-level await is allowed too.
  • Only two imports are permitted — manifold-3d/manifoldCAD and cubbycad:params. Any other import is a hard error, and only export default is recognized. Scripts run in a locked-down sandbox with no network or DOM access.
  • Guard your parameter reads with a fallback (Number(params.size) || 10) so a blank or out-of-range value never breaks the build.
  • The Shape ID is locked after the first save so existing scenes keep resolving the part — choose it deliberately.

Try it in your browser

Open CubbyCAD and put Script parts to work — it runs in the browser, no install.