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/*
|
||||
*.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/
|
||||
# cleanup old
|
||||
rm -rf documentation/content/pages/docs/kcl/*.md
|
||||
rm -rf documentation/content/pages/docs/kcl/types
|
||||
# move new
|
||||
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
|
||||
shell: bash
|
||||
run: |
|
||||
|
@ -9,7 +9,7 @@ Compute the angle (in degrees) in o
|
||||
|
||||
|
||||
```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 |
|
||||
| `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
|
||||
|
||||
|
@ -9,7 +9,7 @@ Returns the angle to match the given length for y.
|
||||
|
||||
|
||||
```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 |
|
||||
| `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
|
||||
|
||||
|
@ -9,7 +9,7 @@ Draw a line segment relative to the current origin using the polar
|
||||
measure of some angle and distance.
|
||||
|
||||
```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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `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 |
|
||||
|
||||
### 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
|
||||
|
@ -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.
|
||||
|
||||
```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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `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 |
|
||||
|
||||
### 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
|
||||
|
@ -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.
|
||||
|
||||
```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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `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 |
|
||||
|
||||
### 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
|
||||
|
@ -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.
|
||||
|
||||
```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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `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 |
|
||||
|
||||
### 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
|
||||
|
@ -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.
|
||||
|
||||
```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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `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 |
|
||||
|
||||
### 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
|
||||
|
@ -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.
|
||||
|
||||
```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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `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 |
|
||||
|
||||
### 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
|
||||
|
@ -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.
|
||||
|
||||
```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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `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 |
|
||||
|
||||
### 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
|
||||
|
@ -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.
|
||||
|
||||
```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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `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 |
|
||||
|
||||
### 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
|
||||
@ -31,8 +31,8 @@ arrayReduce(array: [u64], start: SketchGroup, reduce_fn: FunctionParam) -> Sketc
|
||||
```js
|
||||
fn decagon = (radius) => {
|
||||
let step = 1 / 10 * tau()
|
||||
let sketch = startSketchAt([cos(0) * radius, sin(0) * radius])
|
||||
return arrayReduce([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], sketch, (i, sg) => {
|
||||
let sketch001 = startSketchAt([cos(0) * radius, sin(0) * radius])
|
||||
return arrayReduce([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], sketch001, (i, sg) => {
|
||||
let x = cos(step * i) * radius
|
||||
let y = sin(step * i) * radius
|
||||
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.
|
||||
|
||||
```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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `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 |
|
||||
|
||||
### 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
|
||||
|
@ -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.
|
||||
|
||||
```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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `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 |
|
||||
|
||||
### 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
|
||||
|
@ -9,7 +9,7 @@ Construct a 2-dimensional circle, of the specified radius, centered at
|
||||
the provided (x, y) origin point.
|
||||
|
||||
```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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `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 |
|
||||
|
||||
### 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
|
||||
|
@ -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.
|
||||
|
||||
```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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `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 |
|
||||
|
||||
### 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
|
||||
|
@ -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.
|
||||
|
||||
```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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `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
|
||||
|
||||
[`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
|
||||
|
@ -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.
|
||||
|
||||
```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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `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 |
|
||||
|
||||
### 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
|
||||
|
@ -9,7 +9,7 @@ Create a helix on a cylinder.
|
||||
|
||||
|
||||
```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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `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
|
||||
|
||||
[`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
|
||||
|
@ -9,7 +9,7 @@ Use a 2-dimensional sketch to cut a hole in another 2-dimensional sketch.
|
||||
|
||||
|
||||
```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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `hole_sketch_group` | [`SketchGroupSet`](/docs/kcl/types/SketchGroupSet) | A sketch group or a group of sketch groups. | Yes |
|
||||
| `sketch_group` | [`SketchGroup`](/docs/kcl/types/SketchGroup) | A sketch group is a collection of paths. | Yes |
|
||||
| `hole_sketch` | [`SketchSet`](/docs/kcl/types/SketchSet) | A sketch or a group of sketches. | Yes |
|
||||
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | A sketch is a collection of paths. | Yes |
|
||||
|
||||
### 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
|
||||
|
@ -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.
|
||||
|
||||
```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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `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
|
||||
|
||||
[`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
|
||||
|
@ -9,7 +9,7 @@ Extract the 'x' axis value of the last line segment in the provided 2-
|
||||
sketch.
|
||||
|
||||
```js
|
||||
lastSegX(sketch_group: SketchGroup) -> number
|
||||
lastSegX(sketch: Sketch) -> number
|
||||
```
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ lastSegX(sketch_group: SketchGroup) -> number
|
||||
|
||||
| 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
|
||||
|
||||
|
@ -9,7 +9,7 @@ Extract the 'y' axis value of the last line segment in the provided 2-
|
||||
sketch.
|
||||
|
||||
```js
|
||||
lastSegY(sketch_group: SketchGroup) -> number
|
||||
lastSegY(sketch: Sketch) -> number
|
||||
```
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ lastSegY(sketch_group: SketchGroup) -> number
|
||||
|
||||
| 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
|
||||
|
||||
|
@ -9,7 +9,7 @@ Draw a line relative to the current origin to a specified (x, y) away
|
||||
from the current position.
|
||||
|
||||
```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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `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 |
|
||||
|
||||
### 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
|
||||
|
@ -9,7 +9,7 @@ Draw a line from the current origin to some absolute (x, y) point.
|
||||
|
||||
|
||||
```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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `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 |
|
||||
|
||||
### 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
|
||||
|
@ -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.
|
||||
|
||||
```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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `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 |
|
||||
|
||||
### 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
|
||||
|
@ -10,7 +10,7 @@ Only works on unclosed sketches for now.
|
||||
Mirror occurs around a local sketch axis rather than a global axis.
|
||||
|
||||
```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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `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
|
||||
|
||||
[`[SketchGroup]`](/docs/kcl/types/[SketchGroup])
|
||||
[`[Sketch]`](/docs/kcl/types/[Sketch])
|
||||
|
||||
|
||||
### 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.
|
||||
|
||||
```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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `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
|
||||
|
||||
[`[SketchGroup]`](/docs/kcl/types/[SketchGroup])
|
||||
[`[Sketch]`](/docs/kcl/types/[Sketch])
|
||||
|
||||
|
||||
### 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.
|
||||
|
||||
```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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `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
|
||||
|
||||
[`[ExtrudeGroup]`](/docs/kcl/types/[ExtrudeGroup])
|
||||
[`[Solid]`](/docs/kcl/types/[Solid])
|
||||
|
||||
|
||||
### 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.
|
||||
|
||||
```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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `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
|
||||
|
||||
[`[SketchGroup]`](/docs/kcl/types/[SketchGroup])
|
||||
[`[Sketch]`](/docs/kcl/types/[Sketch])
|
||||
|
||||
|
||||
### 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.
|
||||
|
||||
```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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `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
|
||||
|
||||
[`[ExtrudeGroup]`](/docs/kcl/types/[ExtrudeGroup])
|
||||
[`[Solid]`](/docs/kcl/types/[Solid])
|
||||
|
||||
|
||||
### 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.
|
||||
|
||||
```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 |
|
||||
| `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
|
||||
|
||||
[`[ExtrudeGroup]`](/docs/kcl/types/[ExtrudeGroup])
|
||||
[`[Solid]`](/docs/kcl/types/[Solid])
|
||||
|
||||
|
||||
### Examples
|
||||
|
@ -1,15 +1,15 @@
|
||||
---
|
||||
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
|
||||
---
|
||||
|
||||
Extract the provided 2-dimensional sketch group's profile's origin
|
||||
Extract the provided 2-dimensional sketch's profile's origin
|
||||
|
||||
value.
|
||||
|
||||
```js
|
||||
profileStart(sketch_group: SketchGroup) -> [number]
|
||||
profileStart(sketch: Sketch) -> [number]
|
||||
```
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ profileStart(sketch_group: SketchGroup) -> [number]
|
||||
|
||||
| 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
|
||||
|
||||
|
@ -1,15 +1,15 @@
|
||||
---
|
||||
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
|
||||
---
|
||||
|
||||
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.
|
||||
|
||||
```js
|
||||
profileStartX(sketch_group: SketchGroup) -> number
|
||||
profileStartX(sketch: Sketch) -> number
|
||||
```
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ profileStartX(sketch_group: SketchGroup) -> number
|
||||
|
||||
| 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
|
||||
|
||||
|
@ -1,15 +1,15 @@
|
||||
---
|
||||
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
|
||||
---
|
||||
|
||||
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.
|
||||
|
||||
```js
|
||||
profileStartY(sketch_group: SketchGroup) -> number
|
||||
profileStartY(sketch: Sketch) -> number
|
||||
```
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ profileStartY(sketch_group: SketchGroup) -> number
|
||||
|
||||
| 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
|
||||
|
||||
|
@ -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.
|
||||
|
||||
```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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `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
|
||||
|
||||
[`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
|
||||
|
@ -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.
|
||||
|
||||
```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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `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
|
||||
|
||||
[`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
|
||||
|
@ -9,7 +9,7 @@ Start a new profile at a given point.
|
||||
|
||||
|
||||
```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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `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 |
|
||||
|
||||
### 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
|
||||
|
@ -9,7 +9,7 @@ Start a new 2-dimensional sketch at a given point on the 'XY' plane.
|
||||
|
||||
|
||||
```js
|
||||
startSketchAt(data: [number]) -> SketchGroup
|
||||
startSketchAt(data: [number]) -> Sketch
|
||||
```
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ startSketchAt(data: [number]) -> SketchGroup
|
||||
|
||||
### 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
|
||||
|
@ -17,12 +17,12 @@ startSketchOn(data: SketchData, tag?: FaceTag) -> SketchSurface
|
||||
|
||||
| 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 |
|
||||
|
||||
### Returns
|
||||
|
||||
[`SketchSurface`](/docs/kcl/types/SketchSurface) - A sketch group type.
|
||||
[`SketchSurface`](/docs/kcl/types/SketchSurface) - A sketch type.
|
||||
|
||||
|
||||
### 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.
|
||||
|
||||
```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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `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 |
|
||||
|
||||
### 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
|
||||
|
@ -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.
|
||||
|
||||
```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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `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 |
|
||||
|
||||
### 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
|
||||
|
@ -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.
|
||||
|
||||
```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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `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 |
|
||||
|
||||
### 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
|
||||
|
@ -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 |
|
||||
| `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 |
|
||||
|
||||
|
||||
|
@ -23,8 +23,7 @@ Autodesk Filmbox (FBX) format
|
||||
|
||||
| Property | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `type` |enum: `fbx`
|
||||
| | No |
|
||||
| `type` |enum: `fbx`| | 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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `type` |enum: `gltf`
|
||||
| | No |
|
||||
| `type` |enum: `gltf`| | No |
|
||||
|
||||
|
||||
----
|
||||
@ -58,10 +56,8 @@ Wavefront OBJ format.
|
||||
| Property | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `coords` |`object`| Co-ordinate system of input data. Defaults to the [KittyCAD co-ordinate system. | No |
|
||||
| `type` |enum: `obj`
|
||||
| | 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 |
|
||||
| `type` |enum: `obj`| | 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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `coords` |`object`| Co-ordinate system of input data. Defaults to the [KittyCAD co-ordinate system. | No |
|
||||
| `type` |enum: `ply`
|
||||
| | 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 |
|
||||
| `type` |enum: `ply`| | 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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `type` |enum: `sldprt`
|
||||
| | No |
|
||||
| `type` |enum: `sldprt`| | No |
|
||||
|
||||
|
||||
----
|
||||
@ -114,8 +107,7 @@ ISO 10303-21 (STEP) format.
|
||||
|
||||
| Property | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `type` |enum: `step`
|
||||
| | No |
|
||||
| `type` |enum: `step`| | No |
|
||||
|
||||
|
||||
----
|
||||
@ -132,10 +124,8 @@ ST**ereo**L**ithography format.
|
||||
| Property | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `coords` |`object`| Co-ordinate system of input data. Defaults to the [KittyCAD co-ordinate system. | No |
|
||||
| `type` |enum: `stl`
|
||||
| | 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 |
|
||||
| `type` |enum: `stl`| | 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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `axis` |`anyOf`
|
||||
| Axis to use as mirror. | No |
|
||||
| `axis` |`anyOf`| Axis to use as mirror. | No |
|
||||
|
||||
|
||||
|
@ -17,8 +17,7 @@ Data for revolution surfaces.
|
||||
| Property | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `angle` |`number` (`double`)| Angle to revolve (in degrees). Default is 360. | No |
|
||||
| `axis` |`anyOf`
|
||||
| Axis of revolution. | No |
|
||||
| `axis` |`anyOf`| Axis of revolution. | 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"
|
||||
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
|
||||
---
|
||||
|
||||
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`
|
||||
@ -117,11 +117,11 @@ An extrude group is a collection of extrude surfaces.
|
||||
| Property | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `__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 |
|
||||
| `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 |
|
||||
| `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,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"
|
||||
excerpt: "A sketch surface or a sketch group."
|
||||
title: "SketchOrSurface"
|
||||
excerpt: "A sketch surface or a sketch."
|
||||
layout: manual
|
||||
---
|
||||
|
||||
A sketch surface or a sketch group.
|
||||
A sketch surface or a sketch.
|
||||
|
||||
|
||||
|
||||
**This schema accepts any of the following:**
|
||||
|
||||
A sketch group type.
|
||||
A sketch type.
|
||||
|
||||
|
||||
|
||||
@ -32,10 +32,8 @@ A plane.
|
||||
| `__meta` |`array`| | No |
|
||||
| `id` |`string` (`uuid`)| The id of the plane. | No |
|
||||
| `origin` |`object`| Origin of the plane. | No |
|
||||
| `type` |enum: `plane`
|
||||
| | No |
|
||||
| `value` |`oneOf`
|
||||
| Type for a plane. | No |
|
||||
| `type` |enum: `plane`| | No |
|
||||
| `value` |`oneOf`| Type for a plane. | No |
|
||||
| `xAxis` |`object`| What should the plane’s X axis be? | No |
|
||||
| `yAxis` |`object`| What should the plane’s Y axis be? | No |
|
||||
| `zAxis` |`object`| The z-axis (normal). | No |
|
||||
@ -55,10 +53,9 @@ A face.
|
||||
| Property | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `__meta` |`array`| | No |
|
||||
| `extrudeGroup` |`object`| The extrude group the face is on. | No |
|
||||
| `id` |`string` (`uuid`)| The id of the face. | No |
|
||||
| `type` |enum: `face`
|
||||
| | No |
|
||||
| `solid` |`object`| The solid the face is on. | No |
|
||||
| `type` |enum: `face`| | No |
|
||||
| `value` |`string`| The tag of the face. | No |
|
||||
| `xAxis` |`object`| What should the face’s X 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`
|
||||
@ -84,12 +81,11 @@ A sketch group is a collection of paths.
|
||||
| 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 |
|
||||
| `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 group. | No |
|
||||
| `value` |`array`| The paths in the sketch group. | No |
|
||||
| `tags` |`object`| Tag identifiers that have been declared in this sketch. | 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"
|
||||
excerpt: "A sketch group type."
|
||||
excerpt: "A sketch type."
|
||||
layout: manual
|
||||
---
|
||||
|
||||
A sketch group type.
|
||||
A sketch type.
|
||||
|
||||
|
||||
|
||||
@ -26,10 +26,8 @@ A plane.
|
||||
| `__meta` |`array`| | No |
|
||||
| `id` |`string` (`uuid`)| The id of the plane. | No |
|
||||
| `origin` |`object`| Origin of the plane. | No |
|
||||
| `type` |enum: `plane`
|
||||
| | No |
|
||||
| `value` |`oneOf`
|
||||
| Type for a plane. | No |
|
||||
| `type` |enum: `plane`| | No |
|
||||
| `value` |`oneOf`| Type for a plane. | No |
|
||||
| `xAxis` |`object`| What should the plane’s X axis be? | No |
|
||||
| `yAxis` |`object`| What should the plane’s Y axis be? | No |
|
||||
| `zAxis` |`object`| The z-axis (normal). | No |
|
||||
@ -49,10 +47,9 @@ A face.
|
||||
| Property | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `__meta` |`array`| | No |
|
||||
| `extrudeGroup` |`object`| The extrude group the face is on. | No |
|
||||
| `id` |`string` (`uuid`)| The id of the face. | No |
|
||||
| `type` |enum: `face`
|
||||
| | No |
|
||||
| `solid` |`object`| The solid the face is on. | No |
|
||||
| `type` |enum: `face`| | No |
|
||||
| `value` |`string`| The tag of the face. | No |
|
||||
| `xAxis` |`object`| What should the face’s X 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"
|
||||
excerpt: "A extrude group or a group of extrude groups."
|
||||
title: "SolidSet"
|
||||
excerpt: "A solid or a group of solids."
|
||||
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:**
|
||||
|
||||
An extrude group is a collection of extrude surfaces.
|
||||
An solid is a collection of extrude surfaces.
|
||||
|
||||
|
||||
**Type:** `object`
|
||||
@ -24,14 +24,13 @@ An extrude group is a collection of extrude surfaces.
|
||||
| Property | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `__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 |
|
||||
| `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 |
|
||||
| `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 |
|
||||
| `type` |enum: `extrudeGroup`
|
||||
| | No |
|
||||
| `type` |enum: `solid`| | No |
|
||||
| `value` |`array`| The extrude surfaces. | No |
|
||||
|
||||
|
||||
@ -47,8 +46,7 @@ An extrude group is a collection of extrude surfaces.
|
||||
|
||||
| Property | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `type` |enum: `extrudeGroups`
|
||||
| | No |
|
||||
| `type` |enum: `solids`| | 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.
|
||||
|
||||
```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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `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 |
|
||||
|
||||
### 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
|
||||
|
@ -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)
|
||||
|
||||
```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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `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 |
|
||||
|
||||
### 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
|
||||
|
@ -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.
|
||||
|
||||
```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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `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 |
|
||||
|
||||
### 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
|
||||
|
@ -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)
|
||||
|
||||
```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 |
|
||||
|----------|------|-------------|----------|
|
||||
| `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 |
|
||||
|
||||
### 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
|
||||
|
@ -40,7 +40,7 @@ export const isErrorWhitelisted = (exception: Error) => {
|
||||
},
|
||||
{
|
||||
name: '',
|
||||
message: 'sketchGroup not found',
|
||||
message: 'sketch not found',
|
||||
stack: '',
|
||||
foundInSpec:
|
||||
'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',
|
||||
message: 'sketchGroup not found',
|
||||
stack: `Unhandled Promise Rejection: sketchGroup not found
|
||||
message: 'sketch not found',
|
||||
stack: `Unhandled Promise Rejection: sketch not found
|
||||
at unknown (http://localhost:3000/src/machines/modelingMachine.ts:911:49)`,
|
||||
foundInSpec:
|
||||
'e2e/playwright/testing-selections.spec.ts Deselecting line tool should mean nothing happens on click',
|
||||
|
@ -1199,7 +1199,7 @@ test(
|
||||
'kittycad_svg.kcl',
|
||||
'lego.kcl',
|
||||
'math.kcl',
|
||||
'member_expression_sketch_group.kcl',
|
||||
'member_expression_sketch.kcl',
|
||||
'mike_stress_test.kcl',
|
||||
'negative_args.kcl',
|
||||
'order-sketch-extrude-in-order.kcl',
|
||||
|
@ -39,11 +39,11 @@ import {
|
||||
Program,
|
||||
ProgramMemory,
|
||||
recast,
|
||||
SketchGroup,
|
||||
ExtrudeGroup,
|
||||
Sketch,
|
||||
Solid,
|
||||
VariableDeclaration,
|
||||
VariableDeclarator,
|
||||
sketchGroupFromKclValue,
|
||||
sketchFromKclValue,
|
||||
} from 'lang/wasm'
|
||||
import {
|
||||
engineCommandManager,
|
||||
@ -378,7 +378,7 @@ export class SceneEntities {
|
||||
}): Promise<{
|
||||
truncatedAst: Program
|
||||
programMemoryOverride: ProgramMemory
|
||||
sketchGroup: SketchGroup
|
||||
sketch: Sketch
|
||||
variableDeclarationName: string
|
||||
}> {
|
||||
this.createIntersectionPlane()
|
||||
@ -397,19 +397,19 @@ export class SceneEntities {
|
||||
engineCommandManager: this.engineCommandManager,
|
||||
programMemoryOverride,
|
||||
})
|
||||
const sketchGroup = sketchGroupFromPathToNode({
|
||||
const sketch = sketchFromPathToNode({
|
||||
pathToNode: sketchPathToNode,
|
||||
ast: maybeModdedAst,
|
||||
programMemory,
|
||||
})
|
||||
if (err(sketchGroup)) return Promise.reject(sketchGroup)
|
||||
if (!sketchGroup) return Promise.reject('sketchGroup not found')
|
||||
if (err(sketch)) return Promise.reject(sketch)
|
||||
if (!sketch) return Promise.reject('sketch not found')
|
||||
|
||||
if (!isArray(sketchGroup?.value))
|
||||
if (!isArray(sketch?.value))
|
||||
return {
|
||||
truncatedAst,
|
||||
programMemoryOverride,
|
||||
sketchGroup,
|
||||
sketch,
|
||||
variableDeclarationName,
|
||||
}
|
||||
this.sceneProgramMemory = programMemory
|
||||
@ -431,12 +431,12 @@ export class SceneEntities {
|
||||
|
||||
const segPathToNode = getNodePathFromSourceRange(
|
||||
maybeModdedAst,
|
||||
sketchGroup.start.__geoMeta.sourceRange
|
||||
sketch.start.__geoMeta.sourceRange
|
||||
)
|
||||
if (sketchGroup?.value?.[0]?.type !== 'Circle') {
|
||||
if (sketch?.value?.[0]?.type !== 'Circle') {
|
||||
const _profileStart = createProfileStartHandle({
|
||||
from: sketchGroup.start.from,
|
||||
id: sketchGroup.start.__geoMeta.id,
|
||||
from: sketch.start.from,
|
||||
id: sketch.start.__geoMeta.id,
|
||||
pathToNode: segPathToNode,
|
||||
scale: factor,
|
||||
theme: sceneInfra._theme,
|
||||
@ -449,17 +449,16 @@ export class SceneEntities {
|
||||
this.activeSegments[JSON.stringify(segPathToNode)] = _profileStart
|
||||
}
|
||||
const callbacks: (() => SegmentOverlayPayload | null)[] = []
|
||||
sketchGroup.value.forEach((segment, index) => {
|
||||
sketch.value.forEach((segment, index) => {
|
||||
let segPathToNode = getNodePathFromSourceRange(
|
||||
maybeModdedAst,
|
||||
segment.__geoMeta.sourceRange
|
||||
)
|
||||
if (
|
||||
draftExpressionsIndices &&
|
||||
(sketchGroup.value[index - 1] || sketchGroup.start)
|
||||
(sketch.value[index - 1] || sketch.start)
|
||||
) {
|
||||
const previousSegment =
|
||||
sketchGroup.value[index - 1] || sketchGroup.start
|
||||
const previousSegment = sketch.value[index - 1] || sketch.start
|
||||
const previousSegmentPathToNode = getNodePathFromSourceRange(
|
||||
maybeModdedAst,
|
||||
previousSegment.__geoMeta.sourceRange
|
||||
@ -510,7 +509,7 @@ export class SceneEntities {
|
||||
to: segment.to,
|
||||
}
|
||||
const result = initSegment({
|
||||
prevSegment: sketchGroup.value[index - 1],
|
||||
prevSegment: sketch.value[index - 1],
|
||||
callExpName,
|
||||
input,
|
||||
id: segment.__geoMeta.id,
|
||||
@ -554,7 +553,7 @@ export class SceneEntities {
|
||||
return {
|
||||
truncatedAst,
|
||||
programMemoryOverride,
|
||||
sketchGroup,
|
||||
sketch,
|
||||
variableDeclarationName,
|
||||
}
|
||||
}
|
||||
@ -604,7 +603,7 @@ export class SceneEntities {
|
||||
const variableDeclarationName =
|
||||
_node1.node?.declarations?.[0]?.id?.name || ''
|
||||
|
||||
const sg = sketchGroupFromKclValue(
|
||||
const sg = sketchFromKclValue(
|
||||
kclManager.programMemory.get(variableDeclarationName),
|
||||
variableDeclarationName
|
||||
)
|
||||
@ -632,7 +631,7 @@ export class SceneEntities {
|
||||
if (shouldTearDown) await this.tearDownSketch({ removeAxis: false })
|
||||
sceneInfra.resetMouseListeners()
|
||||
|
||||
const { truncatedAst, programMemoryOverride, sketchGroup } =
|
||||
const { truncatedAst, programMemoryOverride, sketch } =
|
||||
await this.setupSketch({
|
||||
sketchPathToNode,
|
||||
forward,
|
||||
@ -653,7 +652,7 @@ export class SceneEntities {
|
||||
|
||||
let modifiedAst
|
||||
if (profileStart) {
|
||||
const lastSegment = sketchGroup.value.slice(-1)[0]
|
||||
const lastSegment = sketch.value.slice(-1)[0]
|
||||
modifiedAst = addCallExpressionsToPipe({
|
||||
node: kclManager.ast,
|
||||
programMemory: kclManager.programMemory,
|
||||
@ -685,7 +684,7 @@ export class SceneEntities {
|
||||
})
|
||||
if (trap(modifiedAst)) return Promise.reject(modifiedAst)
|
||||
} else if (intersection2d) {
|
||||
const lastSegment = sketchGroup.value.slice(-1)[0]
|
||||
const lastSegment = sketch.value.slice(-1)[0]
|
||||
const tmp = addNewSketchLn({
|
||||
node: kclManager.ast,
|
||||
programMemory: kclManager.programMemory,
|
||||
@ -809,24 +808,17 @@ export class SceneEntities {
|
||||
programMemoryOverride,
|
||||
})
|
||||
this.sceneProgramMemory = programMemory
|
||||
const sketchGroup = sketchGroupFromKclValue(
|
||||
const sketch = sketchFromKclValue(
|
||||
programMemory.get(variableDeclarationName),
|
||||
variableDeclarationName
|
||||
)
|
||||
if (err(sketchGroup)) return Promise.reject(sketchGroup)
|
||||
const sgPaths = sketchGroup.value
|
||||
if (err(sketch)) return Promise.reject(sketch)
|
||||
const sgPaths = sketch.value
|
||||
const orthoFactor = orthoScale(sceneInfra.camControls.camera)
|
||||
|
||||
this.updateSegment(
|
||||
sketchGroup.start,
|
||||
0,
|
||||
0,
|
||||
_ast,
|
||||
orthoFactor,
|
||||
sketchGroup
|
||||
)
|
||||
this.updateSegment(sketch.start, 0, 0, _ast, orthoFactor, sketch)
|
||||
sgPaths.forEach((seg, index) =>
|
||||
this.updateSegment(seg, index, 0, _ast, orthoFactor, sketchGroup)
|
||||
this.updateSegment(seg, index, 0, _ast, orthoFactor, sketch)
|
||||
)
|
||||
},
|
||||
onClick: async (args) => {
|
||||
@ -865,26 +857,19 @@ export class SceneEntities {
|
||||
|
||||
// Prepare to update the THREEjs scene
|
||||
this.sceneProgramMemory = programMemory
|
||||
const sketchGroup = sketchGroupFromKclValue(
|
||||
const sketch = sketchFromKclValue(
|
||||
programMemory.get(variableDeclarationName),
|
||||
variableDeclarationName
|
||||
)
|
||||
if (err(sketchGroup)) return
|
||||
const sgPaths = sketchGroup.value
|
||||
if (err(sketch)) return
|
||||
const sgPaths = sketch.value
|
||||
const orthoFactor = orthoScale(sceneInfra.camControls.camera)
|
||||
|
||||
// Update the starting segment of the THREEjs scene
|
||||
this.updateSegment(
|
||||
sketchGroup.start,
|
||||
0,
|
||||
0,
|
||||
_ast,
|
||||
orthoFactor,
|
||||
sketchGroup
|
||||
)
|
||||
this.updateSegment(sketch.start, 0, 0, _ast, orthoFactor, sketch)
|
||||
// Update the rest of the segments of the THREEjs scene
|
||||
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,
|
||||
})
|
||||
this.sceneProgramMemory = programMemory
|
||||
const sketchGroup = sketchGroupFromKclValue(
|
||||
const sketch = sketchFromKclValue(
|
||||
programMemory.get(variableDeclarationName),
|
||||
variableDeclarationName
|
||||
)
|
||||
if (err(sketchGroup)) return
|
||||
const sgPaths = sketchGroup.value
|
||||
if (err(sketch)) return
|
||||
const sgPaths = sketch.value
|
||||
const orthoFactor = orthoScale(sceneInfra.camControls.camera)
|
||||
|
||||
this.updateSegment(
|
||||
sketchGroup.start,
|
||||
0,
|
||||
0,
|
||||
_ast,
|
||||
orthoFactor,
|
||||
sketchGroup
|
||||
)
|
||||
this.updateSegment(sketch.start, 0, 0, _ast, orthoFactor, sketch)
|
||||
sgPaths.forEach((seg, index) =>
|
||||
this.updateSegment(seg, index, 0, _ast, orthoFactor, sketchGroup)
|
||||
this.updateSegment(seg, index, 0, _ast, orthoFactor, sketch)
|
||||
)
|
||||
},
|
||||
onClick: async (args) => {
|
||||
@ -1106,20 +1084,20 @@ export class SceneEntities {
|
||||
(x) => x[1] === 'PipeExpression'
|
||||
)
|
||||
|
||||
const sketchGroup = sketchGroupFromPathToNode({
|
||||
const sketch = sketchFromPathToNode({
|
||||
pathToNode,
|
||||
ast: kclManager.ast,
|
||||
programMemory: kclManager.programMemory,
|
||||
})
|
||||
if (trap(sketchGroup)) return
|
||||
if (!sketchGroup) {
|
||||
trap(new Error('sketchGroup not found'))
|
||||
if (trap(sketch)) return
|
||||
if (!sketch) {
|
||||
trap(new Error('sketch not found'))
|
||||
return
|
||||
}
|
||||
|
||||
const pipeIndex = pathToNode[pathToNodeIndex + 1][0] as number
|
||||
if (addingNewSegmentStatus === 'nothing') {
|
||||
const prevSegment = sketchGroup.value[pipeIndex - 2]
|
||||
const prevSegment = sketch.value[pipeIndex - 2]
|
||||
const mod = addNewSketchLn({
|
||||
node: kclManager.ast,
|
||||
programMemory: kclManager.programMemory,
|
||||
@ -1347,29 +1325,26 @@ export class SceneEntities {
|
||||
})
|
||||
this.sceneProgramMemory = programMemory
|
||||
|
||||
const maybeSketchGroup = programMemory.get(variableDeclarationName)
|
||||
let sketchGroup = undefined
|
||||
const sg = sketchGroupFromKclValue(
|
||||
maybeSketchGroup,
|
||||
variableDeclarationName
|
||||
)
|
||||
const maybeSketch = programMemory.get(variableDeclarationName)
|
||||
let sketch = undefined
|
||||
const sg = sketchFromKclValue(maybeSketch, variableDeclarationName)
|
||||
if (!err(sg)) {
|
||||
sketchGroup = sg
|
||||
} else if ((maybeSketchGroup as ExtrudeGroup).sketchGroup) {
|
||||
sketchGroup = (maybeSketchGroup as ExtrudeGroup).sketchGroup
|
||||
sketch = sg
|
||||
} else if ((maybeSketch as Solid).sketch) {
|
||||
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)
|
||||
|
||||
this.updateSegment(
|
||||
sketchGroup.start,
|
||||
sketch.start,
|
||||
0,
|
||||
varDecIndex,
|
||||
modifiedAst,
|
||||
orthoFactor,
|
||||
sketchGroup
|
||||
sketch
|
||||
)
|
||||
|
||||
const callBacks = sgPaths.map((group, index) =>
|
||||
@ -1379,7 +1354,7 @@ export class SceneEntities {
|
||||
varDecIndex,
|
||||
modifiedAst,
|
||||
orthoFactor,
|
||||
sketchGroup
|
||||
sketch
|
||||
)
|
||||
)
|
||||
sceneInfra.overlayCallbacks(callBacks)
|
||||
@ -1394,29 +1369,29 @@ export class SceneEntities {
|
||||
* @param varDecIndex
|
||||
* @param modifiedAst
|
||||
* @param orthoFactor
|
||||
* @param sketchGroup
|
||||
* @param sketch
|
||||
*/
|
||||
updateSegment = (
|
||||
segment: Path | SketchGroup['start'],
|
||||
segment: Path | Sketch['start'],
|
||||
index: number,
|
||||
varDecIndex: number,
|
||||
modifiedAst: Program,
|
||||
orthoFactor: number,
|
||||
sketchGroup: SketchGroup
|
||||
sketch: Sketch
|
||||
): (() => SegmentOverlayPayload | null) => {
|
||||
const segPathToNode = getNodePathFromSourceRange(
|
||||
modifiedAst,
|
||||
segment.__geoMeta.sourceRange
|
||||
)
|
||||
const sgPaths = sketchGroup.value
|
||||
const sgPaths = sketch.value
|
||||
const originalPathToNodeStr = JSON.stringify(segPathToNode)
|
||||
segPathToNode[1][0] = varDecIndex
|
||||
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 =
|
||||
this.activeSegments[pathToNodeStr] ||
|
||||
this.activeSegments[originalPathToNodeStr]
|
||||
// const prevSegment = sketchGroup.slice(index - 1)[0]
|
||||
// const prevSegment = sketch.slice(index - 1)[0]
|
||||
const type = group?.userData?.type
|
||||
const factor =
|
||||
(sceneInfra.camControls.camera instanceof OrthographicCamera
|
||||
@ -1711,7 +1686,7 @@ function prepareTruncatedMemoryAndAst(
|
||||
)
|
||||
if (err(_node)) return _node
|
||||
const variableDeclarationName = _node.node?.declarations?.[0]?.id?.name || ''
|
||||
const sg = sketchGroupFromKclValue(
|
||||
const sg = sketchFromKclValue(
|
||||
programMemory.get(variableDeclarationName),
|
||||
variableDeclarationName
|
||||
)
|
||||
@ -1739,7 +1714,7 @@ function prepareTruncatedMemoryAndAst(
|
||||
.init as PipeExpression
|
||||
).body.push(newSegment)
|
||||
// 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
|
||||
if (err(updatedSrcRangeAst)) return updatedSrcRangeAst
|
||||
|
||||
@ -1820,7 +1795,7 @@ export function getParentGroup(
|
||||
return null
|
||||
}
|
||||
|
||||
export function sketchGroupFromPathToNode({
|
||||
export function sketchFromPathToNode({
|
||||
pathToNode,
|
||||
ast,
|
||||
programMemory,
|
||||
@ -1828,7 +1803,7 @@ export function sketchGroupFromPathToNode({
|
||||
pathToNode: PathToNode
|
||||
ast: Program
|
||||
programMemory: ProgramMemory
|
||||
}): SketchGroup | null | Error {
|
||||
}): Sketch | null | Error {
|
||||
const _varDec = getNodeFromPath<VariableDeclarator>(
|
||||
kclManager.ast,
|
||||
pathToNode,
|
||||
@ -1837,10 +1812,10 @@ export function sketchGroupFromPathToNode({
|
||||
if (err(_varDec)) return _varDec
|
||||
const varDec = _varDec.node
|
||||
const result = programMemory.get(varDec?.id?.name || '')
|
||||
if (result?.type === 'ExtrudeGroup') {
|
||||
return result.sketchGroup
|
||||
if (result?.type === 'Solid') {
|
||||
return result.sketch
|
||||
}
|
||||
const sg = sketchGroupFromKclValue(result, varDec?.id?.name)
|
||||
const sg = sketchFromKclValue(result, varDec?.id?.name)
|
||||
if (err(sg)) {
|
||||
return null
|
||||
}
|
||||
@ -1872,14 +1847,14 @@ export function getSketchQuaternion(
|
||||
sketchPathToNode: PathToNode,
|
||||
sketchNormalBackUp: [number, number, number] | null
|
||||
): Quaternion | Error {
|
||||
const sketchGroup = sketchGroupFromPathToNode({
|
||||
const sketch = sketchFromPathToNode({
|
||||
pathToNode: sketchPathToNode,
|
||||
ast: kclManager.ast,
|
||||
programMemory: kclManager.programMemory,
|
||||
})
|
||||
if (err(sketchGroup)) return sketchGroup
|
||||
const zAxis = sketchGroup?.on.zAxis || sketchNormalBackUp
|
||||
if (!zAxis) return Error('SketchGroup zAxis not found')
|
||||
if (err(sketch)) return sketch
|
||||
const zAxis = sketch?.on.zAxis || sketchNormalBackUp
|
||||
if (!zAxis) return Error('Sketch zAxis not found')
|
||||
|
||||
return getQuaternionFromZAxis(massageFormats(zAxis))
|
||||
}
|
||||
@ -1889,34 +1864,30 @@ export async function getSketchOrientationDetails(
|
||||
quat: Quaternion
|
||||
sketchDetails: SketchDetails & { faceId?: string }
|
||||
}> {
|
||||
const sketchGroup = sketchGroupFromPathToNode({
|
||||
const sketch = sketchFromPathToNode({
|
||||
pathToNode: sketchPathToNode,
|
||||
ast: kclManager.ast,
|
||||
programMemory: kclManager.programMemory,
|
||||
})
|
||||
if (err(sketchGroup)) return Promise.reject(sketchGroup)
|
||||
if (!sketchGroup) return Promise.reject('sketchGroup not found')
|
||||
if (err(sketch)) return Promise.reject(sketch)
|
||||
if (!sketch) return Promise.reject('sketch not found')
|
||||
|
||||
if (sketchGroup.on.type === 'plane') {
|
||||
const zAxis = sketchGroup?.on.zAxis
|
||||
if (sketch.on.type === 'plane') {
|
||||
const zAxis = sketch?.on.zAxis
|
||||
return {
|
||||
quat: getQuaternionFromZAxis(massageFormats(zAxis)),
|
||||
sketchDetails: {
|
||||
sketchPathToNode,
|
||||
zAxis: [zAxis.x, zAxis.y, zAxis.z],
|
||||
yAxis: [
|
||||
sketchGroup.on.yAxis.x,
|
||||
sketchGroup.on.yAxis.y,
|
||||
sketchGroup.on.yAxis.z,
|
||||
],
|
||||
yAxis: [sketch.on.yAxis.x, sketch.on.yAxis.y, sketch.on.yAxis.z],
|
||||
origin: [0, 0, 0],
|
||||
faceId: sketchGroup.on.id,
|
||||
faceId: sketch.on.id,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
if (sketchGroup.on.type === 'face') {
|
||||
const faceInfo = await getFaceDetails(sketchGroup.on.id)
|
||||
if (sketch.on.type === 'face') {
|
||||
const faceInfo = await getFaceDetails(sketch.on.id)
|
||||
|
||||
if (!faceInfo?.origin || !faceInfo?.z_axis || !faceInfo?.y_axis)
|
||||
return Promise.reject('face info')
|
||||
@ -1932,12 +1903,12 @@ export async function getSketchOrientationDetails(
|
||||
zAxis: [z_axis.x, z_axis.y, z_axis.z],
|
||||
yAxis: [y_axis.x, y_axis.y, y_axis.z],
|
||||
origin: [origin.x, origin.y, origin.z],
|
||||
faceId: sketchGroup.on.id,
|
||||
faceId: sketch.on.id,
|
||||
},
|
||||
}
|
||||
}
|
||||
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'
|
||||
import { mergeGeometries } from 'three/examples/jsm/utils/BufferGeometryUtils.js'
|
||||
import { CSS2DObject } from 'three/examples/jsm/renderers/CSS2DRenderer'
|
||||
import { PathToNode, SketchGroup, getTangentialArcToInfo } from 'lang/wasm'
|
||||
import { PathToNode, Sketch, getTangentialArcToInfo } from 'lang/wasm'
|
||||
import {
|
||||
CIRCLE_CENTER_HANDLE,
|
||||
CIRCLE_SEGMENT,
|
||||
@ -58,7 +58,7 @@ import { err } from 'lib/trap'
|
||||
|
||||
interface CreateSegmentArgs {
|
||||
input: SegmentInputs
|
||||
prevSegment: SketchGroup['value'][number]
|
||||
prevSegment: Sketch['value'][number]
|
||||
id: string
|
||||
pathToNode: PathToNode
|
||||
isDraftSegment?: boolean
|
||||
@ -72,7 +72,7 @@ interface CreateSegmentArgs {
|
||||
|
||||
interface UpdateSegmentArgs {
|
||||
input: SegmentInputs
|
||||
prevSegment: SketchGroup['value'][number]
|
||||
prevSegment: Sketch['value'][number]
|
||||
group: Group
|
||||
sceneInfra: SceneInfra
|
||||
scale?: number
|
||||
|
@ -5,7 +5,7 @@ import {
|
||||
ProgramMemory,
|
||||
Path,
|
||||
ExtrudeSurface,
|
||||
sketchGroupFromKclValue,
|
||||
sketchFromKclValue,
|
||||
} from 'lang/wasm'
|
||||
import { useKclContext } from 'lang/KclProvider'
|
||||
import { useResolvedTheme } from 'hooks/useResolvedTheme'
|
||||
@ -89,8 +89,8 @@ export const processMemory = (programMemory: ProgramMemory) => {
|
||||
const processedMemory: any = {}
|
||||
for (const [key, val] of programMemory?.visibleEntries()) {
|
||||
if (typeof val.value !== 'function') {
|
||||
const sg = sketchGroupFromKclValue(val, null)
|
||||
if (val.type === 'ExtrudeGroup') {
|
||||
const sg = sketchFromKclValue(val, null)
|
||||
if (val.type === 'Solid') {
|
||||
processedMemory[key] = val.value.map(({ ...rest }: ExtrudeSurface) => {
|
||||
return rest
|
||||
})
|
||||
|
@ -57,7 +57,7 @@ ArgumentList { "(" commaSep<expression> ")" }
|
||||
type[@isGroup=Type] {
|
||||
@specialize[@name=PrimitiveType]<
|
||||
identifier,
|
||||
"string" | "number" | "bool" | "sketch_group" | "sketch_surface" | "extrude_group"
|
||||
"string" | "number" | "bool" | "sketch" | "sketch_surface" | "solid"
|
||||
> |
|
||||
ArrayType { type !member "[" "]" } |
|
||||
ObjectType { "{" commaSep<ObjectProperty { PropertyName ":" type }> "}" }
|
||||
|
@ -552,7 +552,7 @@ function defaultSelectionFilter(
|
||||
engineCommandManager: EngineCommandManager
|
||||
) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
programMemory.hasSketchOrExtrudeGroup() &&
|
||||
programMemory.hasSketchOrSolid() &&
|
||||
engineCommandManager.sendSceneCommand({
|
||||
type: 'modeling_cmd_req',
|
||||
cmd_id: uuidv4(),
|
||||
|
@ -21,7 +21,7 @@ const mySketch001 = startSketchOn('XY')
|
||||
type: 'UserVal',
|
||||
__meta: [{ sourceRange: [46, 71] }],
|
||||
value: {
|
||||
type: 'SketchGroup',
|
||||
type: 'Sketch',
|
||||
on: expect.any(Object),
|
||||
start: {
|
||||
to: [0, 0],
|
||||
@ -72,7 +72,7 @@ const mySketch001 = startSketchOn('XY')
|
||||
// @ts-ignore
|
||||
const sketch001 = programMemory?.get('mySketch001')
|
||||
expect(sketch001).toEqual({
|
||||
type: 'ExtrudeGroup',
|
||||
type: 'Solid',
|
||||
id: expect.any(String),
|
||||
value: [
|
||||
{
|
||||
@ -90,12 +90,12 @@ const mySketch001 = startSketchOn('XY')
|
||||
sourceRange: [108, 132],
|
||||
},
|
||||
],
|
||||
sketchGroup: {
|
||||
sketch: {
|
||||
id: expect.any(String),
|
||||
__meta: expect.any(Array),
|
||||
on: expect.any(Object),
|
||||
start: expect.any(Object),
|
||||
type: 'SketchGroup',
|
||||
type: 'Sketch',
|
||||
value: [
|
||||
{
|
||||
type: 'ToPoint',
|
||||
@ -153,7 +153,7 @@ const sk2 = startSketchOn('XY')
|
||||
const geos = [programMemory?.get('theExtrude'), programMemory?.get('sk2')]
|
||||
expect(geos).toEqual([
|
||||
{
|
||||
type: 'ExtrudeGroup',
|
||||
type: 'Solid',
|
||||
id: expect.any(String),
|
||||
value: [
|
||||
{
|
||||
@ -184,12 +184,12 @@ const sk2 = startSketchOn('XY')
|
||||
sourceRange: [123, 142],
|
||||
},
|
||||
],
|
||||
sketchGroup: {
|
||||
sketch: {
|
||||
id: expect.any(String),
|
||||
__meta: expect.any(Array),
|
||||
on: expect.any(Object),
|
||||
start: expect.any(Object),
|
||||
type: 'SketchGroup',
|
||||
type: 'Sketch',
|
||||
tags: {
|
||||
p: {
|
||||
__meta: [
|
||||
@ -247,7 +247,7 @@ const sk2 = startSketchOn('XY')
|
||||
__meta: [{ sourceRange: [38, 63] }],
|
||||
},
|
||||
{
|
||||
type: 'ExtrudeGroup',
|
||||
type: 'Solid',
|
||||
id: expect.any(String),
|
||||
value: [
|
||||
{
|
||||
@ -278,12 +278,12 @@ const sk2 = startSketchOn('XY')
|
||||
sourceRange: [426, 445],
|
||||
},
|
||||
],
|
||||
sketchGroup: {
|
||||
sketch: {
|
||||
id: expect.any(String),
|
||||
__meta: expect.any(Array),
|
||||
on: expect.any(Object),
|
||||
start: expect.any(Object),
|
||||
type: 'SketchGroup',
|
||||
type: 'Sketch',
|
||||
tags: {
|
||||
o: {
|
||||
__meta: [
|
||||
|
@ -3,9 +3,9 @@ import fs from 'node:fs'
|
||||
import {
|
||||
parse,
|
||||
ProgramMemory,
|
||||
SketchGroup,
|
||||
Sketch,
|
||||
initPromise,
|
||||
sketchGroupFromKclValue,
|
||||
sketchFromKclValue,
|
||||
} from './wasm'
|
||||
import { enginelessExecutor } from '../lib/testHelpers'
|
||||
import { KCLError } from './errors'
|
||||
@ -125,12 +125,12 @@ const newVar = myVar + 1`
|
||||
// ].join('\n')
|
||||
// const mem = await exe(code)
|
||||
// expect(mem.get('mySk1')?.value).toHaveLength(3)
|
||||
// expect(mem.get('rotated')?.type).toBe('SketchGroup')
|
||||
// expect(mem.get('rotated')?.type).toBe('Sketch')
|
||||
// if (
|
||||
// mem.get('mySk1')?.type !== 'SketchGroup' ||
|
||||
// mem.get('rotated')?.type !== 'SketchGroup'
|
||||
// mem.get('mySk1')?.type !== 'Sketch' ||
|
||||
// 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('rotated')?.rotation.map((a) => a.toFixed(4))).toEqual([
|
||||
// '0.7071',
|
||||
@ -154,7 +154,7 @@ const newVar = myVar + 1`
|
||||
expect(mem.get('mySk1')).toEqual({
|
||||
type: 'UserVal',
|
||||
value: {
|
||||
type: 'SketchGroup',
|
||||
type: 'Sketch',
|
||||
on: expect.any(Object),
|
||||
start: {
|
||||
to: [0, 0],
|
||||
@ -368,9 +368,9 @@ describe('testing math operators', () => {
|
||||
'|> line([-2.21, -legLen(5, min(3, 999))], %)',
|
||||
].join('\n')
|
||||
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
|
||||
const yVal = (sketch as SketchGroup).value?.[0]?.to?.[1]
|
||||
const yVal = (sketch as Sketch).value?.[0]?.to?.[1]
|
||||
expect(yVal).toBe(-4)
|
||||
})
|
||||
it('test that % substitution feeds down CallExp->ArrExp->UnaryExp->CallExp', async () => {
|
||||
@ -386,24 +386,22 @@ describe('testing math operators', () => {
|
||||
``,
|
||||
].join('\n')
|
||||
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((sketch as SketchGroup).value?.[1]?.from).toEqual([3, 4])
|
||||
expect((sketch as SketchGroup).value?.[1]?.to).toEqual([6, 0])
|
||||
expect((sketch as Sketch).value?.[1]?.from).toEqual([3, 4])
|
||||
expect((sketch as Sketch).value?.[1]?.to).toEqual([6, 0])
|
||||
const removedUnaryExp = code.replace(
|
||||
`-legLen(segLen(seg01), myVar)`,
|
||||
`legLen(segLen(seg01), myVar)`
|
||||
)
|
||||
const removedUnaryExpMem = await exe(removedUnaryExp)
|
||||
const removedUnaryExpMemSketch = sketchGroupFromKclValue(
|
||||
const removedUnaryExpMemSketch = sketchFromKclValue(
|
||||
removedUnaryExpMem.get('part001'),
|
||||
'part001'
|
||||
)
|
||||
|
||||
// without the minus sign, the y value should be 8
|
||||
expect((removedUnaryExpMemSketch as SketchGroup).value?.[1]?.to).toEqual([
|
||||
6, 8,
|
||||
])
|
||||
expect((removedUnaryExpMemSketch as Sketch).value?.[1]?.to).toEqual([6, 8])
|
||||
})
|
||||
it('with nested callExpression and binaryExpression', async () => {
|
||||
const code = 'const myVar = 2 + min(100, -1 + legLen(5, 3))'
|
||||
|
@ -17,7 +17,7 @@ import {
|
||||
PathToNode,
|
||||
ProgramMemory,
|
||||
SourceRange,
|
||||
sketchGroupFromKclValue,
|
||||
sketchFromKclValue,
|
||||
} from './wasm'
|
||||
import {
|
||||
isNodeSafeToReplacePath,
|
||||
@ -1049,7 +1049,7 @@ export async function deleteFromSelection(
|
||||
if (err(parent)) {
|
||||
return
|
||||
}
|
||||
const sketchToPreserve = sketchGroupFromKclValue(
|
||||
const sketchToPreserve = sketchFromKclValue(
|
||||
programMemory.get(sketchName),
|
||||
sketchName
|
||||
)
|
||||
|
@ -8,7 +8,7 @@ import {
|
||||
Expr,
|
||||
VariableDeclaration,
|
||||
VariableDeclarator,
|
||||
sketchGroupFromKclValue,
|
||||
sketchFromKclValue,
|
||||
} from '../wasm'
|
||||
import {
|
||||
createCallExpressionStdLib,
|
||||
@ -147,13 +147,13 @@ export function getPathToExtrudeForSegmentSelection(
|
||||
if (err(varDecNode)) return varDecNode
|
||||
const sketchVar = varDecNode.node.declarations[0].id.name
|
||||
|
||||
const sketchGroup = sketchGroupFromKclValue(
|
||||
const sketch = sketchFromKclValue(
|
||||
kclManager.programMemory.get(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
|
||||
|
||||
const pathToExtrudeNode = getNodePathFromSourceRange(
|
||||
|
@ -5,7 +5,7 @@ import {
|
||||
isTypeInValue,
|
||||
getNodePathFromSourceRange,
|
||||
doesPipeHaveCallExp,
|
||||
hasExtrudeSketchGroup,
|
||||
hasExtrudeSketch,
|
||||
findUsesOfTagInPipe,
|
||||
hasSketchPipeBeenExtruded,
|
||||
doesSceneHaveSweepableSketch,
|
||||
@ -340,8 +340,8 @@ const part001 = startSketchAt([-1.41, 3.46])
|
||||
})
|
||||
})
|
||||
|
||||
describe('testing hasExtrudeSketchGroup', () => {
|
||||
it('find sketch group', async () => {
|
||||
describe('testing hasExtrudeSketch', () => {
|
||||
it('find sketch', async () => {
|
||||
const exampleCode = `const length001 = 2
|
||||
const part001 = startSketchAt([-1.41, 3.46])
|
||||
|> line([19.49, 1.16], %, $seg01)
|
||||
@ -352,14 +352,14 @@ const part001 = startSketchAt([-1.41, 3.46])
|
||||
if (err(ast)) throw ast
|
||||
|
||||
const programMemory = await enginelessExecutor(ast)
|
||||
const result = hasExtrudeSketchGroup({
|
||||
const result = hasExtrudeSketch({
|
||||
ast,
|
||||
selection: { type: 'default', range: [100, 101] },
|
||||
programMemory,
|
||||
})
|
||||
expect(result).toEqual(true)
|
||||
})
|
||||
it('find extrude group', async () => {
|
||||
it('find solid', async () => {
|
||||
const exampleCode = `const length001 = 2
|
||||
const part001 = startSketchAt([-1.41, 3.46])
|
||||
|> line([19.49, 1.16], %, $seg01)
|
||||
@ -371,7 +371,7 @@ const part001 = startSketchAt([-1.41, 3.46])
|
||||
if (err(ast)) throw ast
|
||||
|
||||
const programMemory = await enginelessExecutor(ast)
|
||||
const result = hasExtrudeSketchGroup({
|
||||
const result = hasExtrudeSketch({
|
||||
ast,
|
||||
selection: { type: 'default', range: [100, 101] },
|
||||
programMemory,
|
||||
@ -384,7 +384,7 @@ const part001 = startSketchAt([-1.41, 3.46])
|
||||
if (err(ast)) throw ast
|
||||
|
||||
const programMemory = await enginelessExecutor(ast)
|
||||
const result = hasExtrudeSketchGroup({
|
||||
const result = hasExtrudeSketch({
|
||||
ast,
|
||||
selection: { type: 'default', range: [10, 11] },
|
||||
programMemory,
|
||||
|
@ -13,7 +13,7 @@ import {
|
||||
Program,
|
||||
ProgramMemory,
|
||||
ReturnStatement,
|
||||
sketchGroupFromKclValue,
|
||||
sketchFromKclValue,
|
||||
SourceRange,
|
||||
SyntaxType,
|
||||
VariableDeclaration,
|
||||
@ -663,7 +663,7 @@ export function isLinesParallelAndConstrained(
|
||||
if (err(_varDec)) return _varDec
|
||||
const varDec = _varDec.node
|
||||
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
|
||||
const _primarySegment = getSketchSegmentFromSourceRange(
|
||||
sg,
|
||||
@ -757,7 +757,7 @@ export function doesPipeHaveCallExp({
|
||||
)
|
||||
}
|
||||
|
||||
export function hasExtrudeSketchGroup({
|
||||
export function hasExtrudeSketch({
|
||||
ast,
|
||||
selection,
|
||||
programMemory,
|
||||
@ -781,8 +781,7 @@ export function hasExtrudeSketchGroup({
|
||||
const varName = varDec.declarations[0].id.name
|
||||
const varValue = programMemory?.get(varName)
|
||||
return (
|
||||
varValue?.type === 'ExtrudeGroup' ||
|
||||
!err(sketchGroupFromKclValue(varValue, varName))
|
||||
varValue?.type === 'Solid' || !err(sketchFromKclValue(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 {
|
||||
ProgramMemory,
|
||||
Path,
|
||||
SketchGroup,
|
||||
Sketch,
|
||||
SourceRange,
|
||||
PathToNode,
|
||||
Program,
|
||||
@ -11,7 +11,7 @@ import {
|
||||
Expr,
|
||||
VariableDeclaration,
|
||||
Identifier,
|
||||
sketchGroupFromKclValue,
|
||||
sketchFromKclValue,
|
||||
} from 'lang/wasm'
|
||||
import {
|
||||
getNodeFromPath,
|
||||
@ -63,7 +63,7 @@ const ARC_SEGMENT_ERR = new Error('Invalid input, expected "arc-segment"')
|
||||
|
||||
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]
|
||||
if (!currentPath && skGroup?.start) {
|
||||
return skGroup.start.to
|
||||
@ -1216,7 +1216,7 @@ export const angledLineOfXLength: SketchLineHelper = {
|
||||
const { node: varDec } = nodeMeta2
|
||||
|
||||
const variableName = varDec.id.name
|
||||
const sketch = sketchGroupFromKclValue(
|
||||
const sketch = sketchFromKclValue(
|
||||
previousProgramMemory?.get(variableName),
|
||||
variableName
|
||||
)
|
||||
@ -1331,7 +1331,7 @@ export const angledLineOfYLength: SketchLineHelper = {
|
||||
if (err(nodeMeta2)) return nodeMeta2
|
||||
const { node: varDec } = nodeMeta2
|
||||
const variableName = varDec.id.name
|
||||
const sketch = sketchGroupFromKclValue(
|
||||
const sketch = sketchFromKclValue(
|
||||
previousProgramMemory?.get(variableName),
|
||||
variableName
|
||||
)
|
||||
@ -1699,12 +1699,12 @@ export const angledLineThatIntersects: SketchLineHelper = {
|
||||
|
||||
const { node: varDec } = nodeMeta2
|
||||
const varName = varDec.declarations[0].id.name
|
||||
const sketchGroup = sketchGroupFromKclValue(
|
||||
const sketch = sketchFromKclValue(
|
||||
previousProgramMemory.get(varName),
|
||||
varName
|
||||
)
|
||||
if (err(sketchGroup)) return sketchGroup
|
||||
const intersectPath = sketchGroup.value.find(
|
||||
if (err(sketch)) return sketch
|
||||
const intersectPath = sketch.value.find(
|
||||
({ tag }: Path) => tag && tag.value === intersectTagName
|
||||
)
|
||||
let offset = 0
|
||||
|
@ -1,10 +1,4 @@
|
||||
import {
|
||||
parse,
|
||||
SketchGroup,
|
||||
recast,
|
||||
initPromise,
|
||||
sketchGroupFromKclValue,
|
||||
} from '../wasm'
|
||||
import { parse, Sketch, recast, initPromise, sketchFromKclValue } from '../wasm'
|
||||
import {
|
||||
ConstraintType,
|
||||
getTransformInfos,
|
||||
@ -368,10 +362,10 @@ const part001 = startSketchOn('XY')
|
||||
it('normal case works', async () => {
|
||||
const programMemory = await enginelessExecutor(parse(code))
|
||||
const index = code.indexOf('// normal-segment') - 7
|
||||
const sg = sketchGroupFromKclValue(
|
||||
const sg = sketchFromKclValue(
|
||||
programMemory.get('part001'),
|
||||
'part001'
|
||||
) as SketchGroup
|
||||
) as Sketch
|
||||
const _segment = getSketchSegmentFromSourceRange(sg, [index, index])
|
||||
if (err(_segment)) throw _segment
|
||||
const { __geoMeta, ...segment } = _segment.segment
|
||||
@ -386,10 +380,7 @@ const part001 = startSketchOn('XY')
|
||||
const programMemory = await enginelessExecutor(parse(code))
|
||||
const index = code.indexOf('// segment-in-start') - 7
|
||||
const _segment = getSketchSegmentFromSourceRange(
|
||||
sketchGroupFromKclValue(
|
||||
programMemory.get('part001'),
|
||||
'part001'
|
||||
) as SketchGroup,
|
||||
sketchFromKclValue(programMemory.get('part001'), 'part001') as Sketch,
|
||||
[index, index]
|
||||
)
|
||||
if (err(_segment)) throw _segment
|
||||
|
@ -4,7 +4,7 @@ import {
|
||||
Program,
|
||||
VariableDeclarator,
|
||||
CallExpression,
|
||||
SketchGroup,
|
||||
Sketch,
|
||||
SourceRange,
|
||||
Path,
|
||||
PathToNode,
|
||||
@ -13,17 +13,17 @@ import {
|
||||
import { err } from 'lib/trap'
|
||||
|
||||
export function getSketchSegmentFromPathToNode(
|
||||
sketchGroup: SketchGroup,
|
||||
sketch: Sketch,
|
||||
ast: Program,
|
||||
pathToNode: PathToNode
|
||||
):
|
||||
| {
|
||||
segment: SketchGroup['value'][number]
|
||||
segment: Sketch['value'][number]
|
||||
index: number
|
||||
}
|
||||
| Error {
|
||||
// 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
|
||||
const nodeMeta = getNodeFromPath<Expr>(ast, pathToNode)
|
||||
if (err(nodeMeta)) return nodeMeta
|
||||
@ -32,36 +32,36 @@ export function getSketchSegmentFromPathToNode(
|
||||
if (!node || typeof node.start !== 'number' || !node.end)
|
||||
return new Error('no node found')
|
||||
const sourceRange: SourceRange = [node.start, node.end]
|
||||
return getSketchSegmentFromSourceRange(sketchGroup, sourceRange)
|
||||
return getSketchSegmentFromSourceRange(sketch, sourceRange)
|
||||
}
|
||||
export function getSketchSegmentFromSourceRange(
|
||||
sketchGroup: SketchGroup,
|
||||
sketch: Sketch,
|
||||
[rangeStart, rangeEnd]: SourceRange
|
||||
):
|
||||
| {
|
||||
segment: SketchGroup['value'][number]
|
||||
segment: Sketch['value'][number]
|
||||
index: number
|
||||
}
|
||||
| Error {
|
||||
const lineIndex = sketchGroup.value.findIndex(
|
||||
const lineIndex = sketch.value.findIndex(
|
||||
({ __geoMeta: { sourceRange } }: Path) =>
|
||||
sourceRange[0] <= rangeStart && sourceRange[1] >= rangeEnd
|
||||
)
|
||||
const line = sketchGroup.value[lineIndex]
|
||||
const line = sketch.value[lineIndex]
|
||||
if (line) {
|
||||
return {
|
||||
segment: line,
|
||||
index: lineIndex,
|
||||
}
|
||||
}
|
||||
const startSourceRange = sketchGroup.start?.__geoMeta.sourceRange
|
||||
const startSourceRange = sketch.start?.__geoMeta.sourceRange
|
||||
if (
|
||||
startSourceRange &&
|
||||
startSourceRange[0] <= rangeStart &&
|
||||
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')
|
||||
}
|
||||
|
||||
@ -103,7 +103,7 @@ export function isSketchVariablesLinked(
|
||||
!toolTips.includes(firstCallExp?.callee?.name as ToolTip)
|
||||
)
|
||||
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]
|
||||
if (!secondArg || secondArg?.type !== 'Identifier') return false
|
||||
if (secondArg.name === primaryVarDec?.id?.name) return true
|
||||
|
@ -17,7 +17,7 @@ import {
|
||||
VariableDeclarator,
|
||||
PathToNode,
|
||||
ProgramMemory,
|
||||
sketchGroupFromKclValue,
|
||||
sketchFromKclValue,
|
||||
Literal,
|
||||
} from '../wasm'
|
||||
import {
|
||||
@ -1702,33 +1702,29 @@ export function transformAstSketchLines({
|
||||
|
||||
const varName = varDec.node.id.name
|
||||
let kclVal = programMemory.get(varName)
|
||||
let sketchGroup
|
||||
if (kclVal?.type === 'ExtrudeGroup') {
|
||||
sketchGroup = kclVal.sketchGroup
|
||||
let sketch
|
||||
if (kclVal?.type === 'Solid') {
|
||||
sketch = kclVal.sketch
|
||||
} else {
|
||||
sketchGroup = sketchGroupFromKclValue(kclVal, varName)
|
||||
if (err(sketchGroup)) {
|
||||
sketch = sketchFromKclValue(kclVal, varName)
|
||||
if (err(sketch)) {
|
||||
return
|
||||
}
|
||||
}
|
||||
const segMeta = getSketchSegmentFromPathToNode(
|
||||
sketchGroup,
|
||||
ast,
|
||||
_pathToNode
|
||||
)
|
||||
const segMeta = getSketchSegmentFromPathToNode(sketch, ast, _pathToNode)
|
||||
if (err(segMeta)) return segMeta
|
||||
|
||||
const seg = segMeta.segment
|
||||
let referencedSegment
|
||||
if (referencedSegmentRange) {
|
||||
const _segment = getSketchSegmentFromSourceRange(
|
||||
sketchGroup,
|
||||
sketch,
|
||||
referencedSegmentRange
|
||||
)
|
||||
if (err(_segment)) return _segment
|
||||
referencedSegment = _segment.segment
|
||||
} else {
|
||||
referencedSegment = sketchGroup.value.find(
|
||||
referencedSegment = sketch.value.find(
|
||||
(path) => path.tag?.value === _referencedSegmentName
|
||||
)
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ const yi=45`
|
||||
lineTo(2, 3)
|
||||
} |> rx(45, %)`)
|
||||
expect(result).toEqual([
|
||||
"word 'sketch' from 0 to 6",
|
||||
"type 'sketch' from 0 to 6",
|
||||
"whitespace ' ' from 6 to 7",
|
||||
"word 'mySketch' from 7 to 15",
|
||||
"whitespace ' ' from 15 to 16",
|
||||
|
@ -36,7 +36,7 @@ import { err } from 'lib/trap'
|
||||
import { Configuration } from 'wasm-lib/kcl/bindings/Configuration'
|
||||
import { DeepPartial } from 'lib/types'
|
||||
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 { 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 { Path } from '../wasm-lib/kcl/bindings/Path'
|
||||
export type { SketchGroup } from '../wasm-lib/kcl/bindings/SketchGroup'
|
||||
export type { ExtrudeGroup } from '../wasm-lib/kcl/bindings/ExtrudeGroup'
|
||||
export type { Sketch } from '../wasm-lib/kcl/bindings/Sketch'
|
||||
export type { Solid } from '../wasm-lib/kcl/bindings/Solid'
|
||||
export type { KclValue } from '../wasm-lib/kcl/bindings/KclValue'
|
||||
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()) {
|
||||
if (node.type === 'ExtrudeGroup' || node.value?.type === 'SketchGroup') {
|
||||
if (node.type === 'Solid' || node.value?.type === 'Sketch') {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@ -332,13 +332,13 @@ export class ProgramMemory {
|
||||
}
|
||||
|
||||
// TODO: In the future, make the parameter be a KclValue.
|
||||
export function sketchGroupFromKclValue(
|
||||
export function sketchFromKclValue(
|
||||
obj: any,
|
||||
varName: string | null
|
||||
): SketchGroup | Error {
|
||||
if (obj?.value?.type === 'SketchGroup') return obj.value
|
||||
if (obj?.value?.type === 'ExtrudeGroup') return obj.value.sketchGroup
|
||||
if (obj?.type === 'ExtrudeGroup') return obj.sketchGroup
|
||||
): Sketch | Error {
|
||||
if (obj?.value?.type === 'Sketch') return obj.value
|
||||
if (obj?.value?.type === 'Solid') return obj.value.sketch
|
||||
if (obj?.type === 'Solid') return obj.sketch
|
||||
if (!varName) {
|
||||
varName = 'a KCL value'
|
||||
}
|
||||
@ -346,10 +346,10 @@ export function sketchGroupFromKclValue(
|
||||
if (actualType) {
|
||||
console.log(obj)
|
||||
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 {
|
||||
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]]
|
||||
name = "derive-docs"
|
||||
version = "0.1.28"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"Inflector",
|
||||
"anyhow",
|
||||
@ -1414,7 +1414,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kcl-lib"
|
||||
version = "0.2.19"
|
||||
version = "0.2.20"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"approx 0.5.1",
|
||||
@ -1489,7 +1489,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kcl-test-server"
|
||||
version = "0.1.11"
|
||||
version = "0.1.12"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"hyper",
|
||||
|
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "derive-docs"
|
||||
description = "A tool for generating documentation from Rust derive macros"
|
||||
version = "0.1.28"
|
||||
version = "0.1.29"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
repository = "https://github.com/KittyCAD/modeling-app"
|
||||
|
@ -132,9 +132,9 @@ fn test_stdlib_line_to() {
|
||||
/// ```
|
||||
fn inner_line_to(
|
||||
data: LineToData,
|
||||
sketch_group: SketchGroup,
|
||||
sketch: Sketch,
|
||||
args: &Args,
|
||||
) -> Result<SketchGroup, KclError> {
|
||||
) -> Result<Sketch, KclError> {
|
||||
Ok(())
|
||||
}
|
||||
},
|
||||
@ -329,7 +329,7 @@ fn test_stdlib_option_input_format() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_stdlib_return_vec_sketch_group() {
|
||||
fn test_stdlib_return_vec_sketch() {
|
||||
let (item, errors) = do_stdlib(
|
||||
quote! {
|
||||
name = "import",
|
||||
@ -344,7 +344,7 @@ fn test_stdlib_return_vec_sketch_group() {
|
||||
fn inner_import(
|
||||
/// The args to do shit to.
|
||||
args: Option<kittycad::types::InputFormat>
|
||||
) -> Result<Vec<SketchGroup>> {
|
||||
) -> Result<Vec<Sketch>> {
|
||||
args
|
||||
}
|
||||
},
|
||||
@ -352,11 +352,11 @@ fn test_stdlib_return_vec_sketch_group() {
|
||||
.unwrap();
|
||||
|
||||
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]
|
||||
fn test_stdlib_return_vec_box_sketch_group() {
|
||||
fn test_stdlib_return_vec_box_sketch() {
|
||||
let (item, errors) = do_stdlib(
|
||||
quote! {
|
||||
name = "import",
|
||||
@ -371,7 +371,7 @@ fn test_stdlib_return_vec_box_sketch_group() {
|
||||
fn inner_import(
|
||||
/// The args to do shit to.
|
||||
args: Option<kittycad::types::InputFormat>
|
||||
) -> Result<Vec<Box<SketchGroup>>> {
|
||||
) -> Result<Vec<Box<Sketch>>> {
|
||||
args
|
||||
}
|
||||
},
|
||||
@ -379,7 +379,7 @@ fn test_stdlib_return_vec_box_sketch_group() {
|
||||
.unwrap();
|
||||
|
||||
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]
|
||||
@ -404,7 +404,7 @@ fn test_stdlib_doc_comment_with_code() {
|
||||
fn inner_my_func(
|
||||
/// The args to do shit to.
|
||||
args: Option<kittycad::types::InputFormat>
|
||||
) -> Result<Vec<Box<SketchGroup>>> {
|
||||
) -> Result<Vec<Box<Sketch>>> {
|
||||
args
|
||||
}
|
||||
},
|
||||
@ -435,7 +435,7 @@ fn test_stdlib_fail_non_camel_case() {
|
||||
fn inner_import_thing(
|
||||
/// The args to do shit to.
|
||||
args: Option<kittycad::types::InputFormat>
|
||||
) -> Result<Vec<Box<SketchGroup>>> {
|
||||
) -> Result<Vec<Box<Sketch>>> {
|
||||
args
|
||||
}
|
||||
},
|
||||
@ -459,7 +459,7 @@ fn test_stdlib_fail_no_code_block() {
|
||||
fn inner_import(
|
||||
/// The args to do shit to.
|
||||
args: Option<kittycad::types::InputFormat>
|
||||
) -> Result<Vec<Box<SketchGroup>>> {
|
||||
) -> Result<Vec<Box<Sketch>>> {
|
||||
args
|
||||
}
|
||||
},
|
||||
@ -493,7 +493,7 @@ fn test_stdlib_fail_name_not_in_code_block() {
|
||||
fn inner_import(
|
||||
/// The args to do shit to.
|
||||
args: Option<kittycad::types::InputFormat>
|
||||
) -> Result<Vec<Box<SketchGroup>>> {
|
||||
) -> Result<Vec<Box<Sketch>>> {
|
||||
args
|
||||
}
|
||||
},
|
||||
|
@ -126,8 +126,8 @@ impl crate::docs::StdLibFn for MyFunc {
|
||||
let mut generator = schemars::gen::SchemaGenerator::new(settings);
|
||||
Some(crate::docs::StdLibFnArg {
|
||||
name: "".to_string(),
|
||||
type_: "[SketchGroup]".to_string(),
|
||||
schema: <Vec<SketchGroup>>::json_schema(&mut generator),
|
||||
type_: "[Sketch]".to_string(),
|
||||
schema: <Vec<Sketch>>::json_schema(&mut generator),
|
||||
required: true,
|
||||
})
|
||||
}
|
||||
@ -181,6 +181,6 @@ impl crate::docs::StdLibFn for MyFunc {
|
||||
#[doc = r" ```"]
|
||||
fn inner_my_func(
|
||||
#[doc = r" The args to do shit to."] args: Option<kittycad::types::InputFormat>,
|
||||
) -> Result<Vec<Box<SketchGroup>>> {
|
||||
) -> Result<Vec<Box<Sketch>>> {
|
||||
args
|
||||
}
|
||||
|
@ -120,9 +120,9 @@ impl crate::docs::StdLibFn for LineTo {
|
||||
required: true,
|
||||
},
|
||||
crate::docs::StdLibFnArg {
|
||||
name: "sketch_group".to_string(),
|
||||
type_: "SketchGroup".to_string(),
|
||||
schema: SketchGroup::json_schema(&mut generator),
|
||||
name: "sketch".to_string(),
|
||||
type_: "Sketch".to_string(),
|
||||
schema: Sketch::json_schema(&mut generator),
|
||||
required: true,
|
||||
},
|
||||
]
|
||||
@ -134,8 +134,8 @@ impl crate::docs::StdLibFn for LineTo {
|
||||
let mut generator = schemars::gen::SchemaGenerator::new(settings);
|
||||
Some(crate::docs::StdLibFnArg {
|
||||
name: "".to_string(),
|
||||
type_: "SketchGroup".to_string(),
|
||||
schema: <SketchGroup>::json_schema(&mut generator),
|
||||
type_: "Sketch".to_string(),
|
||||
schema: <Sketch>::json_schema(&mut generator),
|
||||
required: true,
|
||||
})
|
||||
}
|
||||
@ -187,10 +187,6 @@ impl crate::docs::StdLibFn for LineTo {
|
||||
#[doc = r" yes sirrr."]
|
||||
#[doc = r" lineTo"]
|
||||
#[doc = r" ```"]
|
||||
fn inner_line_to(
|
||||
data: LineToData,
|
||||
sketch_group: SketchGroup,
|
||||
args: &Args,
|
||||
) -> Result<SketchGroup, KclError> {
|
||||
fn inner_line_to(data: LineToData, sketch: Sketch, args: &Args) -> Result<Sketch, KclError> {
|
||||
Ok(())
|
||||
}
|
||||
|
@ -92,8 +92,8 @@ impl crate::docs::StdLibFn for Import {
|
||||
let mut generator = schemars::gen::SchemaGenerator::new(settings);
|
||||
Some(crate::docs::StdLibFnArg {
|
||||
name: "".to_string(),
|
||||
type_: "[SketchGroup]".to_string(),
|
||||
schema: <Vec<SketchGroup>>::json_schema(&mut generator),
|
||||
type_: "[Sketch]".to_string(),
|
||||
schema: <Vec<Sketch>>::json_schema(&mut generator),
|
||||
required: true,
|
||||
})
|
||||
}
|
||||
@ -138,6 +138,6 @@ impl crate::docs::StdLibFn for Import {
|
||||
#[doc = r" import"]
|
||||
fn inner_import(
|
||||
#[doc = r" The args to do shit to."] args: Option<kittycad::types::InputFormat>,
|
||||
) -> Result<Vec<SketchGroup>> {
|
||||
) -> Result<Vec<Box<Sketch>>> {
|
||||
args
|
||||
}
|
@ -92,8 +92,8 @@ impl crate::docs::StdLibFn for Import {
|
||||
let mut generator = schemars::gen::SchemaGenerator::new(settings);
|
||||
Some(crate::docs::StdLibFnArg {
|
||||
name: "".to_string(),
|
||||
type_: "[SketchGroup]".to_string(),
|
||||
schema: <Vec<SketchGroup>>::json_schema(&mut generator),
|
||||
type_: "[Sketch]".to_string(),
|
||||
schema: <Vec<Sketch>>::json_schema(&mut generator),
|
||||
required: true,
|
||||
})
|
||||
}
|
||||
@ -138,6 +138,6 @@ impl crate::docs::StdLibFn for Import {
|
||||
#[doc = r" import"]
|
||||
fn inner_import(
|
||||
#[doc = r" The args to do shit to."] args: Option<kittycad::types::InputFormat>,
|
||||
) -> Result<Vec<Box<SketchGroup>>> {
|
||||
) -> Result<Vec<Sketch>> {
|
||||
args
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "kcl-test-server"
|
||||
description = "A test server for KCL"
|
||||
version = "0.1.11"
|
||||
version = "0.1.12"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "kcl-lib"
|
||||
description = "KittyCAD Language implementation and tools"
|
||||
version = "0.2.19"
|
||||
version = "0.2.20"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
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"
|
||||
dashmap = "6.1.0"
|
||||
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"
|
||||
futures = { version = "0.3.30" }
|
||||
git_rev = "0.1.0"
|
||||
|
@ -23,8 +23,8 @@ use crate::{
|
||||
docs::StdLibFn,
|
||||
errors::{KclError, KclErrorDetails},
|
||||
executor::{
|
||||
BodyType, ExecState, ExecutorContext, KclValue, Metadata, SketchGroup, SourceRange, StatementKind,
|
||||
TagEngineInfo, TagIdentifier, UserVal,
|
||||
BodyType, ExecState, ExecutorContext, KclValue, Metadata, Sketch, SourceRange, StatementKind, TagEngineInfo,
|
||||
TagIdentifier, UserVal,
|
||||
},
|
||||
parser::PIPE_OPERATOR,
|
||||
std::{kcl_stdlib::KclStdLibFn, FunctionKind},
|
||||
@ -1200,24 +1200,24 @@ impl CallExpression {
|
||||
let args = crate::std::Args::new(fn_args, self.into(), ctx.clone());
|
||||
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.
|
||||
// TODO: This could probably be done in a better way, but as of now this was my only idea
|
||||
// and it works.
|
||||
match result {
|
||||
KclValue::UserVal(ref mut uval) => {
|
||||
uval.mutate(|sketch_group: &mut SketchGroup| {
|
||||
for (_, tag) in sketch_group.tags.iter() {
|
||||
uval.mutate(|sketch: &mut Sketch| {
|
||||
for (_, tag) in sketch.tags.iter() {
|
||||
exec_state.memory.update_tag(&tag.value, tag.clone())?;
|
||||
}
|
||||
Ok::<_, KclError>(())
|
||||
})?;
|
||||
}
|
||||
KclValue::ExtrudeGroup(ref mut extrude_group) => {
|
||||
for value in &extrude_group.value {
|
||||
KclValue::Solid(ref mut solid) => {
|
||||
for value in &solid.value {
|
||||
if let Some(tag) = value.get_tag() {
|
||||
// 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()
|
||||
} else {
|
||||
// It's probably a fillet or a chamfer.
|
||||
@ -1228,7 +1228,7 @@ impl CallExpression {
|
||||
id: value.get_id(),
|
||||
surface: Some(value.clone()),
|
||||
path: None,
|
||||
sketch_group: extrude_group.id,
|
||||
sketch: solid.id,
|
||||
}),
|
||||
meta: vec}})
|
||||
{{else if anyOf ~}}
|
||||
`anyOf`
|
||||
{{else if oneOf ~}}
|
||||
`oneOf`
|
||||
{{else if allOf ~}}
|
||||
`allOf`
|
||||
{{else if enum ~}}
|
||||
enum: {{pretty_enum enum}}
|
||||
{{else ~}}
|
||||
`{{type}}`{{#if format}} (`{{format}}`){{/if}}
|
||||
{{~/if~}}
|
||||
[{{basename $ref}}](#{{lowercase (basename $ref)}}){{else if anyOf ~}}
|
||||
`anyOf`{{else if oneOf ~}}
|
||||
`oneOf`{{else if allOf ~}}
|
||||
`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
|
||||
/// 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
|
||||
.iter()
|
||||
.flat_map(|env| {
|
||||
env.bindings
|
||||
.values()
|
||||
.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,
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
@ -222,7 +222,7 @@ impl Environment {
|
||||
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() {
|
||||
return;
|
||||
}
|
||||
@ -230,19 +230,19 @@ impl Environment {
|
||||
for (_, val) in self.bindings.iter_mut() {
|
||||
let KclValue::UserVal(v) = val else { continue };
|
||||
let meta = v.meta.clone();
|
||||
let maybe_sg: Result<SketchGroup, _> = serde_json::from_value(v.value.clone());
|
||||
let Ok(mut sketch_group) = maybe_sg else {
|
||||
let maybe_sg: Result<Sketch, _> = serde_json::from_value(v.value.clone());
|
||||
let Ok(mut sketch) = maybe_sg else {
|
||||
continue;
|
||||
};
|
||||
|
||||
if sketch_group.original_id == sg.original_id {
|
||||
if sketch.original_id == sg.original_id {
|
||||
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 {
|
||||
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.
|
||||
#[derive(Debug, Default, Clone, PartialEq, Eq, Deserialize, Serialize, ts_rs::TS, JsonSchema)]
|
||||
pub struct DynamicState {
|
||||
pub extrude_group_ids: Vec<ExtrudeGroupLazyIds>,
|
||||
pub solid_ids: Vec<SolidLazyIds>,
|
||||
}
|
||||
|
||||
impl DynamicState {
|
||||
@ -271,18 +271,18 @@ impl DynamicState {
|
||||
pub fn append(&mut self, memory: &ProgramMemory) {
|
||||
for env in &memory.environments {
|
||||
for item in env.bindings.values() {
|
||||
if let KclValue::ExtrudeGroup(eg) = item {
|
||||
self.extrude_group_ids.push(ExtrudeGroupLazyIds::from(eg.as_ref()));
|
||||
if let KclValue::Solid(eg) = item {
|
||||
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> {
|
||||
self.extrude_group_ids
|
||||
pub fn edge_cut_ids_on_sketch(&self, sketch_id: uuid::Uuid) -> Vec<uuid::Uuid> {
|
||||
self.solid_ids
|
||||
.iter()
|
||||
.flat_map(|eg| {
|
||||
if eg.sketch_group_id == sketch_group_id {
|
||||
if eg.sketch_id == sketch_id {
|
||||
eg.edge_cuts.clone()
|
||||
} else {
|
||||
Vec::new()
|
||||
@ -303,9 +303,9 @@ pub enum KclValue {
|
||||
Plane(Box<Plane>),
|
||||
Face(Box<Face>),
|
||||
|
||||
ExtrudeGroup(Box<ExtrudeGroup>),
|
||||
ExtrudeGroups {
|
||||
value: Vec<Box<ExtrudeGroup>>,
|
||||
Solid(Box<Solid>),
|
||||
Solids {
|
||||
value: Vec<Box<Solid>>,
|
||||
},
|
||||
ImportedGeometry(ImportedGeometry),
|
||||
#[ts(skip)]
|
||||
@ -324,26 +324,26 @@ impl KclValue {
|
||||
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 {
|
||||
KclValue::ExtrudeGroup(e) => Ok(ExtrudeGroupSet::ExtrudeGroup(e.clone())),
|
||||
KclValue::ExtrudeGroups { value } => Ok(ExtrudeGroupSet::ExtrudeGroups(value.clone())),
|
||||
KclValue::Solid(e) => Ok(SolidSet::Solid(e.clone())),
|
||||
KclValue::Solids { value } => Ok(SolidSet::Solids(value.clone())),
|
||||
KclValue::UserVal(value) => {
|
||||
let value = value.value.clone();
|
||||
match value {
|
||||
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)
|
||||
)),
|
||||
JValue::Array(_) => serde_json::from_value::<Vec<Box<ExtrudeGroup>>>(value)
|
||||
.map(ExtrudeGroupSet::from)
|
||||
.map_err(|e| anyhow::anyhow!("Failed to deserialize array of extrude groups from JSON: {}", e)),
|
||||
JValue::Object(_) => serde_json::from_value::<Box<ExtrudeGroup>>(value)
|
||||
.map(ExtrudeGroupSet::from)
|
||||
.map_err(|e| anyhow::anyhow!("Failed to deserialize extrude group from JSON: {}", e)),
|
||||
JValue::Array(_) => serde_json::from_value::<Vec<Box<Solid>>>(value)
|
||||
.map(SolidSet::from)
|
||||
.map_err(|e| anyhow::anyhow!("Failed to deserialize array of solids from JSON: {}", e)),
|
||||
JValue::Object(_) => serde_json::from_value::<Box<Solid>>(value)
|
||||
.map(SolidSet::from)
|
||||
.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::TagDeclarator(_) => "TagDeclarator",
|
||||
KclValue::TagIdentifier(_) => "TagIdentifier",
|
||||
KclValue::ExtrudeGroup(_) => "ExtrudeGroup",
|
||||
KclValue::ExtrudeGroups { .. } => "ExtrudeGroups",
|
||||
KclValue::Solid(_) => "Solid",
|
||||
KclValue::Solids { .. } => "Solids",
|
||||
KclValue::ImportedGeometry(_) => "ImportedGeometry",
|
||||
KclValue::Function { .. } => "Function",
|
||||
KclValue::Plane(_) => "Plane",
|
||||
@ -364,34 +364,34 @@ impl KclValue {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<SketchGroupSet> for KclValue {
|
||||
fn from(sg: SketchGroupSet) -> Self {
|
||||
impl From<SketchSet> for KclValue {
|
||||
fn from(sg: SketchSet) -> Self {
|
||||
KclValue::UserVal(UserVal::new(sg.meta(), sg))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Vec<Box<SketchGroup>>> for KclValue {
|
||||
fn from(sg: Vec<Box<SketchGroup>>) -> Self {
|
||||
impl From<Vec<Box<Sketch>>> for KclValue {
|
||||
fn from(sg: Vec<Box<Sketch>>) -> Self {
|
||||
let meta = sg.iter().flat_map(|sg| sg.meta.clone()).collect();
|
||||
KclValue::UserVal(UserVal::new(meta, sg))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ExtrudeGroupSet> for KclValue {
|
||||
fn from(eg: ExtrudeGroupSet) -> Self {
|
||||
impl From<SolidSet> for KclValue {
|
||||
fn from(eg: SolidSet) -> Self {
|
||||
match eg {
|
||||
ExtrudeGroupSet::ExtrudeGroup(eg) => KclValue::ExtrudeGroup(eg),
|
||||
ExtrudeGroupSet::ExtrudeGroups(egs) => KclValue::ExtrudeGroups { value: egs },
|
||||
SolidSet::Solid(eg) => KclValue::Solid(eg),
|
||||
SolidSet::Solids(egs) => KclValue::Solids { value: egs },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Vec<Box<ExtrudeGroup>>> for KclValue {
|
||||
fn from(eg: Vec<Box<ExtrudeGroup>>) -> Self {
|
||||
impl From<Vec<Box<Solid>>> for KclValue {
|
||||
fn from(eg: Vec<Box<Solid>>) -> Self {
|
||||
if eg.len() == 1 {
|
||||
KclValue::ExtrudeGroup(eg[0].clone())
|
||||
KclValue::Solid(eg[0].clone())
|
||||
} else {
|
||||
KclValue::ExtrudeGroups { value: eg }
|
||||
KclValue::Solids { value: eg }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -401,15 +401,15 @@ impl From<Vec<Box<ExtrudeGroup>>> for KclValue {
|
||||
#[ts(export)]
|
||||
#[serde(tag = "type")]
|
||||
pub enum Geometry {
|
||||
SketchGroup(Box<SketchGroup>),
|
||||
ExtrudeGroup(Box<ExtrudeGroup>),
|
||||
Sketch(Box<Sketch>),
|
||||
Solid(Box<Solid>),
|
||||
}
|
||||
|
||||
impl Geometry {
|
||||
pub fn id(&self) -> uuid::Uuid {
|
||||
match self {
|
||||
Geometry::SketchGroup(s) => s.id,
|
||||
Geometry::ExtrudeGroup(e) => e.id,
|
||||
Geometry::Sketch(s) => s.id,
|
||||
Geometry::Solid(e) => e.id,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -419,148 +419,148 @@ impl Geometry {
|
||||
#[ts(export)]
|
||||
#[serde(tag = "type")]
|
||||
pub enum Geometries {
|
||||
SketchGroups(Vec<Box<SketchGroup>>),
|
||||
ExtrudeGroups(Vec<Box<ExtrudeGroup>>),
|
||||
Sketches(Vec<Box<Sketch>>),
|
||||
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)]
|
||||
#[ts(export)]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub enum SketchGroupSet {
|
||||
SketchGroup(Box<SketchGroup>),
|
||||
SketchGroups(Vec<Box<SketchGroup>>),
|
||||
pub enum SketchSet {
|
||||
Sketch(Box<Sketch>),
|
||||
Sketches(Vec<Box<Sketch>>),
|
||||
}
|
||||
|
||||
impl SketchGroupSet {
|
||||
impl SketchSet {
|
||||
pub fn meta(&self) -> Vec<Metadata> {
|
||||
match self {
|
||||
SketchGroupSet::SketchGroup(sg) => sg.meta.clone(),
|
||||
SketchGroupSet::SketchGroups(sg) => sg.iter().flat_map(|sg| sg.meta.clone()).collect(),
|
||||
SketchSet::Sketch(sg) => sg.meta.clone(),
|
||||
SketchSet::Sketches(sg) => sg.iter().flat_map(|sg| sg.meta.clone()).collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<SketchGroupSet> for Vec<SketchGroup> {
|
||||
fn from(value: SketchGroupSet) -> Self {
|
||||
impl From<SketchSet> for Vec<Sketch> {
|
||||
fn from(value: SketchSet) -> Self {
|
||||
match value {
|
||||
SketchGroupSet::SketchGroup(sg) => vec![*sg],
|
||||
SketchGroupSet::SketchGroups(sgs) => sgs.into_iter().map(|sg| *sg).collect(),
|
||||
SketchSet::Sketch(sg) => vec![*sg],
|
||||
SketchSet::Sketches(sgs) => sgs.into_iter().map(|sg| *sg).collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<SketchGroup> for SketchGroupSet {
|
||||
fn from(sg: SketchGroup) -> Self {
|
||||
SketchGroupSet::SketchGroup(Box::new(sg))
|
||||
impl From<Sketch> for SketchSet {
|
||||
fn from(sg: Sketch) -> Self {
|
||||
SketchSet::Sketch(Box::new(sg))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Box<SketchGroup>> for SketchGroupSet {
|
||||
fn from(sg: Box<SketchGroup>) -> Self {
|
||||
SketchGroupSet::SketchGroup(sg)
|
||||
impl From<Box<Sketch>> for SketchSet {
|
||||
fn from(sg: Box<Sketch>) -> Self {
|
||||
SketchSet::Sketch(sg)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Vec<SketchGroup>> for SketchGroupSet {
|
||||
fn from(sg: Vec<SketchGroup>) -> Self {
|
||||
impl From<Vec<Sketch>> for SketchSet {
|
||||
fn from(sg: Vec<Sketch>) -> Self {
|
||||
if sg.len() == 1 {
|
||||
SketchGroupSet::SketchGroup(Box::new(sg[0].clone()))
|
||||
SketchSet::Sketch(Box::new(sg[0].clone()))
|
||||
} 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 {
|
||||
fn from(sg: Vec<Box<SketchGroup>>) -> Self {
|
||||
impl From<Vec<Box<Sketch>>> for SketchSet {
|
||||
fn from(sg: Vec<Box<Sketch>>) -> Self {
|
||||
if sg.len() == 1 {
|
||||
SketchGroupSet::SketchGroup(sg[0].clone())
|
||||
SketchSet::Sketch(sg[0].clone())
|
||||
} else {
|
||||
SketchGroupSet::SketchGroups(sg)
|
||||
SketchSet::Sketches(sg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<SketchGroupSet> for Vec<Box<SketchGroup>> {
|
||||
fn from(sg: SketchGroupSet) -> Self {
|
||||
impl From<SketchSet> for Vec<Box<Sketch>> {
|
||||
fn from(sg: SketchSet) -> Self {
|
||||
match sg {
|
||||
SketchGroupSet::SketchGroup(sg) => vec![sg],
|
||||
SketchGroupSet::SketchGroups(sgs) => sgs,
|
||||
SketchSet::Sketch(sg) => vec![sg],
|
||||
SketchSet::Sketches(sgs) => sgs,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&SketchGroup> for Vec<Box<SketchGroup>> {
|
||||
fn from(sg: &SketchGroup) -> Self {
|
||||
impl From<&Sketch> for Vec<Box<Sketch>> {
|
||||
fn from(sg: &Sketch) -> Self {
|
||||
vec![Box::new(sg.clone())]
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Box<SketchGroup>> for Vec<Box<SketchGroup>> {
|
||||
fn from(sg: Box<SketchGroup>) -> Self {
|
||||
impl From<Box<Sketch>> for Vec<Box<Sketch>> {
|
||||
fn from(sg: Box<Sketch>) -> Self {
|
||||
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)]
|
||||
#[ts(export)]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub enum ExtrudeGroupSet {
|
||||
ExtrudeGroup(Box<ExtrudeGroup>),
|
||||
ExtrudeGroups(Vec<Box<ExtrudeGroup>>),
|
||||
pub enum SolidSet {
|
||||
Solid(Box<Solid>),
|
||||
Solids(Vec<Box<Solid>>),
|
||||
}
|
||||
|
||||
impl From<ExtrudeGroup> for ExtrudeGroupSet {
|
||||
fn from(eg: ExtrudeGroup) -> Self {
|
||||
ExtrudeGroupSet::ExtrudeGroup(Box::new(eg))
|
||||
impl From<Solid> for SolidSet {
|
||||
fn from(eg: Solid) -> Self {
|
||||
SolidSet::Solid(Box::new(eg))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Box<ExtrudeGroup>> for ExtrudeGroupSet {
|
||||
fn from(eg: Box<ExtrudeGroup>) -> Self {
|
||||
ExtrudeGroupSet::ExtrudeGroup(eg)
|
||||
impl From<Box<Solid>> for SolidSet {
|
||||
fn from(eg: Box<Solid>) -> Self {
|
||||
SolidSet::Solid(eg)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Vec<ExtrudeGroup>> for ExtrudeGroupSet {
|
||||
fn from(eg: Vec<ExtrudeGroup>) -> Self {
|
||||
impl From<Vec<Solid>> for SolidSet {
|
||||
fn from(eg: Vec<Solid>) -> Self {
|
||||
if eg.len() == 1 {
|
||||
ExtrudeGroupSet::ExtrudeGroup(Box::new(eg[0].clone()))
|
||||
SolidSet::Solid(Box::new(eg[0].clone()))
|
||||
} 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 {
|
||||
fn from(eg: Vec<Box<ExtrudeGroup>>) -> Self {
|
||||
impl From<Vec<Box<Solid>>> for SolidSet {
|
||||
fn from(eg: Vec<Box<Solid>>) -> Self {
|
||||
if eg.len() == 1 {
|
||||
ExtrudeGroupSet::ExtrudeGroup(eg[0].clone())
|
||||
SolidSet::Solid(eg[0].clone())
|
||||
} else {
|
||||
ExtrudeGroupSet::ExtrudeGroups(eg)
|
||||
SolidSet::Solids(eg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ExtrudeGroupSet> for Vec<Box<ExtrudeGroup>> {
|
||||
fn from(eg: ExtrudeGroupSet) -> Self {
|
||||
impl From<SolidSet> for Vec<Box<Solid>> {
|
||||
fn from(eg: SolidSet) -> Self {
|
||||
match eg {
|
||||
ExtrudeGroupSet::ExtrudeGroup(eg) => vec![eg],
|
||||
ExtrudeGroupSet::ExtrudeGroups(egs) => egs,
|
||||
SolidSet::Solid(eg) => vec![eg],
|
||||
SolidSet::Solids(egs) => egs,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&ExtrudeGroup> for Vec<Box<ExtrudeGroup>> {
|
||||
fn from(eg: &ExtrudeGroup) -> Self {
|
||||
impl From<&Solid> for Vec<Box<Solid>> {
|
||||
fn from(eg: &Solid) -> Self {
|
||||
vec![Box::new(eg.clone())]
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Box<ExtrudeGroup>> for Vec<Box<ExtrudeGroup>> {
|
||||
fn from(eg: Box<ExtrudeGroup>) -> Self {
|
||||
impl From<Box<Solid>> for Vec<Box<Solid>> {
|
||||
fn from(eg: Box<Solid>) -> Self {
|
||||
vec![eg]
|
||||
}
|
||||
}
|
||||
@ -626,8 +626,8 @@ pub struct Face {
|
||||
pub y_axis: Point3d,
|
||||
/// The z-axis (normal).
|
||||
pub z_axis: Point3d,
|
||||
/// The extrude group the face is on.
|
||||
pub extrude_group: Box<ExtrudeGroup>,
|
||||
/// The solid the face is on.
|
||||
pub solid: Box<Solid>,
|
||||
#[serde(rename = "__meta")]
|
||||
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::TagDeclarator(t) => t.into(),
|
||||
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::ExtrudeGroups { value } => value
|
||||
KclValue::Solid(e) => e.meta.iter().map(|m| m.source_range).collect(),
|
||||
KclValue::Solids { value } => value
|
||||
.iter()
|
||||
.flat_map(|eg| eg.meta.iter().map(|m| m.source_range))
|
||||
.collect(),
|
||||
@ -949,31 +949,31 @@ impl KclValue {
|
||||
pub struct TagEngineInfo {
|
||||
/// The id of the tagged object.
|
||||
pub id: uuid::Uuid,
|
||||
/// The sketch group the tag is on.
|
||||
pub sketch_group: uuid::Uuid,
|
||||
/// The sketch the tag is on.
|
||||
pub sketch: uuid::Uuid,
|
||||
/// The path the tag is on.
|
||||
pub path: Option<BasePath>,
|
||||
/// The surface information for the tag.
|
||||
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)]
|
||||
#[ts(export)]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct SketchGroup {
|
||||
/// The id of the sketch group (this will change when the engine's reference to it changes.
|
||||
pub struct Sketch {
|
||||
/// The id of the sketch (this will change when the engine's reference to it changes.
|
||||
pub id: uuid::Uuid,
|
||||
/// The paths in the sketch group.
|
||||
/// The paths in the sketch.
|
||||
pub value: Vec<Path>,
|
||||
/// What the sketch is on (can be a plane or a face).
|
||||
pub on: SketchSurface,
|
||||
/// The starting path.
|
||||
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")]
|
||||
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.
|
||||
#[serde(skip)]
|
||||
pub original_id: uuid::Uuid,
|
||||
@ -982,7 +982,7 @@ pub struct SketchGroup {
|
||||
pub meta: Vec<Metadata>,
|
||||
}
|
||||
|
||||
/// A sketch group type.
|
||||
/// A sketch type.
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
|
||||
#[ts(export)]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
@ -1024,13 +1024,13 @@ pub struct GetTangentialInfoFromPathsResult {
|
||||
pub ccw: bool,
|
||||
}
|
||||
|
||||
impl SketchGroup {
|
||||
impl Sketch {
|
||||
pub(crate) fn add_tag(&mut self, tag: &TagDeclarator, current_path: &Path) {
|
||||
let mut tag_identifier: TagIdentifier = tag.into();
|
||||
let base = current_path.get_base();
|
||||
tag_identifier.info = Some(TagEngineInfo {
|
||||
id: base.geo_meta.id,
|
||||
sketch_group: self.id,
|
||||
sketch: self.id,
|
||||
path: Some(base.clone()),
|
||||
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)]
|
||||
#[ts(export)]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct ExtrudeGroup {
|
||||
/// The id of the extrude group.
|
||||
pub struct Solid {
|
||||
/// The id of the solid.
|
||||
pub id: uuid::Uuid,
|
||||
/// The extrude surfaces.
|
||||
pub value: Vec<ExtrudeSurface>,
|
||||
/// The sketch group.
|
||||
pub sketch_group: SketchGroup,
|
||||
/// The height of the extrude group.
|
||||
/// The sketch.
|
||||
pub sketch: Sketch,
|
||||
/// The height of the solid.
|
||||
pub height: f64,
|
||||
/// The id of the extrusion start cap
|
||||
pub start_cap_id: Option<uuid::Uuid>,
|
||||
/// The id of the extrusion end cap
|
||||
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")]
|
||||
pub edge_cuts: Vec<EdgeCut>,
|
||||
/// Metadata.
|
||||
@ -1111,28 +1111,28 @@ pub struct ExtrudeGroup {
|
||||
pub meta: Vec<Metadata>,
|
||||
}
|
||||
|
||||
impl ExtrudeGroup {
|
||||
impl Solid {
|
||||
pub(crate) fn get_all_edge_cut_ids(&self) -> Vec<uuid::Uuid> {
|
||||
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.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize, ts_rs::TS, JsonSchema)]
|
||||
pub struct ExtrudeGroupLazyIds {
|
||||
pub extrude_group_id: uuid::Uuid,
|
||||
pub sketch_group_id: uuid::Uuid,
|
||||
/// Chamfers or fillets on this extrude group.
|
||||
pub struct SolidLazyIds {
|
||||
pub solid_id: uuid::Uuid,
|
||||
pub sketch_id: uuid::Uuid,
|
||||
/// Chamfers or fillets on this solid.
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub edge_cuts: Vec<uuid::Uuid>,
|
||||
}
|
||||
|
||||
impl From<&ExtrudeGroup> for ExtrudeGroupLazyIds {
|
||||
fn from(eg: &ExtrudeGroup) -> Self {
|
||||
impl From<&Solid> for SolidLazyIds {
|
||||
fn from(eg: &Solid) -> Self {
|
||||
Self {
|
||||
extrude_group_id: eg.id,
|
||||
sketch_group_id: eg.sketch_group.id,
|
||||
solid_id: eg.id,
|
||||
sketch_id: eg.sketch.id,
|
||||
edge_cuts: eg.edge_cuts.iter().map(|foc| foc.id()).collect(),
|
||||
}
|
||||
}
|
||||
@ -3197,10 +3197,10 @@ let w = f() + f()
|
||||
|
||||
#[test]
|
||||
fn test_serialize_memory_item() {
|
||||
let mem = KclValue::ExtrudeGroups {
|
||||
let mem = KclValue::Solids {
|
||||
value: Default::default(),
|
||||
};
|
||||
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`
|
||||
fn member_expression_dot(i: TokenSlice) -> PResult<(LiteralIdentifier, usize, bool)> {
|
||||
period.parse_next(i)?;
|
||||
let property = identifier.parse_next(i)?;
|
||||
let end = property.end;
|
||||
Ok((LiteralIdentifier::Identifier(Box::new(property)), end, false))
|
||||
let property = alt((
|
||||
sketch_keyword.map(Box::new).map(LiteralIdentifier::Identifier),
|
||||
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']`
|
||||
fn member_expression_subscript(i: TokenSlice) -> PResult<(LiteralIdentifier, usize, bool)> {
|
||||
let _ = open_bracket.parse_next(i)?;
|
||||
let property = alt((
|
||||
sketch_keyword.map(Box::new).map(LiteralIdentifier::Identifier),
|
||||
literal.map(Box::new).map(LiteralIdentifier::Literal),
|
||||
identifier.map(Box::new).map(LiteralIdentifier::Identifier),
|
||||
))
|
||||
.parse_next(i)?;
|
||||
|
||||
let end = close_bracket.parse_next(i)?.end;
|
||||
let computed = matches!(property, LiteralIdentifier::Identifier(_));
|
||||
Ok((property, end, computed))
|
||||
@ -1193,6 +1199,26 @@ fn identifier(i: TokenSlice) -> PResult<Identifier> {
|
||||
.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 {
|
||||
type Error = KclError;
|
||||
|
||||
@ -2567,6 +2593,18 @@ const height = 1 - obj.a"#,
|
||||
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]
|
||||
fn test_parse_member_expression_binary_expression_brace_number_first() {
|
||||
let tokens = crate::token::lexer(
|
||||
@ -3182,7 +3220,7 @@ thing(false)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_member_expression_sketch_group() {
|
||||
fn test_member_expression_sketch() {
|
||||
let some_program_string = r#"fn cube = (pos, scale) => {
|
||||
const sg = startSketchOn('XY')
|
||||
|> startProfileAt(pos, %)
|
||||
|
@ -9,10 +9,10 @@ use crate::{
|
||||
ast::types::{parse_json_number_as_f64, TagDeclarator},
|
||||
errors::{KclError, KclErrorDetails},
|
||||
executor::{
|
||||
ExecState, ExecutorContext, ExtrudeGroup, ExtrudeGroupSet, ExtrudeSurface, KclValue, Metadata, SketchGroup,
|
||||
SketchGroupSet, SketchSurface, SourceRange, TagIdentifier,
|
||||
ExecState, ExecutorContext, ExtrudeSurface, KclValue, Metadata, Sketch, SketchSet, SketchSurface, Solid,
|
||||
SolidSet, SourceRange, TagIdentifier,
|
||||
},
|
||||
std::{shapes::SketchSurfaceOrGroup, sketch::FaceTag, FnAsArg},
|
||||
std::{shapes::SketchOrSurface, sketch::FaceTag, FnAsArg},
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@ -125,35 +125,35 @@ impl Args {
|
||||
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)]
|
||||
pub(crate) async fn flush_batch_for_extrude_group_set(
|
||||
pub(crate) async fn flush_batch_for_solid_set(
|
||||
&self,
|
||||
exec_state: &mut ExecState,
|
||||
extrude_groups: Vec<Box<ExtrudeGroup>>,
|
||||
solids: Vec<Box<Solid>>,
|
||||
) -> Result<(), KclError> {
|
||||
// Make sure we don't traverse sketch_groups more than once.
|
||||
let mut traversed_sketch_groups = Vec::new();
|
||||
// Make sure we don't traverse sketches more than once.
|
||||
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();
|
||||
for extrude_group in extrude_groups {
|
||||
// We need to traverse the extrude groups that share the same sketch group.
|
||||
let sketch_group_id = extrude_group.sketch_group.id;
|
||||
if !traversed_sketch_groups.contains(&sketch_group_id) {
|
||||
// Find all the extrude groups on the same shared sketch group.
|
||||
for solid in solids {
|
||||
// We need to traverse the solids that share the same sketch.
|
||||
let sketch_id = solid.sketch.id;
|
||||
if !traversed_sketches.contains(&sketch_id) {
|
||||
// Find all the solids on the same shared sketch.
|
||||
ids.extend(
|
||||
exec_state
|
||||
.memory
|
||||
.find_extrude_groups_on_sketch_group(extrude_group.sketch_group.id)
|
||||
.find_solids_on_sketch(solid.sketch.id)
|
||||
.iter()
|
||||
.flat_map(|eg| eg.get_all_edge_cut_ids()),
|
||||
);
|
||||
ids.extend(exec_state.dynamic_state.edge_cut_ids_on_sketch_group(sketch_group_id));
|
||||
traversed_sketch_groups.push(sketch_group_id);
|
||||
ids.extend(exec_state.dynamic_state.edge_cut_ids_on_sketch(sketch_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.
|
||||
@ -236,7 +236,7 @@ impl Args {
|
||||
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)
|
||||
}
|
||||
|
||||
@ -258,7 +258,7 @@ impl Args {
|
||||
) -> Result<
|
||||
(
|
||||
crate::std::shapes::CircleData,
|
||||
crate::std::shapes::SketchSurfaceOrGroup,
|
||||
crate::std::shapes::SketchOrSurface,
|
||||
Option<TagDeclarator>,
|
||||
),
|
||||
KclError,
|
||||
@ -266,11 +266,11 @@ impl Args {
|
||||
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)
|
||||
}
|
||||
|
||||
pub(crate) fn get_sketch_group(&self) -> Result<SketchGroup, KclError> {
|
||||
pub(crate) fn get_sketch(&self) -> Result<Sketch, KclError> {
|
||||
FromArgs::from_args(self, 0)
|
||||
}
|
||||
|
||||
@ -285,11 +285,11 @@ impl Args {
|
||||
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)
|
||||
}
|
||||
|
||||
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
|
||||
T: FromArgs<'a> + serde::de::DeserializeOwned + FromKclValue<'a> + Sized,
|
||||
{
|
||||
@ -303,23 +303,21 @@ impl Args {
|
||||
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
|
||||
T: serde::de::DeserializeOwned + FromArgs<'a>,
|
||||
{
|
||||
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
|
||||
T: serde::de::DeserializeOwned + FromArgs<'a>,
|
||||
{
|
||||
FromArgs::from_args(self, 0)
|
||||
}
|
||||
|
||||
pub(crate) fn get_data_and_sketch_group_and_tag<'a, T>(
|
||||
&'a self,
|
||||
) -> Result<(T, SketchGroup, Option<TagDeclarator>), KclError>
|
||||
pub(crate) fn get_data_and_sketch_and_tag<'a, T>(&'a self) -> Result<(T, Sketch, Option<TagDeclarator>), KclError>
|
||||
where
|
||||
T: serde::de::DeserializeOwned + FromKclValue<'a> + Sized,
|
||||
{
|
||||
@ -335,30 +333,30 @@ impl Args {
|
||||
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
|
||||
T: serde::de::DeserializeOwned + FromKclValue<'a> + Sized,
|
||||
{
|
||||
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
|
||||
T: serde::de::DeserializeOwned + FromKclValue<'a> + Sized,
|
||||
{
|
||||
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,
|
||||
) -> Result<(T, Box<ExtrudeGroup>, Option<TagDeclarator>), KclError>
|
||||
) -> Result<(T, Box<Solid>, Option<TagDeclarator>), KclError>
|
||||
where
|
||||
T: serde::de::DeserializeOwned + FromKclValue<'a> + Sized,
|
||||
{
|
||||
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)
|
||||
}
|
||||
|
||||
@ -369,7 +367,7 @@ impl Args {
|
||||
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)
|
||||
}
|
||||
|
||||
@ -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::planes::StandardPlane);
|
||||
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!(String);
|
||||
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!(3);
|
||||
|
||||
impl<'a> FromKclValue<'a> for SketchGroupSet {
|
||||
impl<'a> FromKclValue<'a> for SketchSet {
|
||||
fn from_mem_item(arg: &'a KclValue) -> Option<Self> {
|
||||
let KclValue::UserVal(uv) = arg else {
|
||||
return None;
|
||||
};
|
||||
if let Some((x, _meta)) = uv.get::<SketchGroup>() {
|
||||
Some(SketchGroupSet::from(x))
|
||||
if let Some((x, _meta)) = uv.get::<Sketch>() {
|
||||
Some(SketchSet::from(x))
|
||||
} 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> {
|
||||
let KclValue::ExtrudeGroup(s) = arg else {
|
||||
let KclValue::Solid(s) = arg else {
|
||||
return None;
|
||||
};
|
||||
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> {
|
||||
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> {
|
||||
match arg {
|
||||
KclValue::UserVal(uv) => {
|
||||
if let Some((sg, _meta)) = uv.get() {
|
||||
Some(Self::SketchGroup(sg))
|
||||
Some(Self::Sketch(sg))
|
||||
} else {
|
||||
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> {
|
||||
let KclValue::UserVal(uv) = arg else {
|
||||
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 crate::{
|
||||
errors::{KclError, KclErrorDetails},
|
||||
executor::{ExecState, KclValue, SketchGroup, SourceRange, UserVal},
|
||||
executor::{ExecState, KclValue, Sketch, SourceRange, UserVal},
|
||||
function_param::FunctionParam,
|
||||
};
|
||||
|
||||
/// For each item in an array, update a value.
|
||||
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 {
|
||||
inner: f.func,
|
||||
fn_expr: f.expr,
|
||||
@ -28,8 +28,8 @@ pub async fn array_reduce(exec_state: &mut ExecState, args: Args) -> Result<KclV
|
||||
/// ```no_run
|
||||
/// fn decagon = (radius) => {
|
||||
/// let step = (1/10) * tau()
|
||||
/// let sketch = startSketchAt([(cos(0)*radius), (sin(0) * radius)])
|
||||
/// return arrayReduce([1..10], sketch, (i, sg) => {
|
||||
/// let sketch001 = startSketchAt([(cos(0)*radius), (sin(0) * radius)])
|
||||
/// return arrayReduce([1..10], sketch001, (i, sg) => {
|
||||
/// let x = cos(step * i) * radius
|
||||
/// let y = sin(step * i) * radius
|
||||
/// 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>(
|
||||
array: Vec<u64>,
|
||||
start: SketchGroup,
|
||||
start: Sketch,
|
||||
reduce_fn: FunctionParam<'a>,
|
||||
exec_state: &mut ExecState,
|
||||
args: &'a Args,
|
||||
) -> Result<SketchGroup, KclError> {
|
||||
) -> Result<Sketch, KclError> {
|
||||
let mut reduced = start;
|
||||
for i in array {
|
||||
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>(
|
||||
i: u64,
|
||||
start: SketchGroup,
|
||||
start: Sketch,
|
||||
reduce_fn: &FunctionParam<'a>,
|
||||
source_range: SourceRange,
|
||||
exec_state: &mut ExecState,
|
||||
) -> Result<SketchGroup, KclError> {
|
||||
) -> Result<Sketch, KclError> {
|
||||
// Call the reduce fn for this repetition.
|
||||
let reduce_fn_args = vec![
|
||||
KclValue::UserVal(UserVal {
|
||||
@ -88,7 +88,7 @@ async fn call_reduce_closure<'a>(
|
||||
};
|
||||
let Some((out, _meta)) = out.get() else {
|
||||
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(),
|
||||
}));
|
||||
};
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user