# ParaScript > A language model writes language well and does not reliably produce a spatially arranged solid from a prompt. It describes the solid in ParaScript. The workspace turns that script into the solid. Read the language reference before writing a script. It begins with "How to write a solid" and then gives the complete example scripts. The compiler accepts only the forms that page describes. Copy the smallest example that already does the thing you need, and change its parameters. There is no upload API: a person pastes the finished script into the workspace and presses Run solver. Write a shape once and call it wherever that shape appears, including at `export`. Do not copy its faces. Name each face for the surface it is. The broom's handle, ferrule, and hanging hole are three calls to `Cylinder(radius:, height:)`, and `join` turns the hole. Put the model's name in `setup` as `name: "..."`. The field is required. The downloaded STL file uses that name. Put the model's parameters in the `parameters` section, grouped by the part they describe. A size, a count, and a position are fields there. When a measurement comes from a standard, put that field in a group named for the standard. The screw does this with `head.iso_4017` and `thread.iso_68_1`. Read a field with `$`, as in `$plate.size` and `$holes.radius`. Bind `pi` when a curve needs it: `def pi = 3.14159265359`. That is a value the whole script shares. `Box(width:, depth:, height:)` is a solid from `(0, 0, 0)` to `(width, depth, height)`. `corner` and `origin` are `(0, 0, 0)`. `bottom` is the center of the face on z = 0, `(width / 2, depth / 2, 0)`. `top` is the center of the top face, `(width / 2, depth / 2, height)`. `up` is `(0, 0, 1)` and `right` is `(1, 0, 0)`. `Cylinder(radius:, height:)` stands on that same axis. `bottom` is `(0, 0, 0)`, `top` is `(0, 0, height)`, and `center` is `(0, 0, height / 2)`. `forward` is `(0, 1, 0)` and `origin` is `(0, 0, 0)`. Width, depth, height, and radius are numbers greater than zero. `Sphere(radius:)` is centered on the origin. `origin` and `center` are `(0, 0, 0)`. `top` is `(0, 0, radius)` and `bottom` is `(0, 0, 0 - radius)`. `up` is `(0, 0, 1)`, `right` is `(1, 0, 0)`, and `forward` is `(0, 1, 0)`. A script that defines `Sphere`, `Box`, or `Cylinder` uses its own definition. The plate calls `Box(width: $plate.size, depth: $plate.size, height: $plate.thickness)`. The host exposes `up`, `right`, and `corner`. A part that will be seated exposes `up`, `right`, and `bottom`. The exported component exposes `origin`, the point the viewer hangs the model on. `vector_grid` returns the points of a grid. `circular_pattern` returns the points of a circle. Both are `snake_case`. A component uses `PascalCase`, such as `Plate`, `Box`, and `Cylinder`. `place_components` seats one component at each point. It folds the list, and each step is one `join`. The point is added to the host's `corner` and meets the placed part's `bottom`. Pass `combine` at the call, with parameters named `frame` and `placed`. `frame - placed` cuts the placed solid away. `frame + placed` keeps both. The plate cuts holes that way and then unions seven knobs. `integers(start: 0.0, count: 5.0)` is `[0.0, 1.0, 2.0, 3.0, 4.0]`. `start` is the first whole number and `count` is how many. A list has no length. `map`'s parameter is named `item`. `filter`'s predicate returns the literal `true` or `false`. `|>` pipes a value into a function's next argument, and `>>` composes two functions and binds more tightly. `items |> map(f: item => ...)` fills `list`. `items |> map` is rejected. `fold(f:, initial:, list:)` is a right fold. The last item is visited first, and `f` is `item => accumulator =>`. An empty list returns `initial`. A script may define `fold`, and that definition is the one it calls. A `def` may declare a signature. `def same: T => T => number` uses the type variable `T` for both parameters and returns a number. A repeated name is the same variable. `number`, `vector`, `boolean`, `string`, `component`, `solid`, `surface`, and `coordinate_system` are concrete types. `[T]` is a list of `T`. A tuple is `(1.0, true)`, and `(number, vector)` is its type. Each place keeps its own type. Take it apart with `let (n, point) = pair in`. There is no `pair.0`. A vector is `Vector(coords: coords, x:, y:, z:)`. `coords` comes from `Component`, which passes one coordinate system into `solid: coords =>` and `expose: coords =>`. A script cannot construct a coordinate system. A helper defined outside those callbacks takes `coords` and the call passes it, as in `circular_pattern(coords: coords, count: count, radius: radius)`. `join`'s last parameter is that coordinate system, and `join` ignores it, so pass `solid: join(...)`. A component does not expose that system. A direction a mate needs is an anchor. Inside `using`, move a point with `offset(x:, y:, z:)` and combine two vectors with `add(vector:)` or `subtract(vector:)`. Both must carry the same coordinate system, and the result keeps the receiver's system. `+` and `-` do not combine vectors. A call names every argument, in parameter order. A `def` is top-level. `let name = expression in expression` names a value inside a function. The name is in scope after `in`. Wrap the join in `Component(solid: join(...), expose: coords => ...)` and publish the anchors the next mate reads. Seat one feature per `join`. A `Solid3D` is one closed body. The plate is the script to copy for a grid or a circle of features. ## Lessons The language page states these lessons as short rules after "How to write a solid", then gives the complete scripts. Follow them when writing a script. - Write a shape once and call it. The broom's handle, ferrule, and hanging hole are three calls to `Cylinder`. - A plate is a square box: `Plate` calls `Box(width: $plate.size, depth: $plate.size, height: $plate.thickness)`. That box stands on z = 0. `corner` is the minimum point. `bottom` and `top` are the centers of those faces. The box example seats a void from `corner`. - A function that is not a component uses `snake_case`, and the name says what it returns. `vector_grid` returns the grid of points. `circular_pattern` returns the points of a circle. A component uses `PascalCase`, such as `Plate` and `Cylinder`. - The model's parameters belong in the `parameters` section. A size is a parameter of the part. Read them with `$plate` and `$plate.size`. When a measurement comes from a standard, its group is named for that standard. `pi` is the value the whole script shares. - `place_components` seats one component at each point. `combine: frame => placed => frame - placed` cuts a hole. `combine: frame => placed => frame + placed` keeps a knob. The lambda is written at the call, and its parameters are named `frame` and `placed`. The point meets `corner` and `bottom`. - `integers(start: 0.0, count: 5.0)` is `[0.0, 1.0, 2.0, 3.0, 4.0]`. A list has no length. The plate's hole grid uses `$holes.count_width` and `$holes.count_depth`. The knob circle uses `$pins.count`. - `|>` pipes a value into the next argument. `>>` composes two functions, runs the left one first, and binds more tightly. `items |> map` is rejected. Seat one feature per `join`. A `Solid3D` is one closed body. A call names every argument, in parameter order. - A vector is `Vector(coords: coords, x:, y:, z:)`. `Component` passes the coordinate system into `solid: coords =>` and `expose: coords =>`. A script cannot construct that value. A helper outside those callbacks takes `coords`. `join`'s last parameter is that system and `join` ignores it, so the solid is `join(...)`. A component does not expose it. `frame.coords` does not typecheck. Inside `using`, move a point with `offset(x:, y:, z:)` and combine two vectors with `add(vector:)` or `subtract(vector:)`. Copy one of these scripts from the language page: - Sphere: `Sphere(radius:)`, centered on the origin, with the radius chosen at `export`. - Box: `HollowBox` calls `Box` twice and cuts a void with `frame - placed`. - Broom: one `Cylinder` seated several times by `join`. - Plate: a grid and a circle, seated with `place_components`. - Screw: standard measurements in a group named for the standard, and one face per thread turn. - Remote: many different parts seated on one host. - Car: a body, a cabin, and two axles. Each wheel is a `Cylinder(radius:, height:)` seated on the hull so its axis lies along the body's `right`. - Desk set: nested parameter groups, a row of clips, and a shaker. - Letter M: cylinders seated along straight runs and arcs on a plate. The sizes sit in `script`. ## Language - [ParaScript language](https://parascript.lindeque.family/language): Rules and complete scripts for writing a model. - [AI assets](https://parascript.lindeque.family/parascript-assets.md): The prompt and the language in one file a model uses to write a script. ## Workspace - [Workspace](https://parascript.lindeque.family/workspace): Where a person pastes a script and presses Run solver.