Compare commits
24 Commits
franknoiro
...
maxammann/
| Author | SHA1 | Date | |
|---|---|---|---|
| 8b20f898fe | |||
| d7c5c3cf9d | |||
| 270781d5cd | |||
| 96b93f8d51 | |||
| 59b1c414f0 | |||
| fd07b8cff5 | |||
| 21efb2c0bd | |||
| 30029a63a1 | |||
| 9f5003cafc | |||
| 5232e1d40a | |||
| 23c25c2b50 | |||
| 50273c0edc | |||
| 8a03bf50e3 | |||
| 7500ef0065 | |||
| 099c48cd63 | |||
| f35cd3ef26 | |||
| 695c432d1e | |||
| 2835665a6a | |||
| 45707d2974 | |||
| b2e1d21d45 | |||
| b98f5605b6 | |||
| c050e03df1 | |||
| b6fa4325f0 | |||
| 0804aecc63 |
13
.gitattributes
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
# Set default behavior to automatically normalize line endings.
|
||||
* text=auto
|
||||
|
||||
# Force batch scripts to always use CRLF line endings so that if a repo is accessed
|
||||
# in Windows via a file share from Linux, the scripts will work.
|
||||
*.{cmd,[cC][mM][dD]} text working-tree-encoding=UTF-16LE eol=CRLF
|
||||
*.{bat,[bB][aA][tT]} text working-tree-encoding=UTF-16LE eol=CRLF
|
||||
*.{ics,[iI][cC][sS]} text working-tree-encoding=UTF-16LE eol=CRLF
|
||||
*.{ps1,[iP][sS][1]} text working-tree-encoding=UTF-16LE eol=CRLF
|
||||
|
||||
# Force bash scripts to always use LF line endings so that if a repo is accessed
|
||||
# in Unix via a file share from Windows, the scripts will work.
|
||||
*.sh text eol=lfol=lf
|
||||
3
.gitignore
vendored
@ -41,9 +41,12 @@ e2e/playwright/playwright-secrets.env
|
||||
e2e/playwright/temp1.png
|
||||
e2e/playwright/temp2.png
|
||||
e2e/playwright/temp3.png
|
||||
# this will be overridden for specific directories
|
||||
e2e/playwright/**/*.png
|
||||
# exports from snapshot-tests.spec.ts "exports of each format should work"
|
||||
e2e/playwright/export-snapshots/*
|
||||
!e2e/playwright/export-snapshots/*.png
|
||||
!e2e/playwright/snapshot-tests.spec.ts-snapshots/*.png
|
||||
|
||||
/kcl-samples
|
||||
/test-results/
|
||||
|
||||
15
docs/kcl/HALF_TURN.md
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
title: "HALF_TURN"
|
||||
excerpt: ""
|
||||
layout: manual
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
```js
|
||||
HALF_TURN: number(deg) = 180deg
|
||||
```
|
||||
|
||||
|
||||
15
docs/kcl/QUARTER_TURN.md
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
title: "QUARTER_TURN"
|
||||
excerpt: ""
|
||||
layout: manual
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
```js
|
||||
QUARTER_TURN: number(deg) = 90deg
|
||||
```
|
||||
|
||||
|
||||
15
docs/kcl/THREE_QUARTER_TURN.md
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
title: "THREE_QUARTER_TURN"
|
||||
excerpt: ""
|
||||
layout: manual
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
```js
|
||||
THREE_QUARTER_TURN: number(deg) = 270deg
|
||||
```
|
||||
|
||||
|
||||
15
docs/kcl/ZERO.md
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
title: "ZERO"
|
||||
excerpt: ""
|
||||
layout: manual
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
```js
|
||||
ZERO: number = 0
|
||||
```
|
||||
|
||||
|
||||
@ -18,12 +18,12 @@ chamfer(data: ChamferData, solid: Solid, tag?: TagDeclarator) -> Solid
|
||||
| Name | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `data` | [`ChamferData`](/docs/kcl/types/ChamferData) | Data for chamfers. | Yes |
|
||||
| `solid` | [`Solid`](/docs/kcl/types/Solid) | An solid is a collection of extrude surfaces. | Yes |
|
||||
| `solid` | [`Solid`](/docs/kcl/types/Solid) | A solid is a collection of extrude surfaces. | Yes |
|
||||
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
||||
|
||||
### Returns
|
||||
|
||||
[`Solid`](/docs/kcl/types/Solid) - An solid is a collection of extrude surfaces.
|
||||
[`Solid`](/docs/kcl/types/Solid) - A solid is a collection of extrude surfaces.
|
||||
|
||||
|
||||
### Examples
|
||||
|
||||
32
docs/kcl/const_E.md
Normal file
15
docs/kcl/const_HALF_TURN.md
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
title: "HALF_TURN"
|
||||
excerpt: ""
|
||||
layout: manual
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
```js
|
||||
HALF_TURN: number(deg) = 180deg
|
||||
```
|
||||
|
||||
|
||||
28
docs/kcl/const_PI.md
Normal file
15
docs/kcl/const_QUARTER_TURN.md
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
title: "QUARTER_TURN"
|
||||
excerpt: ""
|
||||
layout: manual
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
```js
|
||||
QUARTER_TURN: number(deg) = 90deg
|
||||
```
|
||||
|
||||
|
||||
32
docs/kcl/const_TAU.md
Normal file
15
docs/kcl/const_THREE_QUARTER_TURN.md
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
title: "THREE_QUARTER_TURN"
|
||||
excerpt: ""
|
||||
layout: manual
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
```js
|
||||
THREE_QUARTER_TURN: number(deg) = 270deg
|
||||
```
|
||||
|
||||
|
||||
15
docs/kcl/const_ZERO.md
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
title: "ZERO"
|
||||
excerpt: ""
|
||||
layout: manual
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
```js
|
||||
ZERO: number = 0
|
||||
```
|
||||
|
||||
|
||||
32
docs/kcl/const_const_std-math-E.md
Normal file
28
docs/kcl/const_const_std-math-PI.md
Normal file
32
docs/kcl/const_const_std-math-TAU.md
Normal file
15
docs/kcl/const_const_std-prelude-HALF_TURN.md
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
title: "std::prelude::HALF_TURN"
|
||||
excerpt: ""
|
||||
layout: manual
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
```js
|
||||
std::prelude::HALF_TURN: number(deg) = 180deg
|
||||
```
|
||||
|
||||
|
||||
15
docs/kcl/const_const_std-prelude-QUARTER_TURN.md
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
title: "std::prelude::QUARTER_TURN"
|
||||
excerpt: ""
|
||||
layout: manual
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
```js
|
||||
std::prelude::QUARTER_TURN: number(deg) = 90deg
|
||||
```
|
||||
|
||||
|
||||
15
docs/kcl/const_const_std-prelude-THREE_QUARTER_TURN.md
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
title: "std::prelude::THREE_QUARTER_TURN"
|
||||
excerpt: ""
|
||||
layout: manual
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
```js
|
||||
std::prelude::THREE_QUARTER_TURN: number(deg) = 270deg
|
||||
```
|
||||
|
||||
|
||||
15
docs/kcl/const_const_std-prelude-ZERO.md
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
title: "std::prelude::ZERO"
|
||||
excerpt: ""
|
||||
layout: manual
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
```js
|
||||
std::prelude::ZERO: number = 0
|
||||
```
|
||||
|
||||
|
||||
@ -4,9 +4,11 @@ excerpt: "Return the value of Euler’s number `e`."
|
||||
layout: manual
|
||||
---
|
||||
|
||||
**WARNING:** This function is deprecated.
|
||||
|
||||
Return the value of Euler’s number `e`.
|
||||
|
||||
|
||||
**DEPRECATED** use the constant E
|
||||
|
||||
```js
|
||||
e() -> number
|
||||
|
||||
@ -18,12 +18,12 @@ fillet(data: FilletData, solid: Solid, tag?: TagDeclarator) -> Solid
|
||||
| Name | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `data` | [`FilletData`](/docs/kcl/types/FilletData) | Data for fillets. | Yes |
|
||||
| `solid` | [`Solid`](/docs/kcl/types/Solid) | An solid is a collection of extrude surfaces. | Yes |
|
||||
| `solid` | [`Solid`](/docs/kcl/types/Solid) | A solid is a collection of extrude surfaces. | Yes |
|
||||
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
||||
|
||||
### Returns
|
||||
|
||||
[`Solid`](/docs/kcl/types/Solid) - An solid is a collection of extrude surfaces.
|
||||
[`Solid`](/docs/kcl/types/Solid) - A solid is a collection of extrude surfaces.
|
||||
|
||||
|
||||
### Examples
|
||||
|
||||
@ -18,11 +18,11 @@ helixRevolutions(data: HelixRevolutionsData, solid: Solid) -> Solid
|
||||
| Name | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `data` | [`HelixRevolutionsData`](/docs/kcl/types/HelixRevolutionsData) | Data for helix revolutions. | Yes |
|
||||
| `solid` | [`Solid`](/docs/kcl/types/Solid) | An solid is a collection of extrude surfaces. | Yes |
|
||||
| `solid` | [`Solid`](/docs/kcl/types/Solid) | A solid is a collection of extrude surfaces. | Yes |
|
||||
|
||||
### Returns
|
||||
|
||||
[`Solid`](/docs/kcl/types/Solid) - An solid is a collection of extrude surfaces.
|
||||
[`Solid`](/docs/kcl/types/Solid) - A solid is a collection of extrude surfaces.
|
||||
|
||||
|
||||
### Examples
|
||||
|
||||
@ -18,11 +18,11 @@ hollow(thickness: number, solid: Solid) -> Solid
|
||||
| Name | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `thickness` | `number` | | Yes |
|
||||
| `solid` | [`Solid`](/docs/kcl/types/Solid) | An solid is a collection of extrude surfaces. | Yes |
|
||||
| `solid` | [`Solid`](/docs/kcl/types/Solid) | A solid is a collection of extrude surfaces. | Yes |
|
||||
|
||||
### Returns
|
||||
|
||||
[`Solid`](/docs/kcl/types/Solid) - An solid is a collection of extrude surfaces.
|
||||
[`Solid`](/docs/kcl/types/Solid) - A solid is a collection of extrude surfaces.
|
||||
|
||||
|
||||
### Examples
|
||||
|
||||
@ -9,6 +9,7 @@ layout: manual
|
||||
* [Types](kcl/types)
|
||||
* [Modules](kcl/modules)
|
||||
* [Known Issues](kcl/KNOWN-ISSUES)
|
||||
* **`std`**
|
||||
* [`abs`](kcl/abs)
|
||||
* [`acos`](kcl/acos)
|
||||
* [`angleToMatchLengthX`](kcl/angleToMatchLengthX)
|
||||
@ -38,8 +39,6 @@ layout: manual
|
||||
* [`circleThreePoint`](kcl/circleThreePoint)
|
||||
* [`close`](kcl/close)
|
||||
* [`cm`](kcl/cm)
|
||||
* [`cos`](kcl/cos)
|
||||
* [`e`](kcl/e)
|
||||
* [`extrude`](kcl/extrude)
|
||||
* [`fillet`](kcl/fillet)
|
||||
* [`floor`](kcl/floor)
|
||||
@ -76,7 +75,6 @@ layout: manual
|
||||
* [`patternLinear3d`](kcl/patternLinear3d)
|
||||
* [`patternTransform`](kcl/patternTransform)
|
||||
* [`patternTransform2d`](kcl/patternTransform2d)
|
||||
* [`pi`](kcl/pi)
|
||||
* [`polar`](kcl/polar)
|
||||
* [`polygon`](kcl/polygon)
|
||||
* [`pop`](kcl/pop)
|
||||
@ -98,17 +96,14 @@ layout: manual
|
||||
* [`segStartX`](kcl/segStartX)
|
||||
* [`segStartY`](kcl/segStartY)
|
||||
* [`shell`](kcl/shell)
|
||||
* [`sin`](kcl/sin)
|
||||
* [`sqrt`](kcl/sqrt)
|
||||
* [`startProfileAt`](kcl/startProfileAt)
|
||||
* [`startSketchOn`](kcl/startSketchOn)
|
||||
* [`sweep`](kcl/sweep)
|
||||
* [`tan`](kcl/tan)
|
||||
* [`tangentToEnd`](kcl/tangentToEnd)
|
||||
* [`tangentialArc`](kcl/tangentialArc)
|
||||
* [`tangentialArcTo`](kcl/tangentialArcTo)
|
||||
* [`tangentialArcToRelative`](kcl/tangentialArcToRelative)
|
||||
* [`tau`](kcl/tau)
|
||||
* [`toDegrees`](kcl/toDegrees)
|
||||
* [`toRadians`](kcl/toRadians)
|
||||
* [`xLine`](kcl/xLine)
|
||||
@ -116,3 +111,15 @@ layout: manual
|
||||
* [`yLine`](kcl/yLine)
|
||||
* [`yLineTo`](kcl/yLineTo)
|
||||
* [`yd`](kcl/yd)
|
||||
* **`std::math`**
|
||||
* [`E`](kcl/const_std-math-E)
|
||||
* [`PI`](kcl/const_std-math-PI)
|
||||
* [`TAU`](kcl/const_std-math-TAU)
|
||||
* [`cos`](kcl/std-math-cos)
|
||||
* [`sin`](kcl/std-math-sin)
|
||||
* [`tan`](kcl/std-math-tan)
|
||||
* **`std::prelude`**
|
||||
* [`HALF_TURN`](kcl/const_std-prelude-HALF_TURN)
|
||||
* [`QUARTER_TURN`](kcl/const_std-prelude-QUARTER_TURN)
|
||||
* [`THREE_QUARTER_TURN`](kcl/const_std-prelude-THREE_QUARTER_TURN)
|
||||
* [`ZERO`](kcl/const_std-prelude-ZERO)
|
||||
|
||||
@ -25,7 +25,7 @@ loft(sketches: [Sketch], v_degree: NonZeroU32, bez_approximate_rational: bool, b
|
||||
|
||||
### Returns
|
||||
|
||||
[`Solid`](/docs/kcl/types/Solid) - An solid is a collection of extrude surfaces.
|
||||
[`Solid`](/docs/kcl/types/Solid) - A solid is a collection of extrude surfaces.
|
||||
|
||||
|
||||
### Examples
|
||||
|
||||
@ -9,7 +9,7 @@ Offset a plane by a distance along its normal.
|
||||
For example, if you offset the 'XZ' plane by 10, the new plane will be parallel to the 'XZ' plane and 10 units away from it.
|
||||
|
||||
```js
|
||||
offsetPlane(std_plane: StandardPlane, offset: number) -> Plane
|
||||
offsetPlane(plane: PlaneData, offset: number) -> Plane
|
||||
```
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ offsetPlane(std_plane: StandardPlane, offset: number) -> Plane
|
||||
|
||||
| Name | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `std_plane` | [`StandardPlane`](/docs/kcl/types/StandardPlane) | Which standard plane (e.g. XY) should this new plane be created from? | Yes |
|
||||
| `plane` | [`PlaneData`](/docs/kcl/types/PlaneData) | The plane (e.g. 'XY') which this new plane is created from. | Yes |
|
||||
| `offset` | `number` | Distance from the standard plane this new plane will be created at. | Yes |
|
||||
|
||||
### Returns
|
||||
|
||||
@ -4,9 +4,11 @@ excerpt: "Return the value of `pi`. Archimedes’ constant (π)."
|
||||
layout: manual
|
||||
---
|
||||
|
||||
**WARNING:** This function is deprecated.
|
||||
|
||||
Return the value of `pi`. Archimedes’ constant (π).
|
||||
|
||||
|
||||
**DEPRECATED** use the constant PI
|
||||
|
||||
```js
|
||||
pi() -> number
|
||||
|
||||
@ -76,7 +76,7 @@ assertEqual(sum, 6, 0.00001, "1 + 2 + 3 summed is 6")
|
||||
// Declare a function that sketches a decagon.
|
||||
fn decagon(radius) {
|
||||
// Each side of the decagon is turned this many degrees from the previous angle.
|
||||
stepAngle = 1 / 10 * tau()
|
||||
stepAngle = 1 / 10 * TAU
|
||||
|
||||
// Start the decagon sketch at this point.
|
||||
startOfDecagonSketch = startSketchOn('XY')
|
||||
@ -97,7 +97,7 @@ fn decagon(radius) {
|
||||
|
||||
/* The `decagon` above is basically like this pseudo-code:
|
||||
fn decagon(radius):
|
||||
stepAngle = (1/10) * tau()
|
||||
stepAngle = (1/10) * TAU
|
||||
plane = startSketchOn('XY')
|
||||
startOfDecagonSketch = startProfileAt([(cos(0)*radius), (sin(0) * radius)], plane)
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ revolve(data: RevolveData, sketch: Sketch) -> Solid
|
||||
|
||||
### Returns
|
||||
|
||||
[`Solid`](/docs/kcl/types/Solid) - An solid is a collection of extrude surfaces.
|
||||
[`Solid`](/docs/kcl/types/Solid) - A solid is a collection of extrude surfaces.
|
||||
|
||||
|
||||
### Examples
|
||||
|
||||
@ -6,7 +6,15 @@ layout: manual
|
||||
|
||||
Start a new 2-dimensional sketch on a specific plane or face.
|
||||
|
||||
### Sketch on Face Behavior
|
||||
|
||||
There are some important behaviors to understand when sketching on a face:
|
||||
|
||||
The resulting sketch will _include_ the face and thus Solid that was sketched on. So say you were to export the resulting Sketch / Solid from a sketch on a face, you would get both the artifact of the sketch on the face and the parent face / Solid itself.
|
||||
|
||||
This is important to understand because if you were to then sketch on the resulting Solid, it would again include the face and parent Solid that was sketched on. This could go on indefinitely.
|
||||
|
||||
The point is if you want to export the result of a sketch on a face, you only need to export the final Solid that was created from the sketch on the face, since it will include all the parent faces and Solids.
|
||||
|
||||
```js
|
||||
startSketchOn(data: SketchData, tag?: FaceTag) -> SketchSurface
|
||||
|
||||
44
docs/kcl/std-math-cos.md
Normal file
44
docs/kcl/std-math-sin.md
Normal file
44
docs/kcl/std-math-tan.md
Normal file
40267
docs/kcl/std.json
@ -24,7 +24,7 @@ sweep(sketch: Sketch, path: SweepPath, sectional?: bool, tolerance?: number) ->
|
||||
|
||||
### Returns
|
||||
|
||||
[`Solid`](/docs/kcl/types/Solid) - An solid is a collection of extrude surfaces.
|
||||
[`Solid`](/docs/kcl/types/Solid) - A solid is a collection of extrude surfaces.
|
||||
|
||||
|
||||
### Examples
|
||||
|
||||
@ -4,9 +4,11 @@ excerpt: "Return the value of `tau`. The full circle constant (τ). Equal to 2π
|
||||
layout: manual
|
||||
---
|
||||
|
||||
**WARNING:** This function is deprecated.
|
||||
|
||||
Return the value of `tau`. The full circle constant (τ). Equal to 2π.
|
||||
|
||||
|
||||
**DEPRECATED** use the constant TAU
|
||||
|
||||
```js
|
||||
tau() -> number
|
||||
|
||||
@ -18,6 +18,7 @@ A base path.
|
||||
|----------|------|-------------|----------|
|
||||
| `from` |`[number, number]`| The from point. | No |
|
||||
| `to` |`[number, number]`| The to point. | No |
|
||||
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No |
|
||||
| `tag` |[`TagDeclarator`](/docs/kcl/types#tag-declaration)| The tag of the path. | No |
|
||||
| `__geoMeta` |[`GeoMeta`](/docs/kcl/types/GeoMeta)| Metadata. | No |
|
||||
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
---
|
||||
title: "EnvironmentRef"
|
||||
excerpt: ""
|
||||
excerpt: "An index pointing to a snapshot within a specific (unspecified) environment."
|
||||
layout: manual
|
||||
---
|
||||
|
||||
An index pointing to a snapshot within a specific (unspecified) environment.
|
||||
|
||||
[`SnapshotRef`](/docs/kcl/types/SnapshotRef)
|
||||
|
||||
|
||||
@ -28,7 +28,7 @@ An extrude plane.
|
||||
| `faceId` |`string`| The face id for the extrude plane. | No |
|
||||
| `tag` |[`TagDeclarator`](/docs/kcl/types#tag-declaration)| The tag. | No |
|
||||
| `id` |`string`| The id of the geometry. | No |
|
||||
| `sourceRange` |`SourceRange`| The source range. | No |
|
||||
| `sourceRange` |[`SourceRange`](/docs/kcl/types/SourceRange)| The source range. | No |
|
||||
|
||||
|
||||
----
|
||||
@ -48,7 +48,7 @@ An extruded arc.
|
||||
| `faceId` |`string`| The face id for the extrude plane. | No |
|
||||
| `tag` |[`TagDeclarator`](/docs/kcl/types#tag-declaration)| The tag. | No |
|
||||
| `id` |`string`| The id of the geometry. | No |
|
||||
| `sourceRange` |`SourceRange`| The source range. | No |
|
||||
| `sourceRange` |[`SourceRange`](/docs/kcl/types/SourceRange)| The source range. | No |
|
||||
|
||||
|
||||
----
|
||||
@ -68,7 +68,7 @@ Geometry metadata.
|
||||
| `faceId` |`string`| The id for the chamfer surface. | No |
|
||||
| `tag` |[`TagDeclarator`](/docs/kcl/types#tag-declaration)| The tag. | No |
|
||||
| `id` |`string`| The id of the geometry. | No |
|
||||
| `sourceRange` |`SourceRange`| The source range. | No |
|
||||
| `sourceRange` |[`SourceRange`](/docs/kcl/types/SourceRange)| The source range. | No |
|
||||
|
||||
|
||||
----
|
||||
@ -88,7 +88,7 @@ Geometry metadata.
|
||||
| `faceId` |`string`| The id for the fillet surface. | No |
|
||||
| `tag` |[`TagDeclarator`](/docs/kcl/types#tag-declaration)| The tag. | No |
|
||||
| `id` |`string`| The id of the geometry. | No |
|
||||
| `sourceRange` |`SourceRange`| The source range. | No |
|
||||
| `sourceRange` |[`SourceRange`](/docs/kcl/types/SourceRange)| The source range. | No |
|
||||
|
||||
|
||||
----
|
||||
|
||||
@ -23,7 +23,7 @@ A face.
|
||||
| `yAxis` |[`Point3d`](/docs/kcl/types/Point3d)| What should the face's Y axis be? | No |
|
||||
| `zAxis` |[`Point3d`](/docs/kcl/types/Point3d)| The z-axis (normal). | No |
|
||||
| `solid` |[`Solid`](/docs/kcl/types/Solid)| The solid the face is on. | No |
|
||||
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A face. | No |
|
||||
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No |
|
||||
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| | No |
|
||||
|
||||
|
||||
|
||||
@ -11,7 +11,6 @@ A tag for a face.
|
||||
|
||||
**This schema accepts any of the following:**
|
||||
|
||||
A tag for a face.
|
||||
|
||||
[`StartOrEnd`](/docs/kcl/types/StartOrEnd)
|
||||
|
||||
|
||||
@ -17,6 +17,6 @@ Geometry metadata.
|
||||
| Property | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `id` |`string`| The id of the geometry. | No |
|
||||
| `sourceRange` |`SourceRange`| The source range. | No |
|
||||
| `sourceRange` |[`SourceRange`](/docs/kcl/types/SourceRange)| The source range. | No |
|
||||
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ A helix.
|
||||
| `revolutions` |`number`| Number of revolutions. | No |
|
||||
| `angleStart` |`number`| Start angle (in degrees). | No |
|
||||
| `ccw` |`boolean`| Is the helix rotation counter clockwise? | No |
|
||||
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A helix. | No |
|
||||
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No |
|
||||
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| | No |
|
||||
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ A helix.
|
||||
| `revolutions` |`number`| Number of revolutions. | No |
|
||||
| `angleStart` |`number`| Start angle (in degrees). | No |
|
||||
| `ccw` |`boolean`| Is the helix rotation counter clockwise? | No |
|
||||
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A helix. | No |
|
||||
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No |
|
||||
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| | No |
|
||||
|
||||
|
||||
|
||||
@ -59,7 +59,7 @@ Any KCL value.
|
||||
|----------|------|-------------|----------|
|
||||
| `type` |enum: `Number`| | No |
|
||||
| `value` |`number`| | No |
|
||||
| `ty` |[`NumericType`](/docs/kcl/types/NumericType)| Any KCL value. | No |
|
||||
| `ty` |[`NumericType`](/docs/kcl/types/NumericType)| | No |
|
||||
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| | No |
|
||||
|
||||
|
||||
@ -164,7 +164,7 @@ Any KCL value.
|
||||
| Property | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `type` |enum: [`Plane`](/docs/kcl/types/Plane)| | No |
|
||||
| `value` |[`Plane`](/docs/kcl/types/Plane)| Any KCL value. | No |
|
||||
| `value` |[`Plane`](/docs/kcl/types/Plane)| A plane. | No |
|
||||
|
||||
|
||||
----
|
||||
@ -180,7 +180,7 @@ Any KCL value.
|
||||
| Property | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `type` |enum: [`Face`](/docs/kcl/types/Face)| | No |
|
||||
| `value` |[`Face`](/docs/kcl/types/Face)| Any KCL value. | No |
|
||||
| `value` |[`Face`](/docs/kcl/types/Face)| A face. | No |
|
||||
|
||||
|
||||
----
|
||||
@ -196,7 +196,7 @@ Any KCL value.
|
||||
| Property | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `type` |enum: [`Sketch`](/docs/kcl/types/Sketch)| | No |
|
||||
| `value` |[`Sketch`](/docs/kcl/types/Sketch)| Any KCL value. | No |
|
||||
| `value` |[`Sketch`](/docs/kcl/types/Sketch)| A sketch is a collection of paths. | No |
|
||||
|
||||
|
||||
----
|
||||
@ -228,7 +228,7 @@ Any KCL value.
|
||||
| Property | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `type` |enum: [`Solid`](/docs/kcl/types/Solid)| | No |
|
||||
| `value` |[`Solid`](/docs/kcl/types/Solid)| Any KCL value. | No |
|
||||
| `value` |[`Solid`](/docs/kcl/types/Solid)| A solid is a collection of extrude surfaces. | No |
|
||||
|
||||
|
||||
----
|
||||
@ -260,7 +260,7 @@ Any KCL value.
|
||||
| Property | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `type` |enum: [`Helix`](/docs/kcl/types/Helix)| | No |
|
||||
| `value` |[`Helix`](/docs/kcl/types/Helix)| Any KCL value. | No |
|
||||
| `value` |[`Helix`](/docs/kcl/types/Helix)| A helix. | No |
|
||||
|
||||
|
||||
----
|
||||
@ -295,7 +295,7 @@ Data for an imported geometry.
|
||||
| Property | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `type` |enum: `Function`| | No |
|
||||
| `memory` |[`EnvironmentRef`](/docs/kcl/types/EnvironmentRef)| Any KCL value. | No |
|
||||
| `memory` |[`EnvironmentRef`](/docs/kcl/types/EnvironmentRef)| | No |
|
||||
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| | No |
|
||||
|
||||
|
||||
@ -312,7 +312,7 @@ Data for an imported geometry.
|
||||
| Property | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `type` |enum: `Module`| | No |
|
||||
| `value` |[`ModuleId`](/docs/kcl/types/ModuleId)| Any KCL value. | No |
|
||||
| `value` |[`ModuleId`](/docs/kcl/types/ModuleId)| Identifier of a source file. Uses a u32 to keep the size small. | No |
|
||||
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| | No |
|
||||
|
||||
|
||||
@ -329,7 +329,7 @@ Data for an imported geometry.
|
||||
| Property | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `type` |enum: [`KclNone`](/docs/kcl/types/KclNone)| | No |
|
||||
| `value` |[`KclNone`](/docs/kcl/types/KclNone)| Any KCL value. | No |
|
||||
| `value` |[`KclNone`](/docs/kcl/types/KclNone)| KCL value for an optional parameter which was not given an argument. (remember, parameters are in the function declaration, arguments are in the function call/application). | No |
|
||||
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| | No |
|
||||
|
||||
|
||||
|
||||
@ -16,6 +16,6 @@ Metadata.
|
||||
|
||||
| Property | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `sourceRange` |`SourceRange`| The source range. | No |
|
||||
| `sourceRange` |[`SourceRange`](/docs/kcl/types/SourceRange)| The source range. | No |
|
||||
|
||||
|
||||
|
||||
@ -33,6 +33,7 @@ layout: manual
|
||||
|
||||
|
||||
----
|
||||
A unit of length.
|
||||
|
||||
**Type:** `object`
|
||||
|
||||
@ -140,6 +141,7 @@ layout: manual
|
||||
|
||||
|
||||
----
|
||||
A unit of angle.
|
||||
|
||||
**Type:** `object`
|
||||
|
||||
@ -209,8 +211,8 @@ layout: manual
|
||||
| Property | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `type` |enum: `Default`| | No |
|
||||
| `len` |[`UnitLen`](/docs/kcl/types/UnitLen)| | No |
|
||||
| `angle` |[`UnitAngle`](/docs/kcl/types/UnitAngle)| | No |
|
||||
| `len` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No |
|
||||
| `angle` |[`UnitAngle`](/docs/kcl/types/UnitAngle)| A unit of angle. | No |
|
||||
|
||||
|
||||
----
|
||||
|
||||
@ -27,6 +27,7 @@ A path that goes to a point.
|
||||
| `type` |enum: `ToPoint`| | No |
|
||||
| `from` |`[number, number]`| The from point. | No |
|
||||
| `to` |`[number, number]`| The to point. | No |
|
||||
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No |
|
||||
| `tag` |[`TagDeclarator`](/docs/kcl/types#tag-declaration)| The tag of the path. | No |
|
||||
| `__geoMeta` |[`GeoMeta`](/docs/kcl/types/GeoMeta)| Metadata. | No |
|
||||
|
||||
@ -49,6 +50,7 @@ A arc that is tangential to the last path segment that goes to a point
|
||||
| `ccw` |`boolean`| arc's direction | No |
|
||||
| `from` |`[number, number]`| The from point. | No |
|
||||
| `to` |`[number, number]`| The to point. | No |
|
||||
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No |
|
||||
| `tag` |[`TagDeclarator`](/docs/kcl/types#tag-declaration)| The tag of the path. | No |
|
||||
| `__geoMeta` |[`GeoMeta`](/docs/kcl/types/GeoMeta)| Metadata. | No |
|
||||
|
||||
@ -71,6 +73,7 @@ A arc that is tangential to the last path segment
|
||||
| `ccw` |`boolean`| arc's direction | No |
|
||||
| `from` |`[number, number]`| The from point. | No |
|
||||
| `to` |`[number, number]`| The to point. | No |
|
||||
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No |
|
||||
| `tag` |[`TagDeclarator`](/docs/kcl/types#tag-declaration)| The tag of the path. | No |
|
||||
| `__geoMeta` |[`GeoMeta`](/docs/kcl/types/GeoMeta)| Metadata. | No |
|
||||
|
||||
@ -94,6 +97,7 @@ a complete arc
|
||||
| `ccw` |`boolean`| arc's direction This is used to compute the tangential angle. | No |
|
||||
| `from` |`[number, number]`| The from point. | No |
|
||||
| `to` |`[number, number]`| The to point. | No |
|
||||
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No |
|
||||
| `tag` |[`TagDeclarator`](/docs/kcl/types#tag-declaration)| The tag of the path. | No |
|
||||
| `__geoMeta` |[`GeoMeta`](/docs/kcl/types/GeoMeta)| Metadata. | No |
|
||||
|
||||
@ -117,6 +121,7 @@ A base path.
|
||||
| `p3` |`[number, number]`| Point 3 of the circle | No |
|
||||
| `from` |`[number, number]`| The from point. | No |
|
||||
| `to` |`[number, number]`| The to point. | No |
|
||||
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No |
|
||||
| `tag` |[`TagDeclarator`](/docs/kcl/types#tag-declaration)| The tag of the path. | No |
|
||||
| `__geoMeta` |[`GeoMeta`](/docs/kcl/types/GeoMeta)| Metadata. | No |
|
||||
|
||||
@ -138,6 +143,7 @@ A path that is horizontal.
|
||||
| `x` |`number`| The x coordinate. | No |
|
||||
| `from` |`[number, number]`| The from point. | No |
|
||||
| `to` |`[number, number]`| The to point. | No |
|
||||
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No |
|
||||
| `tag` |[`TagDeclarator`](/docs/kcl/types#tag-declaration)| The tag of the path. | No |
|
||||
| `__geoMeta` |[`GeoMeta`](/docs/kcl/types/GeoMeta)| Metadata. | No |
|
||||
|
||||
@ -160,6 +166,7 @@ An angled line to.
|
||||
| `y` |`number`| The y coordinate. | No |
|
||||
| `from` |`[number, number]`| The from point. | No |
|
||||
| `to` |`[number, number]`| The to point. | No |
|
||||
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No |
|
||||
| `tag` |[`TagDeclarator`](/docs/kcl/types#tag-declaration)| The tag of the path. | No |
|
||||
| `__geoMeta` |[`GeoMeta`](/docs/kcl/types/GeoMeta)| Metadata. | No |
|
||||
|
||||
@ -180,6 +187,7 @@ A base path.
|
||||
| `type` |enum: `Base`| | No |
|
||||
| `from` |`[number, number]`| The from point. | No |
|
||||
| `to` |`[number, number]`| The to point. | No |
|
||||
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No |
|
||||
| `tag` |[`TagDeclarator`](/docs/kcl/types#tag-declaration)| The tag of the path. | No |
|
||||
| `__geoMeta` |[`GeoMeta`](/docs/kcl/types/GeoMeta)| Metadata. | No |
|
||||
|
||||
@ -203,6 +211,7 @@ A circular arc, not necessarily tangential to the current point.
|
||||
| `ccw` |`boolean`| True if the arc is counterclockwise. | No |
|
||||
| `from` |`[number, number]`| The from point. | No |
|
||||
| `to` |`[number, number]`| The to point. | No |
|
||||
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No |
|
||||
| `tag` |[`TagDeclarator`](/docs/kcl/types#tag-declaration)| The tag of the path. | No |
|
||||
| `__geoMeta` |[`GeoMeta`](/docs/kcl/types/GeoMeta)| Metadata. | No |
|
||||
|
||||
|
||||
@ -18,12 +18,12 @@ A plane.
|
||||
|----------|------|-------------|----------|
|
||||
| `id` |`string`| The id of the plane. | No |
|
||||
| `artifactId` |[`ArtifactId`](/docs/kcl/types/ArtifactId)| The artifact ID. | No |
|
||||
| `value` |[`PlaneType`](/docs/kcl/types/PlaneType)| A plane. | No |
|
||||
| `value` |[`PlaneType`](/docs/kcl/types/PlaneType)| Type for a plane. | No |
|
||||
| `origin` |[`Point3d`](/docs/kcl/types/Point3d)| Origin of the plane. | No |
|
||||
| `xAxis` |[`Point3d`](/docs/kcl/types/Point3d)| What should the plane's X axis be? | No |
|
||||
| `yAxis` |[`Point3d`](/docs/kcl/types/Point3d)| What should the plane's Y axis be? | No |
|
||||
| `zAxis` |[`Point3d`](/docs/kcl/types/Point3d)| The z-axis (normal). | No |
|
||||
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A plane. | No |
|
||||
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No |
|
||||
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| | No |
|
||||
|
||||
|
||||
|
||||
@ -17,6 +17,6 @@ Data for polar coordinates.
|
||||
| Property | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `angle` |`number`| The angle of the line (in degrees). | No |
|
||||
| `length` |`number`| The length of the line. | No |
|
||||
| `length` |[`TyF64`](/docs/kcl/types/TyF64)| The length of the line. | No |
|
||||
|
||||
|
||||
|
||||
@ -6,6 +6,40 @@ layout: manual
|
||||
|
||||
A sketch is a collection of paths.
|
||||
|
||||
When you define a sketch to a variable like:
|
||||
|
||||
```kcl
|
||||
mySketch = startSketchOn('XY')
|
||||
|> startProfileAt([-12, 12], %)
|
||||
|> line(end = [24, 0])
|
||||
|> line(end = [0, -24])
|
||||
|> line(end = [-24, 0])
|
||||
|> close()
|
||||
```
|
||||
|
||||
The `mySketch` variable will be an executed [`Sketch`](/docs/kcl/types/Sketch) object. Executed being past tense, because the engine has already executed the commands to create the sketch.
|
||||
|
||||
The previous sketch commands will never be executed again, in this case.
|
||||
|
||||
If you would like to encapsulate the commands to create the sketch any time you call it, you can use a function.
|
||||
|
||||
```kcl
|
||||
fn createSketch() {
|
||||
return startSketchOn('XY')
|
||||
|> startProfileAt([-12, 12], %)
|
||||
|> line(end = [24, 0])
|
||||
|> line(end = [0, -24])
|
||||
|> line(end = [-24, 0])
|
||||
|> close()
|
||||
}
|
||||
```
|
||||
|
||||
Now, every time you call `createSketch()`, the commands will be executed and a new sketch will be created.
|
||||
|
||||
When you assign the result of `createSketch()` to a variable (`mySketch = createSketch()`), you are assigning the executed sketch to that variable. Meaning that the sketch `mySketch` will not be executed again.
|
||||
|
||||
You can still execute _new_ commands on the sketch like `extrude`, `revolve`, `loft`, etc. and the sketch will be updated.
|
||||
|
||||
**Type:** `object`
|
||||
|
||||
|
||||
@ -23,7 +57,7 @@ A sketch is a collection of paths.
|
||||
| `tags` |`object`| Tag identifiers that have been declared in this sketch. | No |
|
||||
| `artifactId` |[`ArtifactId`](/docs/kcl/types/ArtifactId)| The original id of the sketch. This stays the same even if the sketch is is sketched on face etc. | No |
|
||||
| `originalId` |`string`| | No |
|
||||
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A sketch is a collection of paths. | No |
|
||||
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No |
|
||||
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| Metadata. | No |
|
||||
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ Data for start sketch on. You can start a sketch on a plane or an solid.
|
||||
|
||||
**This schema accepts any of the following:**
|
||||
|
||||
Data for start sketch on. You can start a sketch on a plane or an solid.
|
||||
Orientation data that can be used to construct a plane, not a plane in itself.
|
||||
|
||||
[`PlaneData`](/docs/kcl/types/PlaneData)
|
||||
|
||||
@ -23,7 +23,7 @@ Data for start sketch on. You can start a sketch on a plane or an solid.
|
||||
|
||||
|
||||
----
|
||||
Data for start sketch on. You can start a sketch on a plane or an solid.
|
||||
A plane.
|
||||
|
||||
[`Plane`](/docs/kcl/types/Plane)
|
||||
|
||||
@ -35,7 +35,43 @@ Data for start sketch on. You can start a sketch on a plane or an solid.
|
||||
|
||||
|
||||
----
|
||||
Data for start sketch on. You can start a sketch on a plane or an solid.
|
||||
A solid is a collection of extrude surfaces.
|
||||
|
||||
When you define a solid to a variable like:
|
||||
|
||||
```kcl
|
||||
myPart = startSketchOn('XY')
|
||||
|> startProfileAt([-12, 12], %)
|
||||
|> line(end = [24, 0])
|
||||
|> line(end = [0, -24])
|
||||
|> line(end = [-24, 0])
|
||||
|> close()
|
||||
|> extrude(length = 6)
|
||||
```
|
||||
|
||||
The `myPart` variable will be an executed [`Solid`](/docs/kcl/types/Solid) object. Executed being past tense, because the engine has already executed the commands to create the solid.
|
||||
|
||||
The previous solid commands will never be executed again, in this case.
|
||||
|
||||
If you would like to encapsulate the commands to create the solid any time you call it, you can use a function.
|
||||
|
||||
```kcl
|
||||
fn createPart() {
|
||||
return startSketchOn('XY')
|
||||
|> startProfileAt([-12, 12], %)
|
||||
|> line(end = [24, 0])
|
||||
|> line(end = [0, -24])
|
||||
|> line(end = [-24, 0])
|
||||
|> close()
|
||||
|> extrude(length = 6)
|
||||
}
|
||||
```
|
||||
|
||||
Now, every time you call `createPart()`, the commands will be executed and a new solid will be created.
|
||||
|
||||
When you assign the result of `createPart()` to a variable (`myPart = createPart()`), you are assigning the executed solid to that variable. Meaning that the solid `myPart` will not be executed again.
|
||||
|
||||
You can still execute _new_ commands on the solid like `shell`, `fillet`, `chamfer`, etc. and the solid will be updated.
|
||||
|
||||
[`Solid`](/docs/kcl/types/Solid)
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ A sketch surface or a sketch.
|
||||
|
||||
**This schema accepts any of the following:**
|
||||
|
||||
A sketch surface or a sketch.
|
||||
A sketch type.
|
||||
|
||||
[`SketchSurface`](/docs/kcl/types/SketchSurface)
|
||||
|
||||
@ -23,7 +23,41 @@ A sketch surface or a sketch.
|
||||
|
||||
|
||||
----
|
||||
A sketch surface or a sketch.
|
||||
A sketch is a collection of paths.
|
||||
|
||||
When you define a sketch to a variable like:
|
||||
|
||||
```kcl
|
||||
mySketch = startSketchOn('XY')
|
||||
|> startProfileAt([-12, 12], %)
|
||||
|> line(end = [24, 0])
|
||||
|> line(end = [0, -24])
|
||||
|> line(end = [-24, 0])
|
||||
|> close()
|
||||
```
|
||||
|
||||
The `mySketch` variable will be an executed [`Sketch`](/docs/kcl/types/Sketch) object. Executed being past tense, because the engine has already executed the commands to create the sketch.
|
||||
|
||||
The previous sketch commands will never be executed again, in this case.
|
||||
|
||||
If you would like to encapsulate the commands to create the sketch any time you call it, you can use a function.
|
||||
|
||||
```kcl
|
||||
fn createSketch() {
|
||||
return startSketchOn('XY')
|
||||
|> startProfileAt([-12, 12], %)
|
||||
|> line(end = [24, 0])
|
||||
|> line(end = [0, -24])
|
||||
|> line(end = [-24, 0])
|
||||
|> close()
|
||||
}
|
||||
```
|
||||
|
||||
Now, every time you call `createSketch()`, the commands will be executed and a new sketch will be created.
|
||||
|
||||
When you assign the result of `createSketch()` to a variable (`mySketch = createSketch()`), you are assigning the executed sketch to that variable. Meaning that the sketch `mySketch` will not be executed again.
|
||||
|
||||
You can still execute _new_ commands on the sketch like `extrude`, `revolve`, `loft`, etc. and the sketch will be updated.
|
||||
|
||||
[`Sketch`](/docs/kcl/types/Sketch)
|
||||
|
||||
|
||||
@ -14,6 +14,40 @@ A sketch or a group of sketches.
|
||||
|
||||
A sketch is a collection of paths.
|
||||
|
||||
When you define a sketch to a variable like:
|
||||
|
||||
```kcl
|
||||
mySketch = startSketchOn('XY')
|
||||
|> startProfileAt([-12, 12], %)
|
||||
|> line(end = [24, 0])
|
||||
|> line(end = [0, -24])
|
||||
|> line(end = [-24, 0])
|
||||
|> close()
|
||||
```
|
||||
|
||||
The `mySketch` variable will be an executed [`Sketch`](/docs/kcl/types/Sketch) object. Executed being past tense, because the engine has already executed the commands to create the sketch.
|
||||
|
||||
The previous sketch commands will never be executed again, in this case.
|
||||
|
||||
If you would like to encapsulate the commands to create the sketch any time you call it, you can use a function.
|
||||
|
||||
```kcl
|
||||
fn createSketch() {
|
||||
return startSketchOn('XY')
|
||||
|> startProfileAt([-12, 12], %)
|
||||
|> line(end = [24, 0])
|
||||
|> line(end = [0, -24])
|
||||
|> line(end = [-24, 0])
|
||||
|> close()
|
||||
}
|
||||
```
|
||||
|
||||
Now, every time you call `createSketch()`, the commands will be executed and a new sketch will be created.
|
||||
|
||||
When you assign the result of `createSketch()` to a variable (`mySketch = createSketch()`), you are assigning the executed sketch to that variable. Meaning that the sketch `mySketch` will not be executed again.
|
||||
|
||||
You can still execute _new_ commands on the sketch like `extrude`, `revolve`, `loft`, etc. and the sketch will be updated.
|
||||
|
||||
**Type:** `object`
|
||||
|
||||
|
||||
@ -32,7 +66,7 @@ A sketch is a collection of paths.
|
||||
| `tags` |`object`| Tag identifiers that have been declared in this sketch. | No |
|
||||
| `artifactId` |[`ArtifactId`](/docs/kcl/types/ArtifactId)| The original id of the sketch. This stays the same even if the sketch is is sketched on face etc. | No |
|
||||
| `originalId` |`string`| | No |
|
||||
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A sketch or a group of sketches. | No |
|
||||
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No |
|
||||
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| Metadata. | No |
|
||||
|
||||
|
||||
|
||||
@ -27,12 +27,12 @@ A plane.
|
||||
| `type` |enum: `plane`| | No |
|
||||
| `id` |`string`| The id of the plane. | No |
|
||||
| `artifactId` |[`ArtifactId`](/docs/kcl/types/ArtifactId)| The artifact ID. | No |
|
||||
| `value` |[`PlaneType`](/docs/kcl/types/PlaneType)| A sketch type. | No |
|
||||
| `value` |[`PlaneType`](/docs/kcl/types/PlaneType)| Type for a plane. | No |
|
||||
| `origin` |[`Point3d`](/docs/kcl/types/Point3d)| Origin of the plane. | No |
|
||||
| `xAxis` |[`Point3d`](/docs/kcl/types/Point3d)| What should the plane's X axis be? | No |
|
||||
| `yAxis` |[`Point3d`](/docs/kcl/types/Point3d)| What should the plane's Y axis be? | No |
|
||||
| `zAxis` |[`Point3d`](/docs/kcl/types/Point3d)| The z-axis (normal). | No |
|
||||
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A sketch type. | No |
|
||||
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No |
|
||||
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| | No |
|
||||
|
||||
|
||||
@ -57,7 +57,7 @@ A face.
|
||||
| `yAxis` |[`Point3d`](/docs/kcl/types/Point3d)| What should the face's Y axis be? | No |
|
||||
| `zAxis` |[`Point3d`](/docs/kcl/types/Point3d)| The z-axis (normal). | No |
|
||||
| `solid` |[`Solid`](/docs/kcl/types/Solid)| The solid the face is on. | No |
|
||||
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A sketch type. | No |
|
||||
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No |
|
||||
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| | No |
|
||||
|
||||
|
||||
|
||||
@ -1,10 +1,46 @@
|
||||
---
|
||||
title: "Solid"
|
||||
excerpt: "An solid is a collection of extrude surfaces."
|
||||
excerpt: "A solid is a collection of extrude surfaces."
|
||||
layout: manual
|
||||
---
|
||||
|
||||
An solid is a collection of extrude surfaces.
|
||||
A solid is a collection of extrude surfaces.
|
||||
|
||||
When you define a solid to a variable like:
|
||||
|
||||
```kcl
|
||||
myPart = startSketchOn('XY')
|
||||
|> startProfileAt([-12, 12], %)
|
||||
|> line(end = [24, 0])
|
||||
|> line(end = [0, -24])
|
||||
|> line(end = [-24, 0])
|
||||
|> close()
|
||||
|> extrude(length = 6)
|
||||
```
|
||||
|
||||
The `myPart` variable will be an executed [`Solid`](/docs/kcl/types/Solid) object. Executed being past tense, because the engine has already executed the commands to create the solid.
|
||||
|
||||
The previous solid commands will never be executed again, in this case.
|
||||
|
||||
If you would like to encapsulate the commands to create the solid any time you call it, you can use a function.
|
||||
|
||||
```kcl
|
||||
fn createPart() {
|
||||
return startSketchOn('XY')
|
||||
|> startProfileAt([-12, 12], %)
|
||||
|> line(end = [24, 0])
|
||||
|> line(end = [0, -24])
|
||||
|> line(end = [-24, 0])
|
||||
|> close()
|
||||
|> extrude(length = 6)
|
||||
}
|
||||
```
|
||||
|
||||
Now, every time you call `createPart()`, the commands will be executed and a new solid will be created.
|
||||
|
||||
When you assign the result of `createPart()` to a variable (`myPart = createPart()`), you are assigning the executed solid to that variable. Meaning that the solid `myPart` will not be executed again.
|
||||
|
||||
You can still execute _new_ commands on the solid like `shell`, `fillet`, `chamfer`, etc. and the solid will be updated.
|
||||
|
||||
**Type:** `object`
|
||||
|
||||
@ -24,7 +60,7 @@ An solid is a collection of extrude surfaces.
|
||||
| `startCapId` |`string`| The id of the extrusion start cap | No |
|
||||
| `endCapId` |`string`| The id of the extrusion end cap | No |
|
||||
| `edgeCuts` |`[` [`EdgeCut`](/docs/kcl/types/EdgeCut) `]`| Chamfers or fillets on this solid. | No |
|
||||
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| An solid is a collection of extrude surfaces. | No |
|
||||
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No |
|
||||
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| Metadata. | No |
|
||||
|
||||
|
||||
|
||||
@ -12,7 +12,43 @@ A solid or a group of solids.
|
||||
|
||||
**This schema accepts exactly one of the following:**
|
||||
|
||||
An solid is a collection of extrude surfaces.
|
||||
A solid is a collection of extrude surfaces.
|
||||
|
||||
When you define a solid to a variable like:
|
||||
|
||||
```kcl
|
||||
myPart = startSketchOn('XY')
|
||||
|> startProfileAt([-12, 12], %)
|
||||
|> line(end = [24, 0])
|
||||
|> line(end = [0, -24])
|
||||
|> line(end = [-24, 0])
|
||||
|> close()
|
||||
|> extrude(length = 6)
|
||||
```
|
||||
|
||||
The `myPart` variable will be an executed [`Solid`](/docs/kcl/types/Solid) object. Executed being past tense, because the engine has already executed the commands to create the solid.
|
||||
|
||||
The previous solid commands will never be executed again, in this case.
|
||||
|
||||
If you would like to encapsulate the commands to create the solid any time you call it, you can use a function.
|
||||
|
||||
```kcl
|
||||
fn createPart() {
|
||||
return startSketchOn('XY')
|
||||
|> startProfileAt([-12, 12], %)
|
||||
|> line(end = [24, 0])
|
||||
|> line(end = [0, -24])
|
||||
|> line(end = [-24, 0])
|
||||
|> close()
|
||||
|> extrude(length = 6)
|
||||
}
|
||||
```
|
||||
|
||||
Now, every time you call `createPart()`, the commands will be executed and a new solid will be created.
|
||||
|
||||
When you assign the result of `createPart()` to a variable (`myPart = createPart()`), you are assigning the executed solid to that variable. Meaning that the solid `myPart` will not be executed again.
|
||||
|
||||
You can still execute _new_ commands on the solid like `shell`, `fillet`, `chamfer`, etc. and the solid will be updated.
|
||||
|
||||
**Type:** `object`
|
||||
|
||||
@ -33,7 +69,7 @@ An solid is a collection of extrude surfaces.
|
||||
| `startCapId` |`string`| The id of the extrusion start cap | No |
|
||||
| `endCapId` |`string`| The id of the extrusion end cap | No |
|
||||
| `edgeCuts` |`[` [`EdgeCut`](/docs/kcl/types/EdgeCut) `]`| Chamfers or fillets on this solid. | No |
|
||||
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A solid or a group of solids. | No |
|
||||
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No |
|
||||
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| Metadata. | No |
|
||||
|
||||
|
||||
|
||||
15
docs/kcl/types/SourceRange.md
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
title: "SourceRange"
|
||||
excerpt: ""
|
||||
layout: manual
|
||||
---
|
||||
|
||||
|
||||
**Type:** `integer` (`uint`)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,90 +0,0 @@
|
||||
---
|
||||
title: "StandardPlane"
|
||||
excerpt: "One of the standard planes."
|
||||
layout: manual
|
||||
---
|
||||
|
||||
One of the standard planes.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
**This schema accepts exactly one of the following:**
|
||||
|
||||
The XY plane.
|
||||
|
||||
**enum:** `XY`
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
----
|
||||
The opposite side of the XY plane.
|
||||
|
||||
**enum:** `-XY`
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
----
|
||||
The XZ plane.
|
||||
|
||||
**enum:** `XZ`
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
----
|
||||
The opposite side of the XZ plane.
|
||||
|
||||
**enum:** `-XZ`
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
----
|
||||
The YZ plane.
|
||||
|
||||
**enum:** `YZ`
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
----
|
||||
The opposite side of the YZ plane.
|
||||
|
||||
**enum:** `-YZ`
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
----
|
||||
|
||||
|
||||
|
||||
|
||||
@ -11,7 +11,41 @@ A path to sweep along.
|
||||
|
||||
**This schema accepts any of the following:**
|
||||
|
||||
A path to sweep along.
|
||||
A sketch is a collection of paths.
|
||||
|
||||
When you define a sketch to a variable like:
|
||||
|
||||
```kcl
|
||||
mySketch = startSketchOn('XY')
|
||||
|> startProfileAt([-12, 12], %)
|
||||
|> line(end = [24, 0])
|
||||
|> line(end = [0, -24])
|
||||
|> line(end = [-24, 0])
|
||||
|> close()
|
||||
```
|
||||
|
||||
The `mySketch` variable will be an executed [`Sketch`](/docs/kcl/types/Sketch) object. Executed being past tense, because the engine has already executed the commands to create the sketch.
|
||||
|
||||
The previous sketch commands will never be executed again, in this case.
|
||||
|
||||
If you would like to encapsulate the commands to create the sketch any time you call it, you can use a function.
|
||||
|
||||
```kcl
|
||||
fn createSketch() {
|
||||
return startSketchOn('XY')
|
||||
|> startProfileAt([-12, 12], %)
|
||||
|> line(end = [24, 0])
|
||||
|> line(end = [0, -24])
|
||||
|> line(end = [-24, 0])
|
||||
|> close()
|
||||
}
|
||||
```
|
||||
|
||||
Now, every time you call `createSketch()`, the commands will be executed and a new sketch will be created.
|
||||
|
||||
When you assign the result of `createSketch()` to a variable (`mySketch = createSketch()`), you are assigning the executed sketch to that variable. Meaning that the sketch `mySketch` will not be executed again.
|
||||
|
||||
You can still execute _new_ commands on the sketch like `extrude`, `revolve`, `loft`, etc. and the sketch will be updated.
|
||||
|
||||
[`Sketch`](/docs/kcl/types/Sketch)
|
||||
|
||||
@ -23,7 +57,7 @@ A path to sweep along.
|
||||
|
||||
|
||||
----
|
||||
A path to sweep along.
|
||||
A helix.
|
||||
|
||||
[`Helix`](/docs/kcl/types/Helix)
|
||||
|
||||
|
||||
21
docs/kcl/types/TyF64.md
Normal file
@ -0,0 +1,21 @@
|
||||
---
|
||||
title: "TyF64"
|
||||
excerpt: ""
|
||||
layout: manual
|
||||
---
|
||||
|
||||
|
||||
**Type:** `object`
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `n` |`number`| | No |
|
||||
| `ty` |[`NumericType`](/docs/kcl/types/NumericType)| | No |
|
||||
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
---
|
||||
title: "UnitAngle"
|
||||
excerpt: ""
|
||||
excerpt: "A unit of angle."
|
||||
layout: manual
|
||||
---
|
||||
|
||||
A unit of angle.
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
---
|
||||
title: "UnitLen"
|
||||
excerpt: ""
|
||||
excerpt: "A unit of length."
|
||||
layout: manual
|
||||
---
|
||||
|
||||
A unit of length.
|
||||
|
||||
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ import { ToolbarFixture } from './fixtures/toolbarFixture'
|
||||
import fs from 'node:fs/promises'
|
||||
import path from 'node:path'
|
||||
import { getUtils } from './test-utils'
|
||||
import { Locator } from '@playwright/test'
|
||||
|
||||
// test file is for testing point an click code gen functionality that's not sketch mode related
|
||||
|
||||
@ -2506,6 +2507,94 @@ extrude002 = extrude(sketch002, length = 50)
|
||||
})
|
||||
})
|
||||
|
||||
const shellPointAndClickDeletionCases = [
|
||||
{ shouldUseKeyboard: true },
|
||||
{ shouldUseKeyboard: false },
|
||||
]
|
||||
shellPointAndClickDeletionCases.forEach(({ shouldUseKeyboard }) => {
|
||||
test(`Shell point-and-click deletion (shouldUseKeyboard: ${shouldUseKeyboard})`, async ({
|
||||
context,
|
||||
page,
|
||||
homePage,
|
||||
scene,
|
||||
editor,
|
||||
toolbar,
|
||||
cmdBar,
|
||||
}) => {
|
||||
const sketchCode = `sketch001 = startSketchOn('XY')
|
||||
profile001 = startProfileAt([-20, 20], sketch001)
|
||||
|> xLine(40, %)
|
||||
|> yLine(-60, %)
|
||||
|> xLine(-40, %)
|
||||
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|
||||
|> close()
|
||||
`
|
||||
const extrudeCode = `extrude001 = extrude(profile001, length = 40)
|
||||
`
|
||||
const shellCode = `shell001 = shell(extrude001, faces = ['end'], thickness = 5)
|
||||
`
|
||||
const initialCode = sketchCode + extrudeCode + shellCode
|
||||
await context.addInitScript((initialCode) => {
|
||||
localStorage.setItem('persistCode', initialCode)
|
||||
}, initialCode)
|
||||
await page.setBodyDimensions({ width: 1000, height: 500 })
|
||||
await homePage.goToModelingScene()
|
||||
await scene.waitForExecutionDone()
|
||||
await toolbar.openPane('feature-tree')
|
||||
|
||||
// One dumb hardcoded screen pixel value
|
||||
const testPoint = { x: 590, y: 400 }
|
||||
const extrudeColor: [number, number, number] = [100, 100, 100]
|
||||
const sketchColor: [number, number, number] = [140, 140, 140]
|
||||
const defaultPlaneColor: [number, number, number] = [50, 50, 100]
|
||||
|
||||
const deleteOperation = async (operationButton: Locator) => {
|
||||
if (shouldUseKeyboard) {
|
||||
await operationButton.click({ button: 'left' })
|
||||
await page.keyboard.press('Backspace')
|
||||
} else {
|
||||
await operationButton.click({ button: 'right' })
|
||||
const editButton = page.getByTestId('context-menu-delete')
|
||||
await editButton.click()
|
||||
}
|
||||
}
|
||||
|
||||
await test.step(`Look for the grey of the extrude shape`, async () => {
|
||||
await scene.expectPixelColor(extrudeColor, testPoint, 20)
|
||||
})
|
||||
|
||||
await test.step('Delete shell and confirm deletion', async () => {
|
||||
const operationButton = await toolbar.getFeatureTreeOperation(
|
||||
'Shell',
|
||||
0
|
||||
)
|
||||
await deleteOperation(operationButton)
|
||||
await scene.expectPixelColor(extrudeColor, testPoint, 20)
|
||||
await editor.expectEditor.not.toContain(shellCode)
|
||||
})
|
||||
|
||||
await test.step('Delete extrude and confirm deletion', async () => {
|
||||
const operationButton = await toolbar.getFeatureTreeOperation(
|
||||
'Extrude',
|
||||
0
|
||||
)
|
||||
await deleteOperation(operationButton)
|
||||
await editor.expectEditor.not.toContain(extrudeCode)
|
||||
await scene.expectPixelColor(sketchColor, testPoint, 20)
|
||||
})
|
||||
|
||||
await test.step('Delete sketch and confirm empty scene', async () => {
|
||||
const operationButton = await toolbar.getFeatureTreeOperation(
|
||||
'Sketch',
|
||||
0
|
||||
)
|
||||
await deleteOperation(operationButton)
|
||||
await editor.expectEditor.toContain('')
|
||||
await scene.expectPixelColor(defaultPlaneColor, testPoint, 20)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test(`Shell dry-run validation rejects sweeps`, async ({
|
||||
context,
|
||||
page,
|
||||
|
||||
@ -117,7 +117,7 @@ test(
|
||||
test(
|
||||
'open a file in a project works and renders, open another file in different project with errors, it should clear the scene',
|
||||
{ tag: '@electron' },
|
||||
async ({ context, page }, testInfo) => {
|
||||
async ({ context, page, editor }, testInfo) => {
|
||||
await context.folderSetupFn(async (dir) => {
|
||||
const bracketDir = path.join(dir, 'bracket')
|
||||
await fsp.mkdir(bracketDir, { recursive: true })
|
||||
@ -180,6 +180,11 @@ test(
|
||||
|
||||
await page.getByText('broken-code').click()
|
||||
|
||||
await page.waitForTimeout(2000)
|
||||
await editor.scrollToText(
|
||||
"|> line(end = [0, wallMountL], tag = 'outerEdge')"
|
||||
)
|
||||
|
||||
// error in guter
|
||||
await expect(page.locator('.cm-lint-marker-error')).toBeVisible()
|
||||
|
||||
|
||||
@ -2029,9 +2029,6 @@ profile003 = circle({ center = [6.92, -4.2], radius = 3.16 }, sketch001)
|
||||
await moveToClearToolBarPopover()
|
||||
await pointOnSegment({ shouldDbClick: true })
|
||||
await page.waitForTimeout(600)
|
||||
|
||||
await toolbar.lineBtn.click()
|
||||
await page.waitForTimeout(100)
|
||||
})
|
||||
|
||||
await test.step('select and delete code for a profile', async () => {})
|
||||
@ -2049,7 +2046,9 @@ profile003 = circle({ center = [6.92, -4.2], radius = 3.16 }, sketch001)
|
||||
await test.step('add random new var between profiles', async () => {
|
||||
await page.keyboard.type('myVar = 5')
|
||||
await page.keyboard.press('Enter')
|
||||
await page.waitForTimeout(600)
|
||||
// If this timeout isn't long enough, the test breaks.
|
||||
// TODO: fix https://github.com/KittyCAD/modeling-app/issues/5437
|
||||
await page.waitForTimeout(3_000)
|
||||
})
|
||||
|
||||
await sketchIsDrawnProperly()
|
||||
|
||||
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 60 KiB |
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 51 KiB |
|
Before Width: | Height: | Size: 143 KiB After Width: | Height: | Size: 143 KiB |
|
Before Width: | Height: | Size: 127 KiB After Width: | Height: | Size: 127 KiB |
|
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 49 KiB |
@ -945,4 +945,76 @@ fn cube`
|
||||
).toBeVisible()
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
* This test assumes that the default value of the "highlight edges" setting is "on".
|
||||
*/
|
||||
test(`Toggle stream settings multiple times`, async ({
|
||||
page,
|
||||
scene,
|
||||
homePage,
|
||||
context,
|
||||
toolbar,
|
||||
cmdBar,
|
||||
}, testInfo) => {
|
||||
await context.folderSetupFn(async (dir) => {
|
||||
const projectDir = join(dir, 'project-000')
|
||||
await fsp.mkdir(projectDir, { recursive: true })
|
||||
await fsp.copyFile(
|
||||
executorInputPath('cube.kcl'),
|
||||
join(projectDir, 'main.kcl')
|
||||
)
|
||||
})
|
||||
|
||||
await test.step(`First snapshot`, async () => {
|
||||
await homePage.openProject('project-000')
|
||||
await toolbar.closePane('code')
|
||||
await expect(toolbar.startSketchBtn).toBeEnabled({ timeout: 20_000 })
|
||||
await scene.clickNoWhere()
|
||||
})
|
||||
|
||||
const toast = (value: boolean) =>
|
||||
page.getByText(
|
||||
`Set highlight edges to "${String(value)}" as a user default`
|
||||
)
|
||||
const initialPath = testInfo.snapshotPath('toggle-settings-initial.png')
|
||||
const initialScreenshot = await scene.streamWrapper.screenshot({
|
||||
path: initialPath,
|
||||
mask: [page.getByTestId('model-state-indicator')],
|
||||
})
|
||||
|
||||
await test.step(`Toggle highlightEdges off`, async () => {
|
||||
await cmdBar.openCmdBar()
|
||||
await cmdBar.chooseCommand('Settings · modeling · highlight edges')
|
||||
await cmdBar.selectOption({ name: 'off' }).click()
|
||||
const falseToast = toast(false)
|
||||
await expect(falseToast).toBeVisible()
|
||||
await falseToast.waitFor({ state: 'detached' })
|
||||
})
|
||||
|
||||
await expect(scene.streamWrapper).not.toHaveScreenshot(
|
||||
'toggle-settings-initial.png',
|
||||
{
|
||||
maxDiffPixels: 15,
|
||||
mask: [page.getByTestId('model-state-indicator')],
|
||||
}
|
||||
)
|
||||
|
||||
await test.step(`Toggle highlightEdges on`, async () => {
|
||||
await cmdBar.openCmdBar()
|
||||
await cmdBar.chooseCommand('Settings · modeling · highlight edges')
|
||||
await cmdBar.selectOption({ name: 'on' }).click()
|
||||
const trueToast = toast(true)
|
||||
await expect(trueToast).toBeVisible()
|
||||
await trueToast.waitFor({ state: 'detached' })
|
||||
})
|
||||
|
||||
await expect(scene.streamWrapper).toHaveScreenshot(
|
||||
'toggle-settings-initial.png',
|
||||
{
|
||||
maxDiffPixels: 15,
|
||||
mask: [page.getByTestId('model-state-indicator')],
|
||||
}
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@ -20,10 +20,14 @@ export const kclHighlight = styleTags({
|
||||
LineComment: t.lineComment,
|
||||
BlockComment: t.blockComment,
|
||||
Shebang: t.meta,
|
||||
AnnotationName: t.annotation,
|
||||
PipeSubstitution: t.atom,
|
||||
VariableDefinition: t.definition(t.variableName),
|
||||
VariableName: t.variableName,
|
||||
PropertyName: t.propertyName,
|
||||
'AnnotationProperty/PropertyName': t.definition(t.propertyName),
|
||||
'ObjectProperty/PropertyName': t.definition(t.propertyName),
|
||||
'LabeledArgument/ArgumentLabel': t.definition(t.propertyName),
|
||||
TagDeclarator: t.tagName,
|
||||
'( )': t.paren,
|
||||
'{ }': t.brace,
|
||||
|
||||
@ -1,4 +1,11 @@
|
||||
[
|
||||
{
|
||||
"file": "main.kcl",
|
||||
"pathFromProjectDirectoryToFirstFile": "3d-boaty/main.kcl",
|
||||
"multipleFiles": true,
|
||||
"title": "3D Boaty",
|
||||
"description": "This is a slight remix of Depep1's original 3D Boaty (https://www.printables.com/model/1141963-3d-boaty). This is a tool used for benchmarking 3D FDM printers for bed adhesion, overhangs, bridging and top surface quality. The name of this file is a bit of misnomer, the shape of the object is a typical park bench."
|
||||
},
|
||||
{
|
||||
"file": "main.kcl",
|
||||
"pathFromProjectDirectoryToFirstFile": "80-20-rail/main.kcl",
|
||||
@ -34,6 +41,13 @@
|
||||
"title": "Car Wheel Assembly",
|
||||
"description": "A car wheel assembly with a rotor, tire, and lug nuts."
|
||||
},
|
||||
{
|
||||
"file": "main.kcl",
|
||||
"pathFromProjectDirectoryToFirstFile": "color-cube/main.kcl",
|
||||
"multipleFiles": false,
|
||||
"title": "Color Cube",
|
||||
"description": "This is a color cube centered about the origin. It is used to help determine orientation in the scene."
|
||||
},
|
||||
{
|
||||
"file": "main.kcl",
|
||||
"pathFromProjectDirectoryToFirstFile": "cycloidal-gear/main.kcl",
|
||||
|
||||
@ -179,10 +179,7 @@ const Overlays = () => {
|
||||
// Set a large zIndex, the overlay for hover dropdown menu on line segments needs to render
|
||||
// over the length labels on the line segments
|
||||
return (
|
||||
<div
|
||||
className="absolute inset-0 pointer-events-none"
|
||||
style={{ zIndex: '99999999' }}
|
||||
>
|
||||
<div className="absolute inset-0 pointer-events-none z-sketchOverlayDropdown">
|
||||
{Object.entries(context.segmentOverlays)
|
||||
.flatMap((a) =>
|
||||
a[1].map((b) => ({ pathToNodeString: a[0], overlay: b }))
|
||||
|
||||
@ -291,6 +291,7 @@ export class SceneInfra {
|
||||
this.labelRenderer.domElement.style.position = 'absolute'
|
||||
this.labelRenderer.domElement.style.top = '0px'
|
||||
this.labelRenderer.domElement.style.pointerEvents = 'none'
|
||||
this.labelRenderer.domElement.className = 'z-sketchSegmentIndicators'
|
||||
window.addEventListener('resize', this.onWindowResize)
|
||||
|
||||
this.camControls = new CameraControls(
|
||||
|
||||
82
src/commandLineArgs.test.ts
Normal file
@ -0,0 +1,82 @@
|
||||
import { getPathOrUrlFromArgs, parseCLIArgs } from 'commandLineArgs'
|
||||
|
||||
const linuxDeepLinkArgv = [
|
||||
'/tmp/.mount_Zoo Movq3t0x/zoo-modeling-app',
|
||||
'--no-sandbox',
|
||||
'--allow-file-access-from-files',
|
||||
'zoo-studio://?create-file=true&name=deeplinks&code=cGxhbmUwMDEgPSBvZmZzZXRQbGFuZSgnWFonLCBvZmZzZXQgPSA1KQ%3D%3D',
|
||||
]
|
||||
|
||||
const linuxNoPathArgv = [
|
||||
'/tmp/.mount_Zoo MogQS2hd/zoo-modeling-app',
|
||||
'--no-sandbox',
|
||||
'--allow-file-access-from-files',
|
||||
]
|
||||
|
||||
const linuxPathArgv = [
|
||||
'/tmp/.mount_Zoo MogQS2hd/zoo-modeling-app',
|
||||
'--no-sandbox',
|
||||
'--allow-file-access-from-files',
|
||||
'/home/pierremtb/Documents/zoo-modeling-app-projects/project-001/main.kcl',
|
||||
]
|
||||
|
||||
const winDeepLinkArgv = [
|
||||
'C:\\Program Files\\Zoo Modeling App\\Zoo Modeling App.exe',
|
||||
'--allow-file-access-from-files',
|
||||
'zoo-studio:///?create-file=true&name=deeplinkscopy&code=cGxhbmUwMDEgPSBvZmZzZXRQbGFuZSgnWFonLCBvZmZzZXQgPSA1KQo%3D',
|
||||
]
|
||||
|
||||
const winNoPathArgv = [
|
||||
'C:\\Program Files\\Zoo Modeling App\\Zoo Modeling App.exe',
|
||||
'--allow-file-access-from-files',
|
||||
]
|
||||
|
||||
const winPathArgv = [
|
||||
'C:\\Program Files\\Zoo Modeling App\\Zoo Modeling App.exe',
|
||||
'--allow-file-access-from-files',
|
||||
'C:\\Users\\pierr\\Documents\\zoo-modeling-app-projects\\deeplink\\main.kcl',
|
||||
]
|
||||
|
||||
// macos doesn't uses the open-url scheme so is different so no macDeepLinkArgv
|
||||
|
||||
const macNoPathArgv = [
|
||||
'/Applications/Zoo Modeling App.app/Contents/MacOS/Zoo Modeling App',
|
||||
]
|
||||
|
||||
const macPathArgv = [
|
||||
'/Applications/Zoo Modeling App.app/Contents/MacOS/Zoo Modeling App',
|
||||
'/Users/pierremtb/Documents/zoo-modeling-app-projects/loft/main.kcl',
|
||||
]
|
||||
|
||||
describe('getPathOrUrlFromArgs', () => {
|
||||
;[
|
||||
['linux', linuxDeepLinkArgv],
|
||||
['windows', winDeepLinkArgv],
|
||||
// macos doesn't uses the open-url scheme so is different
|
||||
].map(([os, argv]) => {
|
||||
it(`should parse second-instance deep link argv on ${os}`, () => {
|
||||
const args = parseCLIArgs(argv as string[])
|
||||
expect(getPathOrUrlFromArgs(args)).toContain('zoo-studio://')
|
||||
})
|
||||
})
|
||||
;[
|
||||
['linux', linuxPathArgv],
|
||||
['windows', winPathArgv],
|
||||
['mac', macPathArgv],
|
||||
].map(([os, argv]) => {
|
||||
it(`should parse path argv on ${os}`, () => {
|
||||
const args = parseCLIArgs(argv as string[])
|
||||
expect(getPathOrUrlFromArgs(args)).toContain('main.kcl')
|
||||
})
|
||||
})
|
||||
;[
|
||||
['linux', linuxNoPathArgv],
|
||||
['windows', winNoPathArgv],
|
||||
['mac', macNoPathArgv],
|
||||
].map(([os, argv]) => {
|
||||
it(`should return undefined without path argv on ${os}`, () => {
|
||||
const args = parseCLIArgs(argv as string[])
|
||||
expect(getPathOrUrlFromArgs(args)).toBeUndefined()
|
||||
})
|
||||
})
|
||||
})
|
||||
@ -1,7 +1,8 @@
|
||||
import minimist from 'minimist'
|
||||
import yargs from 'yargs'
|
||||
import { hideBin } from 'yargs/helpers'
|
||||
|
||||
const argv = yargs(hideBin(process.argv))
|
||||
export const argvFromYargs = yargs(hideBin(process.argv))
|
||||
.option('telemetry', {
|
||||
alias: 't',
|
||||
type: 'boolean',
|
||||
@ -9,4 +10,20 @@ const argv = yargs(hideBin(process.argv))
|
||||
})
|
||||
.parse()
|
||||
|
||||
export default argv
|
||||
// TODO: find a better way to merge minimist and yargs parsers.
|
||||
|
||||
export function parseCLIArgs(argv: string[]): minimist.ParsedArgs {
|
||||
return minimist(argv, {
|
||||
// Treat all double-hyphenated arguments without equal signs as boolean
|
||||
boolean: true,
|
||||
})
|
||||
}
|
||||
|
||||
export function getPathOrUrlFromArgs(
|
||||
args: minimist.ParsedArgs
|
||||
): string | undefined {
|
||||
if (args._.length > 1) {
|
||||
return args._[1]
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import toast from 'react-hot-toast'
|
||||
import { ActionIcon, ActionIconProps } from './ActionIcon'
|
||||
import {
|
||||
MouseEvent,
|
||||
RefObject,
|
||||
useCallback,
|
||||
useEffect,
|
||||
@ -148,24 +147,22 @@ interface ContextMenuItemProps {
|
||||
onClick?: () => void
|
||||
hotkey?: string
|
||||
'data-testid'?: string
|
||||
disabled?: boolean
|
||||
}
|
||||
|
||||
export function ContextMenuItem(props: ContextMenuItemProps) {
|
||||
const { children, icon, onClick, hotkey } = props
|
||||
const { children, icon, onClick, hotkey, disabled } = props
|
||||
|
||||
return (
|
||||
<button
|
||||
disabled={disabled}
|
||||
data-testid={props['data-testid']}
|
||||
className="flex items-center gap-2 py-1 px-2 cursor-pointer hover:bg-chalkboard-20 dark:hover:bg-chalkboard-80 border-none text-left"
|
||||
onClick={onClick}
|
||||
onClick={disabled ? undefined : onClick}
|
||||
>
|
||||
{icon && <ActionIcon icon={icon} bgClassName="!bg-transparent" />}
|
||||
<div className="flex-1">{children}</div>
|
||||
{hotkey && (
|
||||
<kbd className="px-1.5 py-0.5 rounded bg-primary/10 text-primary dark:bg-chalkboard-80 dark:text-chalkboard-40">
|
||||
{hotkey}
|
||||
</kbd>
|
||||
)}
|
||||
{hotkey && <kbd className="hotkey">{hotkey}</kbd>}
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
@ -800,11 +800,18 @@ export const ModelingMachineProvider = ({
|
||||
}),
|
||||
'animate-to-sketch': fromPromise(
|
||||
async ({ input: { selectionRanges } }) => {
|
||||
const artifact = selectionRanges.graphSelections[0].artifact
|
||||
const plane = getPlaneFromArtifact(
|
||||
selectionRanges.graphSelections[0].artifact,
|
||||
artifact,
|
||||
engineCommandManager.artifactGraph
|
||||
)
|
||||
if (err(plane)) return Promise.reject(plane)
|
||||
// if the user selected a segment, make sure we enter the right sketch as there can be multiple on a plan
|
||||
// but still works if the user selected a plane/face by defaulting to the first path
|
||||
const mainPath =
|
||||
artifact?.type === 'segment' || artifact?.type === 'solid2d'
|
||||
? artifact?.pathId
|
||||
: plane?.pathIds[0]
|
||||
let sketch: KclValue | null = null
|
||||
for (const variable of Object.values(
|
||||
kclManager.execState.variables
|
||||
@ -812,7 +819,7 @@ export const ModelingMachineProvider = ({
|
||||
// find programMemory that matches path artifact
|
||||
if (
|
||||
variable?.type === 'Sketch' &&
|
||||
variable.value.artifactId === plane.pathIds[0]
|
||||
variable.value.artifactId === mainPath
|
||||
) {
|
||||
sketch = variable
|
||||
break
|
||||
@ -821,7 +828,7 @@ export const ModelingMachineProvider = ({
|
||||
// if the variable is an sweep, check if the underlying sketch matches the artifact
|
||||
variable?.type === 'Solid' &&
|
||||
variable.value.sketch.on.type === 'plane' &&
|
||||
variable.value.sketch.artifactId === plane.pathIds[0]
|
||||
variable.value.sketch.artifactId === mainPath
|
||||
) {
|
||||
sketch = {
|
||||
type: 'Sketch',
|
||||
@ -841,9 +848,8 @@ export const ModelingMachineProvider = ({
|
||||
info?.sketchDetails?.faceId || ''
|
||||
)
|
||||
|
||||
const sketchArtifact = engineCommandManager.artifactGraph.get(
|
||||
plane.pathIds[0]
|
||||
)
|
||||
const sketchArtifact =
|
||||
engineCommandManager.artifactGraph.get(mainPath)
|
||||
if (sketchArtifact?.type !== 'path')
|
||||
return Promise.reject(new Error('No sketch artifact'))
|
||||
const sketchPaths = getPathsFromArtifact({
|
||||
|
||||
@ -324,6 +324,20 @@ const OperationItem = (props: {
|
||||
}
|
||||
}
|
||||
|
||||
function deleteOperation() {
|
||||
if (
|
||||
props.item.type === 'StdLibCall' ||
|
||||
props.item.type === 'UserDefinedFunctionCall'
|
||||
) {
|
||||
props.send({
|
||||
type: 'deleteOperation',
|
||||
data: {
|
||||
targetSourceRange: sourceRangeFromRust(props.item.sourceRange),
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const menuItems = useMemo(
|
||||
() => [
|
||||
<ContextMenuItem
|
||||
@ -364,14 +378,24 @@ const OperationItem = (props: {
|
||||
</ContextMenuItem>,
|
||||
]
|
||||
: []),
|
||||
...(props.item.type === 'StdLibCall' &&
|
||||
stdLibMap[props.item.name]?.prepareToEdit
|
||||
...(props.item.type === 'StdLibCall'
|
||||
? [
|
||||
<ContextMenuItem onClick={enterEditFlow}>
|
||||
Edit {name}
|
||||
<ContextMenuItem
|
||||
disabled={!stdLibMap[props.item.name]?.prepareToEdit}
|
||||
onClick={enterEditFlow}
|
||||
hotkey="Double click"
|
||||
>
|
||||
Edit
|
||||
</ContextMenuItem>,
|
||||
]
|
||||
: []),
|
||||
<ContextMenuItem
|
||||
onClick={deleteOperation}
|
||||
hotkey="Delete"
|
||||
data-testid="context-menu-delete"
|
||||
>
|
||||
Delete
|
||||
</ContextMenuItem>,
|
||||
],
|
||||
[props.item, props.send]
|
||||
)
|
||||
|
||||
@ -33,11 +33,8 @@ describe('processMemory', () => {
|
||||
const output = processMemory(execState.variables)
|
||||
expect(output.myVar).toEqual(5)
|
||||
expect(output.otherVar).toEqual(3)
|
||||
expect(output).toEqual({
|
||||
myVar: 5,
|
||||
myFn: '__function(a)__',
|
||||
otherVar: 3,
|
||||
theExtrude: [
|
||||
expect(output.myFn).toEqual('__function(a)__')
|
||||
expect(output.theExtrude).toEqual([
|
||||
{
|
||||
type: 'extrudePlane',
|
||||
tag: null,
|
||||
@ -52,12 +49,29 @@ describe('processMemory', () => {
|
||||
faceId: expect.any(String),
|
||||
sourceRange: [expect.any(Number), expect.any(Number), 0],
|
||||
},
|
||||
],
|
||||
theSketch: [
|
||||
{ type: 'ToPoint', to: [-3.35, 0.17], from: [0, 0], tag: null },
|
||||
{ type: 'ToPoint', to: [0.98, 5.16], from: [-3.35, 0.17], tag: null },
|
||||
{ type: 'ToPoint', to: [2.15, 4.32], from: [0.98, 5.16], tag: null },
|
||||
],
|
||||
})
|
||||
])
|
||||
expect(output.theSketch).toEqual([
|
||||
{
|
||||
type: 'ToPoint',
|
||||
to: [-3.35, 0.17],
|
||||
from: [0, 0],
|
||||
units: { type: 'Mm' },
|
||||
tag: null,
|
||||
},
|
||||
{
|
||||
type: 'ToPoint',
|
||||
to: [0.98, 5.16],
|
||||
from: [-3.35, 0.17],
|
||||
units: { type: 'Mm' },
|
||||
tag: null,
|
||||
},
|
||||
{
|
||||
type: 'ToPoint',
|
||||
to: [2.15, 4.32],
|
||||
from: [0.98, 5.16],
|
||||
units: { type: 'Mm' },
|
||||
tag: null,
|
||||
},
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
@ -20,7 +20,7 @@ import {
|
||||
getSettingsFolderPaths,
|
||||
} from 'lib/desktopFS'
|
||||
import { useDotDotSlash } from 'hooks/useDotDotSlash'
|
||||
import { ForwardedRef, forwardRef, useEffect } from 'react'
|
||||
import { ForwardedRef, forwardRef, useEffect, useMemo } from 'react'
|
||||
import { useLspContext } from 'components/LspProvider'
|
||||
import { toSync } from 'lib/utils'
|
||||
import { reportRejection } from 'lib/trap'
|
||||
@ -44,21 +44,23 @@ export const AllSettingsFields = forwardRef(
|
||||
settings: { send, context, state },
|
||||
} = useSettingsAuthContext()
|
||||
|
||||
const projectPath = useMemo(() => {
|
||||
const filteredPathname = location.pathname
|
||||
.replace(PATHS.FILE, '')
|
||||
.replace(PATHS.SETTINGS, '')
|
||||
const lastSlashIndex = filteredPathname.lastIndexOf(
|
||||
// This is slicing off any remaining browser path segments,
|
||||
// so we don't use window.electron.sep here
|
||||
'/'
|
||||
)
|
||||
const projectPath =
|
||||
isFileSettings && isDesktop()
|
||||
? decodeURI(
|
||||
location.pathname
|
||||
.replace(PATHS.FILE + window.electron.sep, '')
|
||||
.replace(PATHS.SETTINGS, '')
|
||||
.slice(
|
||||
0,
|
||||
decodeURI(location.pathname).lastIndexOf(
|
||||
window.electron.path.sep
|
||||
)
|
||||
)
|
||||
)
|
||||
? decodeURIComponent(filteredPathname.slice(lastSlashIndex + 1))
|
||||
: undefined
|
||||
|
||||
return projectPath
|
||||
}, [location.pathname])
|
||||
|
||||
function restartOnboarding() {
|
||||
send({
|
||||
type: `set.app.onboardingStatus`,
|
||||
@ -197,9 +199,7 @@ export const AllSettingsFields = forwardRef(
|
||||
<ActionButton
|
||||
Element="button"
|
||||
onClick={toSync(async () => {
|
||||
const paths = await getSettingsFolderPaths(
|
||||
projectPath ? decodeURIComponent(projectPath) : undefined
|
||||
)
|
||||
const paths = await getSettingsFolderPaths(projectPath)
|
||||
const finalPath = paths[searchParamTab]
|
||||
if (!finalPath) {
|
||||
return new Error('finalPath undefined')
|
||||
|
||||
@ -57,6 +57,7 @@ export function UnitsMenu() {
|
||||
const newCode = changeKclSettings(codeManager.code, {
|
||||
defaultLengthUnits: unitLengthToUnitLen(unit),
|
||||
defaultAngleUnits: { type: 'Degrees' },
|
||||
stdPath: null,
|
||||
})
|
||||
if (err(newCode)) {
|
||||
toast.error(
|
||||
|
||||
@ -401,6 +401,10 @@ export class KclManager {
|
||||
this.errors = errors
|
||||
// Do not add the errors since the program was interrupted and the error is not a real KCL error
|
||||
this.addDiagnostics(isInterrupted ? [] : kclErrorsToDiagnostics(errors))
|
||||
// Add warnings and non-fatal errors
|
||||
this.addDiagnostics(
|
||||
isInterrupted ? [] : complilationErrorsToDiagnostics(execState.errors)
|
||||
)
|
||||
this.execState = execState
|
||||
if (!errors.length) {
|
||||
this.lastSuccessfulVariables = execState.variables
|
||||
@ -464,6 +468,8 @@ export class KclManager {
|
||||
|
||||
this._logs = logs
|
||||
this.addDiagnostics(kclErrorsToDiagnostics(errors))
|
||||
// Add warnings and non-fatal errors
|
||||
this.addDiagnostics(complilationErrorsToDiagnostics(execState.errors))
|
||||
|
||||
this._execState = execState
|
||||
this._variables = execState.variables
|
||||
|
||||
@ -24,6 +24,7 @@ const mySketch001 = startSketchOn('XY')
|
||||
start: {
|
||||
to: [0, 0],
|
||||
from: [0, 0],
|
||||
units: { type: 'Mm' },
|
||||
tag: null,
|
||||
__geoMeta: {
|
||||
id: expect.any(String),
|
||||
@ -35,6 +36,7 @@ const mySketch001 = startSketchOn('XY')
|
||||
type: 'ToPoint',
|
||||
tag: null,
|
||||
to: [-1.59, -1.54],
|
||||
units: { type: 'Mm' },
|
||||
from: [0, 0],
|
||||
__geoMeta: {
|
||||
sourceRange: [expect.any(Number), expect.any(Number), 0],
|
||||
@ -45,6 +47,7 @@ const mySketch001 = startSketchOn('XY')
|
||||
type: 'ToPoint',
|
||||
to: [0.46, -5.82],
|
||||
from: [-1.59, -1.54],
|
||||
units: { type: 'Mm' },
|
||||
tag: null,
|
||||
__geoMeta: {
|
||||
sourceRange: [expect.any(Number), expect.any(Number), 0],
|
||||
@ -111,6 +114,7 @@ const mySketch001 = startSketchOn('XY')
|
||||
type: 'ToPoint',
|
||||
from: [0, 0],
|
||||
to: [-1.59, -1.54],
|
||||
units: { type: 'Mm' },
|
||||
tag: null,
|
||||
__geoMeta: {
|
||||
id: expect.any(String),
|
||||
@ -121,6 +125,7 @@ const mySketch001 = startSketchOn('XY')
|
||||
type: 'ToPoint',
|
||||
from: [-1.59, -1.54],
|
||||
to: [0.46, -5.82],
|
||||
units: { type: 'Mm' },
|
||||
tag: null,
|
||||
__geoMeta: {
|
||||
id: expect.any(String),
|
||||
@ -229,6 +234,7 @@ const sk2 = startSketchOn('XY')
|
||||
type: 'ToPoint',
|
||||
from: [0, 0],
|
||||
to: [-2.5, 0],
|
||||
units: { type: 'Mm' },
|
||||
tag: null,
|
||||
__geoMeta: {
|
||||
id: expect.any(String),
|
||||
@ -239,6 +245,7 @@ const sk2 = startSketchOn('XY')
|
||||
type: 'ToPoint',
|
||||
from: [-2.5, 0],
|
||||
to: [0, 10],
|
||||
units: { type: 'Mm' },
|
||||
tag: {
|
||||
end: expect.any(Number),
|
||||
start: expect.any(Number),
|
||||
@ -254,6 +261,7 @@ const sk2 = startSketchOn('XY')
|
||||
type: 'ToPoint',
|
||||
from: [0, 10],
|
||||
to: [2.5, 0],
|
||||
units: { type: 'Mm' },
|
||||
tag: null,
|
||||
__geoMeta: {
|
||||
id: expect.any(String),
|
||||
@ -335,6 +343,7 @@ const sk2 = startSketchOn('XY')
|
||||
type: 'ToPoint',
|
||||
from: [0, 0],
|
||||
to: [-2.5, 0],
|
||||
units: { type: 'Mm' },
|
||||
tag: null,
|
||||
__geoMeta: {
|
||||
id: expect.any(String),
|
||||
@ -345,6 +354,7 @@ const sk2 = startSketchOn('XY')
|
||||
type: 'ToPoint',
|
||||
from: [-2.5, 0],
|
||||
to: [0, 3],
|
||||
units: { type: 'Mm' },
|
||||
tag: {
|
||||
end: expect.any(Number),
|
||||
start: expect.any(Number),
|
||||
@ -360,6 +370,7 @@ const sk2 = startSketchOn('XY')
|
||||
type: 'ToPoint',
|
||||
from: [0, 3],
|
||||
to: [2.5, 0],
|
||||
units: { type: 'Mm' },
|
||||
tag: null,
|
||||
__geoMeta: {
|
||||
id: expect.any(String),
|
||||
|
||||
@ -72,6 +72,7 @@ const newVar = myVar + 1`
|
||||
type: 'ToPoint',
|
||||
to: [0, 2],
|
||||
from: [0, 0],
|
||||
units: { type: 'Mm' },
|
||||
__geoMeta: {
|
||||
sourceRange: [expect.any(Number), expect.any(Number), 0],
|
||||
id: expect.any(String),
|
||||
@ -87,6 +88,7 @@ const newVar = myVar + 1`
|
||||
type: 'ToPoint',
|
||||
to: [2, 3],
|
||||
from: [0, 2],
|
||||
units: { type: 'Mm' },
|
||||
tag: null,
|
||||
__geoMeta: {
|
||||
sourceRange: [expect.any(Number), expect.any(Number), 0],
|
||||
@ -97,6 +99,7 @@ const newVar = myVar + 1`
|
||||
type: 'ToPoint',
|
||||
to: [5, -1],
|
||||
from: [2, 3],
|
||||
units: { type: 'Mm' },
|
||||
__geoMeta: {
|
||||
sourceRange: [expect.any(Number), expect.any(Number), 0],
|
||||
id: expect.any(String),
|
||||
@ -165,6 +168,7 @@ const newVar = myVar + 1`
|
||||
start: {
|
||||
to: [0, 0],
|
||||
from: [0, 0],
|
||||
units: { type: 'Mm' },
|
||||
tag: null,
|
||||
__geoMeta: {
|
||||
id: expect.any(String),
|
||||
@ -188,6 +192,7 @@ const newVar = myVar + 1`
|
||||
type: 'ToPoint',
|
||||
to: [1, 1],
|
||||
from: [0, 0],
|
||||
units: { type: 'Mm' },
|
||||
tag: null,
|
||||
__geoMeta: {
|
||||
sourceRange: [expect.any(Number), expect.any(Number), 0],
|
||||
@ -198,6 +203,7 @@ const newVar = myVar + 1`
|
||||
type: 'ToPoint',
|
||||
to: [0, 1],
|
||||
from: [1, 1],
|
||||
units: { type: 'Mm' },
|
||||
__geoMeta: {
|
||||
sourceRange: [expect.any(Number), expect.any(Number), 0],
|
||||
id: expect.any(String),
|
||||
@ -213,6 +219,7 @@ const newVar = myVar + 1`
|
||||
type: 'ToPoint',
|
||||
to: [1, 1],
|
||||
from: [0, 1],
|
||||
units: { type: 'Mm' },
|
||||
tag: null,
|
||||
__geoMeta: {
|
||||
sourceRange: [expect.any(Number), expect.any(Number), 0],
|
||||
|
||||
38
src/lang/modifyAst/deleteSelection.ts
Normal file
@ -0,0 +1,38 @@
|
||||
import { Selection } from 'lib/selections'
|
||||
import { getFaceDetails } from 'clientSideScene/sceneEntities'
|
||||
import { deleteFromSelection } from 'lang/modifyAst'
|
||||
import { codeManager, engineCommandManager, kclManager } from 'lib/singletons'
|
||||
import { err } from 'lib/trap'
|
||||
import { executeAst } from 'lang/langHelpers'
|
||||
|
||||
export const deletionErrorMessage =
|
||||
'Unable to delete selection. Please edit manually in code pane.'
|
||||
|
||||
export async function deleteSelectionPromise(
|
||||
selection: Selection
|
||||
): Promise<Error | void> {
|
||||
let ast = kclManager.ast
|
||||
|
||||
const modifiedAst = await deleteFromSelection(
|
||||
ast,
|
||||
selection,
|
||||
kclManager.variables,
|
||||
engineCommandManager.artifactGraph,
|
||||
getFaceDetails
|
||||
)
|
||||
if (err(modifiedAst)) {
|
||||
return new Error(deletionErrorMessage)
|
||||
}
|
||||
|
||||
const testExecute = await executeAst({
|
||||
ast: modifiedAst,
|
||||
engineCommandManager,
|
||||
isMock: true,
|
||||
})
|
||||
if (testExecute.errors.length) {
|
||||
return new Error(deletionErrorMessage)
|
||||
}
|
||||
|
||||
await kclManager.updateAst(modifiedAst, true)
|
||||
await codeManager.updateEditorWithAstAndWriteToFile(modifiedAst)
|
||||
}
|
||||
@ -589,7 +589,12 @@ class EngineConnection extends EventTarget {
|
||||
}
|
||||
|
||||
const initiateConnectingExclusive = () => {
|
||||
if (that.triggeredStart) return
|
||||
if (!that.sdpAnswer) {
|
||||
console.log('SDP answer is not yet available')
|
||||
return false
|
||||
}
|
||||
|
||||
if (that.triggeredStart) return false
|
||||
that.triggeredStart = true
|
||||
|
||||
// Start connecting.
|
||||
@ -611,6 +616,7 @@ class EngineConnection extends EventTarget {
|
||||
type: ConnectingType.SetRemoteDescription,
|
||||
},
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
this.onIceCandidate = (event: RTCPeerConnectionIceEvent) => {
|
||||
@ -643,7 +649,9 @@ class EngineConnection extends EventTarget {
|
||||
// Sometimes the remote end doesn't report the end of candidates.
|
||||
// They have 3 seconds to.
|
||||
setTimeout(() => {
|
||||
initiateConnectingExclusive()
|
||||
if (initiateConnectingExclusive()) {
|
||||
console.warn('connected after 3 second delay')
|
||||
}
|
||||
}, 3000)
|
||||
}
|
||||
this.pc?.addEventListener?.('icecandidate', this.onIceCandidate)
|
||||
@ -1525,9 +1533,9 @@ export class EngineCommandManager extends EventTarget {
|
||||
return
|
||||
}
|
||||
|
||||
const additionalSettings = this.settings.enableSSAO
|
||||
? '&post_effect=ssao'
|
||||
: ''
|
||||
let additionalSettings = this.settings.enableSSAO ? '&post_effect=ssao' : ''
|
||||
additionalSettings +=
|
||||
'&show_grid=' + (this.settings.showScaleGrid ? 'true' : 'false')
|
||||
const pool = !this.settings.pool ? '' : `&pool=${this.settings.pool}`
|
||||
const url = `${VITE_KC_API_WS_MODELING_URL}?video_res_width=${width}&video_res_height=${height}${additionalSettings}${pool}`
|
||||
this.engineConnection = new EngineConnection({
|
||||
|
||||
@ -386,6 +386,7 @@ part001 = startSketchOn('XY')
|
||||
type: 'ToPoint',
|
||||
to: [5.62, 1.79],
|
||||
from: [3.48, 0.44],
|
||||
units: { type: 'Mm' },
|
||||
tag: null,
|
||||
})
|
||||
})
|
||||
@ -401,6 +402,7 @@ part001 = startSketchOn('XY')
|
||||
expect(segment).toEqual({
|
||||
to: [0, 0.04],
|
||||
from: [0, 0.04],
|
||||
units: { type: 'Mm' },
|
||||
tag: null,
|
||||
type: 'Base',
|
||||
})
|
||||
|
||||
@ -295,6 +295,7 @@ export interface ExecState {
|
||||
artifacts: { [key in ArtifactId]?: RustArtifact }
|
||||
artifactCommands: ArtifactCommand[]
|
||||
artifactGraph: ArtifactGraph
|
||||
errors: CompilationError[]
|
||||
}
|
||||
|
||||
/**
|
||||
@ -308,6 +309,7 @@ export function emptyExecState(): ExecState {
|
||||
artifacts: {},
|
||||
artifactCommands: [],
|
||||
artifactGraph: defaultArtifactGraph(),
|
||||
errors: [],
|
||||
}
|
||||
}
|
||||
|
||||
@ -333,6 +335,7 @@ function execStateFromRust(
|
||||
artifacts: execOutcome.artifacts,
|
||||
artifactCommands: execOutcome.artifactCommands,
|
||||
artifactGraph,
|
||||
errors: execOutcome.errors,
|
||||
}
|
||||
}
|
||||
|
||||
@ -343,6 +346,7 @@ function mockExecStateFromRust(execOutcome: RustExecOutcome): ExecState {
|
||||
artifacts: execOutcome.artifacts,
|
||||
artifactCommands: execOutcome.artifactCommands,
|
||||
artifactGraph: new Map<ArtifactId, Artifact>(),
|
||||
errors: execOutcome.errors,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -106,6 +106,7 @@ export type ModelingCommandSchema = {
|
||||
prompt: string
|
||||
selection: Selections
|
||||
}
|
||||
'Delete selection': {}
|
||||
}
|
||||
|
||||
export const modelingMachineCommandConfig: StateMachineCommandSetConfig<
|
||||
|
||||
@ -44,7 +44,6 @@ import {
|
||||
addHelix,
|
||||
addOffsetPlane,
|
||||
addSweep,
|
||||
deleteFromSelection,
|
||||
extrudeSketch,
|
||||
loftSketches,
|
||||
} from 'lang/modifyAst'
|
||||
@ -70,12 +69,10 @@ import {
|
||||
} from 'components/Toolbar/SetAbsDistance'
|
||||
import { ModelingCommandSchema } from 'lib/commandBarConfigs/modelingCommandConfig'
|
||||
import { err, reportRejection, trap } from 'lib/trap'
|
||||
import { getFaceDetails } from 'clientSideScene/sceneEntities'
|
||||
import { DefaultPlaneStr } from 'lib/planes'
|
||||
import { uuidv4 } from 'lib/utils'
|
||||
import { Coords2d } from 'lang/std/sketch'
|
||||
import { deleteSegment } from 'clientSideScene/ClientSideSceneComp'
|
||||
import { executeAst } from 'lang/langHelpers'
|
||||
import toast from 'react-hot-toast'
|
||||
import { ToolbarModeName } from 'lib/toolbar'
|
||||
import { quaternionFromUpNForward } from 'clientSideScene/helpers'
|
||||
@ -83,6 +80,11 @@ import { Mesh, Vector3 } from 'three'
|
||||
import { MachineManager } from 'components/MachineManagerProvider'
|
||||
import { addShell } from 'lang/modifyAst/addShell'
|
||||
import { KclCommandValue } from 'lib/commandTypes'
|
||||
import { ModelingMachineContext } from 'components/ModelingMachineProvider'
|
||||
import {
|
||||
deleteSelectionPromise,
|
||||
deletionErrorMessage,
|
||||
} from 'lang/modifyAst/deleteSelection'
|
||||
import { getPathsFromPlaneArtifact } from 'lang/std/artifactGraph'
|
||||
import { createProfileStartHandle } from 'clientSideScene/segments'
|
||||
import { DRAFT_POINT } from 'clientSideScene/sceneInfra'
|
||||
@ -308,6 +310,10 @@ export type ModelingMachineEvent =
|
||||
| { type: 'Helix'; data: ModelingCommandSchema['Helix'] }
|
||||
| { type: 'Text-to-CAD'; data: ModelingCommandSchema['Text-to-CAD'] }
|
||||
| { type: 'Prompt-to-edit'; data: ModelingCommandSchema['Prompt-to-edit'] }
|
||||
| {
|
||||
type: 'Delete selection'
|
||||
data: ModelingCommandSchema['Delete selection']
|
||||
}
|
||||
| {
|
||||
type: 'Add rectangle origin'
|
||||
data: [x: number, y: number]
|
||||
@ -731,38 +737,6 @@ export const modelingMachine = setup({
|
||||
}
|
||||
})().catch(reportRejection)
|
||||
},
|
||||
'AST delete selection': ({ context: { selectionRanges } }) => {
|
||||
;(async () => {
|
||||
const errorMessage =
|
||||
'Unable to delete selection. Please edit manually in code pane.'
|
||||
let ast = kclManager.ast
|
||||
|
||||
const modifiedAst = await deleteFromSelection(
|
||||
ast,
|
||||
selectionRanges.graphSelections[0],
|
||||
kclManager.variables,
|
||||
engineCommandManager.artifactGraph,
|
||||
getFaceDetails
|
||||
)
|
||||
if (err(modifiedAst)) {
|
||||
toast.error(errorMessage)
|
||||
return
|
||||
}
|
||||
|
||||
const testExecute = await executeAst({
|
||||
ast: modifiedAst,
|
||||
engineCommandManager,
|
||||
isMock: true,
|
||||
})
|
||||
if (testExecute.errors.length) {
|
||||
toast.error(errorMessage)
|
||||
return
|
||||
}
|
||||
|
||||
await kclManager.updateAst(modifiedAst, true)
|
||||
await codeManager.updateEditorWithAstAndWriteToFile(modifiedAst)
|
||||
})().catch(reportRejection)
|
||||
},
|
||||
'set selection filter to curves only': () => {
|
||||
;(async () => {
|
||||
await engineCommandManager.sendSceneCommand({
|
||||
@ -2170,6 +2144,34 @@ export const modelingMachine = setup({
|
||||
input: ModelingCommandSchema['Prompt-to-edit']
|
||||
}) => {}
|
||||
),
|
||||
deleteSelectionAstMod: fromPromise(
|
||||
({
|
||||
input: { selectionRanges },
|
||||
}: {
|
||||
input: { selectionRanges: Selections }
|
||||
}) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!selectionRanges) {
|
||||
reject(new Error(deletionErrorMessage))
|
||||
}
|
||||
|
||||
const selection = selectionRanges.graphSelections[0]
|
||||
if (!selectionRanges) {
|
||||
reject(new Error(deletionErrorMessage))
|
||||
}
|
||||
|
||||
deleteSelectionPromise(selection)
|
||||
.then((result) => {
|
||||
if (err(result)) {
|
||||
reject(result)
|
||||
return
|
||||
}
|
||||
resolve(result)
|
||||
})
|
||||
.catch(reject)
|
||||
})
|
||||
}
|
||||
),
|
||||
},
|
||||
// end actors
|
||||
}).createMachine({
|
||||
@ -2243,10 +2245,9 @@ export const modelingMachine = setup({
|
||||
},
|
||||
|
||||
'Delete selection': {
|
||||
target: 'idle',
|
||||
target: 'Applying Delete selection',
|
||||
guard: 'has valid selection for deletion',
|
||||
actions: ['AST delete selection'],
|
||||
reenter: false,
|
||||
reenter: true,
|
||||
},
|
||||
|
||||
'Text-to-CAD': {
|
||||
@ -3366,6 +3367,28 @@ export const modelingMachine = setup({
|
||||
onError: 'idle',
|
||||
},
|
||||
},
|
||||
|
||||
'Applying Delete selection': {
|
||||
invoke: {
|
||||
src: 'deleteSelectionAstMod',
|
||||
id: 'deleteSelectionAstMod',
|
||||
|
||||
input: ({ event, context }) => {
|
||||
return { selectionRanges: context.selectionRanges }
|
||||
},
|
||||
|
||||
onDone: 'idle',
|
||||
onError: {
|
||||
target: 'idle',
|
||||
reenter: true,
|
||||
actions: ({ event }) => {
|
||||
if ('error' in event && err(event.error)) {
|
||||
toast.error(event.error.message)
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
initial: 'idle',
|
||||
|
||||