Back to the journal

The makeacut Language Hierarchy

12 minutes read

This article is mostly written with AI! I'm trying to give you a description of how the various pieces of the language fit together, and also the main terminology being used. The core idea is:

  • Design - a single makeacut program, usually consisting of Assemblies and Components
  • Assembly - puts multiple 2D Components - and other Assemblies - together into 3D shapes, optionally adding a roof and a base.
  • Component - a complete 2D unit, for example "front_wall", "back". It is usually made up of Parts, but also various Components
  • Part - a partial reusable 2D unit, for example, "window", "door"
  • Component - the nitty gritty: commands to do things, and commands to make shapes.

Here's the AI part:

How the language is layered, from the whole file down to single drawing commands. Three kinds of reusable definition (parts, patterns and images) can be used at more than one level.

Design
├── Declarations & shared definitions   (units, scale, defaults, variables, image, pattern, part)
├── Assembly ──refers to──► Components
│     ├── Perimeter
│     └── Generated parts (base, floor, roof, loggia)
└── Component
      └── Operation block (cut / score / engrave / guide / print)
            └── Block (group, add/subtract/clip, move:, flow, repeat …)
                  └── Drawing commands (line, turn, arc, rect, circle, text …)

Design

A design's source, the .mac file itself. It starts with declarations that apply to the whole design: units, modeling scale, the intended fabrication medium and defaults (thickness, colour). These must come before any geometry and can't be changed later.

The design also holds definitions that everything else shares: variables, colour constants, image declarations, named pattern presets and part definitions. Drawing commands placed at the top level, outside any component, form an implicit component called Main.

Other docs and error messages call this top level "document level", as in "define it at document level". It means the same thing: the top level of a design's source, outside any block.

Commands: units, scale, medium, defaults:, NAME = expr, image alias:, pattern kind --name …:, part name:

units m
scale 1:87
medium laser-cutting
defaults:
    thickness 1.5

WALL_H = 3

Assembly

A 3D model built from components. An assembly doesn't redraw its walls. It lists existing wall components in order around a closed perimeter, solves the corners and joints, and then generates the parts that fit that footprint: a base, floors, a roof and loggias.

The generated parts show up in the component selector under their own names, such as station_foundation and station_main_a. They can be printed and exported like any other part. Assemblies can also join one another, for example a porch or lean-to onto a house.

Commands: assembly name:, perimeter name: (with component wall, turn, joints), base, floor, roof (with section), loggia, join

assembly station:
    perimeter exterior:
        component front
        component side
        component back
        component side
    base foundation:
        margin 0.2
    roof main

Component

One physical piece, and the unit of output. Each component renders, prints and exports separately, and each starts with a fresh cursor at (0, 0). Cursor state, named geometry and local variables stay inside it.

Components can't be nested and they aren't reusable; that's what parts are for. --quantity says how many identical copies are needed. --z, --color and --material set its 3D placement and appearance.

Commands: component name [--quantity n] [--z …] [--color …] [--material …]:

component side --quantity 2:
    rect 5 WALL_H

Operation block

This says what the machine does with the geometry inside it. cut goes all the way through, score makes fold lines, engrave marks the surface, guide is construction geometry only, and print is coloured ink on paper.

The optional name becomes the operation's identifier. Geometry outside any operation block is treated as an unnamed cut.

Commands: cut, score, engrave, guide, print [--ink COLOR]

component front:
    cut outline:
        rect 8 WALL_H
    engrave sign:
        move 3 2.6
        text "STATION" --height 0.3

Block

Indented structural blocks that scope the cursor, combine material or lay things out, without drawing anything themselves. group restores the cursor when it ends and can carry --thickness, --pattern or --tile. add, subtract, clip and hole combine material. Layout blocks such as box, flow, layout, center and distribute arrange their children. Control blocks such as repeat, walk, if and measure handle repetition, conditions and measuring without drawing.

Every colon needs a body, so use pass as a placeholder.

Commands: group, add, subtract, clip, hole, move dx dy:, zero …:, box, flow, layout, center, repeat, walk, if, measure, pass

    cut outline:
        group --pattern wall_bricks:
            rect 8 WALL_H
    move 1 1
    repeat 3:
        place window
        move 2.5 0 

Drawing commands

The leaves of the tree. Makeacut draws with a turtle-style cursor: path commands extend the current path from the cursor and move it, while shape commands draw a closed shape at the cursor.

Coordinates are Cartesian (y points up, angles run counterclockwise). Measurements are in the design's units, multiplied by its scale.

Commands: path commands line, turn, angle, arc, arcbox, bezier, score, close; shapes rect, circle, ellipse, triangle, arch, text; cursor commands move, zero, space, label

rect 8 WALL_H
move 3 2.6
line 2
turn 90
arc 0.5 180

Reusable definitions

These are defined once and used at any level.

Part. A reusable, parameterised piece of drawing with its own private coordinates. You define it once at the top level of the design and place it anywhere, with arguments. Placing a part doesn't move the cursor.

part window:
    parameters:
        width 1
        height 1.4
    cut opening:
        rect width height

Pattern. A surface texture such as bricks, tiles or siding. You can write it inline, or define a named preset and apply it with --pattern on a group, add, subtract or part, or with pattern on a roof or loggia.

 pattern bricks --name wall_bricks:
    size 0.25 0.08

Image. A declared picture. It can be a tracing reference, printed background artwork or tiled texture (--tile).

Things that are easy to get wrong

  • --pattern is not allowed on the component line itself. Put it on a group or part instead.
  • Assemblies refer to components rather than containing them, so walls stay ordinary components you can print on their own.
  • color is the physical stock colour and ink is printed colour. That rule holds at every level.

Complete example

All of the snippets above, combined into one design:

units m
scale 1:87
medium laser-cutting
defaults:
    thickness 1.5

WALL_H = 3

pattern bricks --name wall_bricks:
    size 0.25 0.08

part window:
    parameters:
        width 1
        height 1.4
    cut opening:
        rect width height

component front:
    cut outline:
        group --pattern wall_bricks:
            rect 8 WALL_H
    move 1 1
    repeat 3:
        place window
        move 2.5 0
    engrave sign:
        zero
        move 3 2.6
        text "STATION" --height 0.3

component side --quantity 2:
    rect 5 WALL_H

component back:
    rect 8 WALL_H

assembly station:
    perimeter exterior:
        component front
        component side
        component back
        component side
    base foundation:
        margin 0.2
    roof main
More from the notebook