renames sketch group/extrude group (#4016)
* renames Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> fixups Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> udpates Signed-off-by: Jess Frazelle <github@jessfraz.com> fix parse Signed-off-by: Jess Frazelle <github@jessfraz.com> fix typos Signed-off-by: Jess Frazelle <github@jessfraz.com> docs Signed-off-by: Jess Frazelle <github@jessfraz.com> update tests Signed-off-by: Jess Frazelle <github@jessfraz.com> empty * fix; Signed-off-by: Jess Frazelle <github@jessfraz.com> * new Signed-off-by: Jess Frazelle <github@jessfraz.com> * add the types pages Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * Look at this (photo)Graph *in the voice of Nickelback* * empty * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
@ -1,2 +1,3 @@
|
|||||||
src/wasm-lib/*
|
src/wasm-lib/*
|
||||||
*.typegen.ts
|
*.typegen.ts
|
||||||
|
packages/codemirror-lsp-client/dist/*
|
||||||
|
2
.github/workflows/generate-website-docs.yml
vendored
2
.github/workflows/generate-website-docs.yml
vendored
@ -38,8 +38,10 @@ jobs:
|
|||||||
mkdir -p documentation/content/pages/docs/kcl/
|
mkdir -p documentation/content/pages/docs/kcl/
|
||||||
# cleanup old
|
# cleanup old
|
||||||
rm -rf documentation/content/pages/docs/kcl/*.md
|
rm -rf documentation/content/pages/docs/kcl/*.md
|
||||||
|
rm -rf documentation/content/pages/docs/kcl/types
|
||||||
# move new
|
# move new
|
||||||
mv -f docs/kcl/*.md documentation/content/pages/docs/kcl/
|
mv -f docs/kcl/*.md documentation/content/pages/docs/kcl/
|
||||||
|
mv -f docs/kcl/types documentation/content/pages/docs/kcl/
|
||||||
- name: commit the changes in the docs repo
|
- name: commit the changes in the docs repo
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
@ -9,7 +9,7 @@ Compute the angle (in degrees) in o
|
|||||||
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
angleToMatchLengthX(tag: TagIdentifier, to: number, sketch_group: SketchGroup) -> number
|
angleToMatchLengthX(tag: TagIdentifier, to: number, sketch: Sketch) -> number
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ angleToMatchLengthX(tag: TagIdentifier, to: number, sketch_group: SketchGroup) -
|
|||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `tag` | [`TagIdentifier`](/docs/kcl/types#tag-identifier) | | Yes |
|
| `tag` | [`TagIdentifier`](/docs/kcl/types#tag-identifier) | | Yes |
|
||||||
| `to` | `number` | | Yes |
|
| `to` | `number` | | Yes |
|
||||||
| `sketch_group` | [`SketchGroup`](/docs/kcl/types/SketchGroup) | A sketch group is a collection of paths. | Yes |
|
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | A sketch is a collection of paths. | Yes |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ Returns the angle to match the given length for y.
|
|||||||
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
angleToMatchLengthY(tag: TagIdentifier, to: number, sketch_group: SketchGroup) -> number
|
angleToMatchLengthY(tag: TagIdentifier, to: number, sketch: Sketch) -> number
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ angleToMatchLengthY(tag: TagIdentifier, to: number, sketch_group: SketchGroup) -
|
|||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `tag` | [`TagIdentifier`](/docs/kcl/types#tag-identifier) | | Yes |
|
| `tag` | [`TagIdentifier`](/docs/kcl/types#tag-identifier) | | Yes |
|
||||||
| `to` | `number` | | Yes |
|
| `to` | `number` | | Yes |
|
||||||
| `sketch_group` | [`SketchGroup`](/docs/kcl/types/SketchGroup) | A sketch group is a collection of paths. | Yes |
|
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | A sketch is a collection of paths. | Yes |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ Draw a line segment relative to the current origin using the polar
|
|||||||
measure of some angle and distance.
|
measure of some angle and distance.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
angledLine(data: AngledLineData, sketch_group: SketchGroup, tag?: TagDeclarator) -> SketchGroup
|
angledLine(data: AngledLineData, sketch: Sketch, tag?: TagDeclarator) -> Sketch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -18,12 +18,12 @@ angledLine(data: AngledLineData, sketch_group: SketchGroup, tag?: TagDeclarator)
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `data` | [`AngledLineData`](/docs/kcl/types/AngledLineData) | Data to draw an angled line. | Yes |
|
| `data` | [`AngledLineData`](/docs/kcl/types/AngledLineData) | Data to draw an angled line. | Yes |
|
||||||
| `sketch_group` | [`SketchGroup`](/docs/kcl/types/SketchGroup) | A sketch group is a collection of paths. | Yes |
|
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | A sketch is a collection of paths. | Yes |
|
||||||
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`SketchGroup`](/docs/kcl/types/SketchGroup) - A sketch group is a collection of paths.
|
[`Sketch`](/docs/kcl/types/Sketch) - A sketch is a collection of paths.
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -9,7 +9,7 @@ Create a line segment from the current 2-dimensional sketch origin
|
|||||||
along some angle (in degrees) for some relative length in the 'x' dimension.
|
along some angle (in degrees) for some relative length in the 'x' dimension.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
angledLineOfXLength(data: AngledLineData, sketch_group: SketchGroup, tag?: TagDeclarator) -> SketchGroup
|
angledLineOfXLength(data: AngledLineData, sketch: Sketch, tag?: TagDeclarator) -> Sketch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -18,12 +18,12 @@ angledLineOfXLength(data: AngledLineData, sketch_group: SketchGroup, tag?: TagDe
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `data` | [`AngledLineData`](/docs/kcl/types/AngledLineData) | Data to draw an angled line. | Yes |
|
| `data` | [`AngledLineData`](/docs/kcl/types/AngledLineData) | Data to draw an angled line. | Yes |
|
||||||
| `sketch_group` | [`SketchGroup`](/docs/kcl/types/SketchGroup) | A sketch group is a collection of paths. | Yes |
|
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | A sketch is a collection of paths. | Yes |
|
||||||
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`SketchGroup`](/docs/kcl/types/SketchGroup) - A sketch group is a collection of paths.
|
[`Sketch`](/docs/kcl/types/Sketch) - A sketch is a collection of paths.
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -9,7 +9,7 @@ Create a line segment from the current 2-dimensional sketch origin
|
|||||||
along some angle (in degrees) for some relative length in the 'y' dimension.
|
along some angle (in degrees) for some relative length in the 'y' dimension.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
angledLineOfYLength(data: AngledLineData, sketch_group: SketchGroup, tag?: TagDeclarator) -> SketchGroup
|
angledLineOfYLength(data: AngledLineData, sketch: Sketch, tag?: TagDeclarator) -> Sketch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -18,12 +18,12 @@ angledLineOfYLength(data: AngledLineData, sketch_group: SketchGroup, tag?: TagDe
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `data` | [`AngledLineData`](/docs/kcl/types/AngledLineData) | Data to draw an angled line. | Yes |
|
| `data` | [`AngledLineData`](/docs/kcl/types/AngledLineData) | Data to draw an angled line. | Yes |
|
||||||
| `sketch_group` | [`SketchGroup`](/docs/kcl/types/SketchGroup) | A sketch group is a collection of paths. | Yes |
|
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | A sketch is a collection of paths. | Yes |
|
||||||
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`SketchGroup`](/docs/kcl/types/SketchGroup) - A sketch group is a collection of paths.
|
[`Sketch`](/docs/kcl/types/Sketch) - A sketch is a collection of paths.
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -9,7 +9,7 @@ Draw an angled line from the current origin, constructing a line segment
|
|||||||
such that the newly created line intersects the desired target line segment.
|
such that the newly created line intersects the desired target line segment.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
angledLineThatIntersects(data: AngledLineThatIntersectsData, sketch_group: SketchGroup, tag?: TagDeclarator) -> SketchGroup
|
angledLineThatIntersects(data: AngledLineThatIntersectsData, sketch: Sketch, tag?: TagDeclarator) -> Sketch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -18,12 +18,12 @@ angledLineThatIntersects(data: AngledLineThatIntersectsData, sketch_group: Sketc
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `data` | [`AngledLineThatIntersectsData`](/docs/kcl/types/AngledLineThatIntersectsData) | Data for drawing an angled line that intersects with a given line. | Yes |
|
| `data` | [`AngledLineThatIntersectsData`](/docs/kcl/types/AngledLineThatIntersectsData) | Data for drawing an angled line that intersects with a given line. | Yes |
|
||||||
| `sketch_group` | [`SketchGroup`](/docs/kcl/types/SketchGroup) | A sketch group is a collection of paths. | Yes |
|
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | A sketch is a collection of paths. | Yes |
|
||||||
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`SketchGroup`](/docs/kcl/types/SketchGroup) - A sketch group is a collection of paths.
|
[`Sketch`](/docs/kcl/types/Sketch) - A sketch is a collection of paths.
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -9,7 +9,7 @@ Create a line segment from the current 2-dimensional sketch origin
|
|||||||
along some angle (in degrees) for some length, ending at the provided value in the 'x' dimension.
|
along some angle (in degrees) for some length, ending at the provided value in the 'x' dimension.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
angledLineToX(data: AngledLineToData, sketch_group: SketchGroup, tag?: TagDeclarator) -> SketchGroup
|
angledLineToX(data: AngledLineToData, sketch: Sketch, tag?: TagDeclarator) -> Sketch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -18,12 +18,12 @@ angledLineToX(data: AngledLineToData, sketch_group: SketchGroup, tag?: TagDeclar
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `data` | [`AngledLineToData`](/docs/kcl/types/AngledLineToData) | Data to draw an angled line to a point. | Yes |
|
| `data` | [`AngledLineToData`](/docs/kcl/types/AngledLineToData) | Data to draw an angled line to a point. | Yes |
|
||||||
| `sketch_group` | [`SketchGroup`](/docs/kcl/types/SketchGroup) | A sketch group is a collection of paths. | Yes |
|
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | A sketch is a collection of paths. | Yes |
|
||||||
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`SketchGroup`](/docs/kcl/types/SketchGroup) - A sketch group is a collection of paths.
|
[`Sketch`](/docs/kcl/types/Sketch) - A sketch is a collection of paths.
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -9,7 +9,7 @@ Create a line segment from the current 2-dimensional sketch origin
|
|||||||
along some angle (in degrees) for some length, ending at the provided value in the 'y' dimension.
|
along some angle (in degrees) for some length, ending at the provided value in the 'y' dimension.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
angledLineToY(data: AngledLineToData, sketch_group: SketchGroup, tag?: TagDeclarator) -> SketchGroup
|
angledLineToY(data: AngledLineToData, sketch: Sketch, tag?: TagDeclarator) -> Sketch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -18,12 +18,12 @@ angledLineToY(data: AngledLineToData, sketch_group: SketchGroup, tag?: TagDeclar
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `data` | [`AngledLineToData`](/docs/kcl/types/AngledLineToData) | Data to draw an angled line to a point. | Yes |
|
| `data` | [`AngledLineToData`](/docs/kcl/types/AngledLineToData) | Data to draw an angled line to a point. | Yes |
|
||||||
| `sketch_group` | [`SketchGroup`](/docs/kcl/types/SketchGroup) | A sketch group is a collection of paths. | Yes |
|
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | A sketch is a collection of paths. | Yes |
|
||||||
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`SketchGroup`](/docs/kcl/types/SketchGroup) - A sketch group is a collection of paths.
|
[`Sketch`](/docs/kcl/types/Sketch) - A sketch is a collection of paths.
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -11,7 +11,7 @@ The arc is constructed such that the current position of the sketch is placed al
|
|||||||
Unless this makes a lot of sense and feels like what you're looking for to construct your shape, you're likely looking for tangentialArc.
|
Unless this makes a lot of sense and feels like what you're looking for to construct your shape, you're likely looking for tangentialArc.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
arc(data: ArcData, sketch_group: SketchGroup, tag?: TagDeclarator) -> SketchGroup
|
arc(data: ArcData, sketch: Sketch, tag?: TagDeclarator) -> Sketch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -20,12 +20,12 @@ arc(data: ArcData, sketch_group: SketchGroup, tag?: TagDeclarator) -> SketchGrou
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `data` | [`ArcData`](/docs/kcl/types/ArcData) | Data to draw an arc. | Yes |
|
| `data` | [`ArcData`](/docs/kcl/types/ArcData) | Data to draw an arc. | Yes |
|
||||||
| `sketch_group` | [`SketchGroup`](/docs/kcl/types/SketchGroup) | A sketch group is a collection of paths. | Yes |
|
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | A sketch is a collection of paths. | Yes |
|
||||||
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`SketchGroup`](/docs/kcl/types/SketchGroup) - A sketch group is a collection of paths.
|
[`Sketch`](/docs/kcl/types/Sketch) - A sketch is a collection of paths.
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -9,7 +9,7 @@ Take a starting value. Then, for each element of an array, calculate the next va
|
|||||||
using the previous value and the element.
|
using the previous value and the element.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
arrayReduce(array: [u64], start: SketchGroup, reduce_fn: FunctionParam) -> SketchGroup
|
arrayReduce(array: [u64], start: Sketch, reduce_fn: FunctionParam) -> Sketch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -18,12 +18,12 @@ arrayReduce(array: [u64], start: SketchGroup, reduce_fn: FunctionParam) -> Sketc
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `array` | [`[u64]`](/docs/kcl/types/[u64]) | | Yes |
|
| `array` | [`[u64]`](/docs/kcl/types/[u64]) | | Yes |
|
||||||
| `start` | [`SketchGroup`](/docs/kcl/types/SketchGroup) | A sketch group is a collection of paths. | Yes |
|
| `start` | [`Sketch`](/docs/kcl/types/Sketch) | A sketch is a collection of paths. | Yes |
|
||||||
| `reduce_fn` | `FunctionParam` | | Yes |
|
| `reduce_fn` | `FunctionParam` | | Yes |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`SketchGroup`](/docs/kcl/types/SketchGroup) - A sketch group is a collection of paths.
|
[`Sketch`](/docs/kcl/types/Sketch) - A sketch is a collection of paths.
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
@ -31,8 +31,8 @@ arrayReduce(array: [u64], start: SketchGroup, reduce_fn: FunctionParam) -> Sketc
|
|||||||
```js
|
```js
|
||||||
fn decagon = (radius) => {
|
fn decagon = (radius) => {
|
||||||
let step = 1 / 10 * tau()
|
let step = 1 / 10 * tau()
|
||||||
let sketch = startSketchAt([cos(0) * radius, sin(0) * radius])
|
let sketch001 = startSketchAt([cos(0) * radius, sin(0) * radius])
|
||||||
return arrayReduce([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], sketch, (i, sg) => {
|
return arrayReduce([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], sketch001, (i, sg) => {
|
||||||
let x = cos(step * i) * radius
|
let x = cos(step * i) * radius
|
||||||
let y = sin(step * i) * radius
|
let y = sin(step * i) * radius
|
||||||
return lineTo([x, y], sg)
|
return lineTo([x, y], sg)
|
||||||
|
@ -9,7 +9,7 @@ Draw a smooth, continuous, curved line segment from the current origin to
|
|||||||
the desired (x, y), using a number of control points to shape the curve's shape.
|
the desired (x, y), using a number of control points to shape the curve's shape.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
bezierCurve(data: BezierData, sketch_group: SketchGroup, tag?: TagDeclarator) -> SketchGroup
|
bezierCurve(data: BezierData, sketch: Sketch, tag?: TagDeclarator) -> Sketch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -18,12 +18,12 @@ bezierCurve(data: BezierData, sketch_group: SketchGroup, tag?: TagDeclarator) ->
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `data` | [`BezierData`](/docs/kcl/types/BezierData) | Data to draw a bezier curve. | Yes |
|
| `data` | [`BezierData`](/docs/kcl/types/BezierData) | Data to draw a bezier curve. | Yes |
|
||||||
| `sketch_group` | [`SketchGroup`](/docs/kcl/types/SketchGroup) | A sketch group is a collection of paths. | Yes |
|
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | A sketch is a collection of paths. | Yes |
|
||||||
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`SketchGroup`](/docs/kcl/types/SketchGroup) - A sketch group is a collection of paths.
|
[`Sketch`](/docs/kcl/types/Sketch) - A sketch is a collection of paths.
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -9,7 +9,7 @@ Cut a straight transitional edge along a tagged path.
|
|||||||
Chamfer is similar in function and use to a fillet, except a fillet will blend the transition along an edge, rather than cut a sharp, straight transitional edge.
|
Chamfer is similar in function and use to a fillet, except a fillet will blend the transition along an edge, rather than cut a sharp, straight transitional edge.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
chamfer(data: ChamferData, extrude_group: ExtrudeGroup, tag?: TagDeclarator) -> ExtrudeGroup
|
chamfer(data: ChamferData, solid: Solid, tag?: TagDeclarator) -> Solid
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -18,12 +18,12 @@ chamfer(data: ChamferData, extrude_group: ExtrudeGroup, tag?: TagDeclarator) ->
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `data` | [`ChamferData`](/docs/kcl/types/ChamferData) | Data for chamfers. | Yes |
|
| `data` | [`ChamferData`](/docs/kcl/types/ChamferData) | Data for chamfers. | Yes |
|
||||||
| `extrude_group` | [`ExtrudeGroup`](/docs/kcl/types/ExtrudeGroup) | An extrude group is a collection of extrude surfaces. | Yes |
|
| `solid` | [`Solid`](/docs/kcl/types/Solid) | An solid is a collection of extrude surfaces. | Yes |
|
||||||
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`ExtrudeGroup`](/docs/kcl/types/ExtrudeGroup) - An extrude group is a collection of extrude surfaces.
|
[`Solid`](/docs/kcl/types/Solid) - An solid is a collection of extrude surfaces.
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -9,7 +9,7 @@ Construct a 2-dimensional circle, of the specified radius, centered at
|
|||||||
the provided (x, y) origin point.
|
the provided (x, y) origin point.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
circle(data: CircleData, sketch_surface_or_group: SketchSurfaceOrGroup, tag?: TagDeclarator) -> SketchGroup
|
circle(data: CircleData, sketch_surface_or_group: SketchOrSurface, tag?: TagDeclarator) -> Sketch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -18,12 +18,12 @@ circle(data: CircleData, sketch_surface_or_group: SketchSurfaceOrGroup, tag?: Ta
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `data` | [`CircleData`](/docs/kcl/types/CircleData) | Data for drawing an circle | Yes |
|
| `data` | [`CircleData`](/docs/kcl/types/CircleData) | Data for drawing an circle | Yes |
|
||||||
| `sketch_surface_or_group` | [`SketchSurfaceOrGroup`](/docs/kcl/types/SketchSurfaceOrGroup) | A sketch surface or a sketch group. | Yes |
|
| `sketch_surface_or_group` | [`SketchOrSurface`](/docs/kcl/types/SketchOrSurface) | A sketch surface or a sketch. | Yes |
|
||||||
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`SketchGroup`](/docs/kcl/types/SketchGroup) - A sketch group is a collection of paths.
|
[`Sketch`](/docs/kcl/types/Sketch) - A sketch is a collection of paths.
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -9,7 +9,7 @@ Construct a line segment from the current origin back to the profile's
|
|||||||
origin, ensuring the resulting 2-dimensional sketch is not open-ended.
|
origin, ensuring the resulting 2-dimensional sketch is not open-ended.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
close(sketch_group: SketchGroup, tag?: TagDeclarator) -> SketchGroup
|
close(sketch: Sketch, tag?: TagDeclarator) -> Sketch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -17,12 +17,12 @@ close(sketch_group: SketchGroup, tag?: TagDeclarator) -> SketchGroup
|
|||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `sketch_group` | [`SketchGroup`](/docs/kcl/types/SketchGroup) | A sketch group is a collection of paths. | Yes |
|
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | A sketch is a collection of paths. | Yes |
|
||||||
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`SketchGroup`](/docs/kcl/types/SketchGroup) - A sketch group is a collection of paths.
|
[`Sketch`](/docs/kcl/types/Sketch) - A sketch is a collection of paths.
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -9,7 +9,7 @@ Extend a 2-dimensional sketch through a third dimension in order to
|
|||||||
create new 3-dimensional volume, or if extruded into an existing volume, cut into an existing solid.
|
create new 3-dimensional volume, or if extruded into an existing volume, cut into an existing solid.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
extrude(length: number, sketch_group_set: SketchGroupSet) -> ExtrudeGroupSet
|
extrude(length: number, sketch_set: SketchSet) -> SolidSet
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -18,11 +18,11 @@ extrude(length: number, sketch_group_set: SketchGroupSet) -> ExtrudeGroupSet
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `length` | `number` | | Yes |
|
| `length` | `number` | | Yes |
|
||||||
| `sketch_group_set` | [`SketchGroupSet`](/docs/kcl/types/SketchGroupSet) | A sketch group or a group of sketch groups. | Yes |
|
| `sketch_set` | [`SketchSet`](/docs/kcl/types/SketchSet) | A sketch or a group of sketches. | Yes |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`ExtrudeGroupSet`](/docs/kcl/types/ExtrudeGroupSet) - A extrude group or a group of extrude groups.
|
[`SolidSet`](/docs/kcl/types/SolidSet) - A solid or a group of solids.
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -9,7 +9,7 @@ Blend a transitional edge along a tagged path, smoothing the sharp edge.
|
|||||||
Fillet is similar in function and use to a chamfer, except a chamfer will cut a sharp transition along an edge while fillet will smoothly blend the transition.
|
Fillet is similar in function and use to a chamfer, except a chamfer will cut a sharp transition along an edge while fillet will smoothly blend the transition.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
fillet(data: FilletData, extrude_group: ExtrudeGroup, tag?: TagDeclarator) -> ExtrudeGroup
|
fillet(data: FilletData, solid: Solid, tag?: TagDeclarator) -> Solid
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -18,12 +18,12 @@ fillet(data: FilletData, extrude_group: ExtrudeGroup, tag?: TagDeclarator) -> Ex
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `data` | [`FilletData`](/docs/kcl/types/FilletData) | Data for fillets. | Yes |
|
| `data` | [`FilletData`](/docs/kcl/types/FilletData) | Data for fillets. | Yes |
|
||||||
| `extrude_group` | [`ExtrudeGroup`](/docs/kcl/types/ExtrudeGroup) | An extrude group is a collection of extrude surfaces. | Yes |
|
| `solid` | [`Solid`](/docs/kcl/types/Solid) | An solid is a collection of extrude surfaces. | Yes |
|
||||||
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`ExtrudeGroup`](/docs/kcl/types/ExtrudeGroup) - An extrude group is a collection of extrude surfaces.
|
[`Solid`](/docs/kcl/types/Solid) - An solid is a collection of extrude surfaces.
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -9,7 +9,7 @@ Create a helix on a cylinder.
|
|||||||
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
helix(data: HelixData, extrude_group: ExtrudeGroup) -> ExtrudeGroup
|
helix(data: HelixData, solid: Solid) -> Solid
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -18,11 +18,11 @@ helix(data: HelixData, extrude_group: ExtrudeGroup) -> ExtrudeGroup
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `data` | [`HelixData`](/docs/kcl/types/HelixData) | Data for helices. | Yes |
|
| `data` | [`HelixData`](/docs/kcl/types/HelixData) | Data for helices. | Yes |
|
||||||
| `extrude_group` | [`ExtrudeGroup`](/docs/kcl/types/ExtrudeGroup) | An extrude group is a collection of extrude surfaces. | Yes |
|
| `solid` | [`Solid`](/docs/kcl/types/Solid) | An solid is a collection of extrude surfaces. | Yes |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`ExtrudeGroup`](/docs/kcl/types/ExtrudeGroup) - An extrude group is a collection of extrude surfaces.
|
[`Solid`](/docs/kcl/types/Solid) - An solid is a collection of extrude surfaces.
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -9,7 +9,7 @@ Use a 2-dimensional sketch to cut a hole in another 2-dimensional sketch.
|
|||||||
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
hole(hole_sketch_group: SketchGroupSet, sketch_group: SketchGroup) -> SketchGroup
|
hole(hole_sketch: SketchSet, sketch: Sketch) -> Sketch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -17,12 +17,12 @@ hole(hole_sketch_group: SketchGroupSet, sketch_group: SketchGroup) -> SketchGrou
|
|||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `hole_sketch_group` | [`SketchGroupSet`](/docs/kcl/types/SketchGroupSet) | A sketch group or a group of sketch groups. | Yes |
|
| `hole_sketch` | [`SketchSet`](/docs/kcl/types/SketchSet) | A sketch or a group of sketches. | Yes |
|
||||||
| `sketch_group` | [`SketchGroup`](/docs/kcl/types/SketchGroup) | A sketch group is a collection of paths. | Yes |
|
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | A sketch is a collection of paths. | Yes |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`SketchGroup`](/docs/kcl/types/SketchGroup) - A sketch group is a collection of paths.
|
[`Sketch`](/docs/kcl/types/Sketch) - A sketch is a collection of paths.
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -9,7 +9,7 @@ Make the inside of a 3D object hollow.
|
|||||||
Remove volume from a 3-dimensional shape such that a wall of the provided thickness remains around the exterior of the shape.
|
Remove volume from a 3-dimensional shape such that a wall of the provided thickness remains around the exterior of the shape.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
hollow(thickness: number, extrude_group: ExtrudeGroup) -> ExtrudeGroup
|
hollow(thickness: number, solid: Solid) -> Solid
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -18,11 +18,11 @@ hollow(thickness: number, extrude_group: ExtrudeGroup) -> ExtrudeGroup
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `thickness` | `number` | | Yes |
|
| `thickness` | `number` | | Yes |
|
||||||
| `extrude_group` | [`ExtrudeGroup`](/docs/kcl/types/ExtrudeGroup) | An extrude group is a collection of extrude surfaces. | Yes |
|
| `solid` | [`Solid`](/docs/kcl/types/Solid) | An solid is a collection of extrude surfaces. | Yes |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`ExtrudeGroup`](/docs/kcl/types/ExtrudeGroup) - An extrude group is a collection of extrude surfaces.
|
[`Solid`](/docs/kcl/types/Solid) - An solid is a collection of extrude surfaces.
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -9,7 +9,7 @@ Extract the 'x' axis value of the last line segment in the provided 2-
|
|||||||
sketch.
|
sketch.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
lastSegX(sketch_group: SketchGroup) -> number
|
lastSegX(sketch: Sketch) -> number
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ lastSegX(sketch_group: SketchGroup) -> number
|
|||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `sketch_group` | [`SketchGroup`](/docs/kcl/types/SketchGroup) | A sketch group is a collection of paths. | Yes |
|
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | A sketch is a collection of paths. | Yes |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ Extract the 'y' axis value of the last line segment in the provided 2-
|
|||||||
sketch.
|
sketch.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
lastSegY(sketch_group: SketchGroup) -> number
|
lastSegY(sketch: Sketch) -> number
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ lastSegY(sketch_group: SketchGroup) -> number
|
|||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `sketch_group` | [`SketchGroup`](/docs/kcl/types/SketchGroup) | A sketch group is a collection of paths. | Yes |
|
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | A sketch is a collection of paths. | Yes |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ Draw a line relative to the current origin to a specified (x, y) away
|
|||||||
from the current position.
|
from the current position.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
line(delta: [number], sketch_group: SketchGroup, tag?: TagDeclarator) -> SketchGroup
|
line(delta: [number], sketch: Sketch, tag?: TagDeclarator) -> Sketch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -18,12 +18,12 @@ line(delta: [number], sketch_group: SketchGroup, tag?: TagDeclarator) -> SketchG
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `delta` | [`[number]`](/docs/kcl/types/[number]) | | Yes |
|
| `delta` | [`[number]`](/docs/kcl/types/[number]) | | Yes |
|
||||||
| `sketch_group` | [`SketchGroup`](/docs/kcl/types/SketchGroup) | A sketch group is a collection of paths. | Yes |
|
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | A sketch is a collection of paths. | Yes |
|
||||||
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`SketchGroup`](/docs/kcl/types/SketchGroup) - A sketch group is a collection of paths.
|
[`Sketch`](/docs/kcl/types/Sketch) - A sketch is a collection of paths.
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -9,7 +9,7 @@ Draw a line from the current origin to some absolute (x, y) point.
|
|||||||
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
lineTo(to: [number], sketch_group: SketchGroup, tag?: TagDeclarator) -> SketchGroup
|
lineTo(to: [number], sketch: Sketch, tag?: TagDeclarator) -> Sketch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -18,12 +18,12 @@ lineTo(to: [number], sketch_group: SketchGroup, tag?: TagDeclarator) -> SketchGr
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `to` | [`[number]`](/docs/kcl/types/[number]) | | Yes |
|
| `to` | [`[number]`](/docs/kcl/types/[number]) | | Yes |
|
||||||
| `sketch_group` | [`SketchGroup`](/docs/kcl/types/SketchGroup) | A sketch group is a collection of paths. | Yes |
|
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | A sketch is a collection of paths. | Yes |
|
||||||
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`SketchGroup`](/docs/kcl/types/SketchGroup) - A sketch group is a collection of paths.
|
[`Sketch`](/docs/kcl/types/Sketch) - A sketch is a collection of paths.
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -9,7 +9,7 @@ Create a 3D surface or solid by interpolating between two or more sketches.
|
|||||||
The sketches need to closed and on the same plane.
|
The sketches need to closed and on the same plane.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
loft(sketch_groups: [SketchGroup], data?: LoftData) -> ExtrudeGroup
|
loft(sketches: [Sketch], data?: LoftData) -> Solid
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -17,12 +17,12 @@ loft(sketch_groups: [SketchGroup], data?: LoftData) -> ExtrudeGroup
|
|||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `sketch_groups` | [`[SketchGroup]`](/docs/kcl/types/[SketchGroup]) | | Yes |
|
| `sketches` | [`[Sketch]`](/docs/kcl/types/[Sketch]) | | Yes |
|
||||||
| `data` | [`LoftData`](/docs/kcl/types/LoftData) | Data for a loft. | No |
|
| `data` | [`LoftData`](/docs/kcl/types/LoftData) | Data for a loft. | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`ExtrudeGroup`](/docs/kcl/types/ExtrudeGroup) - An extrude group is a collection of extrude surfaces.
|
[`Solid`](/docs/kcl/types/Solid) - An solid is a collection of extrude surfaces.
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -10,7 +10,7 @@ Only works on unclosed sketches for now.
|
|||||||
Mirror occurs around a local sketch axis rather than a global axis.
|
Mirror occurs around a local sketch axis rather than a global axis.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
mirror2d(data: Mirror2dData, sketch_group_set: SketchGroupSet) -> [SketchGroup]
|
mirror2d(data: Mirror2dData, sketch_set: SketchSet) -> [Sketch]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -19,11 +19,11 @@ mirror2d(data: Mirror2dData, sketch_group_set: SketchGroupSet) -> [SketchGroup]
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `data` | [`Mirror2dData`](/docs/kcl/types/Mirror2dData) | Data for a mirror. | Yes |
|
| `data` | [`Mirror2dData`](/docs/kcl/types/Mirror2dData) | Data for a mirror. | Yes |
|
||||||
| `sketch_group_set` | [`SketchGroupSet`](/docs/kcl/types/SketchGroupSet) | A sketch group or a group of sketch groups. | Yes |
|
| `sketch_set` | [`SketchSet`](/docs/kcl/types/SketchSet) | A sketch or a group of sketches. | Yes |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`[SketchGroup]`](/docs/kcl/types/[SketchGroup])
|
[`[Sketch]`](/docs/kcl/types/[Sketch])
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -9,7 +9,7 @@ Repeat a 2-dimensional sketch some number of times along a partial or
|
|||||||
complete circle some specified number of times. Each object may additionally be rotated along the circle, ensuring orentation of the solid with respect to the center of the circle is maintained.
|
complete circle some specified number of times. Each object may additionally be rotated along the circle, ensuring orentation of the solid with respect to the center of the circle is maintained.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
patternCircular2d(data: CircularPattern2dData, sketch_group_set: SketchGroupSet) -> [SketchGroup]
|
patternCircular2d(data: CircularPattern2dData, sketch_set: SketchSet) -> [Sketch]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -18,11 +18,11 @@ patternCircular2d(data: CircularPattern2dData, sketch_group_set: SketchGroupSet)
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `data` | [`CircularPattern2dData`](/docs/kcl/types/CircularPattern2dData) | Data for a circular pattern on a 2D sketch. | Yes |
|
| `data` | [`CircularPattern2dData`](/docs/kcl/types/CircularPattern2dData) | Data for a circular pattern on a 2D sketch. | Yes |
|
||||||
| `sketch_group_set` | [`SketchGroupSet`](/docs/kcl/types/SketchGroupSet) | A sketch group or a group of sketch groups. | Yes |
|
| `sketch_set` | [`SketchSet`](/docs/kcl/types/SketchSet) | A sketch or a group of sketches. | Yes |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`[SketchGroup]`](/docs/kcl/types/[SketchGroup])
|
[`[Sketch]`](/docs/kcl/types/[Sketch])
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -9,7 +9,7 @@ Repeat a 3-dimensional solid some number of times along a partial or
|
|||||||
complete circle some specified number of times. Each object may additionally be rotated along the circle, ensuring orentation of the solid with respect to the center of the circle is maintained.
|
complete circle some specified number of times. Each object may additionally be rotated along the circle, ensuring orentation of the solid with respect to the center of the circle is maintained.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
patternCircular3d(data: CircularPattern3dData, extrude_group_set: ExtrudeGroupSet) -> [ExtrudeGroup]
|
patternCircular3d(data: CircularPattern3dData, solid_set: SolidSet) -> [Solid]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -18,11 +18,11 @@ patternCircular3d(data: CircularPattern3dData, extrude_group_set: ExtrudeGroupSe
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `data` | [`CircularPattern3dData`](/docs/kcl/types/CircularPattern3dData) | Data for a circular pattern on a 3D model. | Yes |
|
| `data` | [`CircularPattern3dData`](/docs/kcl/types/CircularPattern3dData) | Data for a circular pattern on a 3D model. | Yes |
|
||||||
| `extrude_group_set` | [`ExtrudeGroupSet`](/docs/kcl/types/ExtrudeGroupSet) | A extrude group or a group of extrude groups. | Yes |
|
| `solid_set` | [`SolidSet`](/docs/kcl/types/SolidSet) | A solid or a group of solids. | Yes |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`[ExtrudeGroup]`](/docs/kcl/types/[ExtrudeGroup])
|
[`[Solid]`](/docs/kcl/types/[Solid])
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -9,7 +9,7 @@ Repeat a 2-dimensional sketch along some dimension, with a dynamic amount
|
|||||||
of distance between each repetition, some specified number of times.
|
of distance between each repetition, some specified number of times.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
patternLinear2d(data: LinearPattern2dData, sketch_group_set: SketchGroupSet) -> [SketchGroup]
|
patternLinear2d(data: LinearPattern2dData, sketch_set: SketchSet) -> [Sketch]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -18,11 +18,11 @@ patternLinear2d(data: LinearPattern2dData, sketch_group_set: SketchGroupSet) ->
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `data` | [`LinearPattern2dData`](/docs/kcl/types/LinearPattern2dData) | Data for a linear pattern on a 2D sketch. | Yes |
|
| `data` | [`LinearPattern2dData`](/docs/kcl/types/LinearPattern2dData) | Data for a linear pattern on a 2D sketch. | Yes |
|
||||||
| `sketch_group_set` | [`SketchGroupSet`](/docs/kcl/types/SketchGroupSet) | A sketch group or a group of sketch groups. | Yes |
|
| `sketch_set` | [`SketchSet`](/docs/kcl/types/SketchSet) | A sketch or a group of sketches. | Yes |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`[SketchGroup]`](/docs/kcl/types/[SketchGroup])
|
[`[Sketch]`](/docs/kcl/types/[Sketch])
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -9,7 +9,7 @@ Repeat a 3-dimensional solid along a linear path, with a dynamic amount
|
|||||||
of distance between each repetition, some specified number of times.
|
of distance between each repetition, some specified number of times.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
patternLinear3d(data: LinearPattern3dData, extrude_group_set: ExtrudeGroupSet) -> [ExtrudeGroup]
|
patternLinear3d(data: LinearPattern3dData, solid_set: SolidSet) -> [Solid]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -18,11 +18,11 @@ patternLinear3d(data: LinearPattern3dData, extrude_group_set: ExtrudeGroupSet) -
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `data` | [`LinearPattern3dData`](/docs/kcl/types/LinearPattern3dData) | Data for a linear pattern on a 3D model. | Yes |
|
| `data` | [`LinearPattern3dData`](/docs/kcl/types/LinearPattern3dData) | Data for a linear pattern on a 3D model. | Yes |
|
||||||
| `extrude_group_set` | [`ExtrudeGroupSet`](/docs/kcl/types/ExtrudeGroupSet) | A extrude group or a group of extrude groups. | Yes |
|
| `solid_set` | [`SolidSet`](/docs/kcl/types/SolidSet) | A solid or a group of solids. | Yes |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`[ExtrudeGroup]`](/docs/kcl/types/[ExtrudeGroup])
|
[`[Solid]`](/docs/kcl/types/[Solid])
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -11,7 +11,7 @@ The `patternTransform` call itself takes a number for how many total i
|
|||||||
The transform function takes a single parameter: an integer representing which number replication the transform is for. E.g. the first replica to be transformed will be passed the argument `1`. This simplifies your math: the transform function can rely on id `0` being the original instance passed into the `patternTransform`. See the examples.
|
The transform function takes a single parameter: an integer representing which number replication the transform is for. E.g. the first replica to be transformed will be passed the argument `1`. This simplifies your math: the transform function can rely on id `0` being the original instance passed into the `patternTransform`. See the examples.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
patternTransform(total_instances: u32, transform_function: FunctionParam, extrude_group_set: ExtrudeGroupSet) -> [ExtrudeGroup]
|
patternTransform(total_instances: u32, transform_function: FunctionParam, solid_set: SolidSet) -> [Solid]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -21,11 +21,11 @@ patternTransform(total_instances: u32, transform_function: FunctionParam, extrud
|
|||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `total_instances` | `u32` | | Yes |
|
| `total_instances` | `u32` | | Yes |
|
||||||
| `transform_function` | `FunctionParam` | | Yes |
|
| `transform_function` | `FunctionParam` | | Yes |
|
||||||
| `extrude_group_set` | [`ExtrudeGroupSet`](/docs/kcl/types/ExtrudeGroupSet) | A extrude group or a group of extrude groups. | Yes |
|
| `solid_set` | [`SolidSet`](/docs/kcl/types/SolidSet) | A solid or a group of solids. | Yes |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`[ExtrudeGroup]`](/docs/kcl/types/[ExtrudeGroup])
|
[`[Solid]`](/docs/kcl/types/[Solid])
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
---
|
---
|
||||||
title: "profileStart"
|
title: "profileStart"
|
||||||
excerpt: "Extract the provided 2-dimensional sketch group's profile's origin"
|
excerpt: "Extract the provided 2-dimensional sketch's profile's origin"
|
||||||
layout: manual
|
layout: manual
|
||||||
---
|
---
|
||||||
|
|
||||||
Extract the provided 2-dimensional sketch group's profile's origin
|
Extract the provided 2-dimensional sketch's profile's origin
|
||||||
|
|
||||||
value.
|
value.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
profileStart(sketch_group: SketchGroup) -> [number]
|
profileStart(sketch: Sketch) -> [number]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ profileStart(sketch_group: SketchGroup) -> [number]
|
|||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `sketch_group` | [`SketchGroup`](/docs/kcl/types/SketchGroup) | A sketch group is a collection of paths. | Yes |
|
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | A sketch is a collection of paths. | Yes |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
---
|
---
|
||||||
title: "profileStartX"
|
title: "profileStartX"
|
||||||
excerpt: "Extract the provided 2-dimensional sketch group's profile's origin's 'x'"
|
excerpt: "Extract the provided 2-dimensional sketch's profile's origin's 'x'"
|
||||||
layout: manual
|
layout: manual
|
||||||
---
|
---
|
||||||
|
|
||||||
Extract the provided 2-dimensional sketch group's profile's origin's 'x'
|
Extract the provided 2-dimensional sketch's profile's origin's 'x'
|
||||||
|
|
||||||
value.
|
value.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
profileStartX(sketch_group: SketchGroup) -> number
|
profileStartX(sketch: Sketch) -> number
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ profileStartX(sketch_group: SketchGroup) -> number
|
|||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `sketch_group` | [`SketchGroup`](/docs/kcl/types/SketchGroup) | A sketch group is a collection of paths. | Yes |
|
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | A sketch is a collection of paths. | Yes |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
---
|
---
|
||||||
title: "profileStartY"
|
title: "profileStartY"
|
||||||
excerpt: "Extract the provided 2-dimensional sketch group's profile's origin's 'y'"
|
excerpt: "Extract the provided 2-dimensional sketch's profile's origin's 'y'"
|
||||||
layout: manual
|
layout: manual
|
||||||
---
|
---
|
||||||
|
|
||||||
Extract the provided 2-dimensional sketch group's profile's origin's 'y'
|
Extract the provided 2-dimensional sketch's profile's origin's 'y'
|
||||||
|
|
||||||
value.
|
value.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
profileStartY(sketch_group: SketchGroup) -> number
|
profileStartY(sketch: Sketch) -> number
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ profileStartY(sketch_group: SketchGroup) -> number
|
|||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `sketch_group` | [`SketchGroup`](/docs/kcl/types/SketchGroup) | A sketch group is a collection of paths. | Yes |
|
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | A sketch is a collection of paths. | Yes |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ This, like extrude, is able to create a 3-dimensional solid from a 2-dimensional
|
|||||||
Revolve occurs around a local sketch axis rather than a global axis.
|
Revolve occurs around a local sketch axis rather than a global axis.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
revolve(data: RevolveData, sketch_group: SketchGroup) -> ExtrudeGroup
|
revolve(data: RevolveData, sketch: Sketch) -> Solid
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -19,11 +19,11 @@ revolve(data: RevolveData, sketch_group: SketchGroup) -> ExtrudeGroup
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `data` | [`RevolveData`](/docs/kcl/types/RevolveData) | Data for revolution surfaces. | Yes |
|
| `data` | [`RevolveData`](/docs/kcl/types/RevolveData) | Data for revolution surfaces. | Yes |
|
||||||
| `sketch_group` | [`SketchGroup`](/docs/kcl/types/SketchGroup) | A sketch group is a collection of paths. | Yes |
|
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | A sketch is a collection of paths. | Yes |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`ExtrudeGroup`](/docs/kcl/types/ExtrudeGroup) - An extrude group is a collection of extrude surfaces.
|
[`Solid`](/docs/kcl/types/Solid) - An solid is a collection of extrude surfaces.
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -9,7 +9,7 @@ Remove volume from a 3-dimensional shape such that a wall of the
|
|||||||
provided thickness remains, taking volume starting at the provided face, leaving it open in that direction.
|
provided thickness remains, taking volume starting at the provided face, leaving it open in that direction.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
shell(data: ShellData, extrude_group_set: ExtrudeGroupSet) -> ExtrudeGroupSet
|
shell(data: ShellData, solid_set: SolidSet) -> SolidSet
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -18,11 +18,11 @@ shell(data: ShellData, extrude_group_set: ExtrudeGroupSet) -> ExtrudeGroupSet
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `data` | [`ShellData`](/docs/kcl/types/ShellData) | Data for shells. | Yes |
|
| `data` | [`ShellData`](/docs/kcl/types/ShellData) | Data for shells. | Yes |
|
||||||
| `extrude_group_set` | [`ExtrudeGroupSet`](/docs/kcl/types/ExtrudeGroupSet) | A extrude group or a group of extrude groups. | Yes |
|
| `solid_set` | [`SolidSet`](/docs/kcl/types/SolidSet) | A solid or a group of solids. | Yes |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`ExtrudeGroupSet`](/docs/kcl/types/ExtrudeGroupSet) - A extrude group or a group of extrude groups.
|
[`SolidSet`](/docs/kcl/types/SolidSet) - A solid or a group of solids.
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -9,7 +9,7 @@ Start a new profile at a given point.
|
|||||||
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
startProfileAt(to: [number], sketch_surface: SketchSurface, tag?: TagDeclarator) -> SketchGroup
|
startProfileAt(to: [number], sketch_surface: SketchSurface, tag?: TagDeclarator) -> Sketch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -18,12 +18,12 @@ startProfileAt(to: [number], sketch_surface: SketchSurface, tag?: TagDeclarator)
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `to` | [`[number]`](/docs/kcl/types/[number]) | | Yes |
|
| `to` | [`[number]`](/docs/kcl/types/[number]) | | Yes |
|
||||||
| `sketch_surface` | [`SketchSurface`](/docs/kcl/types/SketchSurface) | A sketch group type. | Yes |
|
| `sketch_surface` | [`SketchSurface`](/docs/kcl/types/SketchSurface) | A sketch type. | Yes |
|
||||||
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`SketchGroup`](/docs/kcl/types/SketchGroup) - A sketch group is a collection of paths.
|
[`Sketch`](/docs/kcl/types/Sketch) - A sketch is a collection of paths.
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -9,7 +9,7 @@ Start a new 2-dimensional sketch at a given point on the 'XY' plane.
|
|||||||
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
startSketchAt(data: [number]) -> SketchGroup
|
startSketchAt(data: [number]) -> Sketch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ startSketchAt(data: [number]) -> SketchGroup
|
|||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`SketchGroup`](/docs/kcl/types/SketchGroup) - A sketch group is a collection of paths.
|
[`Sketch`](/docs/kcl/types/Sketch) - A sketch is a collection of paths.
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -17,12 +17,12 @@ startSketchOn(data: SketchData, tag?: FaceTag) -> SketchSurface
|
|||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `data` | [`SketchData`](/docs/kcl/types/SketchData) | Data for start sketch on. You can start a sketch on a plane or an extrude group. | Yes |
|
| `data` | [`SketchData`](/docs/kcl/types/SketchData) | Data for start sketch on. You can start a sketch on a plane or an solid. | Yes |
|
||||||
| `tag` | [`FaceTag`](/docs/kcl/types/FaceTag) | A tag for a face. | No |
|
| `tag` | [`FaceTag`](/docs/kcl/types/FaceTag) | A tag for a face. | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`SketchSurface`](/docs/kcl/types/SketchSurface) - A sketch group type.
|
[`SketchSurface`](/docs/kcl/types/SketchSurface) - A sketch type.
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
5284
docs/kcl/std.json
5284
docs/kcl/std.json
File diff suppressed because it is too large
Load Diff
@ -10,7 +10,7 @@ some part of an imaginary circle of the specified radius.
|
|||||||
The arc is constructed such that the last line segment is placed tangent to the imaginary circle of the specified radius. The resulting arc is the segment of the imaginary circle from that tangent point for 'offset' degrees along the imaginary circle.
|
The arc is constructed such that the last line segment is placed tangent to the imaginary circle of the specified radius. The resulting arc is the segment of the imaginary circle from that tangent point for 'offset' degrees along the imaginary circle.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
tangentialArc(data: TangentialArcData, sketch_group: SketchGroup, tag?: TagDeclarator) -> SketchGroup
|
tangentialArc(data: TangentialArcData, sketch: Sketch, tag?: TagDeclarator) -> Sketch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -19,12 +19,12 @@ tangentialArc(data: TangentialArcData, sketch_group: SketchGroup, tag?: TagDecla
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `data` | [`TangentialArcData`](/docs/kcl/types/TangentialArcData) | Data to draw a tangential arc. | Yes |
|
| `data` | [`TangentialArcData`](/docs/kcl/types/TangentialArcData) | Data to draw a tangential arc. | Yes |
|
||||||
| `sketch_group` | [`SketchGroup`](/docs/kcl/types/SketchGroup) | A sketch group is a collection of paths. | Yes |
|
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | A sketch is a collection of paths. | Yes |
|
||||||
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`SketchGroup`](/docs/kcl/types/SketchGroup) - A sketch group is a collection of paths.
|
[`Sketch`](/docs/kcl/types/Sketch) - A sketch is a collection of paths.
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -9,7 +9,7 @@ Starting at the current sketch's origin, draw a curved line segment along
|
|||||||
some part of an imaginary circle until it reaches the desired (x, y) coordinates.
|
some part of an imaginary circle until it reaches the desired (x, y) coordinates.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
tangentialArcTo(to: [number], sketch_group: SketchGroup, tag?: TagDeclarator) -> SketchGroup
|
tangentialArcTo(to: [number], sketch: Sketch, tag?: TagDeclarator) -> Sketch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -18,12 +18,12 @@ tangentialArcTo(to: [number], sketch_group: SketchGroup, tag?: TagDeclarator) ->
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `to` | [`[number]`](/docs/kcl/types/[number]) | | Yes |
|
| `to` | [`[number]`](/docs/kcl/types/[number]) | | Yes |
|
||||||
| `sketch_group` | [`SketchGroup`](/docs/kcl/types/SketchGroup) | A sketch group is a collection of paths. | Yes |
|
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | A sketch is a collection of paths. | Yes |
|
||||||
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`SketchGroup`](/docs/kcl/types/SketchGroup) - A sketch group is a collection of paths.
|
[`Sketch`](/docs/kcl/types/Sketch) - A sketch is a collection of paths.
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -9,7 +9,7 @@ Starting at the current sketch's origin, draw a curved line segment along
|
|||||||
some part of an imaginary circle until it reaches a point the given (x, y) distance away.
|
some part of an imaginary circle until it reaches a point the given (x, y) distance away.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
tangentialArcToRelative(delta: [number], sketch_group: SketchGroup, tag?: TagDeclarator) -> SketchGroup
|
tangentialArcToRelative(delta: [number], sketch: Sketch, tag?: TagDeclarator) -> Sketch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -18,12 +18,12 @@ tangentialArcToRelative(delta: [number], sketch_group: SketchGroup, tag?: TagDec
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `delta` | [`[number]`](/docs/kcl/types/[number]) | | Yes |
|
| `delta` | [`[number]`](/docs/kcl/types/[number]) | | Yes |
|
||||||
| `sketch_group` | [`SketchGroup`](/docs/kcl/types/SketchGroup) | A sketch group is a collection of paths. | Yes |
|
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | A sketch is a collection of paths. | Yes |
|
||||||
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`SketchGroup`](/docs/kcl/types/SketchGroup) - A sketch group is a collection of paths.
|
[`Sketch`](/docs/kcl/types/Sketch) - A sketch is a collection of paths.
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
---
|
|
||||||
title: "ExtrudeGroup"
|
|
||||||
excerpt: "An extrude group is a collection of extrude surfaces."
|
|
||||||
layout: manual
|
|
||||||
---
|
|
||||||
|
|
||||||
An extrude group is a collection of extrude surfaces.
|
|
||||||
|
|
||||||
|
|
||||||
**Type:** `object`
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
| Property | Type | Description | Required |
|
|
||||||
|----------|------|-------------|----------|
|
|
||||||
| `__meta` |`array`| Metadata. | No |
|
|
||||||
| `edgeCuts` |`array`| Chamfers or fillets on this extrude group. | No |
|
|
||||||
| `endCapId` |`string` (`uuid`)| The id of the extrusion end cap | No |
|
|
||||||
| `height` |`number` (`double`)| The height of the extrude group. | No |
|
|
||||||
| `id` |`string` (`uuid`)| The id of the extrude group. | No |
|
|
||||||
| `sketchGroup` |`object`| The sketch group. | No |
|
|
||||||
| `startCapId` |`string` (`uuid`)| The id of the extrusion start cap | No |
|
|
||||||
| `value` |`array`| The extrude surfaces. | No |
|
|
||||||
|
|
||||||
|
|
@ -18,7 +18,7 @@ Data for helices.
|
|||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `angleStart` |`number` (`double`)| Start angle (in degrees). | No |
|
| `angleStart` |`number` (`double`)| Start angle (in degrees). | No |
|
||||||
| `ccw` |`boolean`| Is the helix rotation counter clockwise? The default is `false`. | No |
|
| `ccw` |`boolean`| Is the helix rotation counter clockwise? The default is `false`. | No |
|
||||||
| `length` |`number` (`double`)| Length of the helix. If this argument is not provided, the height of the extrude group is used. | No |
|
| `length` |`number` (`double`)| Length of the helix. If this argument is not provided, the height of the solid is used. | No |
|
||||||
| `revolutions` |`number` (`double`)| Number of revolutions. | No |
|
| `revolutions` |`number` (`double`)| Number of revolutions. | No |
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,8 +23,7 @@ Autodesk Filmbox (FBX) format
|
|||||||
|
|
||||||
| Property | Type | Description | Required |
|
| Property | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `type` |enum: `fbx`
|
| `type` |enum: `fbx`| | No |
|
||||||
| | No |
|
|
||||||
|
|
||||||
|
|
||||||
----
|
----
|
||||||
@ -40,8 +39,7 @@ Binary glTF 2.0. We refer to this as glTF since that is how our customers refer
|
|||||||
|
|
||||||
| Property | Type | Description | Required |
|
| Property | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `type` |enum: `gltf`
|
| `type` |enum: `gltf`| | No |
|
||||||
| | No |
|
|
||||||
|
|
||||||
|
|
||||||
----
|
----
|
||||||
@ -58,10 +56,8 @@ Wavefront OBJ format.
|
|||||||
| Property | Type | Description | Required |
|
| Property | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `coords` |`object`| Co-ordinate system of input data. Defaults to the [KittyCAD co-ordinate system. | No |
|
| `coords` |`object`| Co-ordinate system of input data. Defaults to the [KittyCAD co-ordinate system. | No |
|
||||||
| `type` |enum: `obj`
|
| `type` |enum: `obj`| | No |
|
||||||
| | No |
|
| `units` |`oneOf`| The units of the input data. This is very important for correct scaling and when calculating physics properties like mass, etc. Defaults to millimeters. | No |
|
||||||
| `units` |`oneOf`
|
|
||||||
| The units of the input data. This is very important for correct scaling and when calculating physics properties like mass, etc. Defaults to millimeters. | No |
|
|
||||||
|
|
||||||
|
|
||||||
----
|
----
|
||||||
@ -78,10 +74,8 @@ The PLY Polygon File Format.
|
|||||||
| Property | Type | Description | Required |
|
| Property | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `coords` |`object`| Co-ordinate system of input data. Defaults to the [KittyCAD co-ordinate system. | No |
|
| `coords` |`object`| Co-ordinate system of input data. Defaults to the [KittyCAD co-ordinate system. | No |
|
||||||
| `type` |enum: `ply`
|
| `type` |enum: `ply`| | No |
|
||||||
| | No |
|
| `units` |`oneOf`| The units of the input data. This is very important for correct scaling and when calculating physics properties like mass, etc. Defaults to millimeters. | No |
|
||||||
| `units` |`oneOf`
|
|
||||||
| The units of the input data. This is very important for correct scaling and when calculating physics properties like mass, etc. Defaults to millimeters. | No |
|
|
||||||
|
|
||||||
|
|
||||||
----
|
----
|
||||||
@ -97,8 +91,7 @@ SolidWorks part (SLDPRT) format.
|
|||||||
|
|
||||||
| Property | Type | Description | Required |
|
| Property | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `type` |enum: `sldprt`
|
| `type` |enum: `sldprt`| | No |
|
||||||
| | No |
|
|
||||||
|
|
||||||
|
|
||||||
----
|
----
|
||||||
@ -114,8 +107,7 @@ ISO 10303-21 (STEP) format.
|
|||||||
|
|
||||||
| Property | Type | Description | Required |
|
| Property | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `type` |enum: `step`
|
| `type` |enum: `step`| | No |
|
||||||
| | No |
|
|
||||||
|
|
||||||
|
|
||||||
----
|
----
|
||||||
@ -132,10 +124,8 @@ ST**ereo**L**ithography format.
|
|||||||
| Property | Type | Description | Required |
|
| Property | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `coords` |`object`| Co-ordinate system of input data. Defaults to the [KittyCAD co-ordinate system. | No |
|
| `coords` |`object`| Co-ordinate system of input data. Defaults to the [KittyCAD co-ordinate system. | No |
|
||||||
| `type` |enum: `stl`
|
| `type` |enum: `stl`| | No |
|
||||||
| | No |
|
| `units` |`oneOf`| The units of the input data. This is very important for correct scaling and when calculating physics properties like mass, etc. Defaults to millimeters. | No |
|
||||||
| `units` |`oneOf`
|
|
||||||
| The units of the input data. This is very important for correct scaling and when calculating physics properties like mass, etc. Defaults to millimeters. | No |
|
|
||||||
|
|
||||||
|
|
||||||
----
|
----
|
||||||
|
@ -16,7 +16,6 @@ Data for a mirror.
|
|||||||
|
|
||||||
| Property | Type | Description | Required |
|
| Property | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `axis` |`anyOf`
|
| `axis` |`anyOf`| Axis to use as mirror. | No |
|
||||||
| Axis to use as mirror. | No |
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,8 +17,7 @@ Data for revolution surfaces.
|
|||||||
| Property | Type | Description | Required |
|
| Property | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `angle` |`number` (`double`)| Angle to revolve (in degrees). Default is 360. | No |
|
| `angle` |`number` (`double`)| Angle to revolve (in degrees). Default is 360. | No |
|
||||||
| `axis` |`anyOf`
|
| `axis` |`anyOf`| Axis of revolution. | No |
|
||||||
| Axis of revolution. | No |
|
|
||||||
| `tolerance` |`number` (`double`)| Tolerance for the revolve operation. | No |
|
| `tolerance` |`number` (`double`)| Tolerance for the revolve operation. | No |
|
||||||
|
|
||||||
|
|
||||||
|
26
docs/kcl/types/Sketch.md
Normal file
26
docs/kcl/types/Sketch.md
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
---
|
||||||
|
title: "Sketch"
|
||||||
|
excerpt: "A sketch is a collection of paths."
|
||||||
|
layout: manual
|
||||||
|
---
|
||||||
|
|
||||||
|
A sketch is a collection of paths.
|
||||||
|
|
||||||
|
|
||||||
|
**Type:** `object`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
| Property | Type | Description | Required |
|
||||||
|
|----------|------|-------------|----------|
|
||||||
|
| `__meta` |`array`| Metadata. | No |
|
||||||
|
| `id` |`string` (`uuid`)| The id of the sketch (this will change when the engine's reference to it changes. | No |
|
||||||
|
| `on` |`oneOf`| What the sketch is on (can be a plane or a face). | No |
|
||||||
|
| `start` |`object`| The starting path. | No |
|
||||||
|
| `tags` |`object`| Tag identifiers that have been declared in this sketch. | No |
|
||||||
|
| `value` |`array`| The paths in the sketch. | No |
|
||||||
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
|||||||
---
|
---
|
||||||
title: "SketchData"
|
title: "SketchData"
|
||||||
excerpt: "Data for start sketch on. You can start a sketch on a plane or an extrude group."
|
excerpt: "Data for start sketch on. You can start a sketch on a plane or an solid."
|
||||||
layout: manual
|
layout: manual
|
||||||
---
|
---
|
||||||
|
|
||||||
Data for start sketch on. You can start a sketch on a plane or an extrude group.
|
Data for start sketch on. You can start a sketch on a plane or an solid.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ A defined plane.
|
|||||||
|
|
||||||
|
|
||||||
----
|
----
|
||||||
An extrude group is a collection of extrude surfaces.
|
An solid is a collection of extrude surfaces.
|
||||||
|
|
||||||
|
|
||||||
**Type:** `object`
|
**Type:** `object`
|
||||||
@ -117,11 +117,11 @@ An extrude group is a collection of extrude surfaces.
|
|||||||
| Property | Type | Description | Required |
|
| Property | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `__meta` |`array`| Metadata. | No |
|
| `__meta` |`array`| Metadata. | No |
|
||||||
| `edgeCuts` |`array`| Chamfers or fillets on this extrude group. | No |
|
| `edgeCuts` |`array`| Chamfers or fillets on this solid. | No |
|
||||||
| `endCapId` |`string` (`uuid`)| The id of the extrusion end cap | No |
|
| `endCapId` |`string` (`uuid`)| The id of the extrusion end cap | No |
|
||||||
| `height` |`number` (`double`)| The height of the extrude group. | No |
|
| `height` |`number` (`double`)| The height of the solid. | No |
|
||||||
| `id` |`string` (`uuid`)| The id of the extrude group. | No |
|
| `id` |`string` (`uuid`)| The id of the solid. | No |
|
||||||
| `sketchGroup` |`object`| The sketch group. | No |
|
| `sketch` |`object`| The sketch. | No |
|
||||||
| `startCapId` |`string` (`uuid`)| The id of the extrusion start cap | No |
|
| `startCapId` |`string` (`uuid`)| The id of the extrusion start cap | No |
|
||||||
| `value` |`array`| The extrude surfaces. | No |
|
| `value` |`array`| The extrude surfaces. | No |
|
||||||
|
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
---
|
|
||||||
title: "SketchGroup"
|
|
||||||
excerpt: "A sketch group is a collection of paths."
|
|
||||||
layout: manual
|
|
||||||
---
|
|
||||||
|
|
||||||
A sketch group is a collection of paths.
|
|
||||||
|
|
||||||
|
|
||||||
**Type:** `object`
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
| Property | Type | Description | Required |
|
|
||||||
|----------|------|-------------|----------|
|
|
||||||
| `__meta` |`array`| Metadata. | No |
|
|
||||||
| `id` |`string` (`uuid`)| The id of the sketch group (this will change when the engine's reference to it changes. | No |
|
|
||||||
| `on` |`oneOf`
|
|
||||||
| What the sketch is on (can be a plane or a face). | No |
|
|
||||||
| `start` |`object`| The starting path. | No |
|
|
||||||
| `tags` |`object`| Tag identifiers that have been declared in this sketch group. | No |
|
|
||||||
| `value` |`array`| The paths in the sketch group. | No |
|
|
||||||
|
|
||||||
|
|
@ -1,57 +0,0 @@
|
|||||||
---
|
|
||||||
title: "SketchGroupSet"
|
|
||||||
excerpt: "A sketch group or a group of sketch groups."
|
|
||||||
layout: manual
|
|
||||||
---
|
|
||||||
|
|
||||||
A sketch group or a group of sketch groups.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
**This schema accepts exactly one of the following:**
|
|
||||||
|
|
||||||
A sketch group is a collection of paths.
|
|
||||||
|
|
||||||
|
|
||||||
**Type:** `object`
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
| Property | Type | Description | Required |
|
|
||||||
|----------|------|-------------|----------|
|
|
||||||
| `__meta` |`array`| Metadata. | No |
|
|
||||||
| `id` |`string` (`uuid`)| The id of the sketch group (this will change when the engine's reference to it changes. | No |
|
|
||||||
| `on` |`oneOf`
|
|
||||||
| What the sketch is on (can be a plane or a face). | No |
|
|
||||||
| `start` |`object`| The starting path. | No |
|
|
||||||
| `tags` |`object`| Tag identifiers that have been declared in this sketch group. | No |
|
|
||||||
| `type` |enum: `sketchGroup`
|
|
||||||
| | No |
|
|
||||||
| `value` |`array`| The paths in the sketch group. | No |
|
|
||||||
|
|
||||||
|
|
||||||
----
|
|
||||||
|
|
||||||
|
|
||||||
**Type:** `[object, array]`
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
| Property | Type | Description | Required |
|
|
||||||
|----------|------|-------------|----------|
|
|
||||||
| `type` |enum: `sketchGroups`
|
|
||||||
| | No |
|
|
||||||
|
|
||||||
|
|
||||||
----
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
|||||||
---
|
---
|
||||||
title: "SketchSurfaceOrGroup"
|
title: "SketchOrSurface"
|
||||||
excerpt: "A sketch surface or a sketch group."
|
excerpt: "A sketch surface or a sketch."
|
||||||
layout: manual
|
layout: manual
|
||||||
---
|
---
|
||||||
|
|
||||||
A sketch surface or a sketch group.
|
A sketch surface or a sketch.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
**This schema accepts any of the following:**
|
**This schema accepts any of the following:**
|
||||||
|
|
||||||
A sketch group type.
|
A sketch type.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -32,10 +32,8 @@ A plane.
|
|||||||
| `__meta` |`array`| | No |
|
| `__meta` |`array`| | No |
|
||||||
| `id` |`string` (`uuid`)| The id of the plane. | No |
|
| `id` |`string` (`uuid`)| The id of the plane. | No |
|
||||||
| `origin` |`object`| Origin of the plane. | No |
|
| `origin` |`object`| Origin of the plane. | No |
|
||||||
| `type` |enum: `plane`
|
| `type` |enum: `plane`| | No |
|
||||||
| | No |
|
| `value` |`oneOf`| Type for a plane. | No |
|
||||||
| `value` |`oneOf`
|
|
||||||
| Type for a plane. | No |
|
|
||||||
| `xAxis` |`object`| What should the plane’s X axis be? | No |
|
| `xAxis` |`object`| What should the plane’s X axis be? | No |
|
||||||
| `yAxis` |`object`| What should the plane’s Y axis be? | No |
|
| `yAxis` |`object`| What should the plane’s Y axis be? | No |
|
||||||
| `zAxis` |`object`| The z-axis (normal). | No |
|
| `zAxis` |`object`| The z-axis (normal). | No |
|
||||||
@ -55,10 +53,9 @@ A face.
|
|||||||
| Property | Type | Description | Required |
|
| Property | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `__meta` |`array`| | No |
|
| `__meta` |`array`| | No |
|
||||||
| `extrudeGroup` |`object`| The extrude group the face is on. | No |
|
|
||||||
| `id` |`string` (`uuid`)| The id of the face. | No |
|
| `id` |`string` (`uuid`)| The id of the face. | No |
|
||||||
| `type` |enum: `face`
|
| `solid` |`object`| The solid the face is on. | No |
|
||||||
| | No |
|
| `type` |enum: `face`| | No |
|
||||||
| `value` |`string`| The tag of the face. | No |
|
| `value` |`string`| The tag of the face. | No |
|
||||||
| `xAxis` |`object`| What should the face’s X axis be? | No |
|
| `xAxis` |`object`| What should the face’s X axis be? | No |
|
||||||
| `yAxis` |`object`| What should the face’s Y axis be? | No |
|
| `yAxis` |`object`| What should the face’s Y axis be? | No |
|
||||||
@ -71,7 +68,7 @@ A face.
|
|||||||
|
|
||||||
|
|
||||||
----
|
----
|
||||||
A sketch group is a collection of paths.
|
A sketch is a collection of paths.
|
||||||
|
|
||||||
|
|
||||||
**Type:** `object`
|
**Type:** `object`
|
||||||
@ -84,12 +81,11 @@ A sketch group is a collection of paths.
|
|||||||
| Property | Type | Description | Required |
|
| Property | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `__meta` |`array`| Metadata. | No |
|
| `__meta` |`array`| Metadata. | No |
|
||||||
| `id` |`string` (`uuid`)| The id of the sketch group (this will change when the engine's reference to it changes. | No |
|
| `id` |`string` (`uuid`)| The id of the sketch (this will change when the engine's reference to it changes. | No |
|
||||||
| `on` |`oneOf`
|
| `on` |`oneOf`| What the sketch is on (can be a plane or a face). | No |
|
||||||
| What the sketch is on (can be a plane or a face). | No |
|
|
||||||
| `start` |`object`| The starting path. | No |
|
| `start` |`object`| The starting path. | No |
|
||||||
| `tags` |`object`| Tag identifiers that have been declared in this sketch group. | No |
|
| `tags` |`object`| Tag identifiers that have been declared in this sketch. | No |
|
||||||
| `value` |`array`| The paths in the sketch group. | No |
|
| `value` |`array`| The paths in the sketch. | No |
|
||||||
|
|
||||||
|
|
||||||
----
|
----
|
54
docs/kcl/types/SketchSet.md
Normal file
54
docs/kcl/types/SketchSet.md
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
---
|
||||||
|
title: "SketchSet"
|
||||||
|
excerpt: "A sketch or a group of sketches."
|
||||||
|
layout: manual
|
||||||
|
---
|
||||||
|
|
||||||
|
A sketch or a group of sketches.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
**This schema accepts exactly one of the following:**
|
||||||
|
|
||||||
|
A sketch is a collection of paths.
|
||||||
|
|
||||||
|
|
||||||
|
**Type:** `object`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
| Property | Type | Description | Required |
|
||||||
|
|----------|------|-------------|----------|
|
||||||
|
| `__meta` |`array`| Metadata. | No |
|
||||||
|
| `id` |`string` (`uuid`)| The id of the sketch (this will change when the engine's reference to it changes. | No |
|
||||||
|
| `on` |`oneOf`| What the sketch is on (can be a plane or a face). | No |
|
||||||
|
| `start` |`object`| The starting path. | No |
|
||||||
|
| `tags` |`object`| Tag identifiers that have been declared in this sketch. | No |
|
||||||
|
| `type` |enum: `sketch`| | No |
|
||||||
|
| `value` |`array`| The paths in the sketch. | No |
|
||||||
|
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
|
||||||
|
**Type:** `[object, array]`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
| Property | Type | Description | Required |
|
||||||
|
|----------|------|-------------|----------|
|
||||||
|
| `type` |enum: `sketches`| | No |
|
||||||
|
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
|||||||
---
|
---
|
||||||
title: "SketchSurface"
|
title: "SketchSurface"
|
||||||
excerpt: "A sketch group type."
|
excerpt: "A sketch type."
|
||||||
layout: manual
|
layout: manual
|
||||||
---
|
---
|
||||||
|
|
||||||
A sketch group type.
|
A sketch type.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -26,10 +26,8 @@ A plane.
|
|||||||
| `__meta` |`array`| | No |
|
| `__meta` |`array`| | No |
|
||||||
| `id` |`string` (`uuid`)| The id of the plane. | No |
|
| `id` |`string` (`uuid`)| The id of the plane. | No |
|
||||||
| `origin` |`object`| Origin of the plane. | No |
|
| `origin` |`object`| Origin of the plane. | No |
|
||||||
| `type` |enum: `plane`
|
| `type` |enum: `plane`| | No |
|
||||||
| | No |
|
| `value` |`oneOf`| Type for a plane. | No |
|
||||||
| `value` |`oneOf`
|
|
||||||
| Type for a plane. | No |
|
|
||||||
| `xAxis` |`object`| What should the plane’s X axis be? | No |
|
| `xAxis` |`object`| What should the plane’s X axis be? | No |
|
||||||
| `yAxis` |`object`| What should the plane’s Y axis be? | No |
|
| `yAxis` |`object`| What should the plane’s Y axis be? | No |
|
||||||
| `zAxis` |`object`| The z-axis (normal). | No |
|
| `zAxis` |`object`| The z-axis (normal). | No |
|
||||||
@ -49,10 +47,9 @@ A face.
|
|||||||
| Property | Type | Description | Required |
|
| Property | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `__meta` |`array`| | No |
|
| `__meta` |`array`| | No |
|
||||||
| `extrudeGroup` |`object`| The extrude group the face is on. | No |
|
|
||||||
| `id` |`string` (`uuid`)| The id of the face. | No |
|
| `id` |`string` (`uuid`)| The id of the face. | No |
|
||||||
| `type` |enum: `face`
|
| `solid` |`object`| The solid the face is on. | No |
|
||||||
| | No |
|
| `type` |enum: `face`| | No |
|
||||||
| `value` |`string`| The tag of the face. | No |
|
| `value` |`string`| The tag of the face. | No |
|
||||||
| `xAxis` |`object`| What should the face’s X axis be? | No |
|
| `xAxis` |`object`| What should the face’s X axis be? | No |
|
||||||
| `yAxis` |`object`| What should the face’s Y axis be? | No |
|
| `yAxis` |`object`| What should the face’s Y axis be? | No |
|
||||||
|
28
docs/kcl/types/Solid.md
Normal file
28
docs/kcl/types/Solid.md
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
---
|
||||||
|
title: "Solid"
|
||||||
|
excerpt: "An solid is a collection of extrude surfaces."
|
||||||
|
layout: manual
|
||||||
|
---
|
||||||
|
|
||||||
|
An solid is a collection of extrude surfaces.
|
||||||
|
|
||||||
|
|
||||||
|
**Type:** `object`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
| Property | Type | Description | Required |
|
||||||
|
|----------|------|-------------|----------|
|
||||||
|
| `__meta` |`array`| Metadata. | No |
|
||||||
|
| `edgeCuts` |`array`| Chamfers or fillets on this solid. | No |
|
||||||
|
| `endCapId` |`string` (`uuid`)| The id of the extrusion end cap | No |
|
||||||
|
| `height` |`number` (`double`)| The height of the solid. | No |
|
||||||
|
| `id` |`string` (`uuid`)| The id of the solid. | No |
|
||||||
|
| `sketch` |`object`| The sketch. | No |
|
||||||
|
| `startCapId` |`string` (`uuid`)| The id of the extrusion start cap | No |
|
||||||
|
| `value` |`array`| The extrude surfaces. | No |
|
||||||
|
|
||||||
|
|
@ -1,17 +1,17 @@
|
|||||||
---
|
---
|
||||||
title: "ExtrudeGroupSet"
|
title: "SolidSet"
|
||||||
excerpt: "A extrude group or a group of extrude groups."
|
excerpt: "A solid or a group of solids."
|
||||||
layout: manual
|
layout: manual
|
||||||
---
|
---
|
||||||
|
|
||||||
A extrude group or a group of extrude groups.
|
A solid or a group of solids.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
**This schema accepts exactly one of the following:**
|
**This schema accepts exactly one of the following:**
|
||||||
|
|
||||||
An extrude group is a collection of extrude surfaces.
|
An solid is a collection of extrude surfaces.
|
||||||
|
|
||||||
|
|
||||||
**Type:** `object`
|
**Type:** `object`
|
||||||
@ -24,14 +24,13 @@ An extrude group is a collection of extrude surfaces.
|
|||||||
| Property | Type | Description | Required |
|
| Property | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `__meta` |`array`| Metadata. | No |
|
| `__meta` |`array`| Metadata. | No |
|
||||||
| `edgeCuts` |`array`| Chamfers or fillets on this extrude group. | No |
|
| `edgeCuts` |`array`| Chamfers or fillets on this solid. | No |
|
||||||
| `endCapId` |`string` (`uuid`)| The id of the extrusion end cap | No |
|
| `endCapId` |`string` (`uuid`)| The id of the extrusion end cap | No |
|
||||||
| `height` |`number` (`double`)| The height of the extrude group. | No |
|
| `height` |`number` (`double`)| The height of the solid. | No |
|
||||||
| `id` |`string` (`uuid`)| The id of the extrude group. | No |
|
| `id` |`string` (`uuid`)| The id of the solid. | No |
|
||||||
| `sketchGroup` |`object`| The sketch group. | No |
|
| `sketch` |`object`| The sketch. | No |
|
||||||
| `startCapId` |`string` (`uuid`)| The id of the extrusion start cap | No |
|
| `startCapId` |`string` (`uuid`)| The id of the extrusion start cap | No |
|
||||||
| `type` |enum: `extrudeGroup`
|
| `type` |enum: `solid`| | No |
|
||||||
| | No |
|
|
||||||
| `value` |`array`| The extrude surfaces. | No |
|
| `value` |`array`| The extrude surfaces. | No |
|
||||||
|
|
||||||
|
|
||||||
@ -47,8 +46,7 @@ An extrude group is a collection of extrude surfaces.
|
|||||||
|
|
||||||
| Property | Type | Description | Required |
|
| Property | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `type` |enum: `extrudeGroups`
|
| `type` |enum: `solids`| | No |
|
||||||
| | No |
|
|
||||||
|
|
||||||
|
|
||||||
----
|
----
|
@ -9,7 +9,7 @@ Draw a line relative to the current origin to a specified distance away
|
|||||||
from the current position along the 'x' axis.
|
from the current position along the 'x' axis.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
xLine(length: number, sketch_group: SketchGroup, tag?: TagDeclarator) -> SketchGroup
|
xLine(length: number, sketch: Sketch, tag?: TagDeclarator) -> Sketch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -18,12 +18,12 @@ xLine(length: number, sketch_group: SketchGroup, tag?: TagDeclarator) -> SketchG
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `length` | `number` | | Yes |
|
| `length` | `number` | | Yes |
|
||||||
| `sketch_group` | [`SketchGroup`](/docs/kcl/types/SketchGroup) | A sketch group is a collection of paths. | Yes |
|
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | A sketch is a collection of paths. | Yes |
|
||||||
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`SketchGroup`](/docs/kcl/types/SketchGroup) - A sketch group is a collection of paths.
|
[`Sketch`](/docs/kcl/types/Sketch) - A sketch is a collection of paths.
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -9,7 +9,7 @@ Draw a line parallel to the X axis, that ends at the given X.
|
|||||||
E.g. if the previous line ended at (1, 1), then xLineTo(4) draws a line from (1, 1) to (4, 1)
|
E.g. if the previous line ended at (1, 1), then xLineTo(4) draws a line from (1, 1) to (4, 1)
|
||||||
|
|
||||||
```js
|
```js
|
||||||
xLineTo(to: number, sketch_group: SketchGroup, tag?: TagDeclarator) -> SketchGroup
|
xLineTo(to: number, sketch: Sketch, tag?: TagDeclarator) -> Sketch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -18,12 +18,12 @@ xLineTo(to: number, sketch_group: SketchGroup, tag?: TagDeclarator) -> SketchGro
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `to` | `number` | | Yes |
|
| `to` | `number` | | Yes |
|
||||||
| `sketch_group` | [`SketchGroup`](/docs/kcl/types/SketchGroup) | A sketch group is a collection of paths. | Yes |
|
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | A sketch is a collection of paths. | Yes |
|
||||||
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`SketchGroup`](/docs/kcl/types/SketchGroup) - A sketch group is a collection of paths.
|
[`Sketch`](/docs/kcl/types/Sketch) - A sketch is a collection of paths.
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -9,7 +9,7 @@ Draw a line relative to the current origin to a specified distance away
|
|||||||
from the current position along the 'y' axis.
|
from the current position along the 'y' axis.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
yLine(length: number, sketch_group: SketchGroup, tag?: TagDeclarator) -> SketchGroup
|
yLine(length: number, sketch: Sketch, tag?: TagDeclarator) -> Sketch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -18,12 +18,12 @@ yLine(length: number, sketch_group: SketchGroup, tag?: TagDeclarator) -> SketchG
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `length` | `number` | | Yes |
|
| `length` | `number` | | Yes |
|
||||||
| `sketch_group` | [`SketchGroup`](/docs/kcl/types/SketchGroup) | A sketch group is a collection of paths. | Yes |
|
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | A sketch is a collection of paths. | Yes |
|
||||||
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`SketchGroup`](/docs/kcl/types/SketchGroup) - A sketch group is a collection of paths.
|
[`Sketch`](/docs/kcl/types/Sketch) - A sketch is a collection of paths.
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -9,7 +9,7 @@ Draw a line parallel to the Y axis, that ends at the given Y.
|
|||||||
E.g. if the previous line ended at (1, 1), then yLineTo(4) draws a line from (1, 1) to (1, 4)
|
E.g. if the previous line ended at (1, 1), then yLineTo(4) draws a line from (1, 1) to (1, 4)
|
||||||
|
|
||||||
```js
|
```js
|
||||||
yLineTo(to: number, sketch_group: SketchGroup, tag?: TagDeclarator) -> SketchGroup
|
yLineTo(to: number, sketch: Sketch, tag?: TagDeclarator) -> Sketch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -18,12 +18,12 @@ yLineTo(to: number, sketch_group: SketchGroup, tag?: TagDeclarator) -> SketchGro
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `to` | `number` | | Yes |
|
| `to` | `number` | | Yes |
|
||||||
| `sketch_group` | [`SketchGroup`](/docs/kcl/types/SketchGroup) | A sketch group is a collection of paths. | Yes |
|
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | A sketch is a collection of paths. | Yes |
|
||||||
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
[`SketchGroup`](/docs/kcl/types/SketchGroup) - A sketch group is a collection of paths.
|
[`Sketch`](/docs/kcl/types/Sketch) - A sketch is a collection of paths.
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -40,7 +40,7 @@ export const isErrorWhitelisted = (exception: Error) => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '',
|
name: '',
|
||||||
message: 'sketchGroup not found',
|
message: 'sketch not found',
|
||||||
stack: '',
|
stack: '',
|
||||||
foundInSpec:
|
foundInSpec:
|
||||||
'e2e/playwright/testing-selections.spec.ts Deselecting line tool should mean nothing happens on click',
|
'e2e/playwright/testing-selections.spec.ts Deselecting line tool should mean nothing happens on click',
|
||||||
@ -206,8 +206,8 @@ export const isErrorWhitelisted = (exception: Error) => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Unhandled Promise Rejection',
|
name: 'Unhandled Promise Rejection',
|
||||||
message: 'sketchGroup not found',
|
message: 'sketch not found',
|
||||||
stack: `Unhandled Promise Rejection: sketchGroup not found
|
stack: `Unhandled Promise Rejection: sketch not found
|
||||||
at unknown (http://localhost:3000/src/machines/modelingMachine.ts:911:49)`,
|
at unknown (http://localhost:3000/src/machines/modelingMachine.ts:911:49)`,
|
||||||
foundInSpec:
|
foundInSpec:
|
||||||
'e2e/playwright/testing-selections.spec.ts Deselecting line tool should mean nothing happens on click',
|
'e2e/playwright/testing-selections.spec.ts Deselecting line tool should mean nothing happens on click',
|
||||||
|
@ -1199,7 +1199,7 @@ test(
|
|||||||
'kittycad_svg.kcl',
|
'kittycad_svg.kcl',
|
||||||
'lego.kcl',
|
'lego.kcl',
|
||||||
'math.kcl',
|
'math.kcl',
|
||||||
'member_expression_sketch_group.kcl',
|
'member_expression_sketch.kcl',
|
||||||
'mike_stress_test.kcl',
|
'mike_stress_test.kcl',
|
||||||
'negative_args.kcl',
|
'negative_args.kcl',
|
||||||
'order-sketch-extrude-in-order.kcl',
|
'order-sketch-extrude-in-order.kcl',
|
||||||
|
@ -39,11 +39,11 @@ import {
|
|||||||
Program,
|
Program,
|
||||||
ProgramMemory,
|
ProgramMemory,
|
||||||
recast,
|
recast,
|
||||||
SketchGroup,
|
Sketch,
|
||||||
ExtrudeGroup,
|
Solid,
|
||||||
VariableDeclaration,
|
VariableDeclaration,
|
||||||
VariableDeclarator,
|
VariableDeclarator,
|
||||||
sketchGroupFromKclValue,
|
sketchFromKclValue,
|
||||||
} from 'lang/wasm'
|
} from 'lang/wasm'
|
||||||
import {
|
import {
|
||||||
engineCommandManager,
|
engineCommandManager,
|
||||||
@ -378,7 +378,7 @@ export class SceneEntities {
|
|||||||
}): Promise<{
|
}): Promise<{
|
||||||
truncatedAst: Program
|
truncatedAst: Program
|
||||||
programMemoryOverride: ProgramMemory
|
programMemoryOverride: ProgramMemory
|
||||||
sketchGroup: SketchGroup
|
sketch: Sketch
|
||||||
variableDeclarationName: string
|
variableDeclarationName: string
|
||||||
}> {
|
}> {
|
||||||
this.createIntersectionPlane()
|
this.createIntersectionPlane()
|
||||||
@ -397,19 +397,19 @@ export class SceneEntities {
|
|||||||
engineCommandManager: this.engineCommandManager,
|
engineCommandManager: this.engineCommandManager,
|
||||||
programMemoryOverride,
|
programMemoryOverride,
|
||||||
})
|
})
|
||||||
const sketchGroup = sketchGroupFromPathToNode({
|
const sketch = sketchFromPathToNode({
|
||||||
pathToNode: sketchPathToNode,
|
pathToNode: sketchPathToNode,
|
||||||
ast: maybeModdedAst,
|
ast: maybeModdedAst,
|
||||||
programMemory,
|
programMemory,
|
||||||
})
|
})
|
||||||
if (err(sketchGroup)) return Promise.reject(sketchGroup)
|
if (err(sketch)) return Promise.reject(sketch)
|
||||||
if (!sketchGroup) return Promise.reject('sketchGroup not found')
|
if (!sketch) return Promise.reject('sketch not found')
|
||||||
|
|
||||||
if (!isArray(sketchGroup?.value))
|
if (!isArray(sketch?.value))
|
||||||
return {
|
return {
|
||||||
truncatedAst,
|
truncatedAst,
|
||||||
programMemoryOverride,
|
programMemoryOverride,
|
||||||
sketchGroup,
|
sketch,
|
||||||
variableDeclarationName,
|
variableDeclarationName,
|
||||||
}
|
}
|
||||||
this.sceneProgramMemory = programMemory
|
this.sceneProgramMemory = programMemory
|
||||||
@ -431,12 +431,12 @@ export class SceneEntities {
|
|||||||
|
|
||||||
const segPathToNode = getNodePathFromSourceRange(
|
const segPathToNode = getNodePathFromSourceRange(
|
||||||
maybeModdedAst,
|
maybeModdedAst,
|
||||||
sketchGroup.start.__geoMeta.sourceRange
|
sketch.start.__geoMeta.sourceRange
|
||||||
)
|
)
|
||||||
if (sketchGroup?.value?.[0]?.type !== 'Circle') {
|
if (sketch?.value?.[0]?.type !== 'Circle') {
|
||||||
const _profileStart = createProfileStartHandle({
|
const _profileStart = createProfileStartHandle({
|
||||||
from: sketchGroup.start.from,
|
from: sketch.start.from,
|
||||||
id: sketchGroup.start.__geoMeta.id,
|
id: sketch.start.__geoMeta.id,
|
||||||
pathToNode: segPathToNode,
|
pathToNode: segPathToNode,
|
||||||
scale: factor,
|
scale: factor,
|
||||||
theme: sceneInfra._theme,
|
theme: sceneInfra._theme,
|
||||||
@ -449,17 +449,16 @@ export class SceneEntities {
|
|||||||
this.activeSegments[JSON.stringify(segPathToNode)] = _profileStart
|
this.activeSegments[JSON.stringify(segPathToNode)] = _profileStart
|
||||||
}
|
}
|
||||||
const callbacks: (() => SegmentOverlayPayload | null)[] = []
|
const callbacks: (() => SegmentOverlayPayload | null)[] = []
|
||||||
sketchGroup.value.forEach((segment, index) => {
|
sketch.value.forEach((segment, index) => {
|
||||||
let segPathToNode = getNodePathFromSourceRange(
|
let segPathToNode = getNodePathFromSourceRange(
|
||||||
maybeModdedAst,
|
maybeModdedAst,
|
||||||
segment.__geoMeta.sourceRange
|
segment.__geoMeta.sourceRange
|
||||||
)
|
)
|
||||||
if (
|
if (
|
||||||
draftExpressionsIndices &&
|
draftExpressionsIndices &&
|
||||||
(sketchGroup.value[index - 1] || sketchGroup.start)
|
(sketch.value[index - 1] || sketch.start)
|
||||||
) {
|
) {
|
||||||
const previousSegment =
|
const previousSegment = sketch.value[index - 1] || sketch.start
|
||||||
sketchGroup.value[index - 1] || sketchGroup.start
|
|
||||||
const previousSegmentPathToNode = getNodePathFromSourceRange(
|
const previousSegmentPathToNode = getNodePathFromSourceRange(
|
||||||
maybeModdedAst,
|
maybeModdedAst,
|
||||||
previousSegment.__geoMeta.sourceRange
|
previousSegment.__geoMeta.sourceRange
|
||||||
@ -510,7 +509,7 @@ export class SceneEntities {
|
|||||||
to: segment.to,
|
to: segment.to,
|
||||||
}
|
}
|
||||||
const result = initSegment({
|
const result = initSegment({
|
||||||
prevSegment: sketchGroup.value[index - 1],
|
prevSegment: sketch.value[index - 1],
|
||||||
callExpName,
|
callExpName,
|
||||||
input,
|
input,
|
||||||
id: segment.__geoMeta.id,
|
id: segment.__geoMeta.id,
|
||||||
@ -554,7 +553,7 @@ export class SceneEntities {
|
|||||||
return {
|
return {
|
||||||
truncatedAst,
|
truncatedAst,
|
||||||
programMemoryOverride,
|
programMemoryOverride,
|
||||||
sketchGroup,
|
sketch,
|
||||||
variableDeclarationName,
|
variableDeclarationName,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -604,7 +603,7 @@ export class SceneEntities {
|
|||||||
const variableDeclarationName =
|
const variableDeclarationName =
|
||||||
_node1.node?.declarations?.[0]?.id?.name || ''
|
_node1.node?.declarations?.[0]?.id?.name || ''
|
||||||
|
|
||||||
const sg = sketchGroupFromKclValue(
|
const sg = sketchFromKclValue(
|
||||||
kclManager.programMemory.get(variableDeclarationName),
|
kclManager.programMemory.get(variableDeclarationName),
|
||||||
variableDeclarationName
|
variableDeclarationName
|
||||||
)
|
)
|
||||||
@ -632,7 +631,7 @@ export class SceneEntities {
|
|||||||
if (shouldTearDown) await this.tearDownSketch({ removeAxis: false })
|
if (shouldTearDown) await this.tearDownSketch({ removeAxis: false })
|
||||||
sceneInfra.resetMouseListeners()
|
sceneInfra.resetMouseListeners()
|
||||||
|
|
||||||
const { truncatedAst, programMemoryOverride, sketchGroup } =
|
const { truncatedAst, programMemoryOverride, sketch } =
|
||||||
await this.setupSketch({
|
await this.setupSketch({
|
||||||
sketchPathToNode,
|
sketchPathToNode,
|
||||||
forward,
|
forward,
|
||||||
@ -653,7 +652,7 @@ export class SceneEntities {
|
|||||||
|
|
||||||
let modifiedAst
|
let modifiedAst
|
||||||
if (profileStart) {
|
if (profileStart) {
|
||||||
const lastSegment = sketchGroup.value.slice(-1)[0]
|
const lastSegment = sketch.value.slice(-1)[0]
|
||||||
modifiedAst = addCallExpressionsToPipe({
|
modifiedAst = addCallExpressionsToPipe({
|
||||||
node: kclManager.ast,
|
node: kclManager.ast,
|
||||||
programMemory: kclManager.programMemory,
|
programMemory: kclManager.programMemory,
|
||||||
@ -685,7 +684,7 @@ export class SceneEntities {
|
|||||||
})
|
})
|
||||||
if (trap(modifiedAst)) return Promise.reject(modifiedAst)
|
if (trap(modifiedAst)) return Promise.reject(modifiedAst)
|
||||||
} else if (intersection2d) {
|
} else if (intersection2d) {
|
||||||
const lastSegment = sketchGroup.value.slice(-1)[0]
|
const lastSegment = sketch.value.slice(-1)[0]
|
||||||
const tmp = addNewSketchLn({
|
const tmp = addNewSketchLn({
|
||||||
node: kclManager.ast,
|
node: kclManager.ast,
|
||||||
programMemory: kclManager.programMemory,
|
programMemory: kclManager.programMemory,
|
||||||
@ -809,24 +808,17 @@ export class SceneEntities {
|
|||||||
programMemoryOverride,
|
programMemoryOverride,
|
||||||
})
|
})
|
||||||
this.sceneProgramMemory = programMemory
|
this.sceneProgramMemory = programMemory
|
||||||
const sketchGroup = sketchGroupFromKclValue(
|
const sketch = sketchFromKclValue(
|
||||||
programMemory.get(variableDeclarationName),
|
programMemory.get(variableDeclarationName),
|
||||||
variableDeclarationName
|
variableDeclarationName
|
||||||
)
|
)
|
||||||
if (err(sketchGroup)) return Promise.reject(sketchGroup)
|
if (err(sketch)) return Promise.reject(sketch)
|
||||||
const sgPaths = sketchGroup.value
|
const sgPaths = sketch.value
|
||||||
const orthoFactor = orthoScale(sceneInfra.camControls.camera)
|
const orthoFactor = orthoScale(sceneInfra.camControls.camera)
|
||||||
|
|
||||||
this.updateSegment(
|
this.updateSegment(sketch.start, 0, 0, _ast, orthoFactor, sketch)
|
||||||
sketchGroup.start,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
_ast,
|
|
||||||
orthoFactor,
|
|
||||||
sketchGroup
|
|
||||||
)
|
|
||||||
sgPaths.forEach((seg, index) =>
|
sgPaths.forEach((seg, index) =>
|
||||||
this.updateSegment(seg, index, 0, _ast, orthoFactor, sketchGroup)
|
this.updateSegment(seg, index, 0, _ast, orthoFactor, sketch)
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
onClick: async (args) => {
|
onClick: async (args) => {
|
||||||
@ -865,26 +857,19 @@ export class SceneEntities {
|
|||||||
|
|
||||||
// Prepare to update the THREEjs scene
|
// Prepare to update the THREEjs scene
|
||||||
this.sceneProgramMemory = programMemory
|
this.sceneProgramMemory = programMemory
|
||||||
const sketchGroup = sketchGroupFromKclValue(
|
const sketch = sketchFromKclValue(
|
||||||
programMemory.get(variableDeclarationName),
|
programMemory.get(variableDeclarationName),
|
||||||
variableDeclarationName
|
variableDeclarationName
|
||||||
)
|
)
|
||||||
if (err(sketchGroup)) return
|
if (err(sketch)) return
|
||||||
const sgPaths = sketchGroup.value
|
const sgPaths = sketch.value
|
||||||
const orthoFactor = orthoScale(sceneInfra.camControls.camera)
|
const orthoFactor = orthoScale(sceneInfra.camControls.camera)
|
||||||
|
|
||||||
// Update the starting segment of the THREEjs scene
|
// Update the starting segment of the THREEjs scene
|
||||||
this.updateSegment(
|
this.updateSegment(sketch.start, 0, 0, _ast, orthoFactor, sketch)
|
||||||
sketchGroup.start,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
_ast,
|
|
||||||
orthoFactor,
|
|
||||||
sketchGroup
|
|
||||||
)
|
|
||||||
// Update the rest of the segments of the THREEjs scene
|
// Update the rest of the segments of the THREEjs scene
|
||||||
sgPaths.forEach((seg, index) =>
|
sgPaths.forEach((seg, index) =>
|
||||||
this.updateSegment(seg, index, 0, _ast, orthoFactor, sketchGroup)
|
this.updateSegment(seg, index, 0, _ast, orthoFactor, sketch)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -987,24 +972,17 @@ export class SceneEntities {
|
|||||||
programMemoryOverride,
|
programMemoryOverride,
|
||||||
})
|
})
|
||||||
this.sceneProgramMemory = programMemory
|
this.sceneProgramMemory = programMemory
|
||||||
const sketchGroup = sketchGroupFromKclValue(
|
const sketch = sketchFromKclValue(
|
||||||
programMemory.get(variableDeclarationName),
|
programMemory.get(variableDeclarationName),
|
||||||
variableDeclarationName
|
variableDeclarationName
|
||||||
)
|
)
|
||||||
if (err(sketchGroup)) return
|
if (err(sketch)) return
|
||||||
const sgPaths = sketchGroup.value
|
const sgPaths = sketch.value
|
||||||
const orthoFactor = orthoScale(sceneInfra.camControls.camera)
|
const orthoFactor = orthoScale(sceneInfra.camControls.camera)
|
||||||
|
|
||||||
this.updateSegment(
|
this.updateSegment(sketch.start, 0, 0, _ast, orthoFactor, sketch)
|
||||||
sketchGroup.start,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
_ast,
|
|
||||||
orthoFactor,
|
|
||||||
sketchGroup
|
|
||||||
)
|
|
||||||
sgPaths.forEach((seg, index) =>
|
sgPaths.forEach((seg, index) =>
|
||||||
this.updateSegment(seg, index, 0, _ast, orthoFactor, sketchGroup)
|
this.updateSegment(seg, index, 0, _ast, orthoFactor, sketch)
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
onClick: async (args) => {
|
onClick: async (args) => {
|
||||||
@ -1106,20 +1084,20 @@ export class SceneEntities {
|
|||||||
(x) => x[1] === 'PipeExpression'
|
(x) => x[1] === 'PipeExpression'
|
||||||
)
|
)
|
||||||
|
|
||||||
const sketchGroup = sketchGroupFromPathToNode({
|
const sketch = sketchFromPathToNode({
|
||||||
pathToNode,
|
pathToNode,
|
||||||
ast: kclManager.ast,
|
ast: kclManager.ast,
|
||||||
programMemory: kclManager.programMemory,
|
programMemory: kclManager.programMemory,
|
||||||
})
|
})
|
||||||
if (trap(sketchGroup)) return
|
if (trap(sketch)) return
|
||||||
if (!sketchGroup) {
|
if (!sketch) {
|
||||||
trap(new Error('sketchGroup not found'))
|
trap(new Error('sketch not found'))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const pipeIndex = pathToNode[pathToNodeIndex + 1][0] as number
|
const pipeIndex = pathToNode[pathToNodeIndex + 1][0] as number
|
||||||
if (addingNewSegmentStatus === 'nothing') {
|
if (addingNewSegmentStatus === 'nothing') {
|
||||||
const prevSegment = sketchGroup.value[pipeIndex - 2]
|
const prevSegment = sketch.value[pipeIndex - 2]
|
||||||
const mod = addNewSketchLn({
|
const mod = addNewSketchLn({
|
||||||
node: kclManager.ast,
|
node: kclManager.ast,
|
||||||
programMemory: kclManager.programMemory,
|
programMemory: kclManager.programMemory,
|
||||||
@ -1347,29 +1325,26 @@ export class SceneEntities {
|
|||||||
})
|
})
|
||||||
this.sceneProgramMemory = programMemory
|
this.sceneProgramMemory = programMemory
|
||||||
|
|
||||||
const maybeSketchGroup = programMemory.get(variableDeclarationName)
|
const maybeSketch = programMemory.get(variableDeclarationName)
|
||||||
let sketchGroup = undefined
|
let sketch = undefined
|
||||||
const sg = sketchGroupFromKclValue(
|
const sg = sketchFromKclValue(maybeSketch, variableDeclarationName)
|
||||||
maybeSketchGroup,
|
|
||||||
variableDeclarationName
|
|
||||||
)
|
|
||||||
if (!err(sg)) {
|
if (!err(sg)) {
|
||||||
sketchGroup = sg
|
sketch = sg
|
||||||
} else if ((maybeSketchGroup as ExtrudeGroup).sketchGroup) {
|
} else if ((maybeSketch as Solid).sketch) {
|
||||||
sketchGroup = (maybeSketchGroup as ExtrudeGroup).sketchGroup
|
sketch = (maybeSketch as Solid).sketch
|
||||||
}
|
}
|
||||||
if (!sketchGroup) return
|
if (!sketch) return
|
||||||
|
|
||||||
const sgPaths = sketchGroup.value
|
const sgPaths = sketch.value
|
||||||
const orthoFactor = orthoScale(sceneInfra.camControls.camera)
|
const orthoFactor = orthoScale(sceneInfra.camControls.camera)
|
||||||
|
|
||||||
this.updateSegment(
|
this.updateSegment(
|
||||||
sketchGroup.start,
|
sketch.start,
|
||||||
0,
|
0,
|
||||||
varDecIndex,
|
varDecIndex,
|
||||||
modifiedAst,
|
modifiedAst,
|
||||||
orthoFactor,
|
orthoFactor,
|
||||||
sketchGroup
|
sketch
|
||||||
)
|
)
|
||||||
|
|
||||||
const callBacks = sgPaths.map((group, index) =>
|
const callBacks = sgPaths.map((group, index) =>
|
||||||
@ -1379,7 +1354,7 @@ export class SceneEntities {
|
|||||||
varDecIndex,
|
varDecIndex,
|
||||||
modifiedAst,
|
modifiedAst,
|
||||||
orthoFactor,
|
orthoFactor,
|
||||||
sketchGroup
|
sketch
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
sceneInfra.overlayCallbacks(callBacks)
|
sceneInfra.overlayCallbacks(callBacks)
|
||||||
@ -1394,29 +1369,29 @@ export class SceneEntities {
|
|||||||
* @param varDecIndex
|
* @param varDecIndex
|
||||||
* @param modifiedAst
|
* @param modifiedAst
|
||||||
* @param orthoFactor
|
* @param orthoFactor
|
||||||
* @param sketchGroup
|
* @param sketch
|
||||||
*/
|
*/
|
||||||
updateSegment = (
|
updateSegment = (
|
||||||
segment: Path | SketchGroup['start'],
|
segment: Path | Sketch['start'],
|
||||||
index: number,
|
index: number,
|
||||||
varDecIndex: number,
|
varDecIndex: number,
|
||||||
modifiedAst: Program,
|
modifiedAst: Program,
|
||||||
orthoFactor: number,
|
orthoFactor: number,
|
||||||
sketchGroup: SketchGroup
|
sketch: Sketch
|
||||||
): (() => SegmentOverlayPayload | null) => {
|
): (() => SegmentOverlayPayload | null) => {
|
||||||
const segPathToNode = getNodePathFromSourceRange(
|
const segPathToNode = getNodePathFromSourceRange(
|
||||||
modifiedAst,
|
modifiedAst,
|
||||||
segment.__geoMeta.sourceRange
|
segment.__geoMeta.sourceRange
|
||||||
)
|
)
|
||||||
const sgPaths = sketchGroup.value
|
const sgPaths = sketch.value
|
||||||
const originalPathToNodeStr = JSON.stringify(segPathToNode)
|
const originalPathToNodeStr = JSON.stringify(segPathToNode)
|
||||||
segPathToNode[1][0] = varDecIndex
|
segPathToNode[1][0] = varDecIndex
|
||||||
const pathToNodeStr = JSON.stringify(segPathToNode)
|
const pathToNodeStr = JSON.stringify(segPathToNode)
|
||||||
// more hacks to hopefully be solved by proper pathToNode info in memory/sketchGroup segments
|
// more hacks to hopefully be solved by proper pathToNode info in memory/sketch segments
|
||||||
const group =
|
const group =
|
||||||
this.activeSegments[pathToNodeStr] ||
|
this.activeSegments[pathToNodeStr] ||
|
||||||
this.activeSegments[originalPathToNodeStr]
|
this.activeSegments[originalPathToNodeStr]
|
||||||
// const prevSegment = sketchGroup.slice(index - 1)[0]
|
// const prevSegment = sketch.slice(index - 1)[0]
|
||||||
const type = group?.userData?.type
|
const type = group?.userData?.type
|
||||||
const factor =
|
const factor =
|
||||||
(sceneInfra.camControls.camera instanceof OrthographicCamera
|
(sceneInfra.camControls.camera instanceof OrthographicCamera
|
||||||
@ -1711,7 +1686,7 @@ function prepareTruncatedMemoryAndAst(
|
|||||||
)
|
)
|
||||||
if (err(_node)) return _node
|
if (err(_node)) return _node
|
||||||
const variableDeclarationName = _node.node?.declarations?.[0]?.id?.name || ''
|
const variableDeclarationName = _node.node?.declarations?.[0]?.id?.name || ''
|
||||||
const sg = sketchGroupFromKclValue(
|
const sg = sketchFromKclValue(
|
||||||
programMemory.get(variableDeclarationName),
|
programMemory.get(variableDeclarationName),
|
||||||
variableDeclarationName
|
variableDeclarationName
|
||||||
)
|
)
|
||||||
@ -1739,7 +1714,7 @@ function prepareTruncatedMemoryAndAst(
|
|||||||
.init as PipeExpression
|
.init as PipeExpression
|
||||||
).body.push(newSegment)
|
).body.push(newSegment)
|
||||||
// update source ranges to section we just added.
|
// update source ranges to section we just added.
|
||||||
// hacks like this wouldn't be needed if the AST put pathToNode info in memory/sketchGroup segments
|
// hacks like this wouldn't be needed if the AST put pathToNode info in memory/sketch segments
|
||||||
const updatedSrcRangeAst = parse(recast(_ast)) // get source ranges correct since unfortunately we still rely on them
|
const updatedSrcRangeAst = parse(recast(_ast)) // get source ranges correct since unfortunately we still rely on them
|
||||||
if (err(updatedSrcRangeAst)) return updatedSrcRangeAst
|
if (err(updatedSrcRangeAst)) return updatedSrcRangeAst
|
||||||
|
|
||||||
@ -1820,7 +1795,7 @@ export function getParentGroup(
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
export function sketchGroupFromPathToNode({
|
export function sketchFromPathToNode({
|
||||||
pathToNode,
|
pathToNode,
|
||||||
ast,
|
ast,
|
||||||
programMemory,
|
programMemory,
|
||||||
@ -1828,7 +1803,7 @@ export function sketchGroupFromPathToNode({
|
|||||||
pathToNode: PathToNode
|
pathToNode: PathToNode
|
||||||
ast: Program
|
ast: Program
|
||||||
programMemory: ProgramMemory
|
programMemory: ProgramMemory
|
||||||
}): SketchGroup | null | Error {
|
}): Sketch | null | Error {
|
||||||
const _varDec = getNodeFromPath<VariableDeclarator>(
|
const _varDec = getNodeFromPath<VariableDeclarator>(
|
||||||
kclManager.ast,
|
kclManager.ast,
|
||||||
pathToNode,
|
pathToNode,
|
||||||
@ -1837,10 +1812,10 @@ export function sketchGroupFromPathToNode({
|
|||||||
if (err(_varDec)) return _varDec
|
if (err(_varDec)) return _varDec
|
||||||
const varDec = _varDec.node
|
const varDec = _varDec.node
|
||||||
const result = programMemory.get(varDec?.id?.name || '')
|
const result = programMemory.get(varDec?.id?.name || '')
|
||||||
if (result?.type === 'ExtrudeGroup') {
|
if (result?.type === 'Solid') {
|
||||||
return result.sketchGroup
|
return result.sketch
|
||||||
}
|
}
|
||||||
const sg = sketchGroupFromKclValue(result, varDec?.id?.name)
|
const sg = sketchFromKclValue(result, varDec?.id?.name)
|
||||||
if (err(sg)) {
|
if (err(sg)) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@ -1872,14 +1847,14 @@ export function getSketchQuaternion(
|
|||||||
sketchPathToNode: PathToNode,
|
sketchPathToNode: PathToNode,
|
||||||
sketchNormalBackUp: [number, number, number] | null
|
sketchNormalBackUp: [number, number, number] | null
|
||||||
): Quaternion | Error {
|
): Quaternion | Error {
|
||||||
const sketchGroup = sketchGroupFromPathToNode({
|
const sketch = sketchFromPathToNode({
|
||||||
pathToNode: sketchPathToNode,
|
pathToNode: sketchPathToNode,
|
||||||
ast: kclManager.ast,
|
ast: kclManager.ast,
|
||||||
programMemory: kclManager.programMemory,
|
programMemory: kclManager.programMemory,
|
||||||
})
|
})
|
||||||
if (err(sketchGroup)) return sketchGroup
|
if (err(sketch)) return sketch
|
||||||
const zAxis = sketchGroup?.on.zAxis || sketchNormalBackUp
|
const zAxis = sketch?.on.zAxis || sketchNormalBackUp
|
||||||
if (!zAxis) return Error('SketchGroup zAxis not found')
|
if (!zAxis) return Error('Sketch zAxis not found')
|
||||||
|
|
||||||
return getQuaternionFromZAxis(massageFormats(zAxis))
|
return getQuaternionFromZAxis(massageFormats(zAxis))
|
||||||
}
|
}
|
||||||
@ -1889,34 +1864,30 @@ export async function getSketchOrientationDetails(
|
|||||||
quat: Quaternion
|
quat: Quaternion
|
||||||
sketchDetails: SketchDetails & { faceId?: string }
|
sketchDetails: SketchDetails & { faceId?: string }
|
||||||
}> {
|
}> {
|
||||||
const sketchGroup = sketchGroupFromPathToNode({
|
const sketch = sketchFromPathToNode({
|
||||||
pathToNode: sketchPathToNode,
|
pathToNode: sketchPathToNode,
|
||||||
ast: kclManager.ast,
|
ast: kclManager.ast,
|
||||||
programMemory: kclManager.programMemory,
|
programMemory: kclManager.programMemory,
|
||||||
})
|
})
|
||||||
if (err(sketchGroup)) return Promise.reject(sketchGroup)
|
if (err(sketch)) return Promise.reject(sketch)
|
||||||
if (!sketchGroup) return Promise.reject('sketchGroup not found')
|
if (!sketch) return Promise.reject('sketch not found')
|
||||||
|
|
||||||
if (sketchGroup.on.type === 'plane') {
|
if (sketch.on.type === 'plane') {
|
||||||
const zAxis = sketchGroup?.on.zAxis
|
const zAxis = sketch?.on.zAxis
|
||||||
return {
|
return {
|
||||||
quat: getQuaternionFromZAxis(massageFormats(zAxis)),
|
quat: getQuaternionFromZAxis(massageFormats(zAxis)),
|
||||||
sketchDetails: {
|
sketchDetails: {
|
||||||
sketchPathToNode,
|
sketchPathToNode,
|
||||||
zAxis: [zAxis.x, zAxis.y, zAxis.z],
|
zAxis: [zAxis.x, zAxis.y, zAxis.z],
|
||||||
yAxis: [
|
yAxis: [sketch.on.yAxis.x, sketch.on.yAxis.y, sketch.on.yAxis.z],
|
||||||
sketchGroup.on.yAxis.x,
|
|
||||||
sketchGroup.on.yAxis.y,
|
|
||||||
sketchGroup.on.yAxis.z,
|
|
||||||
],
|
|
||||||
origin: [0, 0, 0],
|
origin: [0, 0, 0],
|
||||||
faceId: sketchGroup.on.id,
|
faceId: sketch.on.id,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sketchGroup.on.type === 'face') {
|
if (sketch.on.type === 'face') {
|
||||||
const faceInfo = await getFaceDetails(sketchGroup.on.id)
|
const faceInfo = await getFaceDetails(sketch.on.id)
|
||||||
|
|
||||||
if (!faceInfo?.origin || !faceInfo?.z_axis || !faceInfo?.y_axis)
|
if (!faceInfo?.origin || !faceInfo?.z_axis || !faceInfo?.y_axis)
|
||||||
return Promise.reject('face info')
|
return Promise.reject('face info')
|
||||||
@ -1932,12 +1903,12 @@ export async function getSketchOrientationDetails(
|
|||||||
zAxis: [z_axis.x, z_axis.y, z_axis.z],
|
zAxis: [z_axis.x, z_axis.y, z_axis.z],
|
||||||
yAxis: [y_axis.x, y_axis.y, y_axis.z],
|
yAxis: [y_axis.x, y_axis.y, y_axis.z],
|
||||||
origin: [origin.x, origin.y, origin.z],
|
origin: [origin.x, origin.y, origin.z],
|
||||||
faceId: sketchGroup.on.id,
|
faceId: sketch.on.id,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Promise.reject(
|
return Promise.reject(
|
||||||
'sketchGroup.on.type not recognized, has a new type been added?'
|
'sketch.on.type not recognized, has a new type been added?'
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ import {
|
|||||||
} from 'three'
|
} from 'three'
|
||||||
import { mergeGeometries } from 'three/examples/jsm/utils/BufferGeometryUtils.js'
|
import { mergeGeometries } from 'three/examples/jsm/utils/BufferGeometryUtils.js'
|
||||||
import { CSS2DObject } from 'three/examples/jsm/renderers/CSS2DRenderer'
|
import { CSS2DObject } from 'three/examples/jsm/renderers/CSS2DRenderer'
|
||||||
import { PathToNode, SketchGroup, getTangentialArcToInfo } from 'lang/wasm'
|
import { PathToNode, Sketch, getTangentialArcToInfo } from 'lang/wasm'
|
||||||
import {
|
import {
|
||||||
CIRCLE_CENTER_HANDLE,
|
CIRCLE_CENTER_HANDLE,
|
||||||
CIRCLE_SEGMENT,
|
CIRCLE_SEGMENT,
|
||||||
@ -58,7 +58,7 @@ import { err } from 'lib/trap'
|
|||||||
|
|
||||||
interface CreateSegmentArgs {
|
interface CreateSegmentArgs {
|
||||||
input: SegmentInputs
|
input: SegmentInputs
|
||||||
prevSegment: SketchGroup['value'][number]
|
prevSegment: Sketch['value'][number]
|
||||||
id: string
|
id: string
|
||||||
pathToNode: PathToNode
|
pathToNode: PathToNode
|
||||||
isDraftSegment?: boolean
|
isDraftSegment?: boolean
|
||||||
@ -72,7 +72,7 @@ interface CreateSegmentArgs {
|
|||||||
|
|
||||||
interface UpdateSegmentArgs {
|
interface UpdateSegmentArgs {
|
||||||
input: SegmentInputs
|
input: SegmentInputs
|
||||||
prevSegment: SketchGroup['value'][number]
|
prevSegment: Sketch['value'][number]
|
||||||
group: Group
|
group: Group
|
||||||
sceneInfra: SceneInfra
|
sceneInfra: SceneInfra
|
||||||
scale?: number
|
scale?: number
|
||||||
|
@ -5,7 +5,7 @@ import {
|
|||||||
ProgramMemory,
|
ProgramMemory,
|
||||||
Path,
|
Path,
|
||||||
ExtrudeSurface,
|
ExtrudeSurface,
|
||||||
sketchGroupFromKclValue,
|
sketchFromKclValue,
|
||||||
} from 'lang/wasm'
|
} from 'lang/wasm'
|
||||||
import { useKclContext } from 'lang/KclProvider'
|
import { useKclContext } from 'lang/KclProvider'
|
||||||
import { useResolvedTheme } from 'hooks/useResolvedTheme'
|
import { useResolvedTheme } from 'hooks/useResolvedTheme'
|
||||||
@ -89,8 +89,8 @@ export const processMemory = (programMemory: ProgramMemory) => {
|
|||||||
const processedMemory: any = {}
|
const processedMemory: any = {}
|
||||||
for (const [key, val] of programMemory?.visibleEntries()) {
|
for (const [key, val] of programMemory?.visibleEntries()) {
|
||||||
if (typeof val.value !== 'function') {
|
if (typeof val.value !== 'function') {
|
||||||
const sg = sketchGroupFromKclValue(val, null)
|
const sg = sketchFromKclValue(val, null)
|
||||||
if (val.type === 'ExtrudeGroup') {
|
if (val.type === 'Solid') {
|
||||||
processedMemory[key] = val.value.map(({ ...rest }: ExtrudeSurface) => {
|
processedMemory[key] = val.value.map(({ ...rest }: ExtrudeSurface) => {
|
||||||
return rest
|
return rest
|
||||||
})
|
})
|
||||||
|
@ -57,7 +57,7 @@ ArgumentList { "(" commaSep<expression> ")" }
|
|||||||
type[@isGroup=Type] {
|
type[@isGroup=Type] {
|
||||||
@specialize[@name=PrimitiveType]<
|
@specialize[@name=PrimitiveType]<
|
||||||
identifier,
|
identifier,
|
||||||
"string" | "number" | "bool" | "sketch_group" | "sketch_surface" | "extrude_group"
|
"string" | "number" | "bool" | "sketch" | "sketch_surface" | "solid"
|
||||||
> |
|
> |
|
||||||
ArrayType { type !member "[" "]" } |
|
ArrayType { type !member "[" "]" } |
|
||||||
ObjectType { "{" commaSep<ObjectProperty { PropertyName ":" type }> "}" }
|
ObjectType { "{" commaSep<ObjectProperty { PropertyName ":" type }> "}" }
|
||||||
|
@ -552,7 +552,7 @@ function defaultSelectionFilter(
|
|||||||
engineCommandManager: EngineCommandManager
|
engineCommandManager: EngineCommandManager
|
||||||
) {
|
) {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||||
programMemory.hasSketchOrExtrudeGroup() &&
|
programMemory.hasSketchOrSolid() &&
|
||||||
engineCommandManager.sendSceneCommand({
|
engineCommandManager.sendSceneCommand({
|
||||||
type: 'modeling_cmd_req',
|
type: 'modeling_cmd_req',
|
||||||
cmd_id: uuidv4(),
|
cmd_id: uuidv4(),
|
||||||
|
@ -21,7 +21,7 @@ const mySketch001 = startSketchOn('XY')
|
|||||||
type: 'UserVal',
|
type: 'UserVal',
|
||||||
__meta: [{ sourceRange: [46, 71] }],
|
__meta: [{ sourceRange: [46, 71] }],
|
||||||
value: {
|
value: {
|
||||||
type: 'SketchGroup',
|
type: 'Sketch',
|
||||||
on: expect.any(Object),
|
on: expect.any(Object),
|
||||||
start: {
|
start: {
|
||||||
to: [0, 0],
|
to: [0, 0],
|
||||||
@ -72,7 +72,7 @@ const mySketch001 = startSketchOn('XY')
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const sketch001 = programMemory?.get('mySketch001')
|
const sketch001 = programMemory?.get('mySketch001')
|
||||||
expect(sketch001).toEqual({
|
expect(sketch001).toEqual({
|
||||||
type: 'ExtrudeGroup',
|
type: 'Solid',
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
value: [
|
value: [
|
||||||
{
|
{
|
||||||
@ -90,12 +90,12 @@ const mySketch001 = startSketchOn('XY')
|
|||||||
sourceRange: [108, 132],
|
sourceRange: [108, 132],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
sketchGroup: {
|
sketch: {
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
__meta: expect.any(Array),
|
__meta: expect.any(Array),
|
||||||
on: expect.any(Object),
|
on: expect.any(Object),
|
||||||
start: expect.any(Object),
|
start: expect.any(Object),
|
||||||
type: 'SketchGroup',
|
type: 'Sketch',
|
||||||
value: [
|
value: [
|
||||||
{
|
{
|
||||||
type: 'ToPoint',
|
type: 'ToPoint',
|
||||||
@ -153,7 +153,7 @@ const sk2 = startSketchOn('XY')
|
|||||||
const geos = [programMemory?.get('theExtrude'), programMemory?.get('sk2')]
|
const geos = [programMemory?.get('theExtrude'), programMemory?.get('sk2')]
|
||||||
expect(geos).toEqual([
|
expect(geos).toEqual([
|
||||||
{
|
{
|
||||||
type: 'ExtrudeGroup',
|
type: 'Solid',
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
value: [
|
value: [
|
||||||
{
|
{
|
||||||
@ -184,12 +184,12 @@ const sk2 = startSketchOn('XY')
|
|||||||
sourceRange: [123, 142],
|
sourceRange: [123, 142],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
sketchGroup: {
|
sketch: {
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
__meta: expect.any(Array),
|
__meta: expect.any(Array),
|
||||||
on: expect.any(Object),
|
on: expect.any(Object),
|
||||||
start: expect.any(Object),
|
start: expect.any(Object),
|
||||||
type: 'SketchGroup',
|
type: 'Sketch',
|
||||||
tags: {
|
tags: {
|
||||||
p: {
|
p: {
|
||||||
__meta: [
|
__meta: [
|
||||||
@ -247,7 +247,7 @@ const sk2 = startSketchOn('XY')
|
|||||||
__meta: [{ sourceRange: [38, 63] }],
|
__meta: [{ sourceRange: [38, 63] }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'ExtrudeGroup',
|
type: 'Solid',
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
value: [
|
value: [
|
||||||
{
|
{
|
||||||
@ -278,12 +278,12 @@ const sk2 = startSketchOn('XY')
|
|||||||
sourceRange: [426, 445],
|
sourceRange: [426, 445],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
sketchGroup: {
|
sketch: {
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
__meta: expect.any(Array),
|
__meta: expect.any(Array),
|
||||||
on: expect.any(Object),
|
on: expect.any(Object),
|
||||||
start: expect.any(Object),
|
start: expect.any(Object),
|
||||||
type: 'SketchGroup',
|
type: 'Sketch',
|
||||||
tags: {
|
tags: {
|
||||||
o: {
|
o: {
|
||||||
__meta: [
|
__meta: [
|
||||||
|
@ -3,9 +3,9 @@ import fs from 'node:fs'
|
|||||||
import {
|
import {
|
||||||
parse,
|
parse,
|
||||||
ProgramMemory,
|
ProgramMemory,
|
||||||
SketchGroup,
|
Sketch,
|
||||||
initPromise,
|
initPromise,
|
||||||
sketchGroupFromKclValue,
|
sketchFromKclValue,
|
||||||
} from './wasm'
|
} from './wasm'
|
||||||
import { enginelessExecutor } from '../lib/testHelpers'
|
import { enginelessExecutor } from '../lib/testHelpers'
|
||||||
import { KCLError } from './errors'
|
import { KCLError } from './errors'
|
||||||
@ -125,12 +125,12 @@ const newVar = myVar + 1`
|
|||||||
// ].join('\n')
|
// ].join('\n')
|
||||||
// const mem = await exe(code)
|
// const mem = await exe(code)
|
||||||
// expect(mem.get('mySk1')?.value).toHaveLength(3)
|
// expect(mem.get('mySk1')?.value).toHaveLength(3)
|
||||||
// expect(mem.get('rotated')?.type).toBe('SketchGroup')
|
// expect(mem.get('rotated')?.type).toBe('Sketch')
|
||||||
// if (
|
// if (
|
||||||
// mem.get('mySk1')?.type !== 'SketchGroup' ||
|
// mem.get('mySk1')?.type !== 'Sketch' ||
|
||||||
// mem.get('rotated')?.type !== 'SketchGroup'
|
// mem.get('rotated')?.type !== 'Sketch'
|
||||||
// )
|
// )
|
||||||
// throw new Error('not a sketch group')
|
// throw new Error('not a sketch')
|
||||||
// expect(mem.get('mySk1')?.rotation).toEqual([0, 0, 0, 1])
|
// expect(mem.get('mySk1')?.rotation).toEqual([0, 0, 0, 1])
|
||||||
// expect(mem.get('rotated')?.rotation.map((a) => a.toFixed(4))).toEqual([
|
// expect(mem.get('rotated')?.rotation.map((a) => a.toFixed(4))).toEqual([
|
||||||
// '0.7071',
|
// '0.7071',
|
||||||
@ -154,7 +154,7 @@ const newVar = myVar + 1`
|
|||||||
expect(mem.get('mySk1')).toEqual({
|
expect(mem.get('mySk1')).toEqual({
|
||||||
type: 'UserVal',
|
type: 'UserVal',
|
||||||
value: {
|
value: {
|
||||||
type: 'SketchGroup',
|
type: 'Sketch',
|
||||||
on: expect.any(Object),
|
on: expect.any(Object),
|
||||||
start: {
|
start: {
|
||||||
to: [0, 0],
|
to: [0, 0],
|
||||||
@ -368,9 +368,9 @@ describe('testing math operators', () => {
|
|||||||
'|> line([-2.21, -legLen(5, min(3, 999))], %)',
|
'|> line([-2.21, -legLen(5, min(3, 999))], %)',
|
||||||
].join('\n')
|
].join('\n')
|
||||||
const mem = await exe(code)
|
const mem = await exe(code)
|
||||||
const sketch = sketchGroupFromKclValue(mem.get('part001'), 'part001')
|
const sketch = sketchFromKclValue(mem.get('part001'), 'part001')
|
||||||
// result of `-legLen(5, min(3, 999))` should be -4
|
// result of `-legLen(5, min(3, 999))` should be -4
|
||||||
const yVal = (sketch as SketchGroup).value?.[0]?.to?.[1]
|
const yVal = (sketch as Sketch).value?.[0]?.to?.[1]
|
||||||
expect(yVal).toBe(-4)
|
expect(yVal).toBe(-4)
|
||||||
})
|
})
|
||||||
it('test that % substitution feeds down CallExp->ArrExp->UnaryExp->CallExp', async () => {
|
it('test that % substitution feeds down CallExp->ArrExp->UnaryExp->CallExp', async () => {
|
||||||
@ -386,24 +386,22 @@ describe('testing math operators', () => {
|
|||||||
``,
|
``,
|
||||||
].join('\n')
|
].join('\n')
|
||||||
const mem = await exe(code)
|
const mem = await exe(code)
|
||||||
const sketch = sketchGroupFromKclValue(mem.get('part001'), 'part001')
|
const sketch = sketchFromKclValue(mem.get('part001'), 'part001')
|
||||||
// expect -legLen(segLen('seg01'), myVar) to equal -4 setting the y value back to 0
|
// expect -legLen(segLen('seg01'), myVar) to equal -4 setting the y value back to 0
|
||||||
expect((sketch as SketchGroup).value?.[1]?.from).toEqual([3, 4])
|
expect((sketch as Sketch).value?.[1]?.from).toEqual([3, 4])
|
||||||
expect((sketch as SketchGroup).value?.[1]?.to).toEqual([6, 0])
|
expect((sketch as Sketch).value?.[1]?.to).toEqual([6, 0])
|
||||||
const removedUnaryExp = code.replace(
|
const removedUnaryExp = code.replace(
|
||||||
`-legLen(segLen(seg01), myVar)`,
|
`-legLen(segLen(seg01), myVar)`,
|
||||||
`legLen(segLen(seg01), myVar)`
|
`legLen(segLen(seg01), myVar)`
|
||||||
)
|
)
|
||||||
const removedUnaryExpMem = await exe(removedUnaryExp)
|
const removedUnaryExpMem = await exe(removedUnaryExp)
|
||||||
const removedUnaryExpMemSketch = sketchGroupFromKclValue(
|
const removedUnaryExpMemSketch = sketchFromKclValue(
|
||||||
removedUnaryExpMem.get('part001'),
|
removedUnaryExpMem.get('part001'),
|
||||||
'part001'
|
'part001'
|
||||||
)
|
)
|
||||||
|
|
||||||
// without the minus sign, the y value should be 8
|
// without the minus sign, the y value should be 8
|
||||||
expect((removedUnaryExpMemSketch as SketchGroup).value?.[1]?.to).toEqual([
|
expect((removedUnaryExpMemSketch as Sketch).value?.[1]?.to).toEqual([6, 8])
|
||||||
6, 8,
|
|
||||||
])
|
|
||||||
})
|
})
|
||||||
it('with nested callExpression and binaryExpression', async () => {
|
it('with nested callExpression and binaryExpression', async () => {
|
||||||
const code = 'const myVar = 2 + min(100, -1 + legLen(5, 3))'
|
const code = 'const myVar = 2 + min(100, -1 + legLen(5, 3))'
|
||||||
|
@ -17,7 +17,7 @@ import {
|
|||||||
PathToNode,
|
PathToNode,
|
||||||
ProgramMemory,
|
ProgramMemory,
|
||||||
SourceRange,
|
SourceRange,
|
||||||
sketchGroupFromKclValue,
|
sketchFromKclValue,
|
||||||
} from './wasm'
|
} from './wasm'
|
||||||
import {
|
import {
|
||||||
isNodeSafeToReplacePath,
|
isNodeSafeToReplacePath,
|
||||||
@ -1049,7 +1049,7 @@ export async function deleteFromSelection(
|
|||||||
if (err(parent)) {
|
if (err(parent)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const sketchToPreserve = sketchGroupFromKclValue(
|
const sketchToPreserve = sketchFromKclValue(
|
||||||
programMemory.get(sketchName),
|
programMemory.get(sketchName),
|
||||||
sketchName
|
sketchName
|
||||||
)
|
)
|
||||||
|
@ -8,7 +8,7 @@ import {
|
|||||||
Expr,
|
Expr,
|
||||||
VariableDeclaration,
|
VariableDeclaration,
|
||||||
VariableDeclarator,
|
VariableDeclarator,
|
||||||
sketchGroupFromKclValue,
|
sketchFromKclValue,
|
||||||
} from '../wasm'
|
} from '../wasm'
|
||||||
import {
|
import {
|
||||||
createCallExpressionStdLib,
|
createCallExpressionStdLib,
|
||||||
@ -147,13 +147,13 @@ export function getPathToExtrudeForSegmentSelection(
|
|||||||
if (err(varDecNode)) return varDecNode
|
if (err(varDecNode)) return varDecNode
|
||||||
const sketchVar = varDecNode.node.declarations[0].id.name
|
const sketchVar = varDecNode.node.declarations[0].id.name
|
||||||
|
|
||||||
const sketchGroup = sketchGroupFromKclValue(
|
const sketch = sketchFromKclValue(
|
||||||
kclManager.programMemory.get(sketchVar),
|
kclManager.programMemory.get(sketchVar),
|
||||||
sketchVar
|
sketchVar
|
||||||
)
|
)
|
||||||
if (trap(sketchGroup)) return sketchGroup
|
if (trap(sketch)) return sketch
|
||||||
|
|
||||||
const extrusion = getSweepFromSuspectedPath(sketchGroup.id, artifactGraph)
|
const extrusion = getSweepFromSuspectedPath(sketch.id, artifactGraph)
|
||||||
if (err(extrusion)) return extrusion
|
if (err(extrusion)) return extrusion
|
||||||
|
|
||||||
const pathToExtrudeNode = getNodePathFromSourceRange(
|
const pathToExtrudeNode = getNodePathFromSourceRange(
|
||||||
|
@ -5,7 +5,7 @@ import {
|
|||||||
isTypeInValue,
|
isTypeInValue,
|
||||||
getNodePathFromSourceRange,
|
getNodePathFromSourceRange,
|
||||||
doesPipeHaveCallExp,
|
doesPipeHaveCallExp,
|
||||||
hasExtrudeSketchGroup,
|
hasExtrudeSketch,
|
||||||
findUsesOfTagInPipe,
|
findUsesOfTagInPipe,
|
||||||
hasSketchPipeBeenExtruded,
|
hasSketchPipeBeenExtruded,
|
||||||
doesSceneHaveSweepableSketch,
|
doesSceneHaveSweepableSketch,
|
||||||
@ -340,8 +340,8 @@ const part001 = startSketchAt([-1.41, 3.46])
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('testing hasExtrudeSketchGroup', () => {
|
describe('testing hasExtrudeSketch', () => {
|
||||||
it('find sketch group', async () => {
|
it('find sketch', async () => {
|
||||||
const exampleCode = `const length001 = 2
|
const exampleCode = `const length001 = 2
|
||||||
const part001 = startSketchAt([-1.41, 3.46])
|
const part001 = startSketchAt([-1.41, 3.46])
|
||||||
|> line([19.49, 1.16], %, $seg01)
|
|> line([19.49, 1.16], %, $seg01)
|
||||||
@ -352,14 +352,14 @@ const part001 = startSketchAt([-1.41, 3.46])
|
|||||||
if (err(ast)) throw ast
|
if (err(ast)) throw ast
|
||||||
|
|
||||||
const programMemory = await enginelessExecutor(ast)
|
const programMemory = await enginelessExecutor(ast)
|
||||||
const result = hasExtrudeSketchGroup({
|
const result = hasExtrudeSketch({
|
||||||
ast,
|
ast,
|
||||||
selection: { type: 'default', range: [100, 101] },
|
selection: { type: 'default', range: [100, 101] },
|
||||||
programMemory,
|
programMemory,
|
||||||
})
|
})
|
||||||
expect(result).toEqual(true)
|
expect(result).toEqual(true)
|
||||||
})
|
})
|
||||||
it('find extrude group', async () => {
|
it('find solid', async () => {
|
||||||
const exampleCode = `const length001 = 2
|
const exampleCode = `const length001 = 2
|
||||||
const part001 = startSketchAt([-1.41, 3.46])
|
const part001 = startSketchAt([-1.41, 3.46])
|
||||||
|> line([19.49, 1.16], %, $seg01)
|
|> line([19.49, 1.16], %, $seg01)
|
||||||
@ -371,7 +371,7 @@ const part001 = startSketchAt([-1.41, 3.46])
|
|||||||
if (err(ast)) throw ast
|
if (err(ast)) throw ast
|
||||||
|
|
||||||
const programMemory = await enginelessExecutor(ast)
|
const programMemory = await enginelessExecutor(ast)
|
||||||
const result = hasExtrudeSketchGroup({
|
const result = hasExtrudeSketch({
|
||||||
ast,
|
ast,
|
||||||
selection: { type: 'default', range: [100, 101] },
|
selection: { type: 'default', range: [100, 101] },
|
||||||
programMemory,
|
programMemory,
|
||||||
@ -384,7 +384,7 @@ const part001 = startSketchAt([-1.41, 3.46])
|
|||||||
if (err(ast)) throw ast
|
if (err(ast)) throw ast
|
||||||
|
|
||||||
const programMemory = await enginelessExecutor(ast)
|
const programMemory = await enginelessExecutor(ast)
|
||||||
const result = hasExtrudeSketchGroup({
|
const result = hasExtrudeSketch({
|
||||||
ast,
|
ast,
|
||||||
selection: { type: 'default', range: [10, 11] },
|
selection: { type: 'default', range: [10, 11] },
|
||||||
programMemory,
|
programMemory,
|
||||||
|
@ -13,7 +13,7 @@ import {
|
|||||||
Program,
|
Program,
|
||||||
ProgramMemory,
|
ProgramMemory,
|
||||||
ReturnStatement,
|
ReturnStatement,
|
||||||
sketchGroupFromKclValue,
|
sketchFromKclValue,
|
||||||
SourceRange,
|
SourceRange,
|
||||||
SyntaxType,
|
SyntaxType,
|
||||||
VariableDeclaration,
|
VariableDeclaration,
|
||||||
@ -663,7 +663,7 @@ export function isLinesParallelAndConstrained(
|
|||||||
if (err(_varDec)) return _varDec
|
if (err(_varDec)) return _varDec
|
||||||
const varDec = _varDec.node
|
const varDec = _varDec.node
|
||||||
const varName = (varDec as VariableDeclaration)?.declarations[0]?.id?.name
|
const varName = (varDec as VariableDeclaration)?.declarations[0]?.id?.name
|
||||||
const sg = sketchGroupFromKclValue(programMemory?.get(varName), varName)
|
const sg = sketchFromKclValue(programMemory?.get(varName), varName)
|
||||||
if (err(sg)) return sg
|
if (err(sg)) return sg
|
||||||
const _primarySegment = getSketchSegmentFromSourceRange(
|
const _primarySegment = getSketchSegmentFromSourceRange(
|
||||||
sg,
|
sg,
|
||||||
@ -757,7 +757,7 @@ export function doesPipeHaveCallExp({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function hasExtrudeSketchGroup({
|
export function hasExtrudeSketch({
|
||||||
ast,
|
ast,
|
||||||
selection,
|
selection,
|
||||||
programMemory,
|
programMemory,
|
||||||
@ -781,8 +781,7 @@ export function hasExtrudeSketchGroup({
|
|||||||
const varName = varDec.declarations[0].id.name
|
const varName = varDec.declarations[0].id.name
|
||||||
const varValue = programMemory?.get(varName)
|
const varValue = programMemory?.get(varName)
|
||||||
return (
|
return (
|
||||||
varValue?.type === 'ExtrudeGroup' ||
|
varValue?.type === 'Solid' || !err(sketchFromKclValue(varValue, varName))
|
||||||
!err(sketchGroupFromKclValue(varValue, varName))
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 378 KiB After Width: | Height: | Size: 357 KiB |
Binary file not shown.
Before Width: | Height: | Size: 613 KiB After Width: | Height: | Size: 577 KiB |
@ -1,7 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
ProgramMemory,
|
ProgramMemory,
|
||||||
Path,
|
Path,
|
||||||
SketchGroup,
|
Sketch,
|
||||||
SourceRange,
|
SourceRange,
|
||||||
PathToNode,
|
PathToNode,
|
||||||
Program,
|
Program,
|
||||||
@ -11,7 +11,7 @@ import {
|
|||||||
Expr,
|
Expr,
|
||||||
VariableDeclaration,
|
VariableDeclaration,
|
||||||
Identifier,
|
Identifier,
|
||||||
sketchGroupFromKclValue,
|
sketchFromKclValue,
|
||||||
} from 'lang/wasm'
|
} from 'lang/wasm'
|
||||||
import {
|
import {
|
||||||
getNodeFromPath,
|
getNodeFromPath,
|
||||||
@ -63,7 +63,7 @@ const ARC_SEGMENT_ERR = new Error('Invalid input, expected "arc-segment"')
|
|||||||
|
|
||||||
export type Coords2d = [number, number]
|
export type Coords2d = [number, number]
|
||||||
|
|
||||||
export function getCoordsFromPaths(skGroup: SketchGroup, index = 0): Coords2d {
|
export function getCoordsFromPaths(skGroup: Sketch, index = 0): Coords2d {
|
||||||
const currentPath = skGroup?.value?.[index]
|
const currentPath = skGroup?.value?.[index]
|
||||||
if (!currentPath && skGroup?.start) {
|
if (!currentPath && skGroup?.start) {
|
||||||
return skGroup.start.to
|
return skGroup.start.to
|
||||||
@ -1216,7 +1216,7 @@ export const angledLineOfXLength: SketchLineHelper = {
|
|||||||
const { node: varDec } = nodeMeta2
|
const { node: varDec } = nodeMeta2
|
||||||
|
|
||||||
const variableName = varDec.id.name
|
const variableName = varDec.id.name
|
||||||
const sketch = sketchGroupFromKclValue(
|
const sketch = sketchFromKclValue(
|
||||||
previousProgramMemory?.get(variableName),
|
previousProgramMemory?.get(variableName),
|
||||||
variableName
|
variableName
|
||||||
)
|
)
|
||||||
@ -1331,7 +1331,7 @@ export const angledLineOfYLength: SketchLineHelper = {
|
|||||||
if (err(nodeMeta2)) return nodeMeta2
|
if (err(nodeMeta2)) return nodeMeta2
|
||||||
const { node: varDec } = nodeMeta2
|
const { node: varDec } = nodeMeta2
|
||||||
const variableName = varDec.id.name
|
const variableName = varDec.id.name
|
||||||
const sketch = sketchGroupFromKclValue(
|
const sketch = sketchFromKclValue(
|
||||||
previousProgramMemory?.get(variableName),
|
previousProgramMemory?.get(variableName),
|
||||||
variableName
|
variableName
|
||||||
)
|
)
|
||||||
@ -1699,12 +1699,12 @@ export const angledLineThatIntersects: SketchLineHelper = {
|
|||||||
|
|
||||||
const { node: varDec } = nodeMeta2
|
const { node: varDec } = nodeMeta2
|
||||||
const varName = varDec.declarations[0].id.name
|
const varName = varDec.declarations[0].id.name
|
||||||
const sketchGroup = sketchGroupFromKclValue(
|
const sketch = sketchFromKclValue(
|
||||||
previousProgramMemory.get(varName),
|
previousProgramMemory.get(varName),
|
||||||
varName
|
varName
|
||||||
)
|
)
|
||||||
if (err(sketchGroup)) return sketchGroup
|
if (err(sketch)) return sketch
|
||||||
const intersectPath = sketchGroup.value.find(
|
const intersectPath = sketch.value.find(
|
||||||
({ tag }: Path) => tag && tag.value === intersectTagName
|
({ tag }: Path) => tag && tag.value === intersectTagName
|
||||||
)
|
)
|
||||||
let offset = 0
|
let offset = 0
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
import {
|
import { parse, Sketch, recast, initPromise, sketchFromKclValue } from '../wasm'
|
||||||
parse,
|
|
||||||
SketchGroup,
|
|
||||||
recast,
|
|
||||||
initPromise,
|
|
||||||
sketchGroupFromKclValue,
|
|
||||||
} from '../wasm'
|
|
||||||
import {
|
import {
|
||||||
ConstraintType,
|
ConstraintType,
|
||||||
getTransformInfos,
|
getTransformInfos,
|
||||||
@ -368,10 +362,10 @@ const part001 = startSketchOn('XY')
|
|||||||
it('normal case works', async () => {
|
it('normal case works', async () => {
|
||||||
const programMemory = await enginelessExecutor(parse(code))
|
const programMemory = await enginelessExecutor(parse(code))
|
||||||
const index = code.indexOf('// normal-segment') - 7
|
const index = code.indexOf('// normal-segment') - 7
|
||||||
const sg = sketchGroupFromKclValue(
|
const sg = sketchFromKclValue(
|
||||||
programMemory.get('part001'),
|
programMemory.get('part001'),
|
||||||
'part001'
|
'part001'
|
||||||
) as SketchGroup
|
) as Sketch
|
||||||
const _segment = getSketchSegmentFromSourceRange(sg, [index, index])
|
const _segment = getSketchSegmentFromSourceRange(sg, [index, index])
|
||||||
if (err(_segment)) throw _segment
|
if (err(_segment)) throw _segment
|
||||||
const { __geoMeta, ...segment } = _segment.segment
|
const { __geoMeta, ...segment } = _segment.segment
|
||||||
@ -386,10 +380,7 @@ const part001 = startSketchOn('XY')
|
|||||||
const programMemory = await enginelessExecutor(parse(code))
|
const programMemory = await enginelessExecutor(parse(code))
|
||||||
const index = code.indexOf('// segment-in-start') - 7
|
const index = code.indexOf('// segment-in-start') - 7
|
||||||
const _segment = getSketchSegmentFromSourceRange(
|
const _segment = getSketchSegmentFromSourceRange(
|
||||||
sketchGroupFromKclValue(
|
sketchFromKclValue(programMemory.get('part001'), 'part001') as Sketch,
|
||||||
programMemory.get('part001'),
|
|
||||||
'part001'
|
|
||||||
) as SketchGroup,
|
|
||||||
[index, index]
|
[index, index]
|
||||||
)
|
)
|
||||||
if (err(_segment)) throw _segment
|
if (err(_segment)) throw _segment
|
||||||
|
@ -4,7 +4,7 @@ import {
|
|||||||
Program,
|
Program,
|
||||||
VariableDeclarator,
|
VariableDeclarator,
|
||||||
CallExpression,
|
CallExpression,
|
||||||
SketchGroup,
|
Sketch,
|
||||||
SourceRange,
|
SourceRange,
|
||||||
Path,
|
Path,
|
||||||
PathToNode,
|
PathToNode,
|
||||||
@ -13,17 +13,17 @@ import {
|
|||||||
import { err } from 'lib/trap'
|
import { err } from 'lib/trap'
|
||||||
|
|
||||||
export function getSketchSegmentFromPathToNode(
|
export function getSketchSegmentFromPathToNode(
|
||||||
sketchGroup: SketchGroup,
|
sketch: Sketch,
|
||||||
ast: Program,
|
ast: Program,
|
||||||
pathToNode: PathToNode
|
pathToNode: PathToNode
|
||||||
):
|
):
|
||||||
| {
|
| {
|
||||||
segment: SketchGroup['value'][number]
|
segment: Sketch['value'][number]
|
||||||
index: number
|
index: number
|
||||||
}
|
}
|
||||||
| Error {
|
| Error {
|
||||||
// TODO: once pathTodNode is stored on program memory as part of execution,
|
// TODO: once pathTodNode is stored on program memory as part of execution,
|
||||||
// we can check if the pathToNode matches the pathToNode of the sketchGroup.
|
// we can check if the pathToNode matches the pathToNode of the sketch.
|
||||||
// For now we fall back to the sourceRange
|
// For now we fall back to the sourceRange
|
||||||
const nodeMeta = getNodeFromPath<Expr>(ast, pathToNode)
|
const nodeMeta = getNodeFromPath<Expr>(ast, pathToNode)
|
||||||
if (err(nodeMeta)) return nodeMeta
|
if (err(nodeMeta)) return nodeMeta
|
||||||
@ -32,36 +32,36 @@ export function getSketchSegmentFromPathToNode(
|
|||||||
if (!node || typeof node.start !== 'number' || !node.end)
|
if (!node || typeof node.start !== 'number' || !node.end)
|
||||||
return new Error('no node found')
|
return new Error('no node found')
|
||||||
const sourceRange: SourceRange = [node.start, node.end]
|
const sourceRange: SourceRange = [node.start, node.end]
|
||||||
return getSketchSegmentFromSourceRange(sketchGroup, sourceRange)
|
return getSketchSegmentFromSourceRange(sketch, sourceRange)
|
||||||
}
|
}
|
||||||
export function getSketchSegmentFromSourceRange(
|
export function getSketchSegmentFromSourceRange(
|
||||||
sketchGroup: SketchGroup,
|
sketch: Sketch,
|
||||||
[rangeStart, rangeEnd]: SourceRange
|
[rangeStart, rangeEnd]: SourceRange
|
||||||
):
|
):
|
||||||
| {
|
| {
|
||||||
segment: SketchGroup['value'][number]
|
segment: Sketch['value'][number]
|
||||||
index: number
|
index: number
|
||||||
}
|
}
|
||||||
| Error {
|
| Error {
|
||||||
const lineIndex = sketchGroup.value.findIndex(
|
const lineIndex = sketch.value.findIndex(
|
||||||
({ __geoMeta: { sourceRange } }: Path) =>
|
({ __geoMeta: { sourceRange } }: Path) =>
|
||||||
sourceRange[0] <= rangeStart && sourceRange[1] >= rangeEnd
|
sourceRange[0] <= rangeStart && sourceRange[1] >= rangeEnd
|
||||||
)
|
)
|
||||||
const line = sketchGroup.value[lineIndex]
|
const line = sketch.value[lineIndex]
|
||||||
if (line) {
|
if (line) {
|
||||||
return {
|
return {
|
||||||
segment: line,
|
segment: line,
|
||||||
index: lineIndex,
|
index: lineIndex,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const startSourceRange = sketchGroup.start?.__geoMeta.sourceRange
|
const startSourceRange = sketch.start?.__geoMeta.sourceRange
|
||||||
if (
|
if (
|
||||||
startSourceRange &&
|
startSourceRange &&
|
||||||
startSourceRange[0] <= rangeStart &&
|
startSourceRange[0] <= rangeStart &&
|
||||||
startSourceRange[1] >= rangeEnd &&
|
startSourceRange[1] >= rangeEnd &&
|
||||||
sketchGroup.start
|
sketch.start
|
||||||
)
|
)
|
||||||
return { segment: { ...sketchGroup.start, type: 'Base' }, index: -1 }
|
return { segment: { ...sketch.start, type: 'Base' }, index: -1 }
|
||||||
return new Error('could not find matching segment')
|
return new Error('could not find matching segment')
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ export function isSketchVariablesLinked(
|
|||||||
!toolTips.includes(firstCallExp?.callee?.name as ToolTip)
|
!toolTips.includes(firstCallExp?.callee?.name as ToolTip)
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
// convention for sketch fns is that the second argument is the sketch group
|
// convention for sketch fns is that the second argument is the sketch
|
||||||
const secondArg = firstCallExp?.arguments[1]
|
const secondArg = firstCallExp?.arguments[1]
|
||||||
if (!secondArg || secondArg?.type !== 'Identifier') return false
|
if (!secondArg || secondArg?.type !== 'Identifier') return false
|
||||||
if (secondArg.name === primaryVarDec?.id?.name) return true
|
if (secondArg.name === primaryVarDec?.id?.name) return true
|
||||||
|
@ -17,7 +17,7 @@ import {
|
|||||||
VariableDeclarator,
|
VariableDeclarator,
|
||||||
PathToNode,
|
PathToNode,
|
||||||
ProgramMemory,
|
ProgramMemory,
|
||||||
sketchGroupFromKclValue,
|
sketchFromKclValue,
|
||||||
Literal,
|
Literal,
|
||||||
} from '../wasm'
|
} from '../wasm'
|
||||||
import {
|
import {
|
||||||
@ -1702,33 +1702,29 @@ export function transformAstSketchLines({
|
|||||||
|
|
||||||
const varName = varDec.node.id.name
|
const varName = varDec.node.id.name
|
||||||
let kclVal = programMemory.get(varName)
|
let kclVal = programMemory.get(varName)
|
||||||
let sketchGroup
|
let sketch
|
||||||
if (kclVal?.type === 'ExtrudeGroup') {
|
if (kclVal?.type === 'Solid') {
|
||||||
sketchGroup = kclVal.sketchGroup
|
sketch = kclVal.sketch
|
||||||
} else {
|
} else {
|
||||||
sketchGroup = sketchGroupFromKclValue(kclVal, varName)
|
sketch = sketchFromKclValue(kclVal, varName)
|
||||||
if (err(sketchGroup)) {
|
if (err(sketch)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const segMeta = getSketchSegmentFromPathToNode(
|
const segMeta = getSketchSegmentFromPathToNode(sketch, ast, _pathToNode)
|
||||||
sketchGroup,
|
|
||||||
ast,
|
|
||||||
_pathToNode
|
|
||||||
)
|
|
||||||
if (err(segMeta)) return segMeta
|
if (err(segMeta)) return segMeta
|
||||||
|
|
||||||
const seg = segMeta.segment
|
const seg = segMeta.segment
|
||||||
let referencedSegment
|
let referencedSegment
|
||||||
if (referencedSegmentRange) {
|
if (referencedSegmentRange) {
|
||||||
const _segment = getSketchSegmentFromSourceRange(
|
const _segment = getSketchSegmentFromSourceRange(
|
||||||
sketchGroup,
|
sketch,
|
||||||
referencedSegmentRange
|
referencedSegmentRange
|
||||||
)
|
)
|
||||||
if (err(_segment)) return _segment
|
if (err(_segment)) return _segment
|
||||||
referencedSegment = _segment.segment
|
referencedSegment = _segment.segment
|
||||||
} else {
|
} else {
|
||||||
referencedSegment = sketchGroup.value.find(
|
referencedSegment = sketch.value.find(
|
||||||
(path) => path.tag?.value === _referencedSegmentName
|
(path) => path.tag?.value === _referencedSegmentName
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ const yi=45`
|
|||||||
lineTo(2, 3)
|
lineTo(2, 3)
|
||||||
} |> rx(45, %)`)
|
} |> rx(45, %)`)
|
||||||
expect(result).toEqual([
|
expect(result).toEqual([
|
||||||
"word 'sketch' from 0 to 6",
|
"type 'sketch' from 0 to 6",
|
||||||
"whitespace ' ' from 6 to 7",
|
"whitespace ' ' from 6 to 7",
|
||||||
"word 'mySketch' from 7 to 15",
|
"word 'mySketch' from 7 to 15",
|
||||||
"whitespace ' ' from 15 to 16",
|
"whitespace ' ' from 15 to 16",
|
||||||
|
@ -36,7 +36,7 @@ import { err } from 'lib/trap'
|
|||||||
import { Configuration } from 'wasm-lib/kcl/bindings/Configuration'
|
import { Configuration } from 'wasm-lib/kcl/bindings/Configuration'
|
||||||
import { DeepPartial } from 'lib/types'
|
import { DeepPartial } from 'lib/types'
|
||||||
import { ProjectConfiguration } from 'wasm-lib/kcl/bindings/ProjectConfiguration'
|
import { ProjectConfiguration } from 'wasm-lib/kcl/bindings/ProjectConfiguration'
|
||||||
import { SketchGroup } from '../wasm-lib/kcl/bindings/SketchGroup'
|
import { Sketch } from '../wasm-lib/kcl/bindings/Sketch'
|
||||||
|
|
||||||
export type { Program } from '../wasm-lib/kcl/bindings/Program'
|
export type { Program } from '../wasm-lib/kcl/bindings/Program'
|
||||||
export type { Expr } from '../wasm-lib/kcl/bindings/Expr'
|
export type { Expr } from '../wasm-lib/kcl/bindings/Expr'
|
||||||
@ -80,8 +80,8 @@ export type SyntaxType =
|
|||||||
|
|
||||||
export type { SourceRange } from '../wasm-lib/kcl/bindings/SourceRange'
|
export type { SourceRange } from '../wasm-lib/kcl/bindings/SourceRange'
|
||||||
export type { Path } from '../wasm-lib/kcl/bindings/Path'
|
export type { Path } from '../wasm-lib/kcl/bindings/Path'
|
||||||
export type { SketchGroup } from '../wasm-lib/kcl/bindings/SketchGroup'
|
export type { Sketch } from '../wasm-lib/kcl/bindings/Sketch'
|
||||||
export type { ExtrudeGroup } from '../wasm-lib/kcl/bindings/ExtrudeGroup'
|
export type { Solid } from '../wasm-lib/kcl/bindings/Solid'
|
||||||
export type { KclValue } from '../wasm-lib/kcl/bindings/KclValue'
|
export type { KclValue } from '../wasm-lib/kcl/bindings/KclValue'
|
||||||
export type { ExtrudeSurface } from '../wasm-lib/kcl/bindings/ExtrudeSurface'
|
export type { ExtrudeSurface } from '../wasm-lib/kcl/bindings/ExtrudeSurface'
|
||||||
|
|
||||||
@ -307,11 +307,11 @@ export class ProgramMemory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if any visible variables are a SketchGroup or ExtrudeGroup.
|
* Returns true if any visible variables are a Sketch or Solid.
|
||||||
*/
|
*/
|
||||||
hasSketchOrExtrudeGroup(): boolean {
|
hasSketchOrSolid(): boolean {
|
||||||
for (const node of this.visibleEntries().values()) {
|
for (const node of this.visibleEntries().values()) {
|
||||||
if (node.type === 'ExtrudeGroup' || node.value?.type === 'SketchGroup') {
|
if (node.type === 'Solid' || node.value?.type === 'Sketch') {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -332,13 +332,13 @@ export class ProgramMemory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: In the future, make the parameter be a KclValue.
|
// TODO: In the future, make the parameter be a KclValue.
|
||||||
export function sketchGroupFromKclValue(
|
export function sketchFromKclValue(
|
||||||
obj: any,
|
obj: any,
|
||||||
varName: string | null
|
varName: string | null
|
||||||
): SketchGroup | Error {
|
): Sketch | Error {
|
||||||
if (obj?.value?.type === 'SketchGroup') return obj.value
|
if (obj?.value?.type === 'Sketch') return obj.value
|
||||||
if (obj?.value?.type === 'ExtrudeGroup') return obj.value.sketchGroup
|
if (obj?.value?.type === 'Solid') return obj.value.sketch
|
||||||
if (obj?.type === 'ExtrudeGroup') return obj.sketchGroup
|
if (obj?.type === 'Solid') return obj.sketch
|
||||||
if (!varName) {
|
if (!varName) {
|
||||||
varName = 'a KCL value'
|
varName = 'a KCL value'
|
||||||
}
|
}
|
||||||
@ -346,10 +346,10 @@ export function sketchGroupFromKclValue(
|
|||||||
if (actualType) {
|
if (actualType) {
|
||||||
console.log(obj)
|
console.log(obj)
|
||||||
return new Error(
|
return new Error(
|
||||||
`Expected ${varName} to be a sketchGroup or extrudeGroup, but it was ${actualType} instead.`
|
`Expected ${varName} to be a sketch or solid, but it was ${actualType} instead.`
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
return new Error(`Expected ${varName} to be a sketchGroup, but it wasn't.`)
|
return new Error(`Expected ${varName} to be a sketch, but it wasn't.`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
6
src/wasm-lib/Cargo.lock
generated
6
src/wasm-lib/Cargo.lock
generated
@ -690,7 +690,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "derive-docs"
|
name = "derive-docs"
|
||||||
version = "0.1.28"
|
version = "0.1.29"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"Inflector",
|
"Inflector",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
@ -1414,7 +1414,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "kcl-lib"
|
name = "kcl-lib"
|
||||||
version = "0.2.19"
|
version = "0.2.20"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"approx 0.5.1",
|
"approx 0.5.1",
|
||||||
@ -1489,7 +1489,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "kcl-test-server"
|
name = "kcl-test-server"
|
||||||
version = "0.1.11"
|
version = "0.1.12"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"hyper",
|
"hyper",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "derive-docs"
|
name = "derive-docs"
|
||||||
description = "A tool for generating documentation from Rust derive macros"
|
description = "A tool for generating documentation from Rust derive macros"
|
||||||
version = "0.1.28"
|
version = "0.1.29"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
repository = "https://github.com/KittyCAD/modeling-app"
|
repository = "https://github.com/KittyCAD/modeling-app"
|
||||||
|
@ -132,9 +132,9 @@ fn test_stdlib_line_to() {
|
|||||||
/// ```
|
/// ```
|
||||||
fn inner_line_to(
|
fn inner_line_to(
|
||||||
data: LineToData,
|
data: LineToData,
|
||||||
sketch_group: SketchGroup,
|
sketch: Sketch,
|
||||||
args: &Args,
|
args: &Args,
|
||||||
) -> Result<SketchGroup, KclError> {
|
) -> Result<Sketch, KclError> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -329,7 +329,7 @@ fn test_stdlib_option_input_format() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_stdlib_return_vec_sketch_group() {
|
fn test_stdlib_return_vec_sketch() {
|
||||||
let (item, errors) = do_stdlib(
|
let (item, errors) = do_stdlib(
|
||||||
quote! {
|
quote! {
|
||||||
name = "import",
|
name = "import",
|
||||||
@ -344,7 +344,7 @@ fn test_stdlib_return_vec_sketch_group() {
|
|||||||
fn inner_import(
|
fn inner_import(
|
||||||
/// The args to do shit to.
|
/// The args to do shit to.
|
||||||
args: Option<kittycad::types::InputFormat>
|
args: Option<kittycad::types::InputFormat>
|
||||||
) -> Result<Vec<SketchGroup>> {
|
) -> Result<Vec<Sketch>> {
|
||||||
args
|
args
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -352,11 +352,11 @@ fn test_stdlib_return_vec_sketch_group() {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
assert!(errors.is_empty());
|
assert!(errors.is_empty());
|
||||||
expectorate::assert_contents("tests/return_vec_sketch_group.gen", &get_text_fmt(&item).unwrap());
|
expectorate::assert_contents("tests/return_vec_sketch.gen", &get_text_fmt(&item).unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_stdlib_return_vec_box_sketch_group() {
|
fn test_stdlib_return_vec_box_sketch() {
|
||||||
let (item, errors) = do_stdlib(
|
let (item, errors) = do_stdlib(
|
||||||
quote! {
|
quote! {
|
||||||
name = "import",
|
name = "import",
|
||||||
@ -371,7 +371,7 @@ fn test_stdlib_return_vec_box_sketch_group() {
|
|||||||
fn inner_import(
|
fn inner_import(
|
||||||
/// The args to do shit to.
|
/// The args to do shit to.
|
||||||
args: Option<kittycad::types::InputFormat>
|
args: Option<kittycad::types::InputFormat>
|
||||||
) -> Result<Vec<Box<SketchGroup>>> {
|
) -> Result<Vec<Box<Sketch>>> {
|
||||||
args
|
args
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -379,7 +379,7 @@ fn test_stdlib_return_vec_box_sketch_group() {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
assert!(errors.is_empty());
|
assert!(errors.is_empty());
|
||||||
expectorate::assert_contents("tests/return_vec_box_sketch_group.gen", &get_text_fmt(&item).unwrap());
|
expectorate::assert_contents("tests/return_vec_box_sketch.gen", &get_text_fmt(&item).unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -404,7 +404,7 @@ fn test_stdlib_doc_comment_with_code() {
|
|||||||
fn inner_my_func(
|
fn inner_my_func(
|
||||||
/// The args to do shit to.
|
/// The args to do shit to.
|
||||||
args: Option<kittycad::types::InputFormat>
|
args: Option<kittycad::types::InputFormat>
|
||||||
) -> Result<Vec<Box<SketchGroup>>> {
|
) -> Result<Vec<Box<Sketch>>> {
|
||||||
args
|
args
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -435,7 +435,7 @@ fn test_stdlib_fail_non_camel_case() {
|
|||||||
fn inner_import_thing(
|
fn inner_import_thing(
|
||||||
/// The args to do shit to.
|
/// The args to do shit to.
|
||||||
args: Option<kittycad::types::InputFormat>
|
args: Option<kittycad::types::InputFormat>
|
||||||
) -> Result<Vec<Box<SketchGroup>>> {
|
) -> Result<Vec<Box<Sketch>>> {
|
||||||
args
|
args
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -459,7 +459,7 @@ fn test_stdlib_fail_no_code_block() {
|
|||||||
fn inner_import(
|
fn inner_import(
|
||||||
/// The args to do shit to.
|
/// The args to do shit to.
|
||||||
args: Option<kittycad::types::InputFormat>
|
args: Option<kittycad::types::InputFormat>
|
||||||
) -> Result<Vec<Box<SketchGroup>>> {
|
) -> Result<Vec<Box<Sketch>>> {
|
||||||
args
|
args
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -493,7 +493,7 @@ fn test_stdlib_fail_name_not_in_code_block() {
|
|||||||
fn inner_import(
|
fn inner_import(
|
||||||
/// The args to do shit to.
|
/// The args to do shit to.
|
||||||
args: Option<kittycad::types::InputFormat>
|
args: Option<kittycad::types::InputFormat>
|
||||||
) -> Result<Vec<Box<SketchGroup>>> {
|
) -> Result<Vec<Box<Sketch>>> {
|
||||||
args
|
args
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -126,8 +126,8 @@ impl crate::docs::StdLibFn for MyFunc {
|
|||||||
let mut generator = schemars::gen::SchemaGenerator::new(settings);
|
let mut generator = schemars::gen::SchemaGenerator::new(settings);
|
||||||
Some(crate::docs::StdLibFnArg {
|
Some(crate::docs::StdLibFnArg {
|
||||||
name: "".to_string(),
|
name: "".to_string(),
|
||||||
type_: "[SketchGroup]".to_string(),
|
type_: "[Sketch]".to_string(),
|
||||||
schema: <Vec<SketchGroup>>::json_schema(&mut generator),
|
schema: <Vec<Sketch>>::json_schema(&mut generator),
|
||||||
required: true,
|
required: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -181,6 +181,6 @@ impl crate::docs::StdLibFn for MyFunc {
|
|||||||
#[doc = r" ```"]
|
#[doc = r" ```"]
|
||||||
fn inner_my_func(
|
fn inner_my_func(
|
||||||
#[doc = r" The args to do shit to."] args: Option<kittycad::types::InputFormat>,
|
#[doc = r" The args to do shit to."] args: Option<kittycad::types::InputFormat>,
|
||||||
) -> Result<Vec<Box<SketchGroup>>> {
|
) -> Result<Vec<Box<Sketch>>> {
|
||||||
args
|
args
|
||||||
}
|
}
|
||||||
|
@ -120,9 +120,9 @@ impl crate::docs::StdLibFn for LineTo {
|
|||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
crate::docs::StdLibFnArg {
|
crate::docs::StdLibFnArg {
|
||||||
name: "sketch_group".to_string(),
|
name: "sketch".to_string(),
|
||||||
type_: "SketchGroup".to_string(),
|
type_: "Sketch".to_string(),
|
||||||
schema: SketchGroup::json_schema(&mut generator),
|
schema: Sketch::json_schema(&mut generator),
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@ -134,8 +134,8 @@ impl crate::docs::StdLibFn for LineTo {
|
|||||||
let mut generator = schemars::gen::SchemaGenerator::new(settings);
|
let mut generator = schemars::gen::SchemaGenerator::new(settings);
|
||||||
Some(crate::docs::StdLibFnArg {
|
Some(crate::docs::StdLibFnArg {
|
||||||
name: "".to_string(),
|
name: "".to_string(),
|
||||||
type_: "SketchGroup".to_string(),
|
type_: "Sketch".to_string(),
|
||||||
schema: <SketchGroup>::json_schema(&mut generator),
|
schema: <Sketch>::json_schema(&mut generator),
|
||||||
required: true,
|
required: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -187,10 +187,6 @@ impl crate::docs::StdLibFn for LineTo {
|
|||||||
#[doc = r" yes sirrr."]
|
#[doc = r" yes sirrr."]
|
||||||
#[doc = r" lineTo"]
|
#[doc = r" lineTo"]
|
||||||
#[doc = r" ```"]
|
#[doc = r" ```"]
|
||||||
fn inner_line_to(
|
fn inner_line_to(data: LineToData, sketch: Sketch, args: &Args) -> Result<Sketch, KclError> {
|
||||||
data: LineToData,
|
|
||||||
sketch_group: SketchGroup,
|
|
||||||
args: &Args,
|
|
||||||
) -> Result<SketchGroup, KclError> {
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -92,8 +92,8 @@ impl crate::docs::StdLibFn for Import {
|
|||||||
let mut generator = schemars::gen::SchemaGenerator::new(settings);
|
let mut generator = schemars::gen::SchemaGenerator::new(settings);
|
||||||
Some(crate::docs::StdLibFnArg {
|
Some(crate::docs::StdLibFnArg {
|
||||||
name: "".to_string(),
|
name: "".to_string(),
|
||||||
type_: "[SketchGroup]".to_string(),
|
type_: "[Sketch]".to_string(),
|
||||||
schema: <Vec<SketchGroup>>::json_schema(&mut generator),
|
schema: <Vec<Sketch>>::json_schema(&mut generator),
|
||||||
required: true,
|
required: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -138,6 +138,6 @@ impl crate::docs::StdLibFn for Import {
|
|||||||
#[doc = r" import"]
|
#[doc = r" import"]
|
||||||
fn inner_import(
|
fn inner_import(
|
||||||
#[doc = r" The args to do shit to."] args: Option<kittycad::types::InputFormat>,
|
#[doc = r" The args to do shit to."] args: Option<kittycad::types::InputFormat>,
|
||||||
) -> Result<Vec<SketchGroup>> {
|
) -> Result<Vec<Box<Sketch>>> {
|
||||||
args
|
args
|
||||||
}
|
}
|
@ -92,8 +92,8 @@ impl crate::docs::StdLibFn for Import {
|
|||||||
let mut generator = schemars::gen::SchemaGenerator::new(settings);
|
let mut generator = schemars::gen::SchemaGenerator::new(settings);
|
||||||
Some(crate::docs::StdLibFnArg {
|
Some(crate::docs::StdLibFnArg {
|
||||||
name: "".to_string(),
|
name: "".to_string(),
|
||||||
type_: "[SketchGroup]".to_string(),
|
type_: "[Sketch]".to_string(),
|
||||||
schema: <Vec<SketchGroup>>::json_schema(&mut generator),
|
schema: <Vec<Sketch>>::json_schema(&mut generator),
|
||||||
required: true,
|
required: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -138,6 +138,6 @@ impl crate::docs::StdLibFn for Import {
|
|||||||
#[doc = r" import"]
|
#[doc = r" import"]
|
||||||
fn inner_import(
|
fn inner_import(
|
||||||
#[doc = r" The args to do shit to."] args: Option<kittycad::types::InputFormat>,
|
#[doc = r" The args to do shit to."] args: Option<kittycad::types::InputFormat>,
|
||||||
) -> Result<Vec<Box<SketchGroup>>> {
|
) -> Result<Vec<Sketch>> {
|
||||||
args
|
args
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "kcl-test-server"
|
name = "kcl-test-server"
|
||||||
description = "A test server for KCL"
|
description = "A test server for KCL"
|
||||||
version = "0.1.11"
|
version = "0.1.12"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "kcl-lib"
|
name = "kcl-lib"
|
||||||
description = "KittyCAD Language implementation and tools"
|
description = "KittyCAD Language implementation and tools"
|
||||||
version = "0.2.19"
|
version = "0.2.20"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
repository = "https://github.com/KittyCAD/modeling-app"
|
repository = "https://github.com/KittyCAD/modeling-app"
|
||||||
@ -20,7 +20,7 @@ clap = { version = "4.5.18", default-features = false, optional = true, features
|
|||||||
convert_case = "0.6.0"
|
convert_case = "0.6.0"
|
||||||
dashmap = "6.1.0"
|
dashmap = "6.1.0"
|
||||||
databake = { version = "0.1.8", features = ["derive"] }
|
databake = { version = "0.1.8", features = ["derive"] }
|
||||||
derive-docs = { version = "0.1.28", path = "../derive-docs" }
|
derive-docs = { version = "0.1.29", path = "../derive-docs" }
|
||||||
form_urlencoded = "1.2.1"
|
form_urlencoded = "1.2.1"
|
||||||
futures = { version = "0.3.30" }
|
futures = { version = "0.3.30" }
|
||||||
git_rev = "0.1.0"
|
git_rev = "0.1.0"
|
||||||
|
@ -23,8 +23,8 @@ use crate::{
|
|||||||
docs::StdLibFn,
|
docs::StdLibFn,
|
||||||
errors::{KclError, KclErrorDetails},
|
errors::{KclError, KclErrorDetails},
|
||||||
executor::{
|
executor::{
|
||||||
BodyType, ExecState, ExecutorContext, KclValue, Metadata, SketchGroup, SourceRange, StatementKind,
|
BodyType, ExecState, ExecutorContext, KclValue, Metadata, Sketch, SourceRange, StatementKind, TagEngineInfo,
|
||||||
TagEngineInfo, TagIdentifier, UserVal,
|
TagIdentifier, UserVal,
|
||||||
},
|
},
|
||||||
parser::PIPE_OPERATOR,
|
parser::PIPE_OPERATOR,
|
||||||
std::{kcl_stdlib::KclStdLibFn, FunctionKind},
|
std::{kcl_stdlib::KclStdLibFn, FunctionKind},
|
||||||
@ -1200,24 +1200,24 @@ impl CallExpression {
|
|||||||
let args = crate::std::Args::new(fn_args, self.into(), ctx.clone());
|
let args = crate::std::Args::new(fn_args, self.into(), ctx.clone());
|
||||||
let mut result = func.std_lib_fn()(exec_state, args).await?;
|
let mut result = func.std_lib_fn()(exec_state, args).await?;
|
||||||
|
|
||||||
// If the return result is a sketch group or extrude group, we want to update the
|
// If the return result is a sketch or solid, we want to update the
|
||||||
// memory for the tags of the group.
|
// memory for the tags of the group.
|
||||||
// TODO: This could probably be done in a better way, but as of now this was my only idea
|
// TODO: This could probably be done in a better way, but as of now this was my only idea
|
||||||
// and it works.
|
// and it works.
|
||||||
match result {
|
match result {
|
||||||
KclValue::UserVal(ref mut uval) => {
|
KclValue::UserVal(ref mut uval) => {
|
||||||
uval.mutate(|sketch_group: &mut SketchGroup| {
|
uval.mutate(|sketch: &mut Sketch| {
|
||||||
for (_, tag) in sketch_group.tags.iter() {
|
for (_, tag) in sketch.tags.iter() {
|
||||||
exec_state.memory.update_tag(&tag.value, tag.clone())?;
|
exec_state.memory.update_tag(&tag.value, tag.clone())?;
|
||||||
}
|
}
|
||||||
Ok::<_, KclError>(())
|
Ok::<_, KclError>(())
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
KclValue::ExtrudeGroup(ref mut extrude_group) => {
|
KclValue::Solid(ref mut solid) => {
|
||||||
for value in &extrude_group.value {
|
for value in &solid.value {
|
||||||
if let Some(tag) = value.get_tag() {
|
if let Some(tag) = value.get_tag() {
|
||||||
// Get the past tag and update it.
|
// Get the past tag and update it.
|
||||||
let mut t = if let Some(t) = extrude_group.sketch_group.tags.get(&tag.name) {
|
let mut t = if let Some(t) = solid.sketch.tags.get(&tag.name) {
|
||||||
t.clone()
|
t.clone()
|
||||||
} else {
|
} else {
|
||||||
// It's probably a fillet or a chamfer.
|
// It's probably a fillet or a chamfer.
|
||||||
@ -1228,7 +1228,7 @@ impl CallExpression {
|
|||||||
id: value.get_id(),
|
id: value.get_id(),
|
||||||
surface: Some(value.clone()),
|
surface: Some(value.clone()),
|
||||||
path: None,
|
path: None,
|
||||||
sketch_group: extrude_group.id,
|
sketch: solid.id,
|
||||||
}),
|
}),
|
||||||
meta: vec}})
|
[{{basename $ref}}](#{{lowercase (basename $ref)}}){{else if anyOf ~}}
|
||||||
{{else if anyOf ~}}
|
`anyOf`{{else if oneOf ~}}
|
||||||
`anyOf`
|
`oneOf`{{else if allOf ~}}
|
||||||
{{else if oneOf ~}}
|
`allOf`{{else if enum ~}}
|
||||||
`oneOf`
|
enum: {{pretty_enum enum}}{{else ~}}
|
||||||
{{else if allOf ~}}
|
`{{type}}`{{#if format}} (`{{format}}`){{/if}}{{~/if~}}
|
||||||
`allOf`
|
|
||||||
{{else if enum ~}}
|
|
||||||
enum: {{pretty_enum enum}}
|
|
||||||
{{else ~}}
|
|
||||||
`{{type}}`{{#if format}} (`{{format}}`){{/if}}
|
|
||||||
{{~/if~}}
|
|
||||||
|
@ -115,17 +115,17 @@ impl ProgramMemory {
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Find all extrude groups in the memory that are on a specific sketch group id.
|
/// Find all solids in the memory that are on a specific sketch id.
|
||||||
/// This does not look inside closures. But as long as we do not allow
|
/// This does not look inside closures. But as long as we do not allow
|
||||||
/// mutation of variables in KCL, closure memory should be a subset of this.
|
/// mutation of variables in KCL, closure memory should be a subset of this.
|
||||||
pub fn find_extrude_groups_on_sketch_group(&self, sketch_group_id: uuid::Uuid) -> Vec<Box<ExtrudeGroup>> {
|
pub fn find_solids_on_sketch(&self, sketch_id: uuid::Uuid) -> Vec<Box<Solid>> {
|
||||||
self.environments
|
self.environments
|
||||||
.iter()
|
.iter()
|
||||||
.flat_map(|env| {
|
.flat_map(|env| {
|
||||||
env.bindings
|
env.bindings
|
||||||
.values()
|
.values()
|
||||||
.filter_map(|item| match item {
|
.filter_map(|item| match item {
|
||||||
KclValue::ExtrudeGroup(eg) if eg.sketch_group.id == sketch_group_id => Some(eg.clone()),
|
KclValue::Solid(eg) if eg.sketch.id == sketch_id => Some(eg.clone()),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
@ -222,7 +222,7 @@ impl Environment {
|
|||||||
self.bindings.contains_key(key)
|
self.bindings.contains_key(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_sketch_group_tags(&mut self, sg: &SketchGroup) {
|
pub fn update_sketch_tags(&mut self, sg: &Sketch) {
|
||||||
if sg.tags.is_empty() {
|
if sg.tags.is_empty() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -230,19 +230,19 @@ impl Environment {
|
|||||||
for (_, val) in self.bindings.iter_mut() {
|
for (_, val) in self.bindings.iter_mut() {
|
||||||
let KclValue::UserVal(v) = val else { continue };
|
let KclValue::UserVal(v) = val else { continue };
|
||||||
let meta = v.meta.clone();
|
let meta = v.meta.clone();
|
||||||
let maybe_sg: Result<SketchGroup, _> = serde_json::from_value(v.value.clone());
|
let maybe_sg: Result<Sketch, _> = serde_json::from_value(v.value.clone());
|
||||||
let Ok(mut sketch_group) = maybe_sg else {
|
let Ok(mut sketch) = maybe_sg else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
if sketch_group.original_id == sg.original_id {
|
if sketch.original_id == sg.original_id {
|
||||||
for tag in sg.tags.iter() {
|
for tag in sg.tags.iter() {
|
||||||
sketch_group.tags.insert(tag.0.clone(), tag.1.clone());
|
sketch.tags.insert(tag.0.clone(), tag.1.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*val = KclValue::UserVal(UserVal {
|
*val = KclValue::UserVal(UserVal {
|
||||||
meta,
|
meta,
|
||||||
value: serde_json::to_value(sketch_group).expect("can always turn SketchGroup into JSON"),
|
value: serde_json::to_value(sketch).expect("can always turn Sketch into JSON"),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -253,7 +253,7 @@ impl Environment {
|
|||||||
/// stack of exception handlers here.
|
/// stack of exception handlers here.
|
||||||
#[derive(Debug, Default, Clone, PartialEq, Eq, Deserialize, Serialize, ts_rs::TS, JsonSchema)]
|
#[derive(Debug, Default, Clone, PartialEq, Eq, Deserialize, Serialize, ts_rs::TS, JsonSchema)]
|
||||||
pub struct DynamicState {
|
pub struct DynamicState {
|
||||||
pub extrude_group_ids: Vec<ExtrudeGroupLazyIds>,
|
pub solid_ids: Vec<SolidLazyIds>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DynamicState {
|
impl DynamicState {
|
||||||
@ -271,18 +271,18 @@ impl DynamicState {
|
|||||||
pub fn append(&mut self, memory: &ProgramMemory) {
|
pub fn append(&mut self, memory: &ProgramMemory) {
|
||||||
for env in &memory.environments {
|
for env in &memory.environments {
|
||||||
for item in env.bindings.values() {
|
for item in env.bindings.values() {
|
||||||
if let KclValue::ExtrudeGroup(eg) = item {
|
if let KclValue::Solid(eg) = item {
|
||||||
self.extrude_group_ids.push(ExtrudeGroupLazyIds::from(eg.as_ref()));
|
self.solid_ids.push(SolidLazyIds::from(eg.as_ref()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn edge_cut_ids_on_sketch_group(&self, sketch_group_id: uuid::Uuid) -> Vec<uuid::Uuid> {
|
pub fn edge_cut_ids_on_sketch(&self, sketch_id: uuid::Uuid) -> Vec<uuid::Uuid> {
|
||||||
self.extrude_group_ids
|
self.solid_ids
|
||||||
.iter()
|
.iter()
|
||||||
.flat_map(|eg| {
|
.flat_map(|eg| {
|
||||||
if eg.sketch_group_id == sketch_group_id {
|
if eg.sketch_id == sketch_id {
|
||||||
eg.edge_cuts.clone()
|
eg.edge_cuts.clone()
|
||||||
} else {
|
} else {
|
||||||
Vec::new()
|
Vec::new()
|
||||||
@ -303,9 +303,9 @@ pub enum KclValue {
|
|||||||
Plane(Box<Plane>),
|
Plane(Box<Plane>),
|
||||||
Face(Box<Face>),
|
Face(Box<Face>),
|
||||||
|
|
||||||
ExtrudeGroup(Box<ExtrudeGroup>),
|
Solid(Box<Solid>),
|
||||||
ExtrudeGroups {
|
Solids {
|
||||||
value: Vec<Box<ExtrudeGroup>>,
|
value: Vec<Box<Solid>>,
|
||||||
},
|
},
|
||||||
ImportedGeometry(ImportedGeometry),
|
ImportedGeometry(ImportedGeometry),
|
||||||
#[ts(skip)]
|
#[ts(skip)]
|
||||||
@ -324,26 +324,26 @@ impl KclValue {
|
|||||||
Self::UserVal(UserVal::new(meta, val))
|
Self::UserVal(UserVal::new(meta, val))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_extrude_group_set(&self) -> Result<ExtrudeGroupSet> {
|
pub(crate) fn get_solid_set(&self) -> Result<SolidSet> {
|
||||||
match self {
|
match self {
|
||||||
KclValue::ExtrudeGroup(e) => Ok(ExtrudeGroupSet::ExtrudeGroup(e.clone())),
|
KclValue::Solid(e) => Ok(SolidSet::Solid(e.clone())),
|
||||||
KclValue::ExtrudeGroups { value } => Ok(ExtrudeGroupSet::ExtrudeGroups(value.clone())),
|
KclValue::Solids { value } => Ok(SolidSet::Solids(value.clone())),
|
||||||
KclValue::UserVal(value) => {
|
KclValue::UserVal(value) => {
|
||||||
let value = value.value.clone();
|
let value = value.value.clone();
|
||||||
match value {
|
match value {
|
||||||
JValue::Null | JValue::Bool(_) | JValue::Number(_) | JValue::String(_) => Err(anyhow::anyhow!(
|
JValue::Null | JValue::Bool(_) | JValue::Number(_) | JValue::String(_) => Err(anyhow::anyhow!(
|
||||||
"Failed to deserialize extrude group set from JSON {}",
|
"Failed to deserialize solid set from JSON {}",
|
||||||
human_friendly_type(&value)
|
human_friendly_type(&value)
|
||||||
)),
|
)),
|
||||||
JValue::Array(_) => serde_json::from_value::<Vec<Box<ExtrudeGroup>>>(value)
|
JValue::Array(_) => serde_json::from_value::<Vec<Box<Solid>>>(value)
|
||||||
.map(ExtrudeGroupSet::from)
|
.map(SolidSet::from)
|
||||||
.map_err(|e| anyhow::anyhow!("Failed to deserialize array of extrude groups from JSON: {}", e)),
|
.map_err(|e| anyhow::anyhow!("Failed to deserialize array of solids from JSON: {}", e)),
|
||||||
JValue::Object(_) => serde_json::from_value::<Box<ExtrudeGroup>>(value)
|
JValue::Object(_) => serde_json::from_value::<Box<Solid>>(value)
|
||||||
.map(ExtrudeGroupSet::from)
|
.map(SolidSet::from)
|
||||||
.map_err(|e| anyhow::anyhow!("Failed to deserialize extrude group from JSON: {}", e)),
|
.map_err(|e| anyhow::anyhow!("Failed to deserialize solid from JSON: {}", e)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => anyhow::bail!("Not a extrude group or extrude groups: {:?}", self),
|
_ => anyhow::bail!("Not a solid or solids: {:?}", self),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -354,8 +354,8 @@ impl KclValue {
|
|||||||
KclValue::UserVal(u) => human_friendly_type(&u.value),
|
KclValue::UserVal(u) => human_friendly_type(&u.value),
|
||||||
KclValue::TagDeclarator(_) => "TagDeclarator",
|
KclValue::TagDeclarator(_) => "TagDeclarator",
|
||||||
KclValue::TagIdentifier(_) => "TagIdentifier",
|
KclValue::TagIdentifier(_) => "TagIdentifier",
|
||||||
KclValue::ExtrudeGroup(_) => "ExtrudeGroup",
|
KclValue::Solid(_) => "Solid",
|
||||||
KclValue::ExtrudeGroups { .. } => "ExtrudeGroups",
|
KclValue::Solids { .. } => "Solids",
|
||||||
KclValue::ImportedGeometry(_) => "ImportedGeometry",
|
KclValue::ImportedGeometry(_) => "ImportedGeometry",
|
||||||
KclValue::Function { .. } => "Function",
|
KclValue::Function { .. } => "Function",
|
||||||
KclValue::Plane(_) => "Plane",
|
KclValue::Plane(_) => "Plane",
|
||||||
@ -364,34 +364,34 @@ impl KclValue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<SketchGroupSet> for KclValue {
|
impl From<SketchSet> for KclValue {
|
||||||
fn from(sg: SketchGroupSet) -> Self {
|
fn from(sg: SketchSet) -> Self {
|
||||||
KclValue::UserVal(UserVal::new(sg.meta(), sg))
|
KclValue::UserVal(UserVal::new(sg.meta(), sg))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Vec<Box<SketchGroup>>> for KclValue {
|
impl From<Vec<Box<Sketch>>> for KclValue {
|
||||||
fn from(sg: Vec<Box<SketchGroup>>) -> Self {
|
fn from(sg: Vec<Box<Sketch>>) -> Self {
|
||||||
let meta = sg.iter().flat_map(|sg| sg.meta.clone()).collect();
|
let meta = sg.iter().flat_map(|sg| sg.meta.clone()).collect();
|
||||||
KclValue::UserVal(UserVal::new(meta, sg))
|
KclValue::UserVal(UserVal::new(meta, sg))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ExtrudeGroupSet> for KclValue {
|
impl From<SolidSet> for KclValue {
|
||||||
fn from(eg: ExtrudeGroupSet) -> Self {
|
fn from(eg: SolidSet) -> Self {
|
||||||
match eg {
|
match eg {
|
||||||
ExtrudeGroupSet::ExtrudeGroup(eg) => KclValue::ExtrudeGroup(eg),
|
SolidSet::Solid(eg) => KclValue::Solid(eg),
|
||||||
ExtrudeGroupSet::ExtrudeGroups(egs) => KclValue::ExtrudeGroups { value: egs },
|
SolidSet::Solids(egs) => KclValue::Solids { value: egs },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Vec<Box<ExtrudeGroup>>> for KclValue {
|
impl From<Vec<Box<Solid>>> for KclValue {
|
||||||
fn from(eg: Vec<Box<ExtrudeGroup>>) -> Self {
|
fn from(eg: Vec<Box<Solid>>) -> Self {
|
||||||
if eg.len() == 1 {
|
if eg.len() == 1 {
|
||||||
KclValue::ExtrudeGroup(eg[0].clone())
|
KclValue::Solid(eg[0].clone())
|
||||||
} else {
|
} else {
|
||||||
KclValue::ExtrudeGroups { value: eg }
|
KclValue::Solids { value: eg }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -401,15 +401,15 @@ impl From<Vec<Box<ExtrudeGroup>>> for KclValue {
|
|||||||
#[ts(export)]
|
#[ts(export)]
|
||||||
#[serde(tag = "type")]
|
#[serde(tag = "type")]
|
||||||
pub enum Geometry {
|
pub enum Geometry {
|
||||||
SketchGroup(Box<SketchGroup>),
|
Sketch(Box<Sketch>),
|
||||||
ExtrudeGroup(Box<ExtrudeGroup>),
|
Solid(Box<Solid>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Geometry {
|
impl Geometry {
|
||||||
pub fn id(&self) -> uuid::Uuid {
|
pub fn id(&self) -> uuid::Uuid {
|
||||||
match self {
|
match self {
|
||||||
Geometry::SketchGroup(s) => s.id,
|
Geometry::Sketch(s) => s.id,
|
||||||
Geometry::ExtrudeGroup(e) => e.id,
|
Geometry::Solid(e) => e.id,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -419,148 +419,148 @@ impl Geometry {
|
|||||||
#[ts(export)]
|
#[ts(export)]
|
||||||
#[serde(tag = "type")]
|
#[serde(tag = "type")]
|
||||||
pub enum Geometries {
|
pub enum Geometries {
|
||||||
SketchGroups(Vec<Box<SketchGroup>>),
|
Sketches(Vec<Box<Sketch>>),
|
||||||
ExtrudeGroups(Vec<Box<ExtrudeGroup>>),
|
Solids(Vec<Box<Solid>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A sketch group or a group of sketch groups.
|
/// A sketch or a group of sketches.
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
|
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
|
||||||
#[ts(export)]
|
#[ts(export)]
|
||||||
#[serde(tag = "type", rename_all = "camelCase")]
|
#[serde(tag = "type", rename_all = "camelCase")]
|
||||||
pub enum SketchGroupSet {
|
pub enum SketchSet {
|
||||||
SketchGroup(Box<SketchGroup>),
|
Sketch(Box<Sketch>),
|
||||||
SketchGroups(Vec<Box<SketchGroup>>),
|
Sketches(Vec<Box<Sketch>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SketchGroupSet {
|
impl SketchSet {
|
||||||
pub fn meta(&self) -> Vec<Metadata> {
|
pub fn meta(&self) -> Vec<Metadata> {
|
||||||
match self {
|
match self {
|
||||||
SketchGroupSet::SketchGroup(sg) => sg.meta.clone(),
|
SketchSet::Sketch(sg) => sg.meta.clone(),
|
||||||
SketchGroupSet::SketchGroups(sg) => sg.iter().flat_map(|sg| sg.meta.clone()).collect(),
|
SketchSet::Sketches(sg) => sg.iter().flat_map(|sg| sg.meta.clone()).collect(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<SketchGroupSet> for Vec<SketchGroup> {
|
impl From<SketchSet> for Vec<Sketch> {
|
||||||
fn from(value: SketchGroupSet) -> Self {
|
fn from(value: SketchSet) -> Self {
|
||||||
match value {
|
match value {
|
||||||
SketchGroupSet::SketchGroup(sg) => vec![*sg],
|
SketchSet::Sketch(sg) => vec![*sg],
|
||||||
SketchGroupSet::SketchGroups(sgs) => sgs.into_iter().map(|sg| *sg).collect(),
|
SketchSet::Sketches(sgs) => sgs.into_iter().map(|sg| *sg).collect(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<SketchGroup> for SketchGroupSet {
|
impl From<Sketch> for SketchSet {
|
||||||
fn from(sg: SketchGroup) -> Self {
|
fn from(sg: Sketch) -> Self {
|
||||||
SketchGroupSet::SketchGroup(Box::new(sg))
|
SketchSet::Sketch(Box::new(sg))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Box<SketchGroup>> for SketchGroupSet {
|
impl From<Box<Sketch>> for SketchSet {
|
||||||
fn from(sg: Box<SketchGroup>) -> Self {
|
fn from(sg: Box<Sketch>) -> Self {
|
||||||
SketchGroupSet::SketchGroup(sg)
|
SketchSet::Sketch(sg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Vec<SketchGroup>> for SketchGroupSet {
|
impl From<Vec<Sketch>> for SketchSet {
|
||||||
fn from(sg: Vec<SketchGroup>) -> Self {
|
fn from(sg: Vec<Sketch>) -> Self {
|
||||||
if sg.len() == 1 {
|
if sg.len() == 1 {
|
||||||
SketchGroupSet::SketchGroup(Box::new(sg[0].clone()))
|
SketchSet::Sketch(Box::new(sg[0].clone()))
|
||||||
} else {
|
} else {
|
||||||
SketchGroupSet::SketchGroups(sg.into_iter().map(Box::new).collect())
|
SketchSet::Sketches(sg.into_iter().map(Box::new).collect())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Vec<Box<SketchGroup>>> for SketchGroupSet {
|
impl From<Vec<Box<Sketch>>> for SketchSet {
|
||||||
fn from(sg: Vec<Box<SketchGroup>>) -> Self {
|
fn from(sg: Vec<Box<Sketch>>) -> Self {
|
||||||
if sg.len() == 1 {
|
if sg.len() == 1 {
|
||||||
SketchGroupSet::SketchGroup(sg[0].clone())
|
SketchSet::Sketch(sg[0].clone())
|
||||||
} else {
|
} else {
|
||||||
SketchGroupSet::SketchGroups(sg)
|
SketchSet::Sketches(sg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<SketchGroupSet> for Vec<Box<SketchGroup>> {
|
impl From<SketchSet> for Vec<Box<Sketch>> {
|
||||||
fn from(sg: SketchGroupSet) -> Self {
|
fn from(sg: SketchSet) -> Self {
|
||||||
match sg {
|
match sg {
|
||||||
SketchGroupSet::SketchGroup(sg) => vec![sg],
|
SketchSet::Sketch(sg) => vec![sg],
|
||||||
SketchGroupSet::SketchGroups(sgs) => sgs,
|
SketchSet::Sketches(sgs) => sgs,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&SketchGroup> for Vec<Box<SketchGroup>> {
|
impl From<&Sketch> for Vec<Box<Sketch>> {
|
||||||
fn from(sg: &SketchGroup) -> Self {
|
fn from(sg: &Sketch) -> Self {
|
||||||
vec![Box::new(sg.clone())]
|
vec![Box::new(sg.clone())]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Box<SketchGroup>> for Vec<Box<SketchGroup>> {
|
impl From<Box<Sketch>> for Vec<Box<Sketch>> {
|
||||||
fn from(sg: Box<SketchGroup>) -> Self {
|
fn from(sg: Box<Sketch>) -> Self {
|
||||||
vec![sg]
|
vec![sg]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A extrude group or a group of extrude groups.
|
/// A solid or a group of solids.
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
|
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
|
||||||
#[ts(export)]
|
#[ts(export)]
|
||||||
#[serde(tag = "type", rename_all = "camelCase")]
|
#[serde(tag = "type", rename_all = "camelCase")]
|
||||||
pub enum ExtrudeGroupSet {
|
pub enum SolidSet {
|
||||||
ExtrudeGroup(Box<ExtrudeGroup>),
|
Solid(Box<Solid>),
|
||||||
ExtrudeGroups(Vec<Box<ExtrudeGroup>>),
|
Solids(Vec<Box<Solid>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ExtrudeGroup> for ExtrudeGroupSet {
|
impl From<Solid> for SolidSet {
|
||||||
fn from(eg: ExtrudeGroup) -> Self {
|
fn from(eg: Solid) -> Self {
|
||||||
ExtrudeGroupSet::ExtrudeGroup(Box::new(eg))
|
SolidSet::Solid(Box::new(eg))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Box<ExtrudeGroup>> for ExtrudeGroupSet {
|
impl From<Box<Solid>> for SolidSet {
|
||||||
fn from(eg: Box<ExtrudeGroup>) -> Self {
|
fn from(eg: Box<Solid>) -> Self {
|
||||||
ExtrudeGroupSet::ExtrudeGroup(eg)
|
SolidSet::Solid(eg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Vec<ExtrudeGroup>> for ExtrudeGroupSet {
|
impl From<Vec<Solid>> for SolidSet {
|
||||||
fn from(eg: Vec<ExtrudeGroup>) -> Self {
|
fn from(eg: Vec<Solid>) -> Self {
|
||||||
if eg.len() == 1 {
|
if eg.len() == 1 {
|
||||||
ExtrudeGroupSet::ExtrudeGroup(Box::new(eg[0].clone()))
|
SolidSet::Solid(Box::new(eg[0].clone()))
|
||||||
} else {
|
} else {
|
||||||
ExtrudeGroupSet::ExtrudeGroups(eg.into_iter().map(Box::new).collect())
|
SolidSet::Solids(eg.into_iter().map(Box::new).collect())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Vec<Box<ExtrudeGroup>>> for ExtrudeGroupSet {
|
impl From<Vec<Box<Solid>>> for SolidSet {
|
||||||
fn from(eg: Vec<Box<ExtrudeGroup>>) -> Self {
|
fn from(eg: Vec<Box<Solid>>) -> Self {
|
||||||
if eg.len() == 1 {
|
if eg.len() == 1 {
|
||||||
ExtrudeGroupSet::ExtrudeGroup(eg[0].clone())
|
SolidSet::Solid(eg[0].clone())
|
||||||
} else {
|
} else {
|
||||||
ExtrudeGroupSet::ExtrudeGroups(eg)
|
SolidSet::Solids(eg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ExtrudeGroupSet> for Vec<Box<ExtrudeGroup>> {
|
impl From<SolidSet> for Vec<Box<Solid>> {
|
||||||
fn from(eg: ExtrudeGroupSet) -> Self {
|
fn from(eg: SolidSet) -> Self {
|
||||||
match eg {
|
match eg {
|
||||||
ExtrudeGroupSet::ExtrudeGroup(eg) => vec![eg],
|
SolidSet::Solid(eg) => vec![eg],
|
||||||
ExtrudeGroupSet::ExtrudeGroups(egs) => egs,
|
SolidSet::Solids(egs) => egs,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&ExtrudeGroup> for Vec<Box<ExtrudeGroup>> {
|
impl From<&Solid> for Vec<Box<Solid>> {
|
||||||
fn from(eg: &ExtrudeGroup) -> Self {
|
fn from(eg: &Solid) -> Self {
|
||||||
vec![Box::new(eg.clone())]
|
vec![Box::new(eg.clone())]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Box<ExtrudeGroup>> for Vec<Box<ExtrudeGroup>> {
|
impl From<Box<Solid>> for Vec<Box<Solid>> {
|
||||||
fn from(eg: Box<ExtrudeGroup>) -> Self {
|
fn from(eg: Box<Solid>) -> Self {
|
||||||
vec![eg]
|
vec![eg]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -626,8 +626,8 @@ pub struct Face {
|
|||||||
pub y_axis: Point3d,
|
pub y_axis: Point3d,
|
||||||
/// The z-axis (normal).
|
/// The z-axis (normal).
|
||||||
pub z_axis: Point3d,
|
pub z_axis: Point3d,
|
||||||
/// The extrude group the face is on.
|
/// The solid the face is on.
|
||||||
pub extrude_group: Box<ExtrudeGroup>,
|
pub solid: Box<Solid>,
|
||||||
#[serde(rename = "__meta")]
|
#[serde(rename = "__meta")]
|
||||||
pub meta: Vec<Metadata>,
|
pub meta: Vec<Metadata>,
|
||||||
}
|
}
|
||||||
@ -763,8 +763,8 @@ impl From<KclValue> for Vec<SourceRange> {
|
|||||||
KclValue::UserVal(u) => u.meta.iter().map(|m| m.source_range).collect(),
|
KclValue::UserVal(u) => u.meta.iter().map(|m| m.source_range).collect(),
|
||||||
KclValue::TagDeclarator(t) => t.into(),
|
KclValue::TagDeclarator(t) => t.into(),
|
||||||
KclValue::TagIdentifier(t) => t.meta.iter().map(|m| m.source_range).collect(),
|
KclValue::TagIdentifier(t) => t.meta.iter().map(|m| m.source_range).collect(),
|
||||||
KclValue::ExtrudeGroup(e) => e.meta.iter().map(|m| m.source_range).collect(),
|
KclValue::Solid(e) => e.meta.iter().map(|m| m.source_range).collect(),
|
||||||
KclValue::ExtrudeGroups { value } => value
|
KclValue::Solids { value } => value
|
||||||
.iter()
|
.iter()
|
||||||
.flat_map(|eg| eg.meta.iter().map(|m| m.source_range))
|
.flat_map(|eg| eg.meta.iter().map(|m| m.source_range))
|
||||||
.collect(),
|
.collect(),
|
||||||
@ -949,31 +949,31 @@ impl KclValue {
|
|||||||
pub struct TagEngineInfo {
|
pub struct TagEngineInfo {
|
||||||
/// The id of the tagged object.
|
/// The id of the tagged object.
|
||||||
pub id: uuid::Uuid,
|
pub id: uuid::Uuid,
|
||||||
/// The sketch group the tag is on.
|
/// The sketch the tag is on.
|
||||||
pub sketch_group: uuid::Uuid,
|
pub sketch: uuid::Uuid,
|
||||||
/// The path the tag is on.
|
/// The path the tag is on.
|
||||||
pub path: Option<BasePath>,
|
pub path: Option<BasePath>,
|
||||||
/// The surface information for the tag.
|
/// The surface information for the tag.
|
||||||
pub surface: Option<ExtrudeSurface>,
|
pub surface: Option<ExtrudeSurface>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A sketch group is a collection of paths.
|
/// A sketch is a collection of paths.
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
|
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
|
||||||
#[ts(export)]
|
#[ts(export)]
|
||||||
#[serde(tag = "type", rename_all = "camelCase")]
|
#[serde(tag = "type", rename_all = "camelCase")]
|
||||||
pub struct SketchGroup {
|
pub struct Sketch {
|
||||||
/// The id of the sketch group (this will change when the engine's reference to it changes.
|
/// The id of the sketch (this will change when the engine's reference to it changes.
|
||||||
pub id: uuid::Uuid,
|
pub id: uuid::Uuid,
|
||||||
/// The paths in the sketch group.
|
/// The paths in the sketch.
|
||||||
pub value: Vec<Path>,
|
pub value: Vec<Path>,
|
||||||
/// What the sketch is on (can be a plane or a face).
|
/// What the sketch is on (can be a plane or a face).
|
||||||
pub on: SketchSurface,
|
pub on: SketchSurface,
|
||||||
/// The starting path.
|
/// The starting path.
|
||||||
pub start: BasePath,
|
pub start: BasePath,
|
||||||
/// Tag identifiers that have been declared in this sketch group.
|
/// Tag identifiers that have been declared in this sketch.
|
||||||
#[serde(default, skip_serializing_if = "HashMap::is_empty")]
|
#[serde(default, skip_serializing_if = "HashMap::is_empty")]
|
||||||
pub tags: HashMap<String, TagIdentifier>,
|
pub tags: HashMap<String, TagIdentifier>,
|
||||||
/// The original id of the sketch group. This stays the same even if the sketch group is
|
/// The original id of the sketch. This stays the same even if the sketch is
|
||||||
/// is sketched on face etc.
|
/// is sketched on face etc.
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
pub original_id: uuid::Uuid,
|
pub original_id: uuid::Uuid,
|
||||||
@ -982,7 +982,7 @@ pub struct SketchGroup {
|
|||||||
pub meta: Vec<Metadata>,
|
pub meta: Vec<Metadata>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A sketch group type.
|
/// A sketch type.
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
|
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
|
||||||
#[ts(export)]
|
#[ts(export)]
|
||||||
#[serde(tag = "type", rename_all = "camelCase")]
|
#[serde(tag = "type", rename_all = "camelCase")]
|
||||||
@ -1024,13 +1024,13 @@ pub struct GetTangentialInfoFromPathsResult {
|
|||||||
pub ccw: bool,
|
pub ccw: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SketchGroup {
|
impl Sketch {
|
||||||
pub(crate) fn add_tag(&mut self, tag: &TagDeclarator, current_path: &Path) {
|
pub(crate) fn add_tag(&mut self, tag: &TagDeclarator, current_path: &Path) {
|
||||||
let mut tag_identifier: TagIdentifier = tag.into();
|
let mut tag_identifier: TagIdentifier = tag.into();
|
||||||
let base = current_path.get_base();
|
let base = current_path.get_base();
|
||||||
tag_identifier.info = Some(TagEngineInfo {
|
tag_identifier.info = Some(TagEngineInfo {
|
||||||
id: base.geo_meta.id,
|
id: base.geo_meta.id,
|
||||||
sketch_group: self.id,
|
sketch: self.id,
|
||||||
path: Some(base.clone()),
|
path: Some(base.clone()),
|
||||||
surface: None,
|
surface: None,
|
||||||
});
|
});
|
||||||
@ -1086,24 +1086,24 @@ impl SketchGroup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An extrude group is a collection of extrude surfaces.
|
/// An solid is a collection of extrude surfaces.
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
|
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
|
||||||
#[ts(export)]
|
#[ts(export)]
|
||||||
#[serde(tag = "type", rename_all = "camelCase")]
|
#[serde(tag = "type", rename_all = "camelCase")]
|
||||||
pub struct ExtrudeGroup {
|
pub struct Solid {
|
||||||
/// The id of the extrude group.
|
/// The id of the solid.
|
||||||
pub id: uuid::Uuid,
|
pub id: uuid::Uuid,
|
||||||
/// The extrude surfaces.
|
/// The extrude surfaces.
|
||||||
pub value: Vec<ExtrudeSurface>,
|
pub value: Vec<ExtrudeSurface>,
|
||||||
/// The sketch group.
|
/// The sketch.
|
||||||
pub sketch_group: SketchGroup,
|
pub sketch: Sketch,
|
||||||
/// The height of the extrude group.
|
/// The height of the solid.
|
||||||
pub height: f64,
|
pub height: f64,
|
||||||
/// The id of the extrusion start cap
|
/// The id of the extrusion start cap
|
||||||
pub start_cap_id: Option<uuid::Uuid>,
|
pub start_cap_id: Option<uuid::Uuid>,
|
||||||
/// The id of the extrusion end cap
|
/// The id of the extrusion end cap
|
||||||
pub end_cap_id: Option<uuid::Uuid>,
|
pub end_cap_id: Option<uuid::Uuid>,
|
||||||
/// Chamfers or fillets on this extrude group.
|
/// Chamfers or fillets on this solid.
|
||||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||||
pub edge_cuts: Vec<EdgeCut>,
|
pub edge_cuts: Vec<EdgeCut>,
|
||||||
/// Metadata.
|
/// Metadata.
|
||||||
@ -1111,28 +1111,28 @@ pub struct ExtrudeGroup {
|
|||||||
pub meta: Vec<Metadata>,
|
pub meta: Vec<Metadata>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ExtrudeGroup {
|
impl Solid {
|
||||||
pub(crate) fn get_all_edge_cut_ids(&self) -> Vec<uuid::Uuid> {
|
pub(crate) fn get_all_edge_cut_ids(&self) -> Vec<uuid::Uuid> {
|
||||||
self.edge_cuts.iter().map(|foc| foc.id()).collect()
|
self.edge_cuts.iter().map(|foc| foc.id()).collect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An extrude group ID and its fillet and chamfer IDs. This is needed for lazy
|
/// An solid ID and its fillet and chamfer IDs. This is needed for lazy
|
||||||
/// fillet evaluation.
|
/// fillet evaluation.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize, ts_rs::TS, JsonSchema)]
|
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize, ts_rs::TS, JsonSchema)]
|
||||||
pub struct ExtrudeGroupLazyIds {
|
pub struct SolidLazyIds {
|
||||||
pub extrude_group_id: uuid::Uuid,
|
pub solid_id: uuid::Uuid,
|
||||||
pub sketch_group_id: uuid::Uuid,
|
pub sketch_id: uuid::Uuid,
|
||||||
/// Chamfers or fillets on this extrude group.
|
/// Chamfers or fillets on this solid.
|
||||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||||
pub edge_cuts: Vec<uuid::Uuid>,
|
pub edge_cuts: Vec<uuid::Uuid>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&ExtrudeGroup> for ExtrudeGroupLazyIds {
|
impl From<&Solid> for SolidLazyIds {
|
||||||
fn from(eg: &ExtrudeGroup) -> Self {
|
fn from(eg: &Solid) -> Self {
|
||||||
Self {
|
Self {
|
||||||
extrude_group_id: eg.id,
|
solid_id: eg.id,
|
||||||
sketch_group_id: eg.sketch_group.id,
|
sketch_id: eg.sketch.id,
|
||||||
edge_cuts: eg.edge_cuts.iter().map(|foc| foc.id()).collect(),
|
edge_cuts: eg.edge_cuts.iter().map(|foc| foc.id()).collect(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3197,10 +3197,10 @@ let w = f() + f()
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_serialize_memory_item() {
|
fn test_serialize_memory_item() {
|
||||||
let mem = KclValue::ExtrudeGroups {
|
let mem = KclValue::Solids {
|
||||||
value: Default::default(),
|
value: Default::default(),
|
||||||
};
|
};
|
||||||
let json = serde_json::to_string(&mem).unwrap();
|
let json = serde_json::to_string(&mem).unwrap();
|
||||||
assert_eq!(json, r#"{"type":"ExtrudeGroups","value":[]}"#);
|
assert_eq!(json, r#"{"type":"Solids","value":[]}"#);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -701,19 +701,25 @@ fn function_expression(i: TokenSlice) -> PResult<FunctionExpression> {
|
|||||||
/// E.g. `person.name`
|
/// E.g. `person.name`
|
||||||
fn member_expression_dot(i: TokenSlice) -> PResult<(LiteralIdentifier, usize, bool)> {
|
fn member_expression_dot(i: TokenSlice) -> PResult<(LiteralIdentifier, usize, bool)> {
|
||||||
period.parse_next(i)?;
|
period.parse_next(i)?;
|
||||||
let property = identifier.parse_next(i)?;
|
let property = alt((
|
||||||
let end = property.end;
|
sketch_keyword.map(Box::new).map(LiteralIdentifier::Identifier),
|
||||||
Ok((LiteralIdentifier::Identifier(Box::new(property)), end, false))
|
identifier.map(Box::new).map(LiteralIdentifier::Identifier),
|
||||||
|
))
|
||||||
|
.parse_next(i)?;
|
||||||
|
let end = property.end();
|
||||||
|
Ok((property, end, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// E.g. `people[0]` or `people[i]` or `people['adam']`
|
/// E.g. `people[0]` or `people[i]` or `people['adam']`
|
||||||
fn member_expression_subscript(i: TokenSlice) -> PResult<(LiteralIdentifier, usize, bool)> {
|
fn member_expression_subscript(i: TokenSlice) -> PResult<(LiteralIdentifier, usize, bool)> {
|
||||||
let _ = open_bracket.parse_next(i)?;
|
let _ = open_bracket.parse_next(i)?;
|
||||||
let property = alt((
|
let property = alt((
|
||||||
|
sketch_keyword.map(Box::new).map(LiteralIdentifier::Identifier),
|
||||||
literal.map(Box::new).map(LiteralIdentifier::Literal),
|
literal.map(Box::new).map(LiteralIdentifier::Literal),
|
||||||
identifier.map(Box::new).map(LiteralIdentifier::Identifier),
|
identifier.map(Box::new).map(LiteralIdentifier::Identifier),
|
||||||
))
|
))
|
||||||
.parse_next(i)?;
|
.parse_next(i)?;
|
||||||
|
|
||||||
let end = close_bracket.parse_next(i)?.end;
|
let end = close_bracket.parse_next(i)?.end;
|
||||||
let computed = matches!(property, LiteralIdentifier::Identifier(_));
|
let computed = matches!(property, LiteralIdentifier::Identifier(_));
|
||||||
Ok((property, end, computed))
|
Ok((property, end, computed))
|
||||||
@ -1193,6 +1199,26 @@ fn identifier(i: TokenSlice) -> PResult<Identifier> {
|
|||||||
.parse_next(i)
|
.parse_next(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn sketch_keyword(i: TokenSlice) -> PResult<Identifier> {
|
||||||
|
any.try_map(|token: Token| {
|
||||||
|
if token.token_type == TokenType::Type && token.value == "sketch" {
|
||||||
|
Ok(Identifier {
|
||||||
|
start: token.start,
|
||||||
|
end: token.end,
|
||||||
|
name: token.value,
|
||||||
|
digest: None,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
Err(KclError::Syntax(KclErrorDetails {
|
||||||
|
source_ranges: token.as_source_ranges(),
|
||||||
|
message: format!("Expected 'sketch' keyword, but found {}", token.value.as_str()),
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.context(expected("the 'sketch' keyword"))
|
||||||
|
.parse_next(i)
|
||||||
|
}
|
||||||
|
|
||||||
impl TryFrom<Token> for TagDeclarator {
|
impl TryFrom<Token> for TagDeclarator {
|
||||||
type Error = KclError;
|
type Error = KclError;
|
||||||
|
|
||||||
@ -2567,6 +2593,18 @@ const height = 1 - obj.a"#,
|
|||||||
parser.ast().unwrap();
|
parser.ast().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_parse_member_expression_allowed_type_in_expression() {
|
||||||
|
let tokens = crate::token::lexer(
|
||||||
|
r#"const obj = { thing: 1 }
|
||||||
|
startSketchOn(obj.sketch)"#,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let parser = crate::parser::Parser::new(tokens);
|
||||||
|
parser.ast().unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_member_expression_binary_expression_brace_number_first() {
|
fn test_parse_member_expression_binary_expression_brace_number_first() {
|
||||||
let tokens = crate::token::lexer(
|
let tokens = crate::token::lexer(
|
||||||
@ -3182,7 +3220,7 @@ thing(false)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_member_expression_sketch_group() {
|
fn test_member_expression_sketch() {
|
||||||
let some_program_string = r#"fn cube = (pos, scale) => {
|
let some_program_string = r#"fn cube = (pos, scale) => {
|
||||||
const sg = startSketchOn('XY')
|
const sg = startSketchOn('XY')
|
||||||
|> startProfileAt(pos, %)
|
|> startProfileAt(pos, %)
|
||||||
|
@ -9,10 +9,10 @@ use crate::{
|
|||||||
ast::types::{parse_json_number_as_f64, TagDeclarator},
|
ast::types::{parse_json_number_as_f64, TagDeclarator},
|
||||||
errors::{KclError, KclErrorDetails},
|
errors::{KclError, KclErrorDetails},
|
||||||
executor::{
|
executor::{
|
||||||
ExecState, ExecutorContext, ExtrudeGroup, ExtrudeGroupSet, ExtrudeSurface, KclValue, Metadata, SketchGroup,
|
ExecState, ExecutorContext, ExtrudeSurface, KclValue, Metadata, Sketch, SketchSet, SketchSurface, Solid,
|
||||||
SketchGroupSet, SketchSurface, SourceRange, TagIdentifier,
|
SolidSet, SourceRange, TagIdentifier,
|
||||||
},
|
},
|
||||||
std::{shapes::SketchSurfaceOrGroup, sketch::FaceTag, FnAsArg},
|
std::{shapes::SketchOrSurface, sketch::FaceTag, FnAsArg},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
@ -125,35 +125,35 @@ impl Args {
|
|||||||
self.get_tag_info_from_memory(exec_state, tag)
|
self.get_tag_info_from_memory(exec_state, tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Flush just the fillets and chamfers for this specific ExtrudeGroupSet.
|
/// Flush just the fillets and chamfers for this specific SolidSet.
|
||||||
#[allow(clippy::vec_box)]
|
#[allow(clippy::vec_box)]
|
||||||
pub(crate) async fn flush_batch_for_extrude_group_set(
|
pub(crate) async fn flush_batch_for_solid_set(
|
||||||
&self,
|
&self,
|
||||||
exec_state: &mut ExecState,
|
exec_state: &mut ExecState,
|
||||||
extrude_groups: Vec<Box<ExtrudeGroup>>,
|
solids: Vec<Box<Solid>>,
|
||||||
) -> Result<(), KclError> {
|
) -> Result<(), KclError> {
|
||||||
// Make sure we don't traverse sketch_groups more than once.
|
// Make sure we don't traverse sketches more than once.
|
||||||
let mut traversed_sketch_groups = Vec::new();
|
let mut traversed_sketches = Vec::new();
|
||||||
|
|
||||||
// Collect all the fillet/chamfer ids for the extrude groups.
|
// Collect all the fillet/chamfer ids for the solids.
|
||||||
let mut ids = Vec::new();
|
let mut ids = Vec::new();
|
||||||
for extrude_group in extrude_groups {
|
for solid in solids {
|
||||||
// We need to traverse the extrude groups that share the same sketch group.
|
// We need to traverse the solids that share the same sketch.
|
||||||
let sketch_group_id = extrude_group.sketch_group.id;
|
let sketch_id = solid.sketch.id;
|
||||||
if !traversed_sketch_groups.contains(&sketch_group_id) {
|
if !traversed_sketches.contains(&sketch_id) {
|
||||||
// Find all the extrude groups on the same shared sketch group.
|
// Find all the solids on the same shared sketch.
|
||||||
ids.extend(
|
ids.extend(
|
||||||
exec_state
|
exec_state
|
||||||
.memory
|
.memory
|
||||||
.find_extrude_groups_on_sketch_group(extrude_group.sketch_group.id)
|
.find_solids_on_sketch(solid.sketch.id)
|
||||||
.iter()
|
.iter()
|
||||||
.flat_map(|eg| eg.get_all_edge_cut_ids()),
|
.flat_map(|eg| eg.get_all_edge_cut_ids()),
|
||||||
);
|
);
|
||||||
ids.extend(exec_state.dynamic_state.edge_cut_ids_on_sketch_group(sketch_group_id));
|
ids.extend(exec_state.dynamic_state.edge_cut_ids_on_sketch(sketch_id));
|
||||||
traversed_sketch_groups.push(sketch_group_id);
|
traversed_sketches.push(sketch_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
ids.extend(extrude_group.get_all_edge_cut_ids());
|
ids.extend(solid.get_all_edge_cut_ids());
|
||||||
}
|
}
|
||||||
|
|
||||||
// We can return early if there are no fillets or chamfers.
|
// We can return early if there are no fillets or chamfers.
|
||||||
@ -236,7 +236,7 @@ impl Args {
|
|||||||
Ok(numbers)
|
Ok(numbers)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_pattern_transform_args(&self) -> Result<(u32, FnAsArg<'_>, ExtrudeGroupSet), KclError> {
|
pub(crate) fn get_pattern_transform_args(&self) -> Result<(u32, FnAsArg<'_>, SolidSet), KclError> {
|
||||||
FromArgs::from_args(self, 0)
|
FromArgs::from_args(self, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,7 +258,7 @@ impl Args {
|
|||||||
) -> Result<
|
) -> Result<
|
||||||
(
|
(
|
||||||
crate::std::shapes::CircleData,
|
crate::std::shapes::CircleData,
|
||||||
crate::std::shapes::SketchSurfaceOrGroup,
|
crate::std::shapes::SketchOrSurface,
|
||||||
Option<TagDeclarator>,
|
Option<TagDeclarator>,
|
||||||
),
|
),
|
||||||
KclError,
|
KclError,
|
||||||
@ -266,11 +266,11 @@ impl Args {
|
|||||||
FromArgs::from_args(self, 0)
|
FromArgs::from_args(self, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_sketch_groups(&self) -> Result<(SketchGroupSet, SketchGroup), KclError> {
|
pub(crate) fn get_sketches(&self) -> Result<(SketchSet, Sketch), KclError> {
|
||||||
FromArgs::from_args(self, 0)
|
FromArgs::from_args(self, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_sketch_group(&self) -> Result<SketchGroup, KclError> {
|
pub(crate) fn get_sketch(&self) -> Result<Sketch, KclError> {
|
||||||
FromArgs::from_args(self, 0)
|
FromArgs::from_args(self, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,11 +285,11 @@ impl Args {
|
|||||||
FromArgs::from_args(self, 0)
|
FromArgs::from_args(self, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_sketch_group_and_optional_tag(&self) -> Result<(SketchGroup, Option<TagDeclarator>), KclError> {
|
pub(crate) fn get_sketch_and_optional_tag(&self) -> Result<(Sketch, Option<TagDeclarator>), KclError> {
|
||||||
FromArgs::from_args(self, 0)
|
FromArgs::from_args(self, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_sketch_groups_and_data<'a, T>(&'a self) -> Result<(Vec<SketchGroup>, Option<T>), KclError>
|
pub(crate) fn get_sketches_and_data<'a, T>(&'a self) -> Result<(Vec<Sketch>, Option<T>), KclError>
|
||||||
where
|
where
|
||||||
T: FromArgs<'a> + serde::de::DeserializeOwned + FromKclValue<'a> + Sized,
|
T: FromArgs<'a> + serde::de::DeserializeOwned + FromKclValue<'a> + Sized,
|
||||||
{
|
{
|
||||||
@ -303,23 +303,21 @@ impl Args {
|
|||||||
FromArgs::from_args(self, 0)
|
FromArgs::from_args(self, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_data_and_sketch_group<'a, T>(&'a self) -> Result<(T, SketchGroup), KclError>
|
pub(crate) fn get_data_and_sketch<'a, T>(&'a self) -> Result<(T, Sketch), KclError>
|
||||||
where
|
where
|
||||||
T: serde::de::DeserializeOwned + FromArgs<'a>,
|
T: serde::de::DeserializeOwned + FromArgs<'a>,
|
||||||
{
|
{
|
||||||
FromArgs::from_args(self, 0)
|
FromArgs::from_args(self, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_data_and_sketch_group_set<'a, T>(&'a self) -> Result<(T, SketchGroupSet), KclError>
|
pub(crate) fn get_data_and_sketch_set<'a, T>(&'a self) -> Result<(T, SketchSet), KclError>
|
||||||
where
|
where
|
||||||
T: serde::de::DeserializeOwned + FromArgs<'a>,
|
T: serde::de::DeserializeOwned + FromArgs<'a>,
|
||||||
{
|
{
|
||||||
FromArgs::from_args(self, 0)
|
FromArgs::from_args(self, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_data_and_sketch_group_and_tag<'a, T>(
|
pub(crate) fn get_data_and_sketch_and_tag<'a, T>(&'a self) -> Result<(T, Sketch, Option<TagDeclarator>), KclError>
|
||||||
&'a self,
|
|
||||||
) -> Result<(T, SketchGroup, Option<TagDeclarator>), KclError>
|
|
||||||
where
|
where
|
||||||
T: serde::de::DeserializeOwned + FromKclValue<'a> + Sized,
|
T: serde::de::DeserializeOwned + FromKclValue<'a> + Sized,
|
||||||
{
|
{
|
||||||
@ -335,30 +333,30 @@ impl Args {
|
|||||||
FromArgs::from_args(self, 0)
|
FromArgs::from_args(self, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_data_and_extrude_group_set<'a, T>(&'a self) -> Result<(T, ExtrudeGroupSet), KclError>
|
pub(crate) fn get_data_and_solid_set<'a, T>(&'a self) -> Result<(T, SolidSet), KclError>
|
||||||
where
|
where
|
||||||
T: serde::de::DeserializeOwned + FromKclValue<'a> + Sized,
|
T: serde::de::DeserializeOwned + FromKclValue<'a> + Sized,
|
||||||
{
|
{
|
||||||
FromArgs::from_args(self, 0)
|
FromArgs::from_args(self, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_data_and_extrude_group<'a, T>(&'a self) -> Result<(T, Box<ExtrudeGroup>), KclError>
|
pub(crate) fn get_data_and_solid<'a, T>(&'a self) -> Result<(T, Box<Solid>), KclError>
|
||||||
where
|
where
|
||||||
T: serde::de::DeserializeOwned + FromKclValue<'a> + Sized,
|
T: serde::de::DeserializeOwned + FromKclValue<'a> + Sized,
|
||||||
{
|
{
|
||||||
FromArgs::from_args(self, 0)
|
FromArgs::from_args(self, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_data_and_extrude_group_and_tag<'a, T>(
|
pub(crate) fn get_data_and_solid_and_tag<'a, T>(
|
||||||
&'a self,
|
&'a self,
|
||||||
) -> Result<(T, Box<ExtrudeGroup>, Option<TagDeclarator>), KclError>
|
) -> Result<(T, Box<Solid>, Option<TagDeclarator>), KclError>
|
||||||
where
|
where
|
||||||
T: serde::de::DeserializeOwned + FromKclValue<'a> + Sized,
|
T: serde::de::DeserializeOwned + FromKclValue<'a> + Sized,
|
||||||
{
|
{
|
||||||
FromArgs::from_args(self, 0)
|
FromArgs::from_args(self, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_tag_to_number_sketch_group(&self) -> Result<(TagIdentifier, f64, SketchGroup), KclError> {
|
pub(crate) fn get_tag_to_number_sketch(&self) -> Result<(TagIdentifier, f64, Sketch), KclError> {
|
||||||
FromArgs::from_args(self, 0)
|
FromArgs::from_args(self, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -369,7 +367,7 @@ impl Args {
|
|||||||
FromArgs::from_args(self, 0)
|
FromArgs::from_args(self, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_number_sketch_group_set(&self) -> Result<(f64, SketchGroupSet), KclError> {
|
pub(crate) fn get_number_sketch_set(&self) -> Result<(f64, SketchSet), KclError> {
|
||||||
FromArgs::from_args(self, 0)
|
FromArgs::from_args(self, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -654,7 +652,7 @@ impl_from_arg_via_json!(crate::std::polar::PolarCoordsData);
|
|||||||
impl_from_arg_via_json!(crate::std::loft::LoftData);
|
impl_from_arg_via_json!(crate::std::loft::LoftData);
|
||||||
impl_from_arg_via_json!(crate::std::planes::StandardPlane);
|
impl_from_arg_via_json!(crate::std::planes::StandardPlane);
|
||||||
impl_from_arg_via_json!(crate::std::mirror::Mirror2dData);
|
impl_from_arg_via_json!(crate::std::mirror::Mirror2dData);
|
||||||
impl_from_arg_via_json!(SketchGroup);
|
impl_from_arg_via_json!(Sketch);
|
||||||
impl_from_arg_via_json!(FaceTag);
|
impl_from_arg_via_json!(FaceTag);
|
||||||
impl_from_arg_via_json!(String);
|
impl_from_arg_via_json!(String);
|
||||||
impl_from_arg_via_json!(crate::ast::types::KclNone);
|
impl_from_arg_via_json!(crate::ast::types::KclNone);
|
||||||
@ -666,22 +664,22 @@ impl_from_arg_via_json!(bool);
|
|||||||
impl_from_arg_for_array!(2);
|
impl_from_arg_for_array!(2);
|
||||||
impl_from_arg_for_array!(3);
|
impl_from_arg_for_array!(3);
|
||||||
|
|
||||||
impl<'a> FromKclValue<'a> for SketchGroupSet {
|
impl<'a> FromKclValue<'a> for SketchSet {
|
||||||
fn from_mem_item(arg: &'a KclValue) -> Option<Self> {
|
fn from_mem_item(arg: &'a KclValue) -> Option<Self> {
|
||||||
let KclValue::UserVal(uv) = arg else {
|
let KclValue::UserVal(uv) = arg else {
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
if let Some((x, _meta)) = uv.get::<SketchGroup>() {
|
if let Some((x, _meta)) = uv.get::<Sketch>() {
|
||||||
Some(SketchGroupSet::from(x))
|
Some(SketchSet::from(x))
|
||||||
} else {
|
} else {
|
||||||
uv.get::<Vec<SketchGroup>>().map(|x| x.0).map(SketchGroupSet::from)
|
uv.get::<Vec<Sketch>>().map(|x| x.0).map(SketchSet::from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> FromKclValue<'a> for Box<ExtrudeGroup> {
|
impl<'a> FromKclValue<'a> for Box<Solid> {
|
||||||
fn from_mem_item(arg: &'a KclValue) -> Option<Self> {
|
fn from_mem_item(arg: &'a KclValue) -> Option<Self> {
|
||||||
let KclValue::ExtrudeGroup(s) = arg else {
|
let KclValue::Solid(s) = arg else {
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
Some(s.to_owned())
|
Some(s.to_owned())
|
||||||
@ -694,17 +692,17 @@ impl<'a> FromKclValue<'a> for FnAsArg<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> FromKclValue<'a> for ExtrudeGroupSet {
|
impl<'a> FromKclValue<'a> for SolidSet {
|
||||||
fn from_mem_item(arg: &'a KclValue) -> Option<Self> {
|
fn from_mem_item(arg: &'a KclValue) -> Option<Self> {
|
||||||
arg.get_extrude_group_set().ok()
|
arg.get_solid_set().ok()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<'a> FromKclValue<'a> for SketchSurfaceOrGroup {
|
impl<'a> FromKclValue<'a> for SketchOrSurface {
|
||||||
fn from_mem_item(arg: &'a KclValue) -> Option<Self> {
|
fn from_mem_item(arg: &'a KclValue) -> Option<Self> {
|
||||||
match arg {
|
match arg {
|
||||||
KclValue::UserVal(uv) => {
|
KclValue::UserVal(uv) => {
|
||||||
if let Some((sg, _meta)) = uv.get() {
|
if let Some((sg, _meta)) = uv.get() {
|
||||||
Some(Self::SketchGroup(sg))
|
Some(Self::Sketch(sg))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
@ -725,13 +723,13 @@ impl<'a> FromKclValue<'a> for SketchSurface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> FromKclValue<'a> for Vec<SketchGroup> {
|
impl<'a> FromKclValue<'a> for Vec<Sketch> {
|
||||||
fn from_mem_item(arg: &'a KclValue) -> Option<Self> {
|
fn from_mem_item(arg: &'a KclValue) -> Option<Self> {
|
||||||
let KclValue::UserVal(uv) = arg else {
|
let KclValue::UserVal(uv) = arg else {
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
|
|
||||||
uv.get::<Vec<SketchGroup>>().map(|x| x.0)
|
uv.get::<Vec<Sketch>>().map(|x| x.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,13 +4,13 @@ use schemars::JsonSchema;
|
|||||||
use super::{args::FromArgs, Args, FnAsArg};
|
use super::{args::FromArgs, Args, FnAsArg};
|
||||||
use crate::{
|
use crate::{
|
||||||
errors::{KclError, KclErrorDetails},
|
errors::{KclError, KclErrorDetails},
|
||||||
executor::{ExecState, KclValue, SketchGroup, SourceRange, UserVal},
|
executor::{ExecState, KclValue, Sketch, SourceRange, UserVal},
|
||||||
function_param::FunctionParam,
|
function_param::FunctionParam,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// For each item in an array, update a value.
|
/// For each item in an array, update a value.
|
||||||
pub async fn array_reduce(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
pub async fn array_reduce(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
||||||
let (array, start, f): (Vec<u64>, SketchGroup, FnAsArg<'_>) = FromArgs::from_args(&args, 0)?;
|
let (array, start, f): (Vec<u64>, Sketch, FnAsArg<'_>) = FromArgs::from_args(&args, 0)?;
|
||||||
let reduce_fn = FunctionParam {
|
let reduce_fn = FunctionParam {
|
||||||
inner: f.func,
|
inner: f.func,
|
||||||
fn_expr: f.expr,
|
fn_expr: f.expr,
|
||||||
@ -28,8 +28,8 @@ pub async fn array_reduce(exec_state: &mut ExecState, args: Args) -> Result<KclV
|
|||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// fn decagon = (radius) => {
|
/// fn decagon = (radius) => {
|
||||||
/// let step = (1/10) * tau()
|
/// let step = (1/10) * tau()
|
||||||
/// let sketch = startSketchAt([(cos(0)*radius), (sin(0) * radius)])
|
/// let sketch001 = startSketchAt([(cos(0)*radius), (sin(0) * radius)])
|
||||||
/// return arrayReduce([1..10], sketch, (i, sg) => {
|
/// return arrayReduce([1..10], sketch001, (i, sg) => {
|
||||||
/// let x = cos(step * i) * radius
|
/// let x = cos(step * i) * radius
|
||||||
/// let y = sin(step * i) * radius
|
/// let y = sin(step * i) * radius
|
||||||
/// return lineTo([x, y], sg)
|
/// return lineTo([x, y], sg)
|
||||||
@ -42,11 +42,11 @@ pub async fn array_reduce(exec_state: &mut ExecState, args: Args) -> Result<KclV
|
|||||||
}]
|
}]
|
||||||
async fn inner_array_reduce<'a>(
|
async fn inner_array_reduce<'a>(
|
||||||
array: Vec<u64>,
|
array: Vec<u64>,
|
||||||
start: SketchGroup,
|
start: Sketch,
|
||||||
reduce_fn: FunctionParam<'a>,
|
reduce_fn: FunctionParam<'a>,
|
||||||
exec_state: &mut ExecState,
|
exec_state: &mut ExecState,
|
||||||
args: &'a Args,
|
args: &'a Args,
|
||||||
) -> Result<SketchGroup, KclError> {
|
) -> Result<Sketch, KclError> {
|
||||||
let mut reduced = start;
|
let mut reduced = start;
|
||||||
for i in array {
|
for i in array {
|
||||||
reduced = call_reduce_closure(i, reduced, &reduce_fn, args.source_range, exec_state).await?;
|
reduced = call_reduce_closure(i, reduced, &reduce_fn, args.source_range, exec_state).await?;
|
||||||
@ -57,11 +57,11 @@ async fn inner_array_reduce<'a>(
|
|||||||
|
|
||||||
async fn call_reduce_closure<'a>(
|
async fn call_reduce_closure<'a>(
|
||||||
i: u64,
|
i: u64,
|
||||||
start: SketchGroup,
|
start: Sketch,
|
||||||
reduce_fn: &FunctionParam<'a>,
|
reduce_fn: &FunctionParam<'a>,
|
||||||
source_range: SourceRange,
|
source_range: SourceRange,
|
||||||
exec_state: &mut ExecState,
|
exec_state: &mut ExecState,
|
||||||
) -> Result<SketchGroup, KclError> {
|
) -> Result<Sketch, KclError> {
|
||||||
// Call the reduce fn for this repetition.
|
// Call the reduce fn for this repetition.
|
||||||
let reduce_fn_args = vec![
|
let reduce_fn_args = vec![
|
||||||
KclValue::UserVal(UserVal {
|
KclValue::UserVal(UserVal {
|
||||||
@ -88,7 +88,7 @@ async fn call_reduce_closure<'a>(
|
|||||||
};
|
};
|
||||||
let Some((out, _meta)) = out.get() else {
|
let Some((out, _meta)) = out.get() else {
|
||||||
return Err(KclError::Semantic(KclErrorDetails {
|
return Err(KclError::Semantic(KclErrorDetails {
|
||||||
message: "Reducer function must return a SketchGroup".to_string(),
|
message: "Reducer function must return a Sketch".to_string(),
|
||||||
source_ranges: source_ranges.clone(),
|
source_ranges: source_ranges.clone(),
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user