You know you want to use them
Script parts
A script part is a part you write in code. It's a short ManifoldCAD-style ES module that returns a solid. Any parameters you declare (sizes, counts, angles, on/off toggles) show up as normal sliders, number fields and switches, so whoever uses the part can adjust it without reading the code.
Use one when a shape is really a loop and a formula: gears, lattices, pegboard and Gridfinity grids, threads. Changing a parameter rebuilds the part immediately.
How to use it
Create the part
In the Parts panel, click the New script part tile (or run from the File menu or command palette). Name the part and click Create.
Open the editor
The script editor opens as a docked panel. On the left are the part's Label, Icon, Shape ID, Description, Tags and Parameters list. On the right is the code editor, with a Live preview underneath.
Start from an example
To start from working code, open the Examples tab and pick a template (Centered cube, Rounded box, Polygon prism, Revolved vase, Pegboard tile, Spur gear, Gridfinity bin, and more).
Write the module
Import the geometry API and your parameters, then
export defaulta 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);Define parameters
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 withparams.<key>.Watch the preview
The Live preview shows building…, then ready, and prints any build or validation errors in red.
Save the part
Click Create script (or Save changes when editing) to save the part to your workspace, then Close to leave the editor.
Place an instance
Drag the part's tile from the Parts panel into the viewport. Select the instance to adjust its parameters in the properties panel.
Tips
- Scripts use the same dialect as manifoldcad.org, so scripts from there usually paste in with little or no change. Use
Manifoldfor 3D primitives and booleans (subtract,add,hull) andCrossSectionfor 2D profiles youextrudeorrevolve. - You can
export defaultone solid or an array of solids. An array gets unioned, which is handy for things built in a loop. - TypeScript works. Type annotations are stripped before the script runs, and top-level
awaitis allowed. - Only two imports are allowed:
manifold-3d/manifoldCADandcubbycad:params. Anything else is a hard error, and onlyexport defaultis recognized. Scripts run in a sandbox with no network or DOM access. - Give parameter reads a fallback (
Number(params.size) || 10) so a blank or out-of-range value doesn't break the build. - The Shape ID is locked after the first save so existing scenes can still find the part. Pick it carefully.