forma-dsl-mcp 0.3.8 → 0.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -18
- package/package.json +2 -2
- package/src/bin.js +1 -1
- package/src/catalogue.js +15 -15
- package/src/document.js +8 -38
- package/src/examples.js +1 -1
- package/src/guide.js +24 -24
- package/src/reference/README.md +15 -5
- package/src/reference/api/describe-parameters.md +4 -4
- package/src/reference/api/evaluation-context.md +13 -13
- package/src/reference/api/export.md +7 -7
- package/src/reference/api/geometry-node.md +9 -9
- package/src/reference/api/kernel.md +8 -8
- package/src/reference/api/low-level.md +9 -9
- package/src/reference/api/render.md +8 -8
- package/src/reference/api/values.md +12 -12
- package/src/reference/cli.md +146 -0
- package/src/reference/errors.md +14 -14
- package/src/reference/language/control-flow.md +3 -3
- package/src/reference/language/expressions.md +10 -10
- package/src/reference/language/overview.md +11 -11
- package/src/reference/language/scope.md +13 -13
- package/src/reference/language/syntax.md +4 -4
- package/src/reference/reference/align.md +9 -9
- package/src/reference/reference/booleans.md +5 -5
- package/src/reference/reference/component.md +12 -12
- package/src/reference/reference/conversions.md +8 -8
- package/src/reference/reference/functions.md +8 -8
- package/src/reference/reference/local.md +4 -4
- package/src/reference/reference/model.md +10 -10
- package/src/reference/reference/param.md +8 -8
- package/src/reference/reference/part.md +12 -12
- package/src/reference/reference/refinement.md +10 -10
- package/src/reference/reference/shapes-2d.md +15 -15
- package/src/reference/reference/shapes-3d.md +13 -13
- package/src/reference/reference/transforms.md +10 -10
- package/src/reference.js +4 -3
- package/src/roots.js +2 -2
- package/src/server.js +2 -2
- package/src/tools.js +15 -15
- package/src/workspace.js +7 -7
|
@@ -49,7 +49,7 @@ extrude {
|
|
|
49
49
|
- A `height` of `0` or less yields empty geometry rather than an error, so a parameter
|
|
50
50
|
sweeping to zero does not break the model.
|
|
51
51
|
- `scale_top = [0, 0]` gives a point, which is one way to build a pyramid from any profile.
|
|
52
|
-
- The profile is swept as drawn
|
|
52
|
+
- The profile is swept as drawn - `extrude` does not centre it. A `rect` that is not centred
|
|
53
53
|
produces a box in the positive quadrant.
|
|
54
54
|
|
|
55
55
|
---
|
|
@@ -76,7 +76,7 @@ revolve { angle = 180 segments = 64 polygon { points = profile } }
|
|
|
76
76
|
radius. A profile drawn from `[0, 0]` upwards produces a solid standing on the XY plane.
|
|
77
77
|
- **Every X must be ≥ 0.** A profile that crosses the axis revolves through itself and the
|
|
78
78
|
result is not what you drew.
|
|
79
|
-
- The profile does not have to touch the axis. One that does not produces a tube
|
|
79
|
+
- The profile does not have to touch the axis. One that does not produces a tube - which is
|
|
80
80
|
how [`torus`](shapes-3d.md#torus) is built internally.
|
|
81
81
|
- An `angle` of `0` or less yields empty geometry rather than an error.
|
|
82
82
|
|
|
@@ -84,7 +84,7 @@ revolve { angle = 180 segments = 64 polygon { points = profile } }
|
|
|
84
84
|
|
|
85
85
|
## `project`
|
|
86
86
|
|
|
87
|
-
The shadow a solid casts on the XY plane
|
|
87
|
+
The shadow a solid casts on the XY plane - its full outline, from any Z.
|
|
88
88
|
|
|
89
89
|
```hcl
|
|
90
90
|
project { bracket { } }
|
|
@@ -120,7 +120,7 @@ slice { z = 12 bracket { } }
|
|
|
120
120
|
|
|
121
121
|
- Takes 3D geometry and produces 2D.
|
|
122
122
|
- A plane that misses the solid gives an empty cross-section, not an error.
|
|
123
|
-
- A plane exactly on a flat face is ambiguous
|
|
123
|
+
- A plane exactly on a flat face is ambiguous - offset it slightly.
|
|
124
124
|
|
|
125
125
|
---
|
|
126
126
|
|
|
@@ -129,7 +129,7 @@ slice { z = 12 bracket { } }
|
|
|
129
129
|
### Profiles are where the modelling happens
|
|
130
130
|
|
|
131
131
|
Most shapes are easier to describe in 2D and then given thickness. A rounded box, for
|
|
132
|
-
instance, has no primitive
|
|
132
|
+
instance, has no primitive - it is a rounded rectangle with a height:
|
|
133
133
|
|
|
134
134
|
```hcl
|
|
135
135
|
extrude {
|
|
@@ -215,7 +215,7 @@ model "m" {
|
|
|
215
215
|
|
|
216
216
|
### Inspecting a cross-section
|
|
217
217
|
|
|
218
|
-
`slice` is a debugging tool as much as a modelling one
|
|
218
|
+
`slice` is a debugging tool as much as a modelling one - extrude the slice thinly to see
|
|
219
219
|
where the walls actually fell:
|
|
220
220
|
|
|
221
221
|
```hcl
|
|
@@ -243,7 +243,7 @@ extrude { height = 10 rect { size = [1, 1] } } // ✓
|
|
|
243
243
|
Two children of different dimensionality. Extrude each profile separately, or union the
|
|
244
244
|
profiles before extruding.
|
|
245
245
|
|
|
246
|
-
### `part "body" is 2D
|
|
246
|
+
### `part "body" is 2D - extrude or revolve it before rendering`
|
|
247
247
|
|
|
248
248
|
A profile reached the renderer. Somewhere the `extrude` or `revolve` is missing, or is
|
|
249
249
|
wrapped around the wrong block.
|
|
@@ -261,7 +261,7 @@ have X ≥ 0.
|
|
|
261
261
|
### My revolved solid is lying down
|
|
262
262
|
|
|
263
263
|
`revolve` maps the profile's **Y** to the result's **Z**. A profile written as (x, z) with
|
|
264
|
-
the height in the first component produces a solid on its side
|
|
264
|
+
the height in the first component produces a solid on its side - swap the components.
|
|
265
265
|
|
|
266
266
|
### `revolve` produced nothing
|
|
267
267
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Functions
|
|
2
2
|
|
|
3
3
|
Thirty builtin functions, callable in any [expression](../language/expressions.md). They take
|
|
4
|
-
**positional arguments only**
|
|
4
|
+
**positional arguments only** - named arguments are an error - and there are no user-defined
|
|
5
5
|
functions: to name a value declare a [`local`](local.md), and to name geometry declare a
|
|
6
6
|
[`component`](component.md).
|
|
7
7
|
|
|
@@ -103,7 +103,7 @@ local bolts = max(3, min(16, var.bolts))
|
|
|
103
103
|
|
|
104
104
|
`len(value)` → number
|
|
105
105
|
|
|
106
|
-
The length of a list or a string. Anything else gives `0`
|
|
106
|
+
The length of a list or a string. Anything else gives `0` - it does not raise.
|
|
107
107
|
|
|
108
108
|
```hcl
|
|
109
109
|
len([1, 2, 3]) // 3
|
|
@@ -168,7 +168,7 @@ range(4) // [0, 1, 2, 3]
|
|
|
168
168
|
range(2, 6) // [2, 3, 4, 5]
|
|
169
169
|
range(0, 10, 2.5) // [0, 2.5, 5, 7.5]
|
|
170
170
|
range(5, 0, -1) // [5, 4, 3, 2, 1]
|
|
171
|
-
range(0, -5) // []
|
|
171
|
+
range(0, -5) // [] - backwards with a positive step is empty, not infinite
|
|
172
172
|
```
|
|
173
173
|
|
|
174
174
|
This is what drives most [`for`](../language/control-flow.md#for) loops.
|
|
@@ -211,14 +211,14 @@ String interpolation already converts, so `str` is mostly useful when building a
|
|
|
211
211
|
| `pi` | 3.141592653589793 |
|
|
212
212
|
| `e` | 2.718281828459045 |
|
|
213
213
|
|
|
214
|
-
They are ordinary names in the root scope, so they can be shadowed by a param or a local
|
|
214
|
+
They are ordinary names in the root scope, so they can be shadowed by a param or a local -
|
|
215
215
|
avoid doing so.
|
|
216
216
|
|
|
217
217
|
```hcl
|
|
218
218
|
local circumference = 2 * pi * var.radius
|
|
219
219
|
```
|
|
220
220
|
|
|
221
|
-
Since every angle in the language is in degrees, `pi` comes up less than it would elsewhere
|
|
221
|
+
Since every angle in the language is in degrees, `pi` comes up less than it would elsewhere -
|
|
222
222
|
mostly in arc lengths and areas rather than in rotations.
|
|
223
223
|
|
|
224
224
|
---
|
|
@@ -281,8 +281,8 @@ model "m" {
|
|
|
281
281
|
|
|
282
282
|
### `len takes 1 argument(s), got 2`
|
|
283
283
|
|
|
284
|
-
A fixed-arity function got the wrong count. The variadic ones
|
|
285
|
-
`concat`, `range`
|
|
284
|
+
A fixed-arity function got the wrong count. The variadic ones - `min`, `max`, `sum`,
|
|
285
|
+
`concat`, `range` - accept any number; the rest do not.
|
|
286
286
|
|
|
287
287
|
### `pow: functions take positional arguments`
|
|
288
288
|
|
|
@@ -305,7 +305,7 @@ allocating until the tab dies.
|
|
|
305
305
|
|
|
306
306
|
### `... must be a finite number`
|
|
307
307
|
|
|
308
|
-
Something upstream produced `NaN` or `Infinity`
|
|
308
|
+
Something upstream produced `NaN` or `Infinity` - `sqrt` of a negative, `min()` of nothing,
|
|
309
309
|
`num("abc")`. The error names the block and attribute that read it, not where it was
|
|
310
310
|
produced, so work backwards from there.
|
|
311
311
|
|
|
@@ -13,7 +13,7 @@ local radius = var.diameter / 2
|
|
|
13
13
|
|
|
14
14
|
### `local NAME = expression`
|
|
15
15
|
|
|
16
|
-
Binds a name to the result of an expression. Locals hold values, never geometry
|
|
16
|
+
Binds a name to the result of an expression. Locals hold values, never geometry - to name a
|
|
17
17
|
piece of geometry, declare a [`component`](component.md).
|
|
18
18
|
|
|
19
19
|
#### Parameters
|
|
@@ -30,7 +30,7 @@ Nothing. A local binds a name; it produces no geometry.
|
|
|
30
30
|
#### Caveats
|
|
31
31
|
|
|
32
32
|
- **Locals are ordered at the top level.** A local may refer to params, to constants and to
|
|
33
|
-
locals declared *above* it
|
|
33
|
+
locals declared *above* it - never below. `local a = b` before `local b = 2` fails with
|
|
34
34
|
`unknown name "b"`.
|
|
35
35
|
- **Locals inside a body are not ordered.** Every local in one block body is resolved before
|
|
36
36
|
any of that body's blocks are built, so a block may use a local declared after it. See
|
|
@@ -130,7 +130,7 @@ model "frame" {
|
|
|
130
130
|
|
|
131
131
|
| Use | When |
|
|
132
132
|
| --- | --- |
|
|
133
|
-
| [`param`](param.md) | The value is an **input**
|
|
133
|
+
| [`param`](param.md) | The value is an **input** - someone outside the document should be able to change it |
|
|
134
134
|
| `local` | The value is **derived** from params or is a fixed table, and should never be a control |
|
|
135
135
|
| [`component`](component.md) | You are naming **geometry**, not a value |
|
|
136
136
|
|
|
@@ -152,7 +152,7 @@ local cavity_top = top + 2 // runs past the opening so the neck is not capp
|
|
|
152
152
|
|
|
153
153
|
### `unknown name "b"`
|
|
154
154
|
|
|
155
|
-
A top-level local referred to something declared below it. Move the declaration up
|
|
155
|
+
A top-level local referred to something declared below it. Move the declaration up - locals
|
|
156
156
|
are resolved strictly in source order:
|
|
157
157
|
|
|
158
158
|
```hcl
|
|
@@ -38,7 +38,7 @@ A scene: a list of parts, each with a name, a colour, an opacity and a geometry
|
|
|
38
38
|
#### Caveats
|
|
39
39
|
|
|
40
40
|
- **Every part must be 3D.** A 2D part is rejected before it is solved:
|
|
41
|
-
`part "body" is 2D
|
|
41
|
+
`part "body" is 2D - extrude or revolve it before rendering`.
|
|
42
42
|
- **A model must produce something.** An empty body, or one whose only loop ran zero times,
|
|
43
43
|
fails with `model "m" produced no geometry`.
|
|
44
44
|
- **Declaring the same model twice is an error**: `model "m" is declared twice`.
|
|
@@ -63,7 +63,7 @@ Naming one that does not exist fails with `no model named "exploded"`. In the ed
|
|
|
63
63
|
first model is the one shown.
|
|
64
64
|
|
|
65
65
|
Several models in one document is the idiomatic way to keep variants of the same object
|
|
66
|
-
together
|
|
66
|
+
together - a printable part and the assembly it belongs to, say:
|
|
67
67
|
|
|
68
68
|
```hcl
|
|
69
69
|
component "bracket" { ... }
|
|
@@ -81,7 +81,7 @@ model "assembly" { // what it looks like assembled
|
|
|
81
81
|
|
|
82
82
|
### Parts, and geometry without them
|
|
83
83
|
|
|
84
|
-
Geometry written straight into a model
|
|
84
|
+
Geometry written straight into a model - outside any `part` - becomes **one default part
|
|
85
85
|
named after the model**, coloured `#b8c4d0`:
|
|
86
86
|
|
|
87
87
|
```hcl
|
|
@@ -101,7 +101,7 @@ model "m" {
|
|
|
101
101
|
// parts: "pin", then "m"
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
-
Prefer explicit parts once there is more than one piece
|
|
104
|
+
Prefer explicit parts once there is more than one piece - they are what the viewer colours
|
|
105
105
|
and lists, and what an exporter can write out separately.
|
|
106
106
|
|
|
107
107
|
### Model params
|
|
@@ -119,10 +119,10 @@ model "bracket" {
|
|
|
119
119
|
|
|
120
120
|
| | Document `param` | Model `param` |
|
|
121
121
|
| --- | --- | --- |
|
|
122
|
-
| Default required | No
|
|
122
|
+
| Default required | No - may be required instead | **Yes**: `model "m": param "s" needs a default` |
|
|
123
123
|
| Settable by the caller | Yes, via `render(source, { params })` | No |
|
|
124
124
|
| Appears in `describeParameters` | Yes | No |
|
|
125
|
-
| Readable as `var.NAME` | Yes | No
|
|
125
|
+
| Readable as `var.NAME` | Yes | No - bare name only |
|
|
126
126
|
|
|
127
127
|
Use them to give one model's fixed numbers a name without adding a control to the editor.
|
|
128
128
|
For anything the caller should change, declare the param at the top level.
|
|
@@ -142,7 +142,7 @@ model "stacked_trays" {
|
|
|
142
142
|
}
|
|
143
143
|
```
|
|
144
144
|
|
|
145
|
-
An optional part goes behind an `if` **around** the part, never inside it
|
|
145
|
+
An optional part goes behind an `if` **around** the part, never inside it - a part with no
|
|
146
146
|
geometry is an error:
|
|
147
147
|
|
|
148
148
|
```hcl
|
|
@@ -174,13 +174,13 @@ model "assembly" {
|
|
|
174
174
|
The body evaluated to nothing. Usual causes:
|
|
175
175
|
|
|
176
176
|
- an empty body;
|
|
177
|
-
- a `for` over an empty list
|
|
177
|
+
- a `for` over an empty list - `range(0, var.n)` where `n` is `0`;
|
|
178
178
|
- an `if` with no `else` whose condition was false.
|
|
179
179
|
|
|
180
180
|
Guard the degenerate case so something is always produced, or make the parameter's minimum
|
|
181
181
|
exclude it.
|
|
182
182
|
|
|
183
|
-
### `part "body" is 2D
|
|
183
|
+
### `part "body" is 2D - extrude or revolve it before rendering`
|
|
184
184
|
|
|
185
185
|
A part ended up holding a cross-section rather than a solid. 2D shapes cannot be rendered
|
|
186
186
|
directly:
|
|
@@ -209,5 +209,5 @@ Two models share a name, so `render(source, { model: 'm' })` would be ambiguous.
|
|
|
209
209
|
### My `render(source, { params })` value is ignored
|
|
210
210
|
|
|
211
211
|
The param is probably declared inside the model rather than at the top level. Only top-level
|
|
212
|
-
params are settable. Check with [`describeParameters`](../api/describe-parameters.md)
|
|
212
|
+
params are settable. Check with [`describeParameters`](../api/describe-parameters.md) - it
|
|
213
213
|
lists exactly the params a caller can set.
|
|
@@ -29,7 +29,7 @@ param bolts {
|
|
|
29
29
|
|
|
30
30
|
#### Attributes
|
|
31
31
|
|
|
32
|
-
Every attribute is optional. **Only `default` affects geometry**
|
|
32
|
+
Every attribute is optional. **Only `default` affects geometry** - the rest describe the
|
|
33
33
|
control the editor should build, and are returned verbatim by
|
|
34
34
|
[`describeParameters`](../api/describe-parameters.md).
|
|
35
35
|
|
|
@@ -43,7 +43,7 @@ control the editor should build, and are returned verbatim by
|
|
|
43
43
|
| `description` | string | Help text |
|
|
44
44
|
| `options` | list | A fixed set of choices, for a dropdown rather than a free field |
|
|
45
45
|
|
|
46
|
-
Unknown attributes are **not** rejected here
|
|
46
|
+
Unknown attributes are **not** rejected here - a param block is metadata, and anything in it
|
|
47
47
|
is passed through to the descriptor. This is the one block in the language that does not
|
|
48
48
|
reject attributes it does not understand.
|
|
49
49
|
|
|
@@ -55,13 +55,13 @@ Nothing. A param binds a name; it produces no geometry.
|
|
|
55
55
|
|
|
56
56
|
- **`min`, `max`, `step` and `options` are not enforced.** They shape the editor's control
|
|
57
57
|
and nothing else. `render(source, { params: { bolts: 9999 } })` succeeds on a param
|
|
58
|
-
declared `max = 16`. Validate in the model if a bound matters
|
|
58
|
+
declared `max = 16`. Validate in the model if a bound matters -
|
|
59
59
|
`local n = min(max(var.bolts, 3), 16)`.
|
|
60
60
|
- A param block may contain **attributes only**. Nested blocks inside it are an error:
|
|
61
61
|
`a param block holds attributes, not nested blocks`.
|
|
62
62
|
- Declaring the same param twice is an error: `param "a" is declared twice`.
|
|
63
63
|
- A param's `default` may refer to params declared **above** it by their bare name, but not
|
|
64
|
-
to `var`
|
|
64
|
+
to `var` - `var` is assembled after every param has resolved. See
|
|
65
65
|
[Scope](../language/scope.md#the-root-scope).
|
|
66
66
|
- A param declared inside a `model` is a different thing: it must have a default and cannot
|
|
67
67
|
be set from outside. See [`model`](model.md#model-params).
|
|
@@ -124,7 +124,7 @@ When `type` is omitted it is inferred from the default: a number gives `number`,
|
|
|
124
124
|
`bool`, a string `string`, a list `vector`. A param with neither a `type` nor a `default`
|
|
125
125
|
falls back to `number`.
|
|
126
126
|
|
|
127
|
-
An `angle` param is an ordinary number as far as the language is concerned
|
|
127
|
+
An `angle` param is an ordinary number as far as the language is concerned - every angle in
|
|
128
128
|
forma is in degrees, and the type only tells the editor to label the control that way.
|
|
129
129
|
|
|
130
130
|
### Declaring a required input
|
|
@@ -155,7 +155,7 @@ param bore = diameter / 2 - wall * 4 // ✓ bare names of earlier params
|
|
|
155
155
|
```
|
|
156
156
|
|
|
157
157
|
For a value that is always derived and should never be a control, use a
|
|
158
|
-
[`local`](local.md) instead
|
|
158
|
+
[`local`](local.md) instead - locals are computed after every param and may use `var.`.
|
|
159
159
|
|
|
160
160
|
### Offering a fixed set of choices
|
|
161
161
|
|
|
@@ -191,7 +191,7 @@ give it a default, or supply one:
|
|
|
191
191
|
await render(source, { params: { height: 20 } });
|
|
192
192
|
```
|
|
193
193
|
|
|
194
|
-
[`describeParameters`](../api/describe-parameters.md) works on such a document
|
|
194
|
+
[`describeParameters`](../api/describe-parameters.md) works on such a document - it is built
|
|
195
195
|
to be callable before any value exists, so a front end can discover what to ask for.
|
|
196
196
|
|
|
197
197
|
### `param "a" is declared twice`
|
|
@@ -201,7 +201,7 @@ overwritten, because a duplicated input would make the editor's control ambiguou
|
|
|
201
201
|
|
|
202
202
|
### `a param block holds attributes, not nested blocks`
|
|
203
203
|
|
|
204
|
-
Something inside the braces was parsed as a block rather than an attribute
|
|
204
|
+
Something inside the braces was parsed as a block rather than an attribute - usually a
|
|
205
205
|
missing `=`:
|
|
206
206
|
|
|
207
207
|
```hcl
|
|
@@ -19,7 +19,7 @@ Groups geometry into one named, coloured piece of the scene. Parts are solved in
|
|
|
19
19
|
and drawn in their own colour.
|
|
20
20
|
|
|
21
21
|
A part is **not an operand**. It does not contribute geometry to the block around it, and an
|
|
22
|
-
enclosing `translate` will not move it
|
|
22
|
+
enclosing `translate` will not move it - which is why a part belongs directly in a
|
|
23
23
|
[`model`](model.md), or inside a `for` or `if` in one.
|
|
24
24
|
|
|
25
25
|
#### Label
|
|
@@ -57,7 +57,7 @@ Nothing, to the enclosing block. The part travels separately and lands in the sc
|
|
|
57
57
|
- **A part cannot come out of a [`component`](component.md)**:
|
|
58
58
|
`a component cannot declare parts`. Call the component inside a part instead.
|
|
59
59
|
- **Every part must be 3D** by the time it renders:
|
|
60
|
-
`part "body" is 2D
|
|
60
|
+
`part "body" is 2D - extrude or revolve it before rendering`.
|
|
61
61
|
- Several blocks inside a part are implicitly unioned, exactly as anywhere else.
|
|
62
62
|
- Nothing rejects two parts with the same name; the viewer will simply list two entries
|
|
63
63
|
called the same thing.
|
|
@@ -121,7 +121,7 @@ if var.show_label {
|
|
|
121
121
|
part "label" { color = "#f4f1e4" label_band { } }
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
// ✗
|
|
124
|
+
// ✗ - when show_label is false this is an empty part, which is an error
|
|
125
125
|
part "label" {
|
|
126
126
|
if var.show_label { label_band { } }
|
|
127
127
|
}
|
|
@@ -159,13 +159,13 @@ for (const part of result.parts) {
|
|
|
159
159
|
part.name; // "bottle"
|
|
160
160
|
part.color; // "#8fd3e8"
|
|
161
161
|
part.opacity; // 1
|
|
162
|
-
part.node; // the GeometryNode
|
|
162
|
+
part.node; // the GeometryNode - what context.collect() wants
|
|
163
163
|
part.concrete; // the solved Manifold solid, owned by the context
|
|
164
164
|
part.mesh; // positions and normals, ready to upload
|
|
165
165
|
}
|
|
166
166
|
```
|
|
167
167
|
|
|
168
|
-
Parts are solved independently, so two parts that share a subtree still solve it once
|
|
168
|
+
Parts are solved independently, so two parts that share a subtree still solve it once - the
|
|
169
169
|
digest cache is keyed on content, not on which part asked.
|
|
170
170
|
|
|
171
171
|
To export one part, pass its `concrete` to [`toBinarySTL`](../api/export.md#tobinarystl).
|
|
@@ -176,7 +176,7 @@ To export one part, pass its `concrete` to [`toBinarySTL`](../api/export.md#tobi
|
|
|
176
176
|
|
|
177
177
|
### `a part needs at least one shape inside it`
|
|
178
178
|
|
|
179
|
-
The part's body produced nothing
|
|
179
|
+
The part's body produced nothing - usually an `if` inside it that took no branch, or a `for`
|
|
180
180
|
over an empty list. Move the condition outside the part.
|
|
181
181
|
|
|
182
182
|
### `a part cannot contain another part`
|
|
@@ -194,9 +194,9 @@ component "shell" { ... } // geometry only
|
|
|
194
194
|
model "m" { part "shell" { shell { } } } // the part lives here
|
|
195
195
|
```
|
|
196
196
|
|
|
197
|
-
### `part "body" is 2D
|
|
197
|
+
### `part "body" is 2D - extrude or revolve it before rendering`
|
|
198
198
|
|
|
199
|
-
The part holds a cross-section. Extrude or revolve it first
|
|
199
|
+
The part holds a cross-section. Extrude or revolve it first - see
|
|
200
200
|
[2D ↔ 3D](conversions.md).
|
|
201
201
|
|
|
202
202
|
### A part inside an operation disappears
|
|
@@ -208,7 +208,7 @@ depends on whether the operation had anything else to work with:
|
|
|
208
208
|
// ✗ fails: "translate" needs at least one shape inside it
|
|
209
209
|
translate { offset = [0, 0, 10] part "p" { box { size = [1, 1, 1] } } }
|
|
210
210
|
|
|
211
|
-
// ✗ worse
|
|
211
|
+
// ✗ worse - renders, but part "p" is silently gone from the scene
|
|
212
212
|
translate {
|
|
213
213
|
offset = [0, 0, 10]
|
|
214
214
|
box { size = [1, 1, 1] }
|
|
@@ -220,10 +220,10 @@ part "p" { translate { offset = [0, 0, 10] box { size = [1, 1, 1] } } }
|
|
|
220
220
|
```
|
|
221
221
|
|
|
222
222
|
Nothing warns about the second case. If a part you declared is missing from the render,
|
|
223
|
-
check that it is written directly in the [`model`](model.md)
|
|
224
|
-
one
|
|
223
|
+
check that it is written directly in the [`model`](model.md) - or inside a `for` or `if` in
|
|
224
|
+
one - and not nested inside a transform or a boolean.
|
|
225
225
|
|
|
226
226
|
### Two parts have the same name
|
|
227
227
|
|
|
228
228
|
Nothing rejects it. Part names come from an expression, so a loop that computes the same
|
|
229
|
-
label twice produces duplicates
|
|
229
|
+
label twice produces duplicates - include the loop index: `part "leg_${i}"`.
|
|
@@ -37,14 +37,14 @@ offset { amount = -1.5 join = "Miter" rect { size = [40, 20] } }
|
|
|
37
37
|
- **2D only.** `"offset" takes 2D geometry, got 3D`. There is no 3D shell operation; build
|
|
38
38
|
one as a `difference` of two profiles, or offset the profile before extruding.
|
|
39
39
|
- A negative amount larger than the shape's half-width erases it, leaving empty geometry.
|
|
40
|
-
- This is the operation [`rounded_rect`](shapes-2d.md#rounded_rect) is built from
|
|
40
|
+
- This is the operation [`rounded_rect`](shapes-2d.md#rounded_rect) is built from - a
|
|
41
41
|
shrunken rectangle offset back out is what makes its corners true arcs.
|
|
42
42
|
|
|
43
43
|
---
|
|
44
44
|
|
|
45
45
|
## `hull`
|
|
46
46
|
|
|
47
|
-
The convex hull of everything inside
|
|
47
|
+
The convex hull of everything inside - the shape a rubber sheet would take around it.
|
|
48
48
|
|
|
49
49
|
```hcl
|
|
50
50
|
hull {
|
|
@@ -61,7 +61,7 @@ None.
|
|
|
61
61
|
#### Caveats
|
|
62
62
|
|
|
63
63
|
- Works in 2D and 3D, passing the dimensionality through.
|
|
64
|
-
- Children are unioned first, so the hull is of everything together
|
|
64
|
+
- Children are unioned first, so the hull is of everything together - which is the point.
|
|
65
65
|
- Any concavity is filled in. A hull of a C-shape is a solid blob.
|
|
66
66
|
|
|
67
67
|
---
|
|
@@ -85,7 +85,7 @@ refine { edge_length = 1 sphere { radius = 20 } }
|
|
|
85
85
|
- 3D only.
|
|
86
86
|
- Triangle count grows quadratically as the limit falls. `edge_length = 0.1` on anything
|
|
87
87
|
large will cost seconds and hundreds of megabytes.
|
|
88
|
-
- Refining does not change the shape
|
|
88
|
+
- Refining does not change the shape - it only adds vertices, usually so that
|
|
89
89
|
[`smooth`](#smooth) or a downstream deformation has something to work with.
|
|
90
90
|
|
|
91
91
|
---
|
|
@@ -133,7 +133,7 @@ smooth { min_sharp_angle = 40 refine { edge_length = 1 blocky_thing { } } }
|
|
|
133
133
|
- 3D only.
|
|
134
134
|
- **Smoothing needs vertices to work with.** On a cube there is nothing between the corners
|
|
135
135
|
to move, so the result is barely different. Pair it with [`refine`](#refine).
|
|
136
|
-
- This is a mesh operation, not a fillet. For a controlled radius, model the fillet
|
|
136
|
+
- This is a mesh operation, not a fillet. For a controlled radius, model the fillet - round
|
|
137
137
|
the profile, or union in a [`torus`](shapes-3d.md#torus).
|
|
138
138
|
|
|
139
139
|
---
|
|
@@ -196,7 +196,7 @@ difference {
|
|
|
196
196
|
|
|
197
197
|
### Organic shapes from a hull
|
|
198
198
|
|
|
199
|
-
A hull of a few spheres is the quickest route to a smooth, blobby form
|
|
199
|
+
A hull of a few spheres is the quickest route to a smooth, blobby form - a handle, a fillet
|
|
200
200
|
between two bosses, a rounded enclosure:
|
|
201
201
|
|
|
202
202
|
```hcl
|
|
@@ -216,7 +216,7 @@ component "rounded_enclosure" {
|
|
|
216
216
|
}
|
|
217
217
|
```
|
|
218
218
|
|
|
219
|
-
Eight spheres, but one sphere node
|
|
219
|
+
Eight spheres, but one sphere node - content identity means the kernel builds the sphere
|
|
220
220
|
once and the hull sees eight transforms of it.
|
|
221
221
|
|
|
222
222
|
### Flat cuts
|
|
@@ -232,7 +232,7 @@ For a half-model view, that is one operation instead of an intersection with a b
|
|
|
232
232
|
|
|
233
233
|
### Refine, then smooth
|
|
234
234
|
|
|
235
|
-
The two go together
|
|
235
|
+
The two go together - smoothing has nothing to move until the mesh is dense enough:
|
|
236
236
|
|
|
237
237
|
```hcl
|
|
238
238
|
smooth {
|
|
@@ -249,7 +249,7 @@ Watch the triangle count; this is the most expensive pair of operations in the l
|
|
|
249
249
|
|
|
250
250
|
### `"offset" takes 2D geometry, got 3D`
|
|
251
251
|
|
|
252
|
-
`offset` works on outlines. To grow a solid, project it, offset the outline and re-extrude
|
|
252
|
+
`offset` works on outlines. To grow a solid, project it, offset the outline and re-extrude -
|
|
253
253
|
or offset the profile before it was extruded in the first place.
|
|
254
254
|
|
|
255
255
|
### `offset: "amount" must be a finite number`
|
|
@@ -259,7 +259,7 @@ or offset the profile before it was extruded in the first place.
|
|
|
259
259
|
### My `smooth` did nothing
|
|
260
260
|
|
|
261
261
|
The mesh has no vertices to move. Refine first, and check that `min_sharp_angle` is above the
|
|
262
|
-
angle of the edges you want rounded
|
|
262
|
+
angle of the edges you want rounded - the default of `60` leaves every edge on a cube alone.
|
|
263
263
|
|
|
264
264
|
### `refine` hung the browser
|
|
265
265
|
|
|
@@ -5,7 +5,7 @@ blocks.
|
|
|
5
5
|
|
|
6
6
|
**2D shapes cannot be rendered on their own.** Give them thickness with
|
|
7
7
|
[`extrude`](conversions.md#extrude) or [`revolve`](conversions.md#revolve) first, or a part
|
|
8
|
-
holding one fails with `part "body" is 2D
|
|
8
|
+
holding one fails with `part "body" is 2D - extrude or revolve it before rendering`.
|
|
9
9
|
|
|
10
10
|
| Block | Sized by | Centred by default |
|
|
11
11
|
| --- | --- | --- |
|
|
@@ -20,7 +20,7 @@ holding one fails with `part "body" is 2D — extrude or revolve it before rende
|
|
|
20
20
|
### A note on `segments`
|
|
21
21
|
|
|
22
22
|
Several shapes take `segments`, the number of straight edges used to approximate a curve.
|
|
23
|
-
`0`
|
|
23
|
+
`0` - the default - means *let the kernel decide* from its global quality settings, which
|
|
24
24
|
[`setQuality`](../api/kernel.md#setquality) controls. Set it explicitly when a specific facet
|
|
25
25
|
count matters: a hole that must clear a printed bolt, or a preview that must stay cheap.
|
|
26
26
|
|
|
@@ -83,7 +83,7 @@ circle { diameter = 24 segments = 64 }
|
|
|
83
83
|
| Attribute | Type | Default | Description |
|
|
84
84
|
| --- | --- | --- | --- |
|
|
85
85
|
| `radius` | number | `1` | |
|
|
86
|
-
| `diameter` | number |
|
|
86
|
+
| `diameter` | number | - | An alternative spelling of the same thing |
|
|
87
87
|
| `segments` | integer | `0` | Segments around the circle; `0` lets the kernel choose |
|
|
88
88
|
|
|
89
89
|
#### Caveats
|
|
@@ -114,7 +114,7 @@ ellipse { radii = [30, 18] }
|
|
|
114
114
|
|
|
115
115
|
- Implemented as a scaled unit circle, so both radii stay exact rather than being
|
|
116
116
|
approximated by a polygon fitted to an ellipse.
|
|
117
|
-
- Always centred. There is no `center` attribute
|
|
117
|
+
- Always centred. There is no `center` attribute - passing one is
|
|
118
118
|
`ellipse: unknown attribute "center"`.
|
|
119
119
|
|
|
120
120
|
---
|
|
@@ -133,16 +133,16 @@ regular_polygon { sides = 8 radius = 20 rotation = 22.5 }
|
|
|
133
133
|
| Attribute | Type | Default | Description |
|
|
134
134
|
| --- | --- | --- | --- |
|
|
135
135
|
| `sides` | integer | **required** | At least 3 |
|
|
136
|
-
| `width_across_flats` | number |
|
|
137
|
-
| `width_across_corners` | number |
|
|
136
|
+
| `width_across_flats` | number | - | Distance between opposite flats - how a hex key or a nut is specified |
|
|
137
|
+
| `width_across_corners` | number | - | Distance between opposite corners |
|
|
138
138
|
| `radius` | number | `1` | Centre to corner. Same as half the across-corners width |
|
|
139
|
-
| `diameter` | number |
|
|
139
|
+
| `diameter` | number | - | Twice the radius |
|
|
140
140
|
| `rotation` | angle | `0` | Where the first corner sits, in degrees |
|
|
141
141
|
|
|
142
142
|
#### Caveats
|
|
143
143
|
|
|
144
144
|
- Give **one** sizing attribute. They are tried in the order above, so
|
|
145
|
-
`width_across_flats` wins if several are present
|
|
145
|
+
`width_across_flats` wins if several are present - do not rely on that; pass one.
|
|
146
146
|
- `radius` and `diameter` together are an error, as on [`circle`](#circle).
|
|
147
147
|
- Fewer than 3 sides is an error: `regular_polygon: "sides" must be at least 3`.
|
|
148
148
|
- Always centred on the origin.
|
|
@@ -153,7 +153,7 @@ regular_polygon { sides = 8 radius = 20 rotation = 22.5 }
|
|
|
153
153
|
|
|
154
154
|
## `stadium`
|
|
155
155
|
|
|
156
|
-
A rectangle fully rounded on its short axis
|
|
156
|
+
A rectangle fully rounded on its short axis - the shape of a slot.
|
|
157
157
|
|
|
158
158
|
```hcl
|
|
159
159
|
stadium { size = [40, 8] center = true }
|
|
@@ -203,7 +203,7 @@ polygon {
|
|
|
203
203
|
without a separate `difference`.
|
|
204
204
|
- The outline should not self-intersect. The fill rule decides what happens when it does,
|
|
205
205
|
rather than the shape being rejected.
|
|
206
|
-
- Points are not closed for you
|
|
206
|
+
- Points are not closed for you - the last point connects back to the first automatically, so
|
|
207
207
|
do not repeat it.
|
|
208
208
|
|
|
209
209
|
---
|
|
@@ -226,7 +226,7 @@ model "vase" {
|
|
|
226
226
|
}
|
|
227
227
|
```
|
|
228
228
|
|
|
229
|
-
Every X must be ≥ 0
|
|
229
|
+
Every X must be ≥ 0 - a profile that crosses the axis revolves through itself.
|
|
230
230
|
|
|
231
231
|
### Slots and keyways
|
|
232
232
|
|
|
@@ -255,7 +255,7 @@ for i, size in [1.5, 2, 2.5, 3, 4, 5, 6] {
|
|
|
255
255
|
}
|
|
256
256
|
```
|
|
257
257
|
|
|
258
|
-
The `+ 0.3` is print clearance
|
|
258
|
+
The `+ 0.3` is print clearance - the language has no opinion about fits, so the model states
|
|
259
259
|
them.
|
|
260
260
|
|
|
261
261
|
### Holes without a boolean
|
|
@@ -276,7 +276,7 @@ polygon {
|
|
|
276
276
|
|
|
277
277
|
## Troubleshooting
|
|
278
278
|
|
|
279
|
-
### `part "body" is 2D
|
|
279
|
+
### `part "body" is 2D - extrude or revolve it before rendering`
|
|
280
280
|
|
|
281
281
|
A 2D shape reached the renderer. Wrap it:
|
|
282
282
|
|
|
@@ -286,7 +286,7 @@ extrude { height = 4 circle { radius = 10 } }
|
|
|
286
286
|
|
|
287
287
|
### `"circle" is a shape and cannot contain other blocks`
|
|
288
288
|
|
|
289
|
-
A shape is a leaf. Something was nested inside its braces
|
|
289
|
+
A shape is a leaf. Something was nested inside its braces - usually a missing `}` on the
|
|
290
290
|
line before, so the next block was swallowed.
|
|
291
291
|
|
|
292
292
|
### `circle: give either "radius" or "diameter", not both`
|
|
@@ -305,5 +305,5 @@ shorter side. Check that it is set and that the shape is big enough to show it.
|
|
|
305
305
|
|
|
306
306
|
### My hexagon is rotated 30° from what I wanted
|
|
307
307
|
|
|
308
|
-
`rotation = 0` puts a **corner** on +X. For a flat on +X, use `rotation = 30`
|
|
308
|
+
`rotation = 0` puts a **corner** on +X. For a flat on +X, use `rotation = 30` - or in general
|
|
309
309
|
`180 / sides`.
|