Compare commits
15 Commits
v0.52.0
...
nightly-v2
Author | SHA1 | Date | |
---|---|---|---|
1a59fc4f99 | |||
d38dcb9ba2 | |||
c7b348390e | |||
bf6c91932c | |||
716ed3acb3 | |||
65e08bea92 | |||
74859e99e7 | |||
aad583be2e | |||
3e4505e2e3 | |||
1fe1cfb397 | |||
2f721c84ed | |||
9112ff8c0a | |||
96e12b5aba | |||
bec3ba71cd | |||
c6766d2a73 |
4
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
4
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@ -1,5 +1,5 @@
|
||||
name: Bug Report
|
||||
description: File a bug report for the Zoo Modeling App
|
||||
description: File a bug report for the Zoo Design Studio
|
||||
title: "[BUG]: "
|
||||
labels: ["bug"]
|
||||
assignees: []
|
||||
@ -70,7 +70,7 @@ body:
|
||||
id: version
|
||||
attributes:
|
||||
label: Version
|
||||
description: "The version of the Zoo Modeling App you're using."
|
||||
description: "The version of the Zoo Design Studio you're using."
|
||||
placeholder: "example: v0.15.0. You can find this in the settings."
|
||||
validations:
|
||||
required: true
|
||||
|
2
.github/workflows/build-apps.yml
vendored
2
.github/workflows/build-apps.yml
vendored
@ -241,7 +241,7 @@ jobs:
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: out-arm64-${{ matrix.platform }}
|
||||
# first two will pick both Zoo Modeling App-$VERSION-arm64-win.exe and Zoo Modeling App-$VERSION-win.exe
|
||||
# first two will pick both Zoo Design Studio-$VERSION-arm64-win.exe and Zoo Design Studio-$VERSION-win.exe
|
||||
path: |
|
||||
out/*-${{ env.VERSION_NO_V }}-win.*
|
||||
out/*-${{ env.VERSION_NO_V }}-arm64-win.*
|
||||
|
20
INSTALL.md
20
INSTALL.md
@ -1,27 +1,27 @@
|
||||
# Setting Up Zoo Modeling App
|
||||
# Setting Up Zoo Design Studio
|
||||
|
||||
Compared to other CAD software, getting Zoo Modeling App up and running is quick and straightforward across platforms. It's about 100MB to download and is quick to install.
|
||||
Compared to other CAD software, getting Zoo Design Studio up and running is quick and straightforward across platforms. It's about 100MB to download and is quick to install.
|
||||
|
||||
## Windows
|
||||
|
||||
1. Download the [Zoo Modeling App installer](https://zoo.dev/modeling-app/download) for Windows and for your processor type.
|
||||
1. Download the [Zoo Design Studio installer](https://zoo.dev/modeling-app/download) for Windows and for your processor type.
|
||||
|
||||
2. Once downloaded, run the installer `Zoo Modeling App-{version}-{arch}-win.exe` which should take a few seconds.
|
||||
2. Once downloaded, run the installer `Zoo Design Studio-{version}-{arch}-win.exe` which should take a few seconds.
|
||||
|
||||
3. The installation happens at `C:\Program Files\Zoo Modeling App`. A shortcut in the start menu is also created so you can run the app easily by clicking on it.
|
||||
3. The installation happens at `C:\Program Files\Zoo Design Studio`. A shortcut in the start menu is also created so you can run the app easily by clicking on it.
|
||||
|
||||
## macOS
|
||||
|
||||
1. Download the [Zoo Modeling App installer](https://zoo.dev/modeling-app/download) for macOS and for your processor type.
|
||||
1. Download the [Zoo Design Studio installer](https://zoo.dev/modeling-app/download) for macOS and for your processor type.
|
||||
|
||||
2. Once downloaded, open the disk image `Zoo Modeling App-{version}-{arch}-mac.dmg` and drag the applications to your `Applications` directory.
|
||||
2. Once downloaded, open the disk image `Zoo Design Studio-{version}-{arch}-mac.dmg` and drag the applications to your `Applications` directory.
|
||||
|
||||
3. You can then open your `Applications` directory and double-click on `Zoo Modeling App` to open.
|
||||
3. You can then open your `Applications` directory and double-click on `Zoo Design Studio` to open.
|
||||
|
||||
|
||||
## Linux
|
||||
|
||||
1. Download the [Zoo Modeling App installer](https://zoo.dev/modeling-app/download) for Linux and for your processor type.
|
||||
1. Download the [Zoo Design Studio installer](https://zoo.dev/modeling-app/download) for Linux and for your processor type.
|
||||
|
||||
2. Install the dependencies needed to run the [AppImage format](https://appimage.org/).
|
||||
- On Ubuntu, install the FUSE library with these commands in a terminal.
|
||||
@ -30,7 +30,7 @@ Compared to other CAD software, getting Zoo Modeling App up and running is quick
|
||||
sudo apt install libfuse2
|
||||
```
|
||||
- Optionally, follow [these steps](https://github.com/probonopd/go-appimage/blob/master/src/appimaged/README.md#initial-setup) to install `appimaged`. It is a daemon that makes interacting with AppImage files more seamless.
|
||||
- Once installed, copy the downloaded `Zoo Modeling App-{version}-{arch}-linux.AppImage` to the directory of your choice, for instance `~/Applications`.
|
||||
- Once installed, copy the downloaded `Zoo Design Studio-{version}-{arch}-linux.AppImage` to the directory of your choice, for instance `~/Applications`.
|
||||
|
||||
- `appimaged` should automatically find it and make it executable. If not, run:
|
||||
```bash
|
||||
|
16
README.md
16
README.md
@ -1,17 +1,17 @@
|
||||

|
||||

|
||||
|
||||
## Zoo Modeling App
|
||||
## Zoo Design Studio
|
||||
|
||||
download at [zoo.dev/modeling-app/download](https://zoo.dev/modeling-app/download)
|
||||
|
||||
A CAD application from the future, brought to you by the [Zoo team](https://zoo.dev).
|
||||
|
||||
Modeling App is our take on what a modern modelling experience can be. It is applying several lessons learned in the decades since most major CAD tools came into existence:
|
||||
Design Studio is our take on what a modern modelling experience can be. It is applying several lessons learned in the decades since most major CAD tools came into existence:
|
||||
|
||||
- All artifacts—including parts and assemblies—should be represented as human-readable code. At the end of the day, your CAD project should be "plain text"
|
||||
- This makes version control—which is a solved problem in software engineering—trivial for CAD
|
||||
- All GUI (or point-and-click) interactions should be actions performed on this code representation under the hood
|
||||
- This unlocks a hybrid approach to modeling. Whether you point-and-click as you always have or you write your own KCL code, you are performing the same action in Modeling App
|
||||
- This unlocks a hybrid approach to modeling. Whether you point-and-click as you always have or you write your own KCL code, you are performing the same action in Design Studio
|
||||
- Everything graphics _has_ to be built for the GPU
|
||||
- Most CAD applications have had to retrofit support for GPUs, but our geometry engine is made for GPUs (primarily Nvidia's Vulkan), getting the order of magnitude rendering performance boost with it
|
||||
- Make the resource-intensive pieces of an application auto-scaling
|
||||
@ -19,9 +19,9 @@ Modeling App is our take on what a modern modelling experience can be. It is app
|
||||
|
||||
We are excited about what a small team of people could build in a short time with our API. We welcome you to try our API, build your own applications, or contribute to ours!
|
||||
|
||||
Modeling App is a _hybrid_ user interface for CAD modeling. You can point-and-click to design parts (and soon assemblies), but everything you make is really just [`kcl` code](https://github.com/KittyCAD/kcl-experiments) under the hood. All of your CAD models can be checked into source control such as GitHub and responsibly versioned, rolled back, and more.
|
||||
Design Studio is a _hybrid_ user interface for CAD modeling. You can point-and-click to design parts (and soon assemblies), but everything you make is really just [`kcl` code](https://github.com/KittyCAD/kcl-experiments) under the hood. All of your CAD models can be checked into source control such as GitHub and responsibly versioned, rolled back, and more.
|
||||
|
||||
The 3D view in Modeling App is just a video stream from our hosted geometry engine. The app sends new modeling commands to the engine via WebSockets, which returns back video frames of the view within the engine.
|
||||
The 3D view in Design Studio is just a video stream from our hosted geometry engine. The app sends new modeling commands to the engine via WebSockets, which returns back video frames of the view within the engine.
|
||||
|
||||
## Tools
|
||||
|
||||
@ -198,13 +198,13 @@ If the prompt doesn't show up, start the app in command line to grab the electro
|
||||
|
||||
```
|
||||
# Windows (PowerShell)
|
||||
& 'C:\Program Files\Zoo Modeling App\Zoo Modeling App.exe'
|
||||
& 'C:\Program Files\Zoo Design Studio\Zoo Design Studio.exe'
|
||||
|
||||
# macOS
|
||||
/Applications/Zoo\ Modeling\ App.app/Contents/MacOS/Zoo\ Modeling\ App
|
||||
|
||||
# Linux
|
||||
./Zoo Modeling App-{version}-{arch}-linux.AppImage
|
||||
./Zoo Design Studio-{version}-{arch}-linux.AppImage
|
||||
```
|
||||
|
||||
#### 4. Publish the release
|
||||
|
@ -54,7 +54,7 @@ example = extrude(exampleSketch, length = 5)
|
||||
// Add color to a revolved solid.
|
||||
sketch001 = startSketchOn(XY)
|
||||
|> circle(center = [15, 0], radius = 5)
|
||||
|> revolve(angle = 360, axis = 'y')
|
||||
|> revolve(angle = 360, axis = Y)
|
||||
|> appearance(color = '#ff0000', metalness = 90, roughness = 90)
|
||||
```
|
||||
|
||||
|
@ -9,9 +9,12 @@ layout: manual
|
||||
|
||||
### `std`
|
||||
|
||||
- [`X`](/docs/kcl/consts/std-X)
|
||||
- [`XY`](/docs/kcl/consts/std-XY)
|
||||
- [`XZ`](/docs/kcl/consts/std-XZ)
|
||||
- [`Y`](/docs/kcl/consts/std-Y)
|
||||
- [`YZ`](/docs/kcl/consts/std-YZ)
|
||||
- [`Z`](/docs/kcl/consts/std-Z)
|
||||
|
||||
### `std::math`
|
||||
|
||||
|
15
docs/kcl/consts/std-X.md
Normal file
15
docs/kcl/consts/std-X.md
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
title: "std::X"
|
||||
excerpt: ""
|
||||
layout: manual
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
```js
|
||||
std::X
|
||||
```
|
||||
|
||||
|
15
docs/kcl/consts/std-Y.md
Normal file
15
docs/kcl/consts/std-Y.md
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
title: "std::Y"
|
||||
excerpt: ""
|
||||
layout: manual
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
```js
|
||||
std::Y
|
||||
```
|
||||
|
||||
|
15
docs/kcl/consts/std-Z.md
Normal file
15
docs/kcl/consts/std-Z.md
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
title: "std::Z"
|
||||
excerpt: ""
|
||||
layout: manual
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
```js
|
||||
std::Z
|
||||
```
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@ -12,7 +12,7 @@ Import a CAD file.
|
||||
|
||||
For formats lacking unit data (such as STL, OBJ, or PLY files), the default unit of measurement is millimeters. Alternatively you may specify the unit by passing your desired measurement unit in the options parameter. When importing a GLTF file, the bin file will be imported as well. Import paths are relative to the current project directory.
|
||||
|
||||
Note: The import command currently only works when using the native Modeling App.
|
||||
Note: The import command currently only works when using the native Design Studio.
|
||||
|
||||
```js
|
||||
import(
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
title: "KCL Standard Library"
|
||||
excerpt: "Documentation for the KCL standard library for the Zoo Modeling App."
|
||||
excerpt: "Documentation for the KCL standard library for the Zoo Design Studio."
|
||||
layout: manual
|
||||
---
|
||||
|
||||
@ -22,6 +22,9 @@ layout: manual
|
||||
* [`string`](kcl/types/string)
|
||||
* [`tag`](kcl/types/tag)
|
||||
* **std**
|
||||
* [`Axis2d`](kcl/types/Axis2d)
|
||||
* [`Axis3d`](kcl/types/Axis3d)
|
||||
* [`Edge`](kcl/types/Edge)
|
||||
* [`Face`](kcl/types/Face)
|
||||
* [`Helix`](kcl/types/Helix)
|
||||
* [`Plane`](kcl/types/Plane)
|
||||
@ -29,9 +32,12 @@ layout: manual
|
||||
* [`Point3d`](kcl/types/Point3d)
|
||||
* [`Sketch`](kcl/types/Sketch)
|
||||
* [`Solid`](kcl/types/Solid)
|
||||
* [`X`](kcl/consts/std-X)
|
||||
* [`XY`](kcl/consts/std-XY)
|
||||
* [`XZ`](kcl/consts/std-XZ)
|
||||
* [`Y`](kcl/consts/std-Y)
|
||||
* [`YZ`](kcl/consts/std-YZ)
|
||||
* [`Z`](kcl/consts/std-Z)
|
||||
* [`abs`](kcl/abs)
|
||||
* [`acos`](kcl/acos)
|
||||
* [`angleToMatchLengthX`](kcl/angleToMatchLengthX)
|
||||
@ -68,7 +74,7 @@ layout: manual
|
||||
* [`getNextAdjacentEdge`](kcl/getNextAdjacentEdge)
|
||||
* [`getOppositeEdge`](kcl/getOppositeEdge)
|
||||
* [`getPreviousAdjacentEdge`](kcl/getPreviousAdjacentEdge)
|
||||
* [`helix`](kcl/helix)
|
||||
* [`helix`](kcl/std-helix)
|
||||
* [`hole`](kcl/hole)
|
||||
* [`hollow`](kcl/hollow)
|
||||
* [`inch`](kcl/inch)
|
||||
@ -87,7 +93,6 @@ layout: manual
|
||||
* [`map`](kcl/map)
|
||||
* [`max`](kcl/max)
|
||||
* [`min`](kcl/min)
|
||||
* [`mirror2d`](kcl/mirror2d)
|
||||
* [`mm`](kcl/mm)
|
||||
* [`offsetPlane`](kcl/offsetPlane)
|
||||
* [`patternCircular2d`](kcl/patternCircular2d)
|
||||
@ -106,7 +111,7 @@ layout: manual
|
||||
* [`push`](kcl/push)
|
||||
* [`reduce`](kcl/reduce)
|
||||
* [`rem`](kcl/rem)
|
||||
* [`revolve`](kcl/revolve)
|
||||
* [`revolve`](kcl/std-revolve)
|
||||
* [`rotate`](kcl/rotate)
|
||||
* [`round`](kcl/round)
|
||||
* [`scale`](kcl/scale)
|
||||
@ -142,6 +147,7 @@ layout: manual
|
||||
* [`tan`](kcl/std-math-tan)
|
||||
* **std::sketch**
|
||||
* [`circle`](kcl/std-sketch-circle)
|
||||
* [`mirror2d`](kcl/std-sketch-mirror2d)
|
||||
* **std::turns**
|
||||
* [`turns::HALF_TURN`](kcl/consts/std-turns-HALF_TURN)
|
||||
* [`turns::QUARTER_TURN`](kcl/consts/std-turns-QUARTER_TURN)
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
||||
---
|
||||
title: "KCL Known Issues"
|
||||
excerpt: "Known issues with the KCL standard library for the Zoo Modeling App."
|
||||
excerpt: "Known issues with the KCL standard library for the Zoo Design Studio."
|
||||
layout: manual
|
||||
---
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
||||
---
|
||||
title: "KCL Modules"
|
||||
excerpt: "Documentation of modules for the KCL language for the Zoo Modeling App."
|
||||
excerpt: "Documentation of modules for the KCL language for the Zoo Design Studio."
|
||||
layout: manual
|
||||
---
|
||||
|
||||
@ -95,7 +95,7 @@ import "tests/inputs/cube.obj"
|
||||
When importing a GLTF file, the bin file will be imported as well.
|
||||
|
||||
Import paths are relative to the current project directory. Imports currently only work when
|
||||
using the native Modeling App, not in the browser.
|
||||
using the native Design Studio, not in the browser.
|
||||
|
||||
### Supported values
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,12 +1,12 @@
|
||||
---
|
||||
title: "KCL Settings"
|
||||
excerpt: "Documentation of settings for the KCL language and Zoo Modeling App."
|
||||
excerpt: "Documentation of settings for the KCL language and Zoo Design Studio."
|
||||
layout: manual
|
||||
---
|
||||
|
||||
# KCL Settings
|
||||
|
||||
There are three levels of settings available in the KittyCAD modeling application:
|
||||
There are three levels of settings available in the KittyCAD Design Studiolication:
|
||||
|
||||
1. [User Settings](/docs/kcl/settings/user): Global settings that apply to all projects, stored in `user.toml`
|
||||
2. [Project Settings](/docs/kcl/settings/project): Settings specific to a project, stored in `project.toml`
|
||||
@ -14,7 +14,7 @@ There are three levels of settings available in the KittyCAD modeling applicatio
|
||||
|
||||
## Configuration Files
|
||||
|
||||
The KittyCAD modeling app uses TOML files for configuration:
|
||||
The KittyCAD Design Studio uses TOML files for configuration:
|
||||
|
||||
* **User Settings**: `user.toml` - See [complete documentation](/docs/kcl/settings/user)
|
||||
* **Project Settings**: `project.toml` - See [complete documentation](/docs/kcl/settings/project)
|
||||
|
@ -35,7 +35,7 @@ base_unit = "in"
|
||||
|
||||
#### app
|
||||
|
||||
The settings for the modeling app.
|
||||
The settings for the Design Studio.
|
||||
|
||||
|
||||
**Default:** None
|
||||
|
@ -37,7 +37,7 @@ text_wrapping = false
|
||||
|
||||
#### app
|
||||
|
||||
The settings for the modeling app.
|
||||
The settings for the Design Studio.
|
||||
|
||||
|
||||
**Default:** None
|
||||
|
@ -146,7 +146,7 @@ exampleSketch = startSketchOn(XY)
|
||||
|> line(end = [-2, 0])
|
||||
|> close()
|
||||
|
||||
example = revolve(exampleSketch, axis = 'y', angle = 180)
|
||||
example = revolve(exampleSketch, axis = Y, angle = 180)
|
||||
|
||||
exampleSketch002 = startSketchOn(example, 'end')
|
||||
|> startProfileAt([4.5, -5], %)
|
||||
@ -177,7 +177,7 @@ exampleSketch = startSketchOn(XY)
|
||||
|
||||
example = revolve(
|
||||
exampleSketch,
|
||||
axis = 'y',
|
||||
axis = Y,
|
||||
angle = 180,
|
||||
tagEnd = $end01,
|
||||
)
|
||||
|
116
docs/kcl/std-helix.md
Normal file
116
docs/kcl/std-helix.md
Normal file
File diff suppressed because one or more lines are too long
246
docs/kcl/std-revolve.md
Normal file
246
docs/kcl/std-revolve.md
Normal file
File diff suppressed because one or more lines are too long
98
docs/kcl/std-sketch-mirror2d.md
Normal file
98
docs/kcl/std-sketch-mirror2d.md
Normal file
File diff suppressed because one or more lines are too long
17432
docs/kcl/std.json
17432
docs/kcl/std.json
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -74,7 +74,7 @@ helixPath = helix(
|
||||
revolutions = 4,
|
||||
length = 10,
|
||||
radius = 5,
|
||||
axis = 'Z',
|
||||
axis = Z,
|
||||
)
|
||||
|
||||
// Create a spring by sweeping around the helix path.
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
||||
---
|
||||
title: "KCL Types"
|
||||
excerpt: "Documentation of types for the KCL standard library for the Zoo Modeling App."
|
||||
excerpt: "Documentation of types for the KCL standard library for the Zoo Design Studio."
|
||||
layout: manual
|
||||
---
|
||||
|
||||
|
12
docs/kcl/types/Axis2d.md
Normal file
12
docs/kcl/types/Axis2d.md
Normal file
@ -0,0 +1,12 @@
|
||||
---
|
||||
title: "std::Axis2d"
|
||||
excerpt: "An infinite line in 2d space."
|
||||
layout: manual
|
||||
---
|
||||
|
||||
An infinite line in 2d space.
|
||||
|
||||
|
||||
|
||||
|
||||
|
12
docs/kcl/types/Axis3d.md
Normal file
12
docs/kcl/types/Axis3d.md
Normal file
@ -0,0 +1,12 @@
|
||||
---
|
||||
title: "std::Axis3d"
|
||||
excerpt: "An infinite line in 3d space."
|
||||
layout: manual
|
||||
---
|
||||
|
||||
An infinite line in 3d space.
|
||||
|
||||
|
||||
|
||||
|
||||
|
12
docs/kcl/types/Edge.md
Normal file
12
docs/kcl/types/Edge.md
Normal file
@ -0,0 +1,12 @@
|
||||
---
|
||||
title: "std::Edge"
|
||||
excerpt: "The edge of a solid."
|
||||
layout: manual
|
||||
---
|
||||
|
||||
The edge of a solid.
|
||||
|
||||
|
||||
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@ -1274,4 +1274,45 @@ sketch001 = startSketchOn(XZ)
|
||||
await middleMousePan(800, 200, 900, 300)
|
||||
})
|
||||
})
|
||||
|
||||
test('Can select lines on the main axis', async ({
|
||||
page,
|
||||
homePage,
|
||||
toolbar,
|
||||
}) => {
|
||||
await page.addInitScript(async () => {
|
||||
localStorage.setItem(
|
||||
'persistCode',
|
||||
`sketch001 = startSketchOn(XZ)
|
||||
profile001 = startProfileAt([100.00, 100.0], sketch001)
|
||||
|> yLine(length = -100.0)
|
||||
|> xLine(length = 200.0)
|
||||
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|
||||
|> close()`
|
||||
)
|
||||
})
|
||||
|
||||
const width = 1200
|
||||
const height = 800
|
||||
const viewportSize = { width, height }
|
||||
await page.setBodyDimensions(viewportSize)
|
||||
|
||||
await homePage.goToModelingScene()
|
||||
|
||||
const u = await getUtils(page)
|
||||
await u.waitForPageLoad()
|
||||
|
||||
await toolbar.editSketch(0)
|
||||
|
||||
await page.waitForTimeout(1000)
|
||||
|
||||
// Click on the bottom segment that lies on the x axis
|
||||
await page.mouse.click(width * 0.85, height / 2)
|
||||
|
||||
await page.waitForTimeout(1000)
|
||||
|
||||
// Verify segment is selected (you can check for visual indicators or state)
|
||||
const element = page.locator('[data-overlay-index="1"]')
|
||||
await expect(element).toHaveAttribute('data-overlay-visible', 'true')
|
||||
})
|
||||
})
|
||||
|
@ -22,7 +22,7 @@ sketch001 = startSketchOn(XZ)
|
||||
|> angledLine([-45, length001], %)
|
||||
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|
||||
|> close()
|
||||
revolve001 = revolve(sketch001, axis = "X")
|
||||
revolve001 = revolve(sketch001, axis = X)
|
||||
triangle()
|
||||
|> extrude(length = 30)
|
||||
plane001 = offsetPlane(XY, offset = 10)
|
||||
@ -127,7 +127,7 @@ test.describe('Feature Tree pane', () => {
|
||||
await testViewSource({
|
||||
operationName: 'Revolve',
|
||||
operationIndex: 0,
|
||||
expectedActiveLine: 'revolve001 = revolve(sketch001, axis = "X")',
|
||||
expectedActiveLine: 'revolve001 = revolve(sketch001, axis = X)',
|
||||
})
|
||||
await testViewSource({
|
||||
operationName: 'Triangle',
|
||||
|
@ -96,7 +96,7 @@ export class HomePageFixture {
|
||||
await expect(this.projectSection).not.toHaveText('Loading your Projects...')
|
||||
}
|
||||
|
||||
createAndGoToProject = async (projectTitle = 'project-$nnn') => {
|
||||
createAndGoToProject = async (projectTitle = 'untitled') => {
|
||||
await this.projectsLoaded()
|
||||
await this.projectButtonNew.click()
|
||||
await this.projectTextName.click()
|
||||
|
@ -24,7 +24,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
|
||||
const actualArgument = await cmdBar.cmdBarElement
|
||||
.getByTestId('cmd-bar-arg-value')
|
||||
.inputValue()
|
||||
const expectedArgument = 'project-$nnn'
|
||||
const expectedArgument = 'untitled'
|
||||
expect(actualArgument).toBe(expectedArgument)
|
||||
})
|
||||
test('File.Open project', async ({ tronApp, cmdBar, page }) => {
|
||||
|
@ -42,10 +42,10 @@ test.describe('Onboarding tests', () => {
|
||||
await homePage.goToModelingScene()
|
||||
|
||||
// Test that the onboarding pane loaded
|
||||
await expect(page.getByText('Welcome to Modeling App! This')).toBeVisible()
|
||||
await expect(page.getByText('Welcome to Design Studio! This')).toBeVisible()
|
||||
|
||||
// Test that the onboarding pane loaded
|
||||
await expect(page.getByText('Welcome to Modeling App! This')).toBeVisible()
|
||||
await expect(page.getByText('Welcome to Design Studio! This')).toBeVisible()
|
||||
|
||||
// *and* that the code is shown in the editor
|
||||
await expect(page.locator('.cm-content')).toContainText('// Shelf Bracket')
|
||||
@ -86,7 +86,7 @@ test.describe('Onboarding tests', () => {
|
||||
await test.step(`Ensure we see the onboarding stuff`, async () => {
|
||||
// Test that the onboarding pane loaded
|
||||
await expect(
|
||||
page.getByText('Welcome to Modeling App! This')
|
||||
page.getByText('Welcome to Design Studio! This')
|
||||
).toBeVisible()
|
||||
|
||||
// *and* that the code is shown in the editor
|
||||
@ -147,7 +147,7 @@ test.describe('Onboarding tests', () => {
|
||||
await nextButton.click()
|
||||
|
||||
// Ensure we see the introduction and that the code has been reset
|
||||
await expect(page.getByText('Welcome to Modeling App!')).toBeVisible()
|
||||
await expect(page.getByText('Welcome to Design Studio!')).toBeVisible()
|
||||
await expect(page.locator('.cm-content')).toContainText('// Shelf Bracket')
|
||||
|
||||
// There used to be old code here that checked if we stored the reset
|
||||
@ -188,7 +188,7 @@ test.describe('Onboarding tests', () => {
|
||||
await homePage.goToModelingScene()
|
||||
|
||||
// Test that the onboarding pane loaded
|
||||
await expect(page.getByText('Welcome to Modeling App! This')).toBeVisible()
|
||||
await expect(page.getByText('Welcome to Design Studio! This')).toBeVisible()
|
||||
|
||||
const nextButton = page.getByTestId('onboarding-next')
|
||||
const prevButton = page.getByTestId('onboarding-prev')
|
||||
@ -494,7 +494,7 @@ test('Restarting onboarding on desktop takes one attempt', async ({
|
||||
const tutorialProjectIndicator = page
|
||||
.getByTestId('project-sidebar-toggle')
|
||||
.filter({ hasText: 'Tutorial Project 00' })
|
||||
const tutorialModalText = page.getByText('Welcome to Modeling App!')
|
||||
const tutorialModalText = page.getByText('Welcome to Design Studio!')
|
||||
const tutorialDismissButton = page.getByRole('button', { name: 'Dismiss' })
|
||||
const userMenuButton = page.getByTestId('user-sidebar-toggle')
|
||||
const userMenuSettingsButton = page.getByRole('button', {
|
||||
|
@ -1084,8 +1084,8 @@ openSketch = startSketchOn(XY)
|
||||
}) => {
|
||||
// One dumb hardcoded screen pixel value
|
||||
const testPoint = { x: 620, y: 257 }
|
||||
const expectedOutput = `helix001 = helix( axis = 'X', radius = 5, length = 5, revolutions = 1, angleStart = 360, ccw = false,)`
|
||||
const expectedLine = `axis='X',`
|
||||
const expectedOutput = `helix001 = helix( axis = X, radius = 5, length = 5, revolutions = 1, angleStart = 360, ccw = false,)`
|
||||
const expectedLine = `axis=X,`
|
||||
|
||||
await homePage.goToModelingScene()
|
||||
|
||||
@ -1217,7 +1217,7 @@ openSketch = startSketchOn(XY)
|
||||
cmdBar,
|
||||
}) => {
|
||||
page.on('console', console.log)
|
||||
const initialCode = `sketch001 = startSketchOn('XZ')
|
||||
const initialCode = `sketch001 = startSketchOn(XZ)
|
||||
profile001 = startProfileAt([0, 0], sketch001)
|
||||
|> yLine(length = 100)
|
||||
|> line(endAbsolute = [100, 0])
|
||||
@ -3474,7 +3474,7 @@ segAng(rectangleSegmentA002),
|
||||
await cmdBar.progressCmdBar()
|
||||
await cmdBar.progressCmdBar()
|
||||
|
||||
const newCodeToFind = `revolve001 = revolve(sketch002, angle = 360, axis = 'X')`
|
||||
const newCodeToFind = `revolve001 = revolve(sketch002, angle = 360, axis = X)`
|
||||
expect(editor.expectEditor.toContain(newCodeToFind)).toBeTruthy()
|
||||
|
||||
// Edit flow
|
||||
|
@ -828,7 +828,7 @@ test.describe(`Project management commands`, () => {
|
||||
const commandButton = page.getByRole('button', { name: 'Commands' })
|
||||
const commandOption = page.getByRole('option', { name: 'rename project' })
|
||||
const projectNameOption = page.getByRole('option', { name: projectName })
|
||||
const projectRenamedName = `project-000`
|
||||
const projectRenamedName = `untitled`
|
||||
// const projectMenuButton = page.getByTestId('project-sidebar-toggle')
|
||||
const commandContinueButton = page.getByRole('button', {
|
||||
name: 'Continue',
|
||||
@ -941,7 +941,7 @@ test.describe(`Project management commands`, () => {
|
||||
const commandButton = page.getByRole('button', { name: 'Commands' })
|
||||
const commandOption = page.getByRole('option', { name: 'rename project' })
|
||||
const projectNameOption = page.getByRole('option', { name: projectName })
|
||||
const projectRenamedName = `project-000`
|
||||
const projectRenamedName = `untitled`
|
||||
const commandContinueButton = page.getByRole('button', {
|
||||
name: 'Continue',
|
||||
})
|
||||
@ -1139,7 +1139,7 @@ test(`Create a few projects using the default project name`, async ({
|
||||
await test.step(`Create project ${i}`, async () => {
|
||||
await homePage.expectState({
|
||||
projectCards: Array.from({ length: i }, (_, i) => ({
|
||||
title: `project-${i.toString().padStart(3, '0')}`,
|
||||
title: i === 0 ? 'untitled' : `untitled-${i}`,
|
||||
fileCount: 1,
|
||||
})).toReversed(),
|
||||
sortBy: 'last-modified-desc',
|
||||
@ -1323,9 +1323,9 @@ test(
|
||||
})
|
||||
|
||||
await test.step('Check we can still create a project', async () => {
|
||||
await createProject({ name: 'project-000', page, returnHome: true })
|
||||
await createProject({ name: 'new-project', page, returnHome: true })
|
||||
await expect(
|
||||
page.getByTestId('project-link').filter({ hasText: 'project-000' })
|
||||
page.getByTestId('project-link').filter({ hasText: 'new-project' })
|
||||
).toBeVisible()
|
||||
})
|
||||
}
|
||||
|
@ -684,7 +684,7 @@ sketch001 = startSketchOn(XZ)
|
||||
|> line(end = [12.73, -0.09])
|
||||
|> tangentialArcTo([24.95, -5.38], %)
|
||||
|> close()
|
||||
|> revolve(axis = "X")`
|
||||
|> revolve(axis = X)`
|
||||
)
|
||||
})
|
||||
|
||||
@ -771,7 +771,7 @@ sketch001 = startSketchOn(XZ)
|
||||
|> tangentialArcTo([24.95, -5.38], %)
|
||||
|> line(end = [1.97, 2.06])
|
||||
|> close()
|
||||
|> revolve(axis = "X")`,
|
||||
|> revolve(axis = X)`,
|
||||
{ shouldNormalise: true }
|
||||
)
|
||||
})
|
||||
@ -1223,7 +1223,7 @@ profile001 = startProfileAt([${roundOff(scale * 69.6)}, ${roundOff(
|
||||
|> xLine(endAbsolute = 0 + .001)
|
||||
|> yLine(endAbsolute = 0)
|
||||
|> close()
|
||||
|> revolve(axis = "Y")
|
||||
|> revolve(axis = Y)
|
||||
|
||||
return lugSketch
|
||||
}
|
||||
|
@ -351,7 +351,7 @@ const extrudeDefaultPlane = async (
|
||||
},
|
||||
},
|
||||
project: {
|
||||
default_project_name: 'project-$nnn',
|
||||
default_project_name: 'untitled',
|
||||
},
|
||||
text_editor: {
|
||||
text_wrapping: true,
|
||||
|
@ -23,7 +23,7 @@ export const TEST_SETTINGS: DeepPartial<Settings> = {
|
||||
camera_projection: 'perspective',
|
||||
},
|
||||
project: {
|
||||
default_project_name: 'project-$nnn',
|
||||
default_project_name: 'untitled',
|
||||
directory: '',
|
||||
},
|
||||
text_editor: {
|
||||
|
@ -324,7 +324,7 @@ part009 = startSketchOn(XY)
|
||||
|> line(end = [0, pipeLength])
|
||||
|> angledLineToX({ angle = 60, to = pipeLargeDia }, %)
|
||||
|> close()
|
||||
rev = revolve(part009, axis = 'y')
|
||||
rev = revolve(part009, axis = Y)
|
||||
sketch006 = startSketchOn(XY)
|
||||
profile001 = circle(
|
||||
sketch006,
|
||||
@ -381,7 +381,7 @@ profile003 = startProfileAt([40.16, -120.48], sketch006)
|
||||
await page.waitForTimeout(200)
|
||||
|
||||
await expect(u.codeLocator).not.toContainText(
|
||||
`rev = revolve(part009, axis: 'y')`
|
||||
`rev = revolve(part009, axis: Y)`
|
||||
)
|
||||
|
||||
// FIXME (commented section below), this test would select a wall that had a sketch on it, and delete the underlying extrude
|
||||
|
@ -57,7 +57,7 @@ test.describe('Testing settings', () => {
|
||||
expect(storedSettings.settings?.modeling?.mouse_controls).toBe('zoo')
|
||||
expect(storedSettings.settings?.project?.directory).toBe('')
|
||||
expect(storedSettings.settings?.project?.default_project_name).toBe(
|
||||
'project-$nnn'
|
||||
'untitled'
|
||||
)
|
||||
})
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
data-domain="app.zoo.dev"
|
||||
src="https://plausible.corp.zoo.dev/js/script.tagged-events.js"
|
||||
></script>
|
||||
<title>Zoo Modeling App</title>
|
||||
<title>Zoo Design Studio</title>
|
||||
</head>
|
||||
<body class="body-bg">
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
|
@ -1 +1,13 @@
|
||||
$ dpdm --no-warning --no-tree -T --skip-dynamic-imports=circular src/index.tsx• Circular Dependencies 01) src/lang/std/sketch.ts -> src/lang/modifyAst.ts -> src/lang/modifyAst/addEdgeTreatment.ts 02) src/lang/std/sketch.ts -> src/lang/modifyAst.ts 03) src/lang/std/sketch.ts -> src/lang/modifyAst.ts -> src/lang/std/sketchcombos.ts 04) src/clientSideScene/CameraControls.ts -> src/clientSideScene/sceneInfra.ts 05) src/lib/singletons.ts -> src/editor/manager.ts -> src/lib/selections.ts 06) src/lib/singletons.ts -> src/editor/manager.ts 07) src/lib/singletons.ts -> src/lang/KclSingleton.ts 08) src/lib/singletons.ts -> src/lang/codeManager.ts 09) src/lib/singletons.ts -> src/clientSideScene/sceneEntities.ts -> src/clientSideScene/segments.ts -> src/components/Toolbar/angleLengthInfo.ts 10) src/lib/singletons.ts -> src/clientSideScene/sceneEntities.ts -> src/clientSideScene/segments.ts -> src/machines/commandBarMachine.ts -> src/lib/commandBarConfigs/authCommandConfig.ts -> src/machines/appMachine.ts -> src/machines/settingsMachine.ts -> src/lib/commandBarConfigs/settingsCommandConfig.ts -> src/lib/createMachineCommand.ts -> src/routes/Settings.tsx -> src/components/Settings/AllSettingsFields.tsx -> src/components/LspProvider.tsx -> src/editor/plugins/lsp/copilot/index.ts 11) src/lib/singletons.ts -> src/clientSideScene/sceneEntities.ts -> src/clientSideScene/segments.ts -> src/machines/commandBarMachine.ts -> src/lib/commandBarConfigs/authCommandConfig.ts -> src/machines/appMachine.ts -> src/machines/settingsMachine.ts -> src/lib/commandBarConfigs/settingsCommandConfig.ts -> src/lib/createMachineCommand.ts -> src/routes/Settings.tsx -> src/components/Settings/AllSettingsFields.tsx -> src/components/LspProvider.tsx -> src/editor/plugins/lsp/kcl/language.ts -> src/editor/plugins/lsp/kcl/index.ts 12) src/lib/singletons.ts -> src/clientSideScene/sceneEntities.ts -> src/clientSideScene/segments.ts -> src/machines/commandBarMachine.ts -> src/lib/commandBarConfigs/authCommandConfig.ts -> src/machines/appMachine.ts -> src/machines/settingsMachine.ts -> src/lib/commandBarConfigs/settingsCommandConfig.ts -> src/lib/createMachineCommand.ts -> src/routes/Settings.tsx -> src/components/Settings/AllSettingsFields.tsx -> src/components/LspProvider.tsx 13) src/machines/appMachine.ts -> src/machines/settingsMachine.ts -> src/lib/commandBarConfigs/settingsCommandConfig.ts -> src/lib/createMachineCommand.ts -> src/routes/Settings.tsx -> src/components/Settings/AllSettingsFields.tsx -> src/components/LspProvider.tsx 14) src/machines/appMachine.ts -> src/machines/settingsMachine.ts -> src/lib/commandBarConfigs/settingsCommandConfig.ts -> src/lib/createMachineCommand.ts -> src/routes/Settings.tsx -> src/components/Settings/AllSettingsFields.tsx -> src/components/Settings/SettingsFieldInput.tsx 15) src/machines/appMachine.ts -> src/machines/settingsMachine.ts -> src/lib/commandBarConfigs/settingsCommandConfig.ts -> src/lib/createMachineCommand.ts -> src/routes/Settings.tsx -> src/components/Settings/AllSettingsFields.tsx 16) src/routes/Settings.tsx -> src/components/Settings/AllSettingsFields.tsx 17) src/machines/appMachine.ts -> src/machines/settingsMachine.ts -> src/lib/commandBarConfigs/settingsCommandConfig.ts -> src/lib/createMachineCommand.ts -> src/routes/Settings.tsx -> src/components/Settings/SettingsSearchBar.tsx 18) src/machines/appMachine.ts -> src/machines/settingsMachine.ts -> src/lib/commandBarConfigs/settingsCommandConfig.ts -> src/lib/createMachineCommand.ts -> src/routes/Settings.tsx -> src/components/Settings/SettingsSectionsList.tsx 19) src/lib/singletons.ts -> src/clientSideScene/sceneEntities.ts -> src/clientSideScene/segments.ts -> src/machines/commandBarMachine.ts -> src/lib/commandBarConfigs/authCommandConfig.ts -> src/machines/appMachine.ts -> src/machines/settingsMachine.ts 20) src/machines/commandBarMachine.ts -> src/lib/commandBarConfigs/authCommandConfig.ts -> src/machines/appMachine.ts -> src/machines/settingsMachine.ts 21) src/hooks/useModelingContext.ts -> src/components/ModelingMachineProvider.tsx -> src/components/Toolbar/Intersect.tsx -> src/components/SetHorVertDistanceModal.tsx -> src/lib/useCalculateKclExpression.ts 22) src/components/ToastTextToCad.tsx -> src/lib/textToCad.ts 23) src/hooks/useModelingContext.ts -> src/components/ModelingMachineProvider.tsx -> src/machines/modelingMachine.ts -> src/clientSideScene/ClientSideSceneComp.tsx 24) src/routes/Onboarding/index.tsx -> src/routes/Onboarding/Camera.tsx -> src/routes/Onboarding/utils.tsx
|
||||
$ dpdm --no-warning --no-tree -T --skip-dynamic-imports=circular src/index.tsx
|
||||
• Circular Dependencies
|
||||
01) src/lang/std/sketch.ts -> src/lang/modifyAst.ts -> src/lang/modifyAst/addEdgeTreatment.ts
|
||||
02) src/lang/std/sketch.ts -> src/lang/modifyAst.ts
|
||||
03) src/lang/std/sketch.ts -> src/lang/modifyAst.ts -> src/lang/std/sketchcombos.ts
|
||||
04) src/lib/singletons.ts -> src/editor/manager.ts -> src/lib/selections.ts
|
||||
05) src/lib/singletons.ts -> src/lang/KclSingleton.ts
|
||||
06) src/lib/singletons.ts -> src/lang/codeManager.ts
|
||||
07) src/lib/singletons.ts -> src/clientSideScene/sceneEntities.ts -> src/clientSideScene/segments.ts -> src/components/Toolbar/angleLengthInfo.ts
|
||||
08) src/lib/singletons.ts -> src/clientSideScene/sceneEntities.ts -> src/clientSideScene/segments.ts -> src/machines/commandBarMachine.ts -> src/lib/commandBarConfigs/authCommandConfig.ts -> src/machines/appMachine.ts -> src/machines/settingsMachine.ts
|
||||
09) src/machines/commandBarMachine.ts -> src/lib/commandBarConfigs/authCommandConfig.ts -> src/machines/appMachine.ts -> src/machines/settingsMachine.ts
|
||||
10) src/hooks/useModelingContext.ts -> src/components/ModelingMachineProvider.tsx -> src/components/Toolbar/Intersect.tsx -> src/components/SetHorVertDistanceModal.tsx -> src/lib/useCalculateKclExpression.ts
|
||||
11) src/routes/Onboarding/index.tsx -> src/routes/Onboarding/Camera.tsx -> src/routes/Onboarding/utils.tsx
|
||||
|
@ -2,13 +2,13 @@
|
||||
"name": "zoo-modeling-app",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"productName": "Zoo Modeling App",
|
||||
"productName": "Zoo Design Studio",
|
||||
"author": {
|
||||
"name": "Zoo Corporation",
|
||||
"email": "info@zoo.dev",
|
||||
"url": "https://zoo.dev"
|
||||
},
|
||||
"description": "Zoo Modeling App",
|
||||
"description": "Zoo Design Studio",
|
||||
"main": ".vite/build/main.js",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@ -26,7 +26,7 @@
|
||||
"@fortawesome/react-fontawesome": "^0.2.0",
|
||||
"@headlessui/react": "^1.7.19",
|
||||
"@headlessui/tailwindcss": "^0.2.2",
|
||||
"@kittycad/lib": "2.0.25",
|
||||
"@kittycad/lib": "2.0.26",
|
||||
"@lezer/highlight": "^1.2.1",
|
||||
"@lezer/lr": "^1.4.1",
|
||||
"@react-hook/resize-observer": "^2.0.1",
|
||||
@ -103,6 +103,7 @@
|
||||
"lint-fix": "eslint --fix --ext .ts --ext .tsx src e2e packages/codemirror-lsp-client/src rust/kcl-language-server/client/src",
|
||||
"lint": "eslint --max-warnings 0 --ext .ts --ext .tsx src e2e packages/codemirror-lsp-client/src rust/kcl-language-server/client/src",
|
||||
"circular-deps": "dpdm --no-warning --no-tree -T --skip-dynamic-imports=circular src/index.tsx",
|
||||
"circular-deps:overwrite": "yarn circular-deps | sed '$d' | grep -v '^yarn run' > known-circular.txt",
|
||||
"circular-deps:diff": "./scripts/diff-circular-deps.sh",
|
||||
"files:set-version": "echo \"$(jq --arg v \"$VERSION\" '.version=$v' package.json --indent 2)\" > package.json",
|
||||
"files:set-notes": "./scripts/set-files-notes.sh",
|
||||
@ -232,7 +233,7 @@
|
||||
"ts-node": "^10.0.0",
|
||||
"typescript": "^5.8.2",
|
||||
"typescript-eslint": "^8.26.1",
|
||||
"vite": "^5.4.12",
|
||||
"vite": "^5.4.16",
|
||||
"vite-plugin-package-version": "^1.1.0",
|
||||
"vite-plugin-top-level-await": "^1.5.0",
|
||||
"vite-tsconfig-paths": "^4.3.2",
|
||||
|
@ -683,9 +683,9 @@ vite-tsconfig-paths@^4.3.2:
|
||||
tsconfck "^3.0.3"
|
||||
|
||||
vite@^5.0.0:
|
||||
version "5.4.14"
|
||||
resolved "https://registry.yarnpkg.com/vite/-/vite-5.4.14.tgz#ff8255edb02134df180dcfca1916c37a6abe8408"
|
||||
integrity sha512-EK5cY7Q1D8JNhSaPKVK4pwBFvaTmZxEnoKXLG/U9gmdDcihQGNzFlgIvaxezFR4glP1LsuiedwMBqCXH3wZccA==
|
||||
version "5.4.16"
|
||||
resolved "https://registry.yarnpkg.com/vite/-/vite-5.4.16.tgz#471983257a890ef33f2700cbbbc2134f2d08abf1"
|
||||
integrity sha512-Y5gnfp4NemVfgOTDQAunSD4346fal44L9mszGGY/e+qxsRT5y1sMlS/8tiQ8AFAp+MFgYNSINdfEchJiPm41vQ==
|
||||
dependencies:
|
||||
esbuild "^0.21.3"
|
||||
postcss "^8.4.43"
|
||||
|
@ -31,7 +31,7 @@ data = {
|
||||
|
||||
{modified_release_body}
|
||||
'''),
|
||||
"username": "Modeling App Release Updates",
|
||||
"username": "Design Studio Release Updates",
|
||||
"avatar_url": "https://raw.githubusercontent.com/KittyCAD/modeling-app/main/public/discord-avatar.png"
|
||||
}
|
||||
|
||||
|
@ -4,9 +4,9 @@
|
||||
|
||||
First off, thank you so much for your interest in being a part of the closed Alpha program! We are thrilled to have others use our product and see what you build with it (and truthfully, how you break it too).
|
||||
|
||||
### Zoo Modeling App (ZMA)
|
||||
### Zoo Design Studio (ZMA)
|
||||
|
||||
What we are introducing to you is our Zoo Modeling App (ZMA). ZMA is a CAD application that expresses a hybrid style of traditional CAD interface along with a code-CAD interface. ZMA is a great way for us to test our own APIs as well as inspire others to develop their own applications.
|
||||
What we are introducing to you is our Zoo Design Studio (ZMA). ZMA is a CAD application that expresses a hybrid style of traditional CAD interface along with a code-CAD interface. ZMA is a great way for us to test our own APIs as well as inspire others to develop their own applications.
|
||||
|
||||
### Why Code?
|
||||
|
||||
|
@ -35,7 +35,7 @@ ballsSketch = startSketchOn(XY)
|
||||
|> close()
|
||||
|
||||
// Revolve the ball to make a sphere and pattern around the inside wall
|
||||
balls = revolve(ballsSketch, axis = "X")
|
||||
balls = revolve(ballsSketch, axis = X)
|
||||
|> patternCircular3d(
|
||||
arcDegrees = 360,
|
||||
axis = [0, 0, 1],
|
||||
@ -60,7 +60,7 @@ chainSketch = startSketchOn(XY)
|
||||
|> close()
|
||||
|
||||
// Revolve the chain sketch
|
||||
chainHead = revolve(chainSketch, axis = "X")
|
||||
chainHead = revolve(chainSketch, axis = X)
|
||||
|> patternCircular3d(
|
||||
arcDegrees = 360,
|
||||
axis = [0, 0, 1],
|
||||
@ -80,7 +80,7 @@ linkSketch = startSketchOn(XZ)
|
||||
)
|
||||
|
||||
// Revolve the link sketch
|
||||
linkRevolve = revolve(linkSketch, axis = 'Y', angle = 360 / nBalls)
|
||||
linkRevolve = revolve(linkSketch, axis = Y, angle = 360 / nBalls)
|
||||
|> patternCircular3d(
|
||||
arcDegrees = 360,
|
||||
axis = [0, 0, 1],
|
||||
|
@ -80,5 +80,5 @@ brakeCaliperSketch = startSketchOn(XY)
|
||||
|> close()
|
||||
|
||||
// Revolve the brake caliper sketch
|
||||
revolve(brakeCaliperSketch, axis = "Y", angle = -70)
|
||||
revolve(brakeCaliperSketch, axis = Y, angle = -70)
|
||||
|> appearance(color = "#c82d2d", metalness = 90, roughness = 90)
|
||||
|
@ -41,5 +41,5 @@ tireSketch = startSketchOn(XY)
|
||||
|> close()
|
||||
|
||||
// Revolve the sketch to create the tire
|
||||
revolve(tireSketch, axis = "Y")
|
||||
revolve(tireSketch, axis = Y)
|
||||
|> appearance(color = "#0f0f0f", roughness = 80)
|
||||
|
@ -54,7 +54,7 @@ wheelCenterInner = startSketchOn(XY)
|
||||
|> yLine(endAbsolute = 0)
|
||||
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|
||||
|> close()
|
||||
|> revolve(axis = 'y')
|
||||
|> revolve(axis = Y)
|
||||
|> appearance(color = "#ffffff", metalness = 0, roughness = 0)
|
||||
|
||||
wheelCenterOuter = startSketchOn(XY)
|
||||
@ -68,7 +68,7 @@ wheelCenterOuter = startSketchOn(XY)
|
||||
|> yLine(endAbsolute = -wheelWidth / 20)
|
||||
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|
||||
|> close()
|
||||
|> revolve(axis = 'y')
|
||||
|> revolve(axis = Y)
|
||||
|> appearance(color = "#ffffff", metalness = 0, roughness = 0)
|
||||
|
||||
// Write a function that defines the spoke geometry, patterns and extrudes it
|
||||
@ -173,5 +173,5 @@ startSketchOn(XY)
|
||||
|> xLine(length = wheelWidth * 0.03)
|
||||
|> yLine(length = wheelWidth * 0.05)
|
||||
|> close()
|
||||
|> revolve(axis = 'y')
|
||||
|> revolve(axis = Y)
|
||||
|> appearance(color = "#ffffff", metalness = 0, roughness = 0)
|
||||
|
@ -32,7 +32,7 @@ fn lug(plane, length, diameter) {
|
||||
|> xLine(endAbsolute = lugThreadDiameter)
|
||||
|> yLine(endAbsolute = 0)
|
||||
|> close()
|
||||
|> revolve(axis = "Y")
|
||||
|> revolve(axis = Y)
|
||||
|> appearance(color = "#dbcd70", roughness = 90, metalness = 90)
|
||||
return lugSketch
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ sketch001 = startSketchOn(XZ)
|
||||
], %, $rectangleSegmentC001)
|
||||
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|
||||
|> close()
|
||||
|> revolve(angle = 360, axis = 'Y')
|
||||
|> revolve(angle = 360, axis = Y)
|
||||
|
||||
// Create an angled plane to sketch the supports
|
||||
plane001 = {
|
||||
@ -132,7 +132,7 @@ sketch005 = startSketchOn(XZ)
|
||||
|> xLine(endAbsolute = 0.15)
|
||||
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|
||||
|> close()
|
||||
|> revolve(axis = 'y')
|
||||
|> revolve(axis = Y)
|
||||
|
||||
// Plunger and stem
|
||||
sketch006 = startSketchOn(XZ)
|
||||
@ -145,7 +145,7 @@ sketch006 = startSketchOn(XZ)
|
||||
|> tangentialArc({ radius = 0.6, offset = -90 }, %)
|
||||
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|
||||
|> close()
|
||||
|> revolve(axis = 'y')
|
||||
|> revolve(axis = Y)
|
||||
|
||||
// Spiral plate
|
||||
sketch007 = startSketchOn(offsetPlane(XY, offset = 1.12))
|
||||
@ -201,7 +201,7 @@ sketch011 = startSketchOn(XZ)
|
||||
}, %)
|
||||
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|
||||
|> close()
|
||||
|> revolve(axis = 'y')
|
||||
|> revolve(axis = Y)
|
||||
|
||||
// Draw and extrude handle
|
||||
sketch012 = startSketchOn(offsetPlane(XZ, offset = handleThickness / 2))
|
||||
|
@ -48,10 +48,8 @@ sides = patternCircular3d(
|
||||
|
||||
// define an axis axis000
|
||||
axis000 = {
|
||||
custom = {
|
||||
axis = [0.0, 1.0],
|
||||
origin = [cornerRadius, cornerRadius]
|
||||
}
|
||||
direction = [0.0, 1.0],
|
||||
origin = [cornerRadius, cornerRadius]
|
||||
}
|
||||
|
||||
// create a single corner of the bin
|
||||
|
@ -45,10 +45,8 @@ sides = patternCircular3d(
|
||||
|
||||
// define an axis axis000
|
||||
axis000 = {
|
||||
custom = {
|
||||
axis = [0.0, 1.0],
|
||||
origin = [cornerRadius, cornerRadius]
|
||||
}
|
||||
direction = [0.0, 1.0],
|
||||
origin = [cornerRadius, cornerRadius]
|
||||
}
|
||||
|
||||
// create a single corner of the bin
|
||||
|
@ -65,13 +65,11 @@ sides = patternCircular3d(
|
||||
|
||||
// define an axis axis000
|
||||
axis000 = {
|
||||
custom = {
|
||||
axis = [0.0, 1.0],
|
||||
origin = [
|
||||
cornerRadius + binTol,
|
||||
cornerRadius + binTol
|
||||
]
|
||||
}
|
||||
direction = [0.0, 1.0],
|
||||
origin = [
|
||||
cornerRadius + binTol,
|
||||
cornerRadius + binTol
|
||||
]
|
||||
}
|
||||
|
||||
// create a single corner of the bin
|
||||
@ -272,10 +270,8 @@ lipWidths = patternCircular3d(
|
||||
|
||||
// define an axis axis000
|
||||
axis001 = {
|
||||
custom = {
|
||||
axis = [0.0, 1.0],
|
||||
origin = [cornerRadius, cornerRadius]
|
||||
}
|
||||
direction = [0.0, 1.0],
|
||||
origin = [cornerRadius, cornerRadius]
|
||||
}
|
||||
|
||||
// create a single corner of the bin
|
||||
|
@ -58,13 +58,11 @@ sides = patternCircular3d(
|
||||
|
||||
// define an axis axis000
|
||||
axis000 = {
|
||||
custom = {
|
||||
axis = [0.0, 1.0],
|
||||
origin = [
|
||||
cornerRadius + binTol,
|
||||
cornerRadius + binTol
|
||||
]
|
||||
}
|
||||
direction = [0.0, 1.0],
|
||||
origin = [
|
||||
cornerRadius + binTol,
|
||||
cornerRadius + binTol
|
||||
]
|
||||
}
|
||||
|
||||
// create a single corner of the bin
|
||||
|
@ -20,6 +20,6 @@ sketch001 = startSketchOn(-XZ)
|
||||
|> xLine(endAbsolute = webThickness / 2 + rootRadius)
|
||||
|> tangentialArc({ radius = rootRadius, offset = 90 }, %)
|
||||
|> yLine(endAbsolute = 0)
|
||||
|> mirror2d({ axis = 'X' }, %)
|
||||
|> mirror2d({ axis = 'Y' }, %)
|
||||
|> mirror2d(axis = X)
|
||||
|> mirror2d(axis = Y)
|
||||
|> extrude(length = beamLength)
|
||||
|
@ -24,4 +24,4 @@ pipeProfile = outerProfile
|
||||
|> hole(innerProfile, %)
|
||||
|
||||
// revolve the pipe profile at the desired angle
|
||||
pipe = revolve(pipeProfile, axis = 'Y', angle = bendAngle)
|
||||
pipe = revolve(pipeProfile, axis = Y, angle = bendAngle)
|
||||
|
@ -33,4 +33,4 @@ pipeSketch = startSketchOn(XY)
|
||||
|> close()
|
||||
|
||||
// Revolve the sketch to create the pipe
|
||||
pipe = revolve(pipeSketch, axis = 'y')
|
||||
pipe = revolve(pipeSketch, axis = Y)
|
||||
|
@ -34,10 +34,8 @@ part001 = revolve(
|
||||
sketch001,
|
||||
angle = 90,
|
||||
axis = {
|
||||
custom = {
|
||||
axis = [1.0, 0.0],
|
||||
origin = [0.0, height + .0001]
|
||||
}
|
||||
direction = [1.0, 0.0],
|
||||
origin = [0.0, height + .0001]
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -21,7 +21,7 @@ export fn knob() {
|
||||
}, %)
|
||||
|> xLine(endAbsolute = 0.0001)
|
||||
|> close()
|
||||
|> revolve(axis = "Y")
|
||||
|> revolve(axis = Y)
|
||||
|> appearance(color = '#D0FF01', metalness = 90, roughness = 50)
|
||||
|
||||
return knob
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"short_name": "ZMA",
|
||||
"name": "Zoo Modeling App",
|
||||
"name": "Zoo Design Studio",
|
||||
"icons": [
|
||||
{
|
||||
"src": "favicon.ico",
|
||||
|
@ -1,4 +1,4 @@
|
||||
## Zoo Modeling App Roadmap
|
||||
## Zoo Design Studio Roadmap
|
||||
|
||||
This document ties into our [GH Discussions Feature List](https://github.com/KittyCAD/modeling-app/discussions). Please upvote any features that you want to see next, or add ones that are not listed and we will review.
|
||||
|
||||
|
20
rust/Cargo.lock
generated
20
rust/Cargo.lock
generated
@ -1780,7 +1780,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kcl-bumper"
|
||||
version = "0.1.57"
|
||||
version = "0.1.58"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
@ -1791,7 +1791,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kcl-derive-docs"
|
||||
version = "0.1.57"
|
||||
version = "0.1.58"
|
||||
dependencies = [
|
||||
"Inflector",
|
||||
"anyhow",
|
||||
@ -1810,7 +1810,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kcl-directory-test-macro"
|
||||
version = "0.1.57"
|
||||
version = "0.1.58"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -1819,7 +1819,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kcl-language-server"
|
||||
version = "0.2.57"
|
||||
version = "0.2.58"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
@ -1840,7 +1840,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kcl-language-server-release"
|
||||
version = "0.1.57"
|
||||
version = "0.1.58"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
@ -1860,7 +1860,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kcl-lib"
|
||||
version = "0.2.57"
|
||||
version = "0.2.58"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"approx 0.5.1",
|
||||
@ -1928,7 +1928,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kcl-python-bindings"
|
||||
version = "0.3.57"
|
||||
version = "0.3.58"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"kcl-lib",
|
||||
@ -1943,7 +1943,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kcl-test-server"
|
||||
version = "0.1.57"
|
||||
version = "0.1.58"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"hyper 0.14.32",
|
||||
@ -1956,7 +1956,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kcl-to-core"
|
||||
version = "0.1.57"
|
||||
version = "0.1.58"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@ -1970,7 +1970,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kcl-wasm-lib"
|
||||
version = "0.1.57"
|
||||
version = "0.1.58"
|
||||
dependencies = [
|
||||
"bson",
|
||||
"console_error_panic_hook",
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
[package]
|
||||
name = "kcl-bumper"
|
||||
version = "0.1.57"
|
||||
version = "0.1.58"
|
||||
edition = "2021"
|
||||
repository = "https://github.com/KittyCAD/modeling-api"
|
||||
rust-version = "1.76"
|
||||
|
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "kcl-derive-docs"
|
||||
description = "A tool for generating documentation from Rust derive macros"
|
||||
version = "0.1.57"
|
||||
version = "0.1.58"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
repository = "https://github.com/KittyCAD/modeling-app"
|
||||
|
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "kcl-directory-test-macro"
|
||||
description = "A tool for generating tests from a directory of kcl files"
|
||||
version = "0.1.57"
|
||||
version = "0.1.58"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
repository = "https://github.com/KittyCAD/modeling-app"
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "kcl-language-server-release"
|
||||
version = "0.1.57"
|
||||
version = "0.1.58"
|
||||
edition = "2021"
|
||||
authors = ["KittyCAD Inc <kcl@kittycad.io>"]
|
||||
publish = false
|
||||
|
@ -2,7 +2,7 @@
|
||||
name = "kcl-language-server"
|
||||
description = "A language server for KCL."
|
||||
authors = ["KittyCAD Inc <kcl@kittycad.io>"]
|
||||
version = "0.2.57"
|
||||
version = "0.2.58"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "kcl-lib"
|
||||
description = "KittyCAD Language implementation and tools"
|
||||
version = "0.2.57"
|
||||
version = "0.2.58"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
repository = "https://github.com/KittyCAD/modeling-app"
|
||||
|
@ -881,7 +881,7 @@ async fn kcl_test_simple_revolve() {
|
||||
|> line(end = [0, -5.5])
|
||||
|> line(end = [-2, 0])
|
||||
|> close()
|
||||
|> revolve(axis = 'y')
|
||||
|> revolve(axis = Y)
|
||||
|
||||
"#;
|
||||
|
||||
@ -901,7 +901,7 @@ async fn kcl_test_simple_revolve_uppercase() {
|
||||
|> line(end = [0, -5.5])
|
||||
|> line(end = [-2, 0])
|
||||
|> close()
|
||||
|> revolve(axis = 'Y')
|
||||
|> revolve(axis = Y)
|
||||
|
||||
"#;
|
||||
|
||||
@ -921,7 +921,7 @@ async fn kcl_test_simple_revolve_negative() {
|
||||
|> line(end = [0, -5.5])
|
||||
|> line(end = [-2, 0])
|
||||
|> close()
|
||||
|> revolve(axis = '-Y', angle = 180)
|
||||
|> revolve(axis = -Y, angle = 180)
|
||||
|
||||
"#;
|
||||
|
||||
@ -941,7 +941,7 @@ async fn kcl_test_revolve_bad_angle_low() {
|
||||
|> line(end = [0, -5.5])
|
||||
|> line(end = [-2, 0])
|
||||
|> close()
|
||||
|> revolve(axis = 'y', angle = -455)
|
||||
|> revolve(axis = Y, angle = -455)
|
||||
|
||||
"#;
|
||||
|
||||
@ -967,7 +967,7 @@ async fn kcl_test_revolve_bad_angle_high() {
|
||||
|> line(end = [0, -5.5])
|
||||
|> line(end = [-2, 0])
|
||||
|> close()
|
||||
|> revolve(axis = 'y', angle = 455)
|
||||
|> revolve(axis = Y, angle = 455)
|
||||
|
||||
"#;
|
||||
|
||||
@ -993,7 +993,7 @@ async fn kcl_test_simple_revolve_custom_angle() {
|
||||
|> line(end = [0, -5.5])
|
||||
|> line(end = [-2, 0])
|
||||
|> close()
|
||||
|> revolve(axis = 'y', angle = 180)
|
||||
|> revolve(axis = Y, angle = 180)
|
||||
|
||||
"#;
|
||||
|
||||
@ -1013,7 +1013,7 @@ async fn kcl_test_simple_revolve_custom_axis() {
|
||||
|> line(end = [0, -5.5])
|
||||
|> line(end = [-2, 0])
|
||||
|> close()
|
||||
|> revolve(axis = {custom: {axis: [0, -1], origin: [0,0]}}, angle = 180)
|
||||
|> revolve(axis = { direction = [0, -1], origin: [0,0] }, angle = 180)
|
||||
|
||||
"#;
|
||||
|
||||
@ -1111,7 +1111,7 @@ sketch001 = startSketchOn(box, "END")
|
||||
|> circle(center = [10,10], radius= 4 )
|
||||
|> revolve(
|
||||
angle = -90,
|
||||
axis = 'y'
|
||||
axis = Y
|
||||
)
|
||||
"#;
|
||||
|
||||
@ -1136,7 +1136,7 @@ sketch001 = startSketchOn(box, "end")
|
||||
|> line(end = [0, 10])
|
||||
|> close()
|
||||
|> revolve(
|
||||
axis = 'y',
|
||||
axis = Y,
|
||||
angle = -90,
|
||||
)
|
||||
"#;
|
||||
@ -1151,7 +1151,7 @@ async fn kcl_test_basic_revolve_circle() {
|
||||
|> circle(center = [15, 0], radius= 5)
|
||||
|> revolve(
|
||||
angle = 360,
|
||||
axis = 'y'
|
||||
axis = Y
|
||||
)
|
||||
"#;
|
||||
|
||||
@ -1171,7 +1171,7 @@ async fn kcl_test_simple_revolve_sketch_on_edge() {
|
||||
|> line(end = [0, -5.5])
|
||||
|> line(end = [-2, 0])
|
||||
|> close()
|
||||
|> revolve(axis = 'y', angle = 180)
|
||||
|> revolve(axis = Y, angle = 180)
|
||||
|
||||
part002 = startSketchOn(part001, 'end')
|
||||
|> startProfileAt([4.5, -5], %)
|
||||
|
@ -164,7 +164,7 @@ impl CoreDumpInfo {
|
||||

|
||||
|
||||
> _Note: If you are capturing from a browser there is limited support for screenshots, only captures the modeling scene.
|
||||
If you are on MacOS native screenshots may be disabled by default. To enable native screenshots add Zoo Modeling App to System Settings -> Screen & SystemAudio Recording for native screenshots._
|
||||
If you are on MacOS native screenshots may be disabled by default. To enable native screenshots add Zoo Design Studio to System Settings -> Screen & SystemAudio Recording for native screenshots._
|
||||
|
||||
<details>
|
||||
<summary><b>Core Dump</b></summary>
|
||||
|
@ -24,8 +24,9 @@ use crate::{
|
||||
const TYPES_DIR: &str = "../../docs/kcl/types";
|
||||
const LANG_TOPICS: [&str; 5] = ["Types", "Modules", "Settings", "Known Issues", "Constants"];
|
||||
// These types are declared in std.
|
||||
const DECLARED_TYPES: [&str; 11] = [
|
||||
"number", "string", "tag", "bool", "Sketch", "Solid", "Plane", "Helix", "Face", "Point2d", "Point3d",
|
||||
const DECLARED_TYPES: [&str; 14] = [
|
||||
"number", "string", "tag", "bool", "Sketch", "Solid", "Plane", "Helix", "Face", "Edge", "Point2d", "Point3d",
|
||||
"Axis2d", "Axis3d",
|
||||
];
|
||||
|
||||
fn init_handlebars() -> Result<handlebars::Handlebars<'static>> {
|
||||
@ -241,7 +242,7 @@ fn init_handlebars() -> Result<handlebars::Handlebars<'static>> {
|
||||
out: &mut dyn handlebars::Output|
|
||||
-> handlebars::HelperResult {
|
||||
let param = h.param(0).and_then(|v| v.value().as_str()).unwrap_or("");
|
||||
let basename = param.split('/').last().unwrap_or("");
|
||||
let basename = param.split('/').next_back().unwrap_or("");
|
||||
out.write(&format!("`{}`", basename))?;
|
||||
Ok(())
|
||||
},
|
||||
|
@ -508,6 +508,7 @@ pub struct ArgData {
|
||||
pub ty: Option<String>,
|
||||
/// If the argument is required.
|
||||
pub kind: ArgKind,
|
||||
pub override_in_snippet: Option<bool>,
|
||||
/// Additional information that could be used instead of the type's description.
|
||||
/// This is helpful if the type is really basic, like "number" -- that won't tell the user much about
|
||||
/// how this argument is meant to be used.
|
||||
@ -528,6 +529,7 @@ impl ArgData {
|
||||
name: arg.identifier.name.clone(),
|
||||
ty: arg.type_.as_ref().map(|t| t.to_string()),
|
||||
docs: None,
|
||||
override_in_snippet: None,
|
||||
kind: if arg.labeled {
|
||||
ArgKind::Labelled(arg.optional())
|
||||
} else {
|
||||
@ -535,26 +537,51 @@ impl ArgData {
|
||||
},
|
||||
};
|
||||
|
||||
for attr in &arg.identifier.outer_attrs {
|
||||
if let Annotation {
|
||||
name: None,
|
||||
properties: Some(props),
|
||||
..
|
||||
} = &attr.inner
|
||||
{
|
||||
for p in props {
|
||||
if p.key.name == "include_in_snippet" {
|
||||
if let Some(b) = p.value.literal_bool() {
|
||||
result.override_in_snippet = Some(b);
|
||||
} else {
|
||||
panic!(
|
||||
"Invalid value for `include_in_snippet`, expected bool literal, found {:?}",
|
||||
p.value
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result.with_comments(&arg.identifier.pre_comments);
|
||||
result
|
||||
}
|
||||
|
||||
pub fn get_autocomplete_snippet(&self, index: usize) -> Option<(usize, String)> {
|
||||
match self.override_in_snippet {
|
||||
Some(false) => return None,
|
||||
None if !self.kind.required() => return None,
|
||||
_ => {}
|
||||
}
|
||||
|
||||
let label = if self.kind == ArgKind::Special {
|
||||
String::new()
|
||||
} else {
|
||||
format!("{} = ", self.name)
|
||||
};
|
||||
match self.ty.as_deref() {
|
||||
Some(s) if ["Sketch", "Solid", "Plane | Face", "Sketch | Plane | Face"].contains(&s) => {
|
||||
Some((index, format!("{label}${{{}:{}}}", index, "%")))
|
||||
}
|
||||
Some("number") if self.kind.required() => Some((index, format!(r#"{label}${{{}:3.14}}"#, index))),
|
||||
Some("Point2d") if self.kind.required() => Some((
|
||||
Some(s) if s.starts_with("number") => Some((index, format!(r#"{label}${{{}:3.14}}"#, index))),
|
||||
Some("Point2d") => Some((
|
||||
index + 1,
|
||||
format!(r#"{label}[${{{}:3.14}}, ${{{}:3.14}}]"#, index, index + 1),
|
||||
)),
|
||||
Some("Point3d") if self.kind.required() => Some((
|
||||
Some("Point3d") => Some((
|
||||
index + 2,
|
||||
format!(
|
||||
r#"{label}[${{{}:3.14}}, ${{{}:3.14}}, ${{{}:3.14}}]"#,
|
||||
@ -563,8 +590,10 @@ impl ArgData {
|
||||
index + 2
|
||||
),
|
||||
)),
|
||||
Some("string") if self.kind.required() => Some((index, format!(r#"{label}${{{}:"string"}}"#, index))),
|
||||
Some("bool") if self.kind.required() => Some((index, format!(r#"{label}${{{}:false}}"#, index))),
|
||||
Some("Axis2d | Edge") | Some("Axis3d | Edge") => Some((index, format!(r#"{label}${{{}:X}}"#, index))),
|
||||
|
||||
Some("string") => Some((index, format!(r#"{label}${{{}:"string"}}"#, index))),
|
||||
Some("bool") => Some((index, format!(r#"{label}${{{}:false}}"#, index))),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
@ -612,7 +612,7 @@ pub fn get_description_string_from_schema(schema: &schemars::schema::RootSchema)
|
||||
}
|
||||
|
||||
if let Some(reference) = &schema.schema.reference {
|
||||
if let Some(definition) = schema.definitions.get(reference.split('/').last().unwrap_or("")) {
|
||||
if let Some(definition) = schema.definitions.get(reference.split('/').next_back().unwrap_or("")) {
|
||||
let schemars::schema::Schema::Object(definition) = definition else {
|
||||
return None;
|
||||
};
|
||||
@ -937,9 +937,12 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn get_autocomplete_snippet_revolve() {
|
||||
let revolve_fn: Box<dyn StdLibFn> = Box::new(crate::std::revolve::Revolve);
|
||||
let snippet = revolve_fn.to_autocomplete_snippet().unwrap();
|
||||
assert_eq!(snippet, r#"revolve(${0:%}, axis = ${1:"X"})${}"#);
|
||||
let data = kcl_doc::walk_prelude();
|
||||
let DocData::Fn(revolve_fn) = data.into_iter().find(|d| d.name() == "revolve").unwrap() else {
|
||||
panic!();
|
||||
};
|
||||
let snippet = revolve_fn.to_autocomplete_snippet();
|
||||
assert_eq!(snippet, r#"revolve(axis = ${0:X})${}"#);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -952,7 +955,7 @@ mod tests {
|
||||
let snippet = circle_fn.to_autocomplete_snippet();
|
||||
assert_eq!(
|
||||
snippet,
|
||||
r#"circle(${0:%}, center = [${1:3.14}, ${2:3.14}], radius = ${3:3.14})${}"#
|
||||
r#"circle(center = [${0:3.14}, ${1:3.14}], radius = ${2:3.14})${}"#
|
||||
);
|
||||
}
|
||||
|
||||
@ -1026,11 +1029,14 @@ mod tests {
|
||||
#[test]
|
||||
#[allow(clippy::literal_string_with_formatting_args)]
|
||||
fn get_autocomplete_snippet_helix() {
|
||||
let helix_fn: Box<dyn StdLibFn> = Box::new(crate::std::helix::Helix);
|
||||
let snippet = helix_fn.to_autocomplete_snippet().unwrap();
|
||||
let data = kcl_doc::walk_prelude();
|
||||
let DocData::Fn(helix_fn) = data.into_iter().find(|d| d.name() == "helix").unwrap() else {
|
||||
panic!();
|
||||
};
|
||||
let snippet = helix_fn.to_autocomplete_snippet();
|
||||
assert_eq!(
|
||||
snippet,
|
||||
r#"helix(revolutions = ${0:3.14}, angleStart = ${1:3.14}, radius = ${2:3.14}, axis = ${3:"X"}, length = ${4:3.14})${}"#
|
||||
r#"helix(revolutions = ${0:3.14}, angleStart = ${1:3.14}, radius = ${2:3.14}, axis = ${3:X}, length = ${4:3.14})${}"#
|
||||
);
|
||||
}
|
||||
|
||||
|
2
rust/kcl-lib/src/docs/templates/index.hbs
vendored
2
rust/kcl-lib/src/docs/templates/index.hbs
vendored
@ -1,6 +1,6 @@
|
||||
---
|
||||
title: "KCL Standard Library"
|
||||
excerpt: "Documentation for the KCL standard library for the Zoo Modeling App."
|
||||
excerpt: "Documentation for the KCL standard library for the Zoo Design Studio."
|
||||
layout: manual
|
||||
---
|
||||
|
||||
|
@ -3,12 +3,12 @@ use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::{types::NumericType, ArtifactId, KclValue};
|
||||
use crate::{docs::StdLibFn, std::get_stdlib_fn, SourceRange};
|
||||
use crate::{docs::StdLibFn, std::get_stdlib_fn, ModuleId, SourceRange};
|
||||
|
||||
/// A CAD modeling operation for display in the feature tree, AKA operations
|
||||
/// timeline.
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
|
||||
#[ts(export)]
|
||||
#[ts(export_to = "Operation.ts")]
|
||||
#[serde(tag = "type")]
|
||||
pub enum Operation {
|
||||
#[serde(rename_all = "camelCase")]
|
||||
@ -27,7 +27,47 @@ pub enum Operation {
|
||||
is_error: bool,
|
||||
},
|
||||
#[serde(rename_all = "camelCase")]
|
||||
UserDefinedFunctionCall {
|
||||
KclStdLibCall {
|
||||
name: String,
|
||||
/// The unlabeled argument to the function.
|
||||
unlabeled_arg: Option<OpArg>,
|
||||
/// The labeled keyword arguments to the function.
|
||||
labeled_args: IndexMap<String, OpArg>,
|
||||
/// The source range of the operation in the source code.
|
||||
source_range: SourceRange,
|
||||
/// True if the operation resulted in an error.
|
||||
#[serde(default, skip_serializing_if = "is_false")]
|
||||
is_error: bool,
|
||||
},
|
||||
#[serde(rename_all = "camelCase")]
|
||||
GroupBegin {
|
||||
/// The details of the group.
|
||||
group: Group,
|
||||
/// The source range of the operation in the source code.
|
||||
source_range: SourceRange,
|
||||
},
|
||||
GroupEnd,
|
||||
}
|
||||
|
||||
impl Operation {
|
||||
/// If the variant is `StdLibCall`, set the `is_error` field.
|
||||
pub(crate) fn set_std_lib_call_is_error(&mut self, is_err: bool) {
|
||||
match self {
|
||||
Self::StdLibCall { ref mut is_error, .. } => *is_error = is_err,
|
||||
Self::KclStdLibCall { ref mut is_error, .. } => *is_error = is_err,
|
||||
Self::GroupBegin { .. } | Self::GroupEnd => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
|
||||
#[ts(export_to = "Operation.ts")]
|
||||
#[serde(tag = "type")]
|
||||
#[expect(clippy::large_enum_variant)]
|
||||
pub enum Group {
|
||||
/// A function call.
|
||||
#[serde(rename_all = "camelCase")]
|
||||
FunctionCall {
|
||||
/// The name of the user-defined function being called. Anonymous
|
||||
/// functions have no name.
|
||||
name: Option<String>,
|
||||
@ -38,25 +78,20 @@ pub enum Operation {
|
||||
unlabeled_arg: Option<OpArg>,
|
||||
/// The labeled keyword arguments to the function.
|
||||
labeled_args: IndexMap<String, OpArg>,
|
||||
/// The source range of the operation in the source code.
|
||||
source_range: SourceRange,
|
||||
},
|
||||
UserDefinedFunctionReturn,
|
||||
}
|
||||
|
||||
impl Operation {
|
||||
/// If the variant is `StdLibCall`, set the `is_error` field.
|
||||
pub(crate) fn set_std_lib_call_is_error(&mut self, is_err: bool) {
|
||||
match self {
|
||||
Self::StdLibCall { ref mut is_error, .. } => *is_error = is_err,
|
||||
Self::UserDefinedFunctionCall { .. } | Self::UserDefinedFunctionReturn => {}
|
||||
}
|
||||
}
|
||||
/// A whole-module import use.
|
||||
#[serde(rename_all = "camelCase")]
|
||||
ModuleInstance {
|
||||
/// The name of the module being used.
|
||||
name: String,
|
||||
/// The ID of the module which can be used to determine its path.
|
||||
module_id: ModuleId,
|
||||
},
|
||||
}
|
||||
|
||||
/// An argument to a CAD modeling operation.
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
|
||||
#[ts(export)]
|
||||
#[ts(export_to = "Operation.ts")]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct OpArg {
|
||||
/// The runtime value of the argument. Instead of using [`KclValue`], we
|
||||
@ -76,7 +111,7 @@ impl OpArg {
|
||||
/// A reference to a standard library function. This exists to implement
|
||||
/// `PartialEq` and `Eq` for `Operation`.
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, ts_rs::TS, JsonSchema)]
|
||||
#[ts(export)]
|
||||
#[ts(export_to = "Operation.ts")]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct StdLibFnRef {
|
||||
// The following doc comment gets inlined into Operation, overriding what's
|
||||
@ -140,7 +175,7 @@ fn is_false(b: &bool) -> bool {
|
||||
/// A KCL value used in Operations. `ArtifactId`s are used to refer to the
|
||||
/// actual scene objects. Any data not needed in the UI may be omitted.
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
|
||||
#[ts(export)]
|
||||
#[ts(export_to = "Operation.ts")]
|
||||
#[serde(tag = "type")]
|
||||
pub enum OpKclValue {
|
||||
Uuid {
|
||||
@ -198,21 +233,21 @@ pub enum OpKclValue {
|
||||
pub type OpKclObjectFields = IndexMap<String, OpKclValue>;
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
|
||||
#[ts(export)]
|
||||
#[ts(export_to = "Operation.ts")]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct OpSketch {
|
||||
artifact_id: ArtifactId,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
|
||||
#[ts(export)]
|
||||
#[ts(export_to = "Operation.ts")]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct OpSolid {
|
||||
artifact_id: ArtifactId,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
|
||||
#[ts(export)]
|
||||
#[ts(export_to = "Operation.ts")]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct OpHelix {
|
||||
artifact_id: ArtifactId,
|
||||
|
@ -3,7 +3,7 @@ use std::collections::HashMap;
|
||||
use async_recursion::async_recursion;
|
||||
use indexmap::IndexMap;
|
||||
|
||||
use super::kcl_value::TypeDef;
|
||||
use super::{cad_op::Group, kcl_value::TypeDef, types::PrimitiveType};
|
||||
use crate::{
|
||||
engine::ExecutionKind,
|
||||
errors::{KclError, KclErrorDetails},
|
||||
@ -20,7 +20,7 @@ use crate::{
|
||||
modules::{ModuleId, ModulePath, ModuleRepr},
|
||||
parsing::ast::types::{
|
||||
Annotation, ArrayExpression, ArrayRangeExpression, BinaryExpression, BinaryOperator, BinaryPart, BodyItem,
|
||||
CallExpression, CallExpressionKw, Expr, FunctionExpression, IfExpression, ImportPath, ImportSelector,
|
||||
BoxNode, CallExpression, CallExpressionKw, Expr, FunctionExpression, IfExpression, ImportPath, ImportSelector,
|
||||
ItemVisibility, LiteralIdentifier, LiteralValue, MemberExpression, MemberObject, Name, Node, NodeRef,
|
||||
ObjectExpression, PipeExpression, Program, TagDeclarator, Type, UnaryExpression, UnaryOperator,
|
||||
},
|
||||
@ -512,10 +512,19 @@ impl ExecutorContext {
|
||||
async fn exec_module_for_result(
|
||||
&self,
|
||||
module_id: ModuleId,
|
||||
module_name: &BoxNode<Name>,
|
||||
exec_state: &mut ExecState,
|
||||
exec_kind: ExecutionKind,
|
||||
source_range: SourceRange,
|
||||
) -> Result<Option<KclValue>, KclError> {
|
||||
exec_state.global.operations.push(Operation::GroupBegin {
|
||||
group: Group::ModuleInstance {
|
||||
name: module_name.to_string(),
|
||||
module_id,
|
||||
},
|
||||
source_range,
|
||||
});
|
||||
|
||||
let path = exec_state.global.module_infos[&module_id].path.clone();
|
||||
let mut repr = exec_state.global.module_infos[&module_id].take_repr();
|
||||
// DON'T EARLY RETURN! We need to restore the module repr
|
||||
@ -541,6 +550,9 @@ impl ExecutorContext {
|
||||
};
|
||||
|
||||
exec_state.global.module_infos[&module_id].restore_repr(repr);
|
||||
|
||||
exec_state.global.operations.push(Operation::GroupEnd);
|
||||
|
||||
result
|
||||
}
|
||||
|
||||
@ -592,7 +604,7 @@ impl ExecutorContext {
|
||||
Expr::Name(name) => {
|
||||
let value = name.get_result(exec_state, self).await?.clone();
|
||||
if let KclValue::Module { value: module_id, meta } = value {
|
||||
self.exec_module_for_result(module_id, exec_state, ExecutionKind::Normal, metadata.source_range)
|
||||
self.exec_module_for_result(module_id, name, exec_state, ExecutionKind::Normal, metadata.source_range)
|
||||
.await?
|
||||
.unwrap_or_else(|| {
|
||||
exec_state.warn(CompilationError::err(
|
||||
@ -902,6 +914,33 @@ impl Node<BinaryExpression> {
|
||||
}
|
||||
}
|
||||
|
||||
// Then check if we have solids.
|
||||
if self.operator == BinaryOperator::Add || self.operator == BinaryOperator::Or {
|
||||
if let (KclValue::Solid { value: left }, KclValue::Solid { value: right }) = (&left_value, &right_value) {
|
||||
let args = crate::std::Args::new(Default::default(), self.into(), ctx.clone(), None);
|
||||
let result =
|
||||
crate::std::csg::inner_union(vec![*left.clone(), *right.clone()], exec_state, args).await?;
|
||||
return Ok(result.into());
|
||||
}
|
||||
} else if self.operator == BinaryOperator::Sub {
|
||||
// Check if we have solids.
|
||||
if let (KclValue::Solid { value: left }, KclValue::Solid { value: right }) = (&left_value, &right_value) {
|
||||
let args = crate::std::Args::new(Default::default(), self.into(), ctx.clone(), None);
|
||||
let result =
|
||||
crate::std::csg::inner_subtract(vec![*left.clone()], vec![*right.clone()], exec_state, args)
|
||||
.await?;
|
||||
return Ok(result.into());
|
||||
}
|
||||
} else if self.operator == BinaryOperator::And {
|
||||
// Check if we have solids.
|
||||
if let (KclValue::Solid { value: left }, KclValue::Solid { value: right }) = (&left_value, &right_value) {
|
||||
let args = crate::std::Args::new(Default::default(), self.into(), ctx.clone(), None);
|
||||
let result =
|
||||
crate::std::csg::inner_intersect(vec![*left.clone(), *right.clone()], exec_state, args).await?;
|
||||
return Ok(result.into());
|
||||
}
|
||||
}
|
||||
|
||||
// Check if we are doing logical operations on booleans.
|
||||
if self.operator == BinaryOperator::Or || self.operator == BinaryOperator::And {
|
||||
let KclValue::Bool {
|
||||
@ -1032,6 +1071,15 @@ impl Node<UnaryExpression> {
|
||||
}
|
||||
|
||||
let value = &self.argument.get_result(exec_state, ctx).await?;
|
||||
let err = || {
|
||||
KclError::Semantic(KclErrorDetails {
|
||||
message: format!(
|
||||
"You can only negate numbers, planes, or lines, but this is a {}",
|
||||
value.human_friendly_type()
|
||||
),
|
||||
source_ranges: vec![self.into()],
|
||||
})
|
||||
};
|
||||
match value {
|
||||
KclValue::Number { value, ty, .. } => {
|
||||
let meta = vec![Metadata {
|
||||
@ -1053,13 +1101,63 @@ impl Node<UnaryExpression> {
|
||||
plane.id = exec_state.next_uuid();
|
||||
Ok(KclValue::Plane { value: plane })
|
||||
}
|
||||
_ => Err(KclError::Semantic(KclErrorDetails {
|
||||
message: format!(
|
||||
"You can only negate numbers or planes, but this is a {}",
|
||||
value.human_friendly_type()
|
||||
),
|
||||
source_ranges: vec![self.into()],
|
||||
})),
|
||||
KclValue::Object { value: values, meta } => {
|
||||
// Special-case for negating line-like objects.
|
||||
let Some(direction) = values.get("direction") else {
|
||||
return Err(err());
|
||||
};
|
||||
|
||||
let direction = match direction {
|
||||
KclValue::MixedArray { value: values, meta } => {
|
||||
let values = values
|
||||
.iter()
|
||||
.map(|v| match v {
|
||||
KclValue::Number { value, ty, meta } => Ok(KclValue::Number {
|
||||
value: *value * -1.0,
|
||||
ty: ty.clone(),
|
||||
meta: meta.clone(),
|
||||
}),
|
||||
_ => Err(err()),
|
||||
})
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
|
||||
KclValue::MixedArray {
|
||||
value: values,
|
||||
meta: meta.clone(),
|
||||
}
|
||||
}
|
||||
KclValue::HomArray {
|
||||
value: values,
|
||||
ty: ty @ RuntimeType::Primitive(PrimitiveType::Number(_)),
|
||||
} => {
|
||||
let values = values
|
||||
.iter()
|
||||
.map(|v| match v {
|
||||
KclValue::Number { value, ty, meta } => Ok(KclValue::Number {
|
||||
value: *value * -1.0,
|
||||
ty: ty.clone(),
|
||||
meta: meta.clone(),
|
||||
}),
|
||||
_ => Err(err()),
|
||||
})
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
|
||||
KclValue::HomArray {
|
||||
value: values,
|
||||
ty: ty.clone(),
|
||||
}
|
||||
}
|
||||
_ => return Err(err()),
|
||||
};
|
||||
|
||||
let mut value = values.clone();
|
||||
value.insert("direction".to_owned(), direction);
|
||||
Ok(KclValue::Object {
|
||||
value,
|
||||
meta: meta.clone(),
|
||||
})
|
||||
}
|
||||
_ => Err(err()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1245,27 +1343,6 @@ impl Node<CallExpressionKw> {
|
||||
// exec_state.
|
||||
let func = fn_name.get_result(exec_state, ctx).await?.clone();
|
||||
|
||||
if !ctx.is_isolated_execution().await {
|
||||
// Track call operation.
|
||||
let op_labeled_args = args
|
||||
.kw_args
|
||||
.labeled
|
||||
.iter()
|
||||
.map(|(k, arg)| (k.clone(), OpArg::new(OpKclValue::from(&arg.value), arg.source_range)))
|
||||
.collect();
|
||||
exec_state.global.operations.push(Operation::UserDefinedFunctionCall {
|
||||
name: Some(fn_name.to_string()),
|
||||
function_source_range: func.function_def_source_range().unwrap_or_default(),
|
||||
unlabeled_arg: args
|
||||
.kw_args
|
||||
.unlabeled
|
||||
.as_ref()
|
||||
.map(|arg| OpArg::new(OpKclValue::from(&arg.value), arg.source_range)),
|
||||
labeled_args: op_labeled_args,
|
||||
source_range: callsite,
|
||||
});
|
||||
}
|
||||
|
||||
let Some(fn_src) = func.as_fn() else {
|
||||
return Err(KclError::Semantic(KclErrorDetails {
|
||||
message: "cannot call this because it isn't a function".to_string(),
|
||||
@ -1273,11 +1350,19 @@ impl Node<CallExpressionKw> {
|
||||
}));
|
||||
};
|
||||
|
||||
let return_value = fn_src.call_kw(exec_state, ctx, args, callsite).await.map_err(|e| {
|
||||
// Add the call expression to the source ranges.
|
||||
// TODO currently ignored by the frontend
|
||||
e.add_source_ranges(vec![callsite])
|
||||
})?;
|
||||
let return_value = fn_src
|
||||
.call_kw(Some(fn_name.to_string()), exec_state, ctx, args, callsite)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
// Add the call expression to the source ranges.
|
||||
// TODO currently ignored by the frontend
|
||||
e.add_source_ranges(vec![callsite])
|
||||
})?;
|
||||
|
||||
if matches!(fn_src, FunctionSource::User { .. }) && !ctx.is_isolated_execution().await {
|
||||
// Track return operation.
|
||||
exec_state.global.operations.push(Operation::GroupEnd);
|
||||
}
|
||||
|
||||
let result = return_value.ok_or_else(move || {
|
||||
let mut source_ranges: Vec<SourceRange> = vec![callsite];
|
||||
@ -1291,11 +1376,6 @@ impl Node<CallExpressionKw> {
|
||||
})
|
||||
})?;
|
||||
|
||||
if !ctx.is_isolated_execution().await {
|
||||
// Track return operation.
|
||||
exec_state.global.operations.push(Operation::UserDefinedFunctionReturn);
|
||||
}
|
||||
|
||||
Ok(result)
|
||||
}
|
||||
}
|
||||
@ -1391,12 +1471,14 @@ impl Node<CallExpression> {
|
||||
|
||||
if !ctx.is_isolated_execution().await {
|
||||
// Track call operation.
|
||||
exec_state.global.operations.push(Operation::UserDefinedFunctionCall {
|
||||
name: Some(fn_name.to_string()),
|
||||
function_source_range: func.function_def_source_range().unwrap_or_default(),
|
||||
unlabeled_arg: None,
|
||||
// TODO: Add the arguments for legacy positional parameters.
|
||||
labeled_args: Default::default(),
|
||||
exec_state.global.operations.push(Operation::GroupBegin {
|
||||
group: Group::FunctionCall {
|
||||
name: Some(fn_name.to_string()),
|
||||
function_source_range: func.function_def_source_range().unwrap_or_default(),
|
||||
unlabeled_arg: None,
|
||||
// TODO: Add the arguments for legacy positional parameters.
|
||||
labeled_args: Default::default(),
|
||||
},
|
||||
source_range: callsite,
|
||||
});
|
||||
}
|
||||
@ -1407,11 +1489,14 @@ impl Node<CallExpression> {
|
||||
source_ranges: vec![source_range],
|
||||
}));
|
||||
};
|
||||
let return_value = fn_src.call(exec_state, ctx, fn_args, source_range).await.map_err(|e| {
|
||||
// Add the call expression to the source ranges.
|
||||
// TODO currently ignored by the frontend
|
||||
e.add_source_ranges(vec![source_range])
|
||||
})?;
|
||||
let return_value = fn_src
|
||||
.call(Some(fn_name.to_string()), exec_state, ctx, fn_args, source_range)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
// Add the call expression to the source ranges.
|
||||
// TODO currently ignored by the frontend
|
||||
e.add_source_ranges(vec![source_range])
|
||||
})?;
|
||||
|
||||
let result = return_value.ok_or_else(move || {
|
||||
let mut source_ranges: Vec<SourceRange> = vec![source_range];
|
||||
@ -1427,7 +1512,7 @@ impl Node<CallExpression> {
|
||||
|
||||
if !ctx.is_isolated_execution().await {
|
||||
// Track return operation.
|
||||
exec_state.global.operations.push(Operation::UserDefinedFunctionReturn);
|
||||
exec_state.global.operations.push(Operation::GroupEnd);
|
||||
}
|
||||
|
||||
Ok(result)
|
||||
@ -2037,6 +2122,7 @@ async fn call_user_defined_function_kw(
|
||||
impl FunctionSource {
|
||||
pub async fn call(
|
||||
&self,
|
||||
fn_name: Option<String>,
|
||||
exec_state: &mut ExecState,
|
||||
ctx: &ExecutorContext,
|
||||
mut args: Vec<Arg>,
|
||||
@ -2054,7 +2140,7 @@ impl FunctionSource {
|
||||
ctx.clone(),
|
||||
exec_state.mod_local.pipe_value.clone().map(|v| Arg::new(v, callsite)),
|
||||
);
|
||||
self.call_kw(exec_state, ctx, args, callsite).await
|
||||
self.call_kw(fn_name, exec_state, ctx, args, callsite).await
|
||||
} else {
|
||||
Err(KclError::Semantic(KclErrorDetails {
|
||||
message: format!("{} requires its arguments to be labelled", props.name),
|
||||
@ -2071,6 +2157,7 @@ impl FunctionSource {
|
||||
|
||||
pub async fn call_kw(
|
||||
&self,
|
||||
fn_name: Option<String>,
|
||||
exec_state: &mut ExecState,
|
||||
ctx: &ExecutorContext,
|
||||
mut args: crate::std::Args,
|
||||
@ -2154,6 +2241,26 @@ impl FunctionSource {
|
||||
}
|
||||
}
|
||||
|
||||
let op = if props.include_in_feature_tree && !ctx.is_isolated_execution().await {
|
||||
let op_labeled_args = args
|
||||
.kw_args
|
||||
.labeled
|
||||
.iter()
|
||||
.map(|(k, arg)| (k.clone(), OpArg::new(OpKclValue::from(&arg.value), arg.source_range)))
|
||||
.collect();
|
||||
Some(Operation::KclStdLibCall {
|
||||
name: fn_name.unwrap_or_default(),
|
||||
unlabeled_arg: args
|
||||
.unlabeled_kw_arg_unconverted()
|
||||
.map(|arg| OpArg::new(OpKclValue::from(&arg.value), arg.source_range)),
|
||||
labeled_args: op_labeled_args,
|
||||
source_range: callsite,
|
||||
is_error: false,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
// Attempt to call the function.
|
||||
exec_state.mut_stack().push_new_env_for_rust_call();
|
||||
let mut result = {
|
||||
@ -2161,7 +2268,15 @@ impl FunctionSource {
|
||||
let result = func(exec_state, args).await;
|
||||
exec_state.mut_stack().pop_env();
|
||||
|
||||
// TODO support recording op into the feature tree
|
||||
if let Some(mut op) = op {
|
||||
op.set_std_lib_call_is_error(result.is_err());
|
||||
// Track call operation. We do this after the call
|
||||
// since things like patternTransform may call user code
|
||||
// before running, and we will likely want to use the
|
||||
// return value. The call takes ownership of the args,
|
||||
// so we need to build the op before the call.
|
||||
exec_state.global.operations.push(op);
|
||||
}
|
||||
result
|
||||
}?;
|
||||
|
||||
@ -2170,6 +2285,29 @@ impl FunctionSource {
|
||||
Ok(Some(result))
|
||||
}
|
||||
FunctionSource::User { ast, memory, .. } => {
|
||||
if !ctx.is_isolated_execution().await {
|
||||
// Track call operation.
|
||||
let op_labeled_args = args
|
||||
.kw_args
|
||||
.labeled
|
||||
.iter()
|
||||
.map(|(k, arg)| (k.clone(), OpArg::new(OpKclValue::from(&arg.value), arg.source_range)))
|
||||
.collect();
|
||||
exec_state.global.operations.push(Operation::GroupBegin {
|
||||
group: Group::FunctionCall {
|
||||
name: fn_name,
|
||||
function_source_range: ast.as_source_range(),
|
||||
unlabeled_arg: args
|
||||
.kw_args
|
||||
.unlabeled
|
||||
.as_ref()
|
||||
.map(|arg| OpArg::new(OpKclValue::from(&arg.value), arg.source_range)),
|
||||
labeled_args: op_labeled_args,
|
||||
},
|
||||
source_range: callsite,
|
||||
});
|
||||
}
|
||||
|
||||
call_user_defined_function_kw(args.kw_args, *memory, ast, exec_state, ctx).await
|
||||
}
|
||||
FunctionSource::None => unreachable!(),
|
||||
|
@ -240,7 +240,7 @@ pub enum ContextType {
|
||||
Live,
|
||||
|
||||
/// Completely mocked connection
|
||||
/// Mock mode is only for the modeling app when they just want to mock engine calls and not
|
||||
/// Mock mode is only for the Design Studio when they just want to mock engine calls and not
|
||||
/// actually make them.
|
||||
Mock,
|
||||
|
||||
|
@ -56,6 +56,20 @@ impl RuntimeType {
|
||||
RuntimeType::Primitive(PrimitiveType::ImportedGeometry)
|
||||
}
|
||||
|
||||
/// `[number; 2]`
|
||||
pub fn point2d() -> Self {
|
||||
RuntimeType::Array(Box::new(RuntimeType::number_any()), ArrayLen::Known(2))
|
||||
}
|
||||
|
||||
/// `[number; 3]`
|
||||
pub fn point3d() -> Self {
|
||||
RuntimeType::Array(Box::new(RuntimeType::number_any()), ArrayLen::Known(3))
|
||||
}
|
||||
|
||||
pub fn number_any() -> Self {
|
||||
RuntimeType::Primitive(PrimitiveType::Number(NumericType::Any))
|
||||
}
|
||||
|
||||
pub fn from_parsed(
|
||||
value: Type,
|
||||
exec_state: &mut ExecState,
|
||||
@ -93,24 +107,30 @@ impl RuntimeType {
|
||||
AstPrimitiveType::Number(suffix) => RuntimeType::Primitive(PrimitiveType::Number(
|
||||
NumericType::from_parsed(suffix, &exec_state.mod_local.settings),
|
||||
)),
|
||||
AstPrimitiveType::Named(name) => {
|
||||
let ty_val = exec_state
|
||||
.stack()
|
||||
.get(&format!("{}{}", memory::TYPE_PREFIX, name.name), source_range)
|
||||
.map_err(|_| CompilationError::err(source_range, format!("Unknown type: {}", name.name)))?;
|
||||
|
||||
match ty_val {
|
||||
KclValue::Type { value, .. } => match value {
|
||||
TypeDef::RustRepr(ty, _) => RuntimeType::Primitive(ty.clone()),
|
||||
TypeDef::Alias(ty) => ty.clone(),
|
||||
},
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
AstPrimitiveType::Named(name) => Self::from_alias(&name.name, exec_state, source_range)?,
|
||||
AstPrimitiveType::Tag => RuntimeType::Primitive(PrimitiveType::Tag),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn from_alias(
|
||||
alias: &str,
|
||||
exec_state: &mut ExecState,
|
||||
source_range: SourceRange,
|
||||
) -> Result<Self, CompilationError> {
|
||||
let ty_val = exec_state
|
||||
.stack()
|
||||
.get(&format!("{}{}", memory::TYPE_PREFIX, alias), source_range)
|
||||
.map_err(|_| CompilationError::err(source_range, format!("Unknown type: {}", alias)))?;
|
||||
|
||||
Ok(match ty_val {
|
||||
KclValue::Type { value, .. } => match value {
|
||||
TypeDef::RustRepr(ty, _) => RuntimeType::Primitive(ty.clone()),
|
||||
TypeDef::Alias(ty) => ty.clone(),
|
||||
},
|
||||
_ => unreachable!(),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn human_friendly_type(&self) -> String {
|
||||
match self {
|
||||
RuntimeType::Primitive(ty) => ty.to_string(),
|
||||
@ -143,6 +163,35 @@ impl RuntimeType {
|
||||
(Object(t1), Object(t2)) => t2
|
||||
.iter()
|
||||
.all(|(f, t)| t1.iter().any(|(ff, tt)| f == ff && tt.subtype(t))),
|
||||
// Equality between Axis types and their object representation.
|
||||
(Object(t1), Primitive(PrimitiveType::Axis2d)) => {
|
||||
t1.iter()
|
||||
.any(|(n, t)| n == "origin" && t.subtype(&RuntimeType::point2d()))
|
||||
&& t1
|
||||
.iter()
|
||||
.any(|(n, t)| n == "direction" && t.subtype(&RuntimeType::point2d()))
|
||||
}
|
||||
(Object(t1), Primitive(PrimitiveType::Axis3d)) => {
|
||||
t1.iter()
|
||||
.any(|(n, t)| n == "origin" && t.subtype(&RuntimeType::point3d()))
|
||||
&& t1
|
||||
.iter()
|
||||
.any(|(n, t)| n == "direction" && t.subtype(&RuntimeType::point3d()))
|
||||
}
|
||||
(Primitive(PrimitiveType::Axis2d), Object(t2)) => {
|
||||
t2.iter()
|
||||
.any(|(n, t)| n == "origin" && t.subtype(&RuntimeType::point2d()))
|
||||
&& t2
|
||||
.iter()
|
||||
.any(|(n, t)| n == "direction" && t.subtype(&RuntimeType::point2d()))
|
||||
}
|
||||
(Primitive(PrimitiveType::Axis3d), Object(t2)) => {
|
||||
t2.iter()
|
||||
.any(|(n, t)| n == "origin" && t.subtype(&RuntimeType::point3d()))
|
||||
&& t2
|
||||
.iter()
|
||||
.any(|(n, t)| n == "direction" && t.subtype(&RuntimeType::point3d()))
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
@ -213,11 +262,11 @@ impl ArrayLen {
|
||||
}
|
||||
|
||||
/// True if the length constraint is satisfied by the supplied length.
|
||||
fn satisfied(self, len: usize) -> bool {
|
||||
fn satisfied(self, len: usize, allow_shrink: bool) -> Option<usize> {
|
||||
match self {
|
||||
ArrayLen::None => true,
|
||||
ArrayLen::NonEmpty => len > 0,
|
||||
ArrayLen::Known(s) => len == s,
|
||||
ArrayLen::None => Some(len),
|
||||
ArrayLen::NonEmpty => (len > 0).then_some(len),
|
||||
ArrayLen::Known(s) => (if allow_shrink { len >= s } else { len == s }).then_some(s),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -233,6 +282,9 @@ pub enum PrimitiveType {
|
||||
Plane,
|
||||
Helix,
|
||||
Face,
|
||||
Edge,
|
||||
Axis2d,
|
||||
Axis3d,
|
||||
ImportedGeometry,
|
||||
}
|
||||
|
||||
@ -248,6 +300,9 @@ impl PrimitiveType {
|
||||
PrimitiveType::Plane => "Planes".to_owned(),
|
||||
PrimitiveType::Helix => "Helices".to_owned(),
|
||||
PrimitiveType::Face => "Faces".to_owned(),
|
||||
PrimitiveType::Edge => "Edges".to_owned(),
|
||||
PrimitiveType::Axis2d => "2d axes".to_owned(),
|
||||
PrimitiveType::Axis3d => "3d axes".to_owned(),
|
||||
PrimitiveType::ImportedGeometry => "imported geometries".to_owned(),
|
||||
PrimitiveType::Tag => "tags".to_owned(),
|
||||
}
|
||||
@ -273,6 +328,9 @@ impl fmt::Display for PrimitiveType {
|
||||
PrimitiveType::Solid => write!(f, "Solid"),
|
||||
PrimitiveType::Plane => write!(f, "Plane"),
|
||||
PrimitiveType::Face => write!(f, "Face"),
|
||||
PrimitiveType::Edge => write!(f, "Edge"),
|
||||
PrimitiveType::Axis2d => write!(f, "Axis2d"),
|
||||
PrimitiveType::Axis3d => write!(f, "Axis3d"),
|
||||
PrimitiveType::Helix => write!(f, "Helix"),
|
||||
PrimitiveType::ImportedGeometry => write!(f, "imported geometry"),
|
||||
}
|
||||
@ -298,6 +356,10 @@ impl NumericType {
|
||||
NumericType::Known(UnitType::Count)
|
||||
}
|
||||
|
||||
pub fn mm() -> Self {
|
||||
NumericType::Known(UnitType::Length(UnitLen::Mm))
|
||||
}
|
||||
|
||||
/// Combine two types when we expect them to be equal.
|
||||
pub fn combine_eq(self, other: &NumericType) -> NumericType {
|
||||
if &self == other {
|
||||
@ -541,7 +603,7 @@ impl KclValue {
|
||||
pub fn coerce(&self, ty: &RuntimeType, exec_state: &mut ExecState) -> Option<KclValue> {
|
||||
match ty {
|
||||
RuntimeType::Primitive(ty) => self.coerce_to_primitive_type(ty, exec_state),
|
||||
RuntimeType::Array(ty, len) => self.coerce_to_array_type(ty, *len, exec_state),
|
||||
RuntimeType::Array(ty, len) => self.coerce_to_array_type(ty, *len, exec_state, false),
|
||||
RuntimeType::Tuple(tys) => self.coerce_to_tuple_type(tys, exec_state),
|
||||
RuntimeType::Union(tys) => self.coerce_to_union_type(tys, exec_state),
|
||||
RuntimeType::Object(tys) => self.coerce_to_object_type(tys, exec_state),
|
||||
@ -609,6 +671,55 @@ impl KclValue {
|
||||
KclValue::Helix { .. } => Some(value.clone()),
|
||||
_ => None,
|
||||
},
|
||||
PrimitiveType::Edge => match value {
|
||||
KclValue::Uuid { .. } => Some(value.clone()),
|
||||
KclValue::TagIdentifier { .. } => Some(value.clone()),
|
||||
_ => None,
|
||||
},
|
||||
PrimitiveType::Axis2d => match value {
|
||||
KclValue::Object { value: values, meta } => {
|
||||
if values.get("origin")?.has_type(&RuntimeType::point2d())
|
||||
&& values.get("direction")?.has_type(&RuntimeType::point2d())
|
||||
{
|
||||
return Some(value.clone());
|
||||
}
|
||||
|
||||
let origin = values.get("origin").and_then(|p| {
|
||||
p.coerce_to_array_type(&RuntimeType::number_any(), ArrayLen::Known(2), exec_state, true)
|
||||
})?;
|
||||
let direction = values.get("direction").and_then(|p| {
|
||||
p.coerce_to_array_type(&RuntimeType::number_any(), ArrayLen::Known(2), exec_state, true)
|
||||
})?;
|
||||
|
||||
Some(KclValue::Object {
|
||||
value: [("origin".to_owned(), origin), ("direction".to_owned(), direction)].into(),
|
||||
meta: meta.clone(),
|
||||
})
|
||||
}
|
||||
_ => None,
|
||||
},
|
||||
PrimitiveType::Axis3d => match value {
|
||||
KclValue::Object { value: values, meta } => {
|
||||
if values.get("origin")?.has_type(&RuntimeType::point3d())
|
||||
&& values.get("direction")?.has_type(&RuntimeType::point3d())
|
||||
{
|
||||
return Some(value.clone());
|
||||
}
|
||||
|
||||
let origin = values.get("origin").and_then(|p| {
|
||||
p.coerce_to_array_type(&RuntimeType::number_any(), ArrayLen::Known(3), exec_state, true)
|
||||
})?;
|
||||
let direction = values.get("direction").and_then(|p| {
|
||||
p.coerce_to_array_type(&RuntimeType::number_any(), ArrayLen::Known(3), exec_state, true)
|
||||
})?;
|
||||
|
||||
Some(KclValue::Object {
|
||||
value: [("origin".to_owned(), origin), ("direction".to_owned(), direction)].into(),
|
||||
meta: meta.clone(),
|
||||
})
|
||||
}
|
||||
_ => None,
|
||||
},
|
||||
PrimitiveType::ImportedGeometry => match value {
|
||||
KclValue::ImportedGeometry { .. } => Some(value.clone()),
|
||||
_ => None,
|
||||
@ -621,60 +732,35 @@ impl KclValue {
|
||||
}
|
||||
}
|
||||
|
||||
fn coerce_to_array_type(&self, ty: &RuntimeType, len: ArrayLen, exec_state: &mut ExecState) -> Option<KclValue> {
|
||||
fn coerce_to_array_type(
|
||||
&self,
|
||||
ty: &RuntimeType,
|
||||
len: ArrayLen,
|
||||
exec_state: &mut ExecState,
|
||||
allow_shrink: bool,
|
||||
) -> Option<KclValue> {
|
||||
match self {
|
||||
KclValue::HomArray { value, ty: aty } if aty == ty => {
|
||||
let value = match len {
|
||||
ArrayLen::None => value.clone(),
|
||||
ArrayLen::NonEmpty => {
|
||||
if value.is_empty() {
|
||||
return None;
|
||||
}
|
||||
|
||||
value.clone()
|
||||
}
|
||||
ArrayLen::Known(n) => {
|
||||
if n != value.len() {
|
||||
return None;
|
||||
}
|
||||
|
||||
value[..n].to_vec()
|
||||
}
|
||||
};
|
||||
|
||||
Some(KclValue::HomArray { value, ty: ty.clone() })
|
||||
KclValue::HomArray { value, ty: aty } if aty.subtype(ty) => {
|
||||
len.satisfied(value.len(), allow_shrink).map(|len| KclValue::HomArray {
|
||||
value: value[..len].to_vec(),
|
||||
ty: aty.clone(),
|
||||
})
|
||||
}
|
||||
value if len.satisfied(1) && value.has_type(ty) => Some(KclValue::HomArray {
|
||||
value if len.satisfied(1, false).is_some() && value.has_type(ty) => Some(KclValue::HomArray {
|
||||
value: vec![value.clone()],
|
||||
ty: ty.clone(),
|
||||
}),
|
||||
KclValue::MixedArray { value, .. } => {
|
||||
let value = match len {
|
||||
ArrayLen::None => value.clone(),
|
||||
ArrayLen::NonEmpty => {
|
||||
if value.is_empty() {
|
||||
return None;
|
||||
}
|
||||
let len = len.satisfied(value.len(), allow_shrink)?;
|
||||
|
||||
value.clone()
|
||||
}
|
||||
ArrayLen::Known(n) => {
|
||||
if n != value.len() {
|
||||
return None;
|
||||
}
|
||||
|
||||
value[..n].to_vec()
|
||||
}
|
||||
};
|
||||
|
||||
let value = value
|
||||
let value = value[..len]
|
||||
.iter()
|
||||
.map(|v| v.coerce(ty, exec_state))
|
||||
.collect::<Option<Vec<_>>>()?;
|
||||
|
||||
Some(KclValue::HomArray { value, ty: ty.clone() })
|
||||
}
|
||||
KclValue::KclNone { .. } if len.satisfied(0) => Some(KclValue::HomArray {
|
||||
KclValue::KclNone { .. } if len.satisfied(0, false).is_some() => Some(KclValue::HomArray {
|
||||
value: Vec::new(),
|
||||
ty: ty.clone(),
|
||||
}),
|
||||
@ -1251,4 +1337,119 @@ mod test {
|
||||
assert!(count.coerce(&tyb, &mut exec_state).is_none());
|
||||
assert!(count.coerce(&tyb2, &mut exec_state).is_none());
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn coerce_axes() {
|
||||
let mut exec_state = ExecState::new(&crate::ExecutorContext::new_mock().await);
|
||||
|
||||
// Subtyping
|
||||
assert!(RuntimeType::Primitive(PrimitiveType::Axis2d).subtype(&RuntimeType::Primitive(PrimitiveType::Axis2d)));
|
||||
assert!(RuntimeType::Primitive(PrimitiveType::Axis3d).subtype(&RuntimeType::Primitive(PrimitiveType::Axis3d)));
|
||||
assert!(!RuntimeType::Primitive(PrimitiveType::Axis3d).subtype(&RuntimeType::Primitive(PrimitiveType::Axis2d)));
|
||||
assert!(!RuntimeType::Primitive(PrimitiveType::Axis2d).subtype(&RuntimeType::Primitive(PrimitiveType::Axis3d)));
|
||||
|
||||
// Coercion
|
||||
let a2d = KclValue::Object {
|
||||
value: [
|
||||
(
|
||||
"origin".to_owned(),
|
||||
KclValue::HomArray {
|
||||
value: vec![
|
||||
KclValue::Number {
|
||||
value: 0.0,
|
||||
ty: NumericType::mm(),
|
||||
meta: Vec::new(),
|
||||
},
|
||||
KclValue::Number {
|
||||
value: 0.0,
|
||||
ty: NumericType::mm(),
|
||||
meta: Vec::new(),
|
||||
},
|
||||
],
|
||||
ty: RuntimeType::Primitive(PrimitiveType::Number(NumericType::mm())),
|
||||
},
|
||||
),
|
||||
(
|
||||
"direction".to_owned(),
|
||||
KclValue::HomArray {
|
||||
value: vec![
|
||||
KclValue::Number {
|
||||
value: 1.0,
|
||||
ty: NumericType::mm(),
|
||||
meta: Vec::new(),
|
||||
},
|
||||
KclValue::Number {
|
||||
value: 0.0,
|
||||
ty: NumericType::mm(),
|
||||
meta: Vec::new(),
|
||||
},
|
||||
],
|
||||
ty: RuntimeType::Primitive(PrimitiveType::Number(NumericType::mm())),
|
||||
},
|
||||
),
|
||||
]
|
||||
.into(),
|
||||
meta: Vec::new(),
|
||||
};
|
||||
let a3d = KclValue::Object {
|
||||
value: [
|
||||
(
|
||||
"origin".to_owned(),
|
||||
KclValue::HomArray {
|
||||
value: vec![
|
||||
KclValue::Number {
|
||||
value: 0.0,
|
||||
ty: NumericType::mm(),
|
||||
meta: Vec::new(),
|
||||
},
|
||||
KclValue::Number {
|
||||
value: 0.0,
|
||||
ty: NumericType::mm(),
|
||||
meta: Vec::new(),
|
||||
},
|
||||
KclValue::Number {
|
||||
value: 0.0,
|
||||
ty: NumericType::mm(),
|
||||
meta: Vec::new(),
|
||||
},
|
||||
],
|
||||
ty: RuntimeType::Primitive(PrimitiveType::Number(NumericType::mm())),
|
||||
},
|
||||
),
|
||||
(
|
||||
"direction".to_owned(),
|
||||
KclValue::HomArray {
|
||||
value: vec![
|
||||
KclValue::Number {
|
||||
value: 1.0,
|
||||
ty: NumericType::mm(),
|
||||
meta: Vec::new(),
|
||||
},
|
||||
KclValue::Number {
|
||||
value: 0.0,
|
||||
ty: NumericType::mm(),
|
||||
meta: Vec::new(),
|
||||
},
|
||||
KclValue::Number {
|
||||
value: 1.0,
|
||||
ty: NumericType::mm(),
|
||||
meta: Vec::new(),
|
||||
},
|
||||
],
|
||||
ty: RuntimeType::Primitive(PrimitiveType::Number(NumericType::mm())),
|
||||
},
|
||||
),
|
||||
]
|
||||
.into(),
|
||||
meta: Vec::new(),
|
||||
};
|
||||
|
||||
let ty2d = RuntimeType::Primitive(PrimitiveType::Axis2d);
|
||||
let ty3d = RuntimeType::Primitive(PrimitiveType::Axis3d);
|
||||
|
||||
assert_coerce_results(&a2d, &ty2d, &a2d, &mut exec_state);
|
||||
assert_coerce_results(&a3d, &ty3d, &a3d, &mut exec_state);
|
||||
assert_coerce_results(&a3d, &ty2d, &a2d, &mut exec_state);
|
||||
assert!(a2d.coerce(&ty3d, &mut exec_state).is_none());
|
||||
}
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ const Part001 = startSketchOn('XY')
|
||||
|> line([0, pipeLength], %)
|
||||
|> angledLineToX({ angle: 60, to: pipeLargeDia }, %)
|
||||
|> close()
|
||||
|> revolve({ axis: 'y' }, %)
|
||||
|> revolve({ axis = Y }, %)
|
||||
"
|
||||
);
|
||||
|
||||
@ -156,7 +156,7 @@ const part001 = startSketchOn('XY')
|
||||
|> line([0, pipeLength], %)
|
||||
|> angledLineToX({ angle: 60, to: pipeLargeDia }, %)
|
||||
|> close()
|
||||
|> revolve({ axis: 'y' }, %)
|
||||
|> revolve({ axis = Y }, %)
|
||||
"
|
||||
);
|
||||
|
||||
|
@ -799,7 +799,7 @@ impl Backend {
|
||||
// We do not have project descriptions yet.
|
||||
project_description: None,
|
||||
project_name,
|
||||
// The UUID for the modeling app.
|
||||
// The UUID for the Design Studio.
|
||||
// We can unwrap here because we know it will not panic.
|
||||
source_id: uuid::Uuid::from_str("70178592-dfca-47b3-bd2d-6fce2bcaee04").unwrap(),
|
||||
type_: kittycad::types::Type::ModelingAppEvent,
|
||||
@ -1194,7 +1194,7 @@ impl LanguageServer for Backend {
|
||||
// Get last word
|
||||
let last_word = line_prefix
|
||||
.split(|c: char| c.is_whitespace() || c.is_ascii_punctuation())
|
||||
.last()
|
||||
.next_back()
|
||||
.unwrap_or("");
|
||||
|
||||
// If the last word starts with a digit, return no completions
|
||||
|
@ -1634,7 +1634,7 @@ insideRevolve = startSketchOn(XZ)
|
||||
|> line(end = [0, -thickness])
|
||||
|> line(end = [-overHangLength, 0])
|
||||
|> close()
|
||||
|> revolve({ axis: 'y' }, %)
|
||||
|> revolve({ axis = Y }, %)
|
||||
|
||||
// Sketch and revolve one of the balls and duplicate it using a circular pattern. (This is currently a workaround, we have a bug with rotating on a sketch that touches the rotation axis)
|
||||
sphere = startSketchOn(XZ)
|
||||
@ -1649,7 +1649,7 @@ sphere = startSketchOn(XZ)
|
||||
radius: sphereDia / 2 - 0.05
|
||||
}, %)
|
||||
|> close()
|
||||
|> revolve({ axis: 'x' }, %)
|
||||
|> revolve({ axis = X }, %)
|
||||
|> patternCircular3d(
|
||||
axis = [0, 0, 1],
|
||||
center = [0, 0, 0],
|
||||
@ -1673,7 +1673,7 @@ outsideRevolve = startSketchOn(XZ)
|
||||
|> line(end = [0, thickness])
|
||||
|> line(end = [overHangLength - thickness, 0])
|
||||
|> close()
|
||||
|> revolve({ axis: 'y' }, %)"#
|
||||
|> revolve({ axis = Y }, %)"#
|
||||
.to_string(),
|
||||
},
|
||||
})
|
||||
@ -1707,7 +1707,7 @@ outsideRevolve = startSketchOn(XZ)
|
||||
start: tower_lsp::lsp_types::Position { line: 0, character: 0 },
|
||||
end: tower_lsp::lsp_types::Position {
|
||||
line: 60,
|
||||
character: 30
|
||||
character: 29
|
||||
}
|
||||
}
|
||||
);
|
||||
@ -1734,7 +1734,7 @@ insideRevolve = startSketchOn(XZ)
|
||||
|> line(end = [0, -thickness])
|
||||
|> line(end = [-overHangLength, 0])
|
||||
|> close()
|
||||
|> revolve({ axis = 'y' }, %)
|
||||
|> revolve({ axis = Y }, %)
|
||||
|
||||
// Sketch and revolve one of the balls and duplicate it using a circular pattern. (This is currently a workaround, we have a bug with rotating on a sketch that touches the rotation axis)
|
||||
sphere = startSketchOn(XZ)
|
||||
@ -1749,7 +1749,7 @@ sphere = startSketchOn(XZ)
|
||||
radius = sphereDia / 2 - 0.05
|
||||
}, %)
|
||||
|> close()
|
||||
|> revolve({ axis = 'x' }, %)
|
||||
|> revolve({ axis = X }, %)
|
||||
|> patternCircular3d(
|
||||
axis = [0, 0, 1],
|
||||
center = [0, 0, 0],
|
||||
@ -1773,7 +1773,7 @@ outsideRevolve = startSketchOn(XZ)
|
||||
|> line(end = [0, thickness])
|
||||
|> line(end = [overHangLength - thickness, 0])
|
||||
|> close()
|
||||
|> revolve({ axis = 'y' }, %)"#
|
||||
|> revolve({ axis = Y }, %)"#
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -286,6 +286,11 @@ fn non_code_node(i: &mut TokenSlice) -> PResult<Node<NonCodeNode>> {
|
||||
alt((non_code_node_leading_whitespace, non_code_node_no_leading_whitespace)).parse_next(i)
|
||||
}
|
||||
|
||||
fn outer_annotation(i: &mut TokenSlice) -> PResult<Node<Annotation>> {
|
||||
peek((at_sign, open_paren)).parse_next(i)?;
|
||||
annotation(i)
|
||||
}
|
||||
|
||||
fn annotation(i: &mut TokenSlice) -> PResult<Node<Annotation>> {
|
||||
let at = at_sign.parse_next(i)?;
|
||||
let name = opt(binding_name).parse_next(i)?;
|
||||
@ -2903,13 +2908,17 @@ struct ParamDescription {
|
||||
arg_name: Token,
|
||||
type_: std::option::Option<Node<Type>>,
|
||||
default_value: Option<DefaultParamVal>,
|
||||
attr: Option<Node<Annotation>>,
|
||||
comments: Option<Node<Vec<String>>>,
|
||||
}
|
||||
|
||||
fn parameter(i: &mut TokenSlice) -> PResult<ParamDescription> {
|
||||
let (_, comments, found_at_sign, arg_name, question_mark, _, type_, _ws, default_literal) = (
|
||||
let (_, comments, _, attr, _, found_at_sign, arg_name, question_mark, _, type_, _ws, default_literal) = (
|
||||
opt(whitespace),
|
||||
opt(comments),
|
||||
opt(whitespace),
|
||||
opt(outer_annotation),
|
||||
opt(whitespace),
|
||||
opt(at_sign),
|
||||
any.verify(|token: &Token| !matches!(token.token_type, TokenType::Brace) || token.value != ")"),
|
||||
opt(question_mark),
|
||||
@ -2934,6 +2943,7 @@ fn parameter(i: &mut TokenSlice) -> PResult<ParamDescription> {
|
||||
return Err(ErrMode::Backtrack(ContextError::from(e)));
|
||||
}
|
||||
},
|
||||
attr,
|
||||
comments,
|
||||
})
|
||||
}
|
||||
@ -2955,6 +2965,7 @@ fn parameters(i: &mut TokenSlice) -> PResult<Vec<Parameter>> {
|
||||
arg_name,
|
||||
type_,
|
||||
default_value,
|
||||
attr,
|
||||
comments,
|
||||
}| {
|
||||
let mut identifier = Node::<Identifier>::try_from(arg_name)?;
|
||||
@ -2962,6 +2973,9 @@ fn parameters(i: &mut TokenSlice) -> PResult<Vec<Parameter>> {
|
||||
identifier.comment_start = comments.start;
|
||||
identifier.pre_comments = comments.inner;
|
||||
}
|
||||
if let Some(attr) = attr {
|
||||
identifier.outer_attrs.push(attr);
|
||||
}
|
||||
|
||||
Ok(Parameter {
|
||||
identifier,
|
||||
|
@ -148,10 +148,10 @@ pub fn generate_settings_docs() {
|
||||
if let Some(metadata) = &obj.metadata {
|
||||
metadata.description.clone().unwrap_or_default()
|
||||
} else {
|
||||
"Project specific settings for the KittyCAD modeling app.".to_string()
|
||||
"Project specific settings for the Zoo Design Studio.".to_string()
|
||||
}
|
||||
} else {
|
||||
"Project specific settings for the KittyCAD modeling app.".to_string()
|
||||
"Project specific settings for the Zoo Design Studio.".to_string()
|
||||
};
|
||||
|
||||
// Convert the schema to our template format
|
||||
@ -183,10 +183,10 @@ pub fn generate_settings_docs() {
|
||||
if let Some(metadata) = &obj.metadata {
|
||||
metadata.description.clone().unwrap_or_default()
|
||||
} else {
|
||||
"User-specific configuration options for the KittyCAD modeling app.".to_string()
|
||||
"User-specific configuration options for the Zoo Design Studio.".to_string()
|
||||
}
|
||||
} else {
|
||||
"User-specific configuration options for the KittyCAD modeling app.".to_string()
|
||||
"User-specific configuration options for the Zoo Design Studio.".to_string()
|
||||
};
|
||||
|
||||
// Trim any trailing periods to avoid double periods
|
||||
|
@ -1,4 +1,4 @@
|
||||
//! This module contains settings for kcl projects as well as the modeling app.
|
||||
//! This module contains settings for kcl projects as well as the Design Studio.
|
||||
|
||||
pub mod types;
|
||||
|
||||
|
@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
|
||||
use validator::{Validate, ValidateRange};
|
||||
|
||||
const DEFAULT_THEME_COLOR: f64 = 264.5;
|
||||
const DEFAULT_PROJECT_NAME_TEMPLATE: &str = "project-$nnn";
|
||||
const DEFAULT_PROJECT_NAME_TEMPLATE: &str = "untitled";
|
||||
|
||||
/// User specific settings for the app.
|
||||
/// These live in `user.toml` in the app's configuration directory.
|
||||
@ -20,7 +20,7 @@ const DEFAULT_PROJECT_NAME_TEMPLATE: &str = "project-$nnn";
|
||||
#[ts(export)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub struct Configuration {
|
||||
/// The settings for the modeling app.
|
||||
/// The settings for the Design Studio.
|
||||
#[serde(default, skip_serializing_if = "is_default")]
|
||||
#[validate(nested)]
|
||||
pub settings: Settings,
|
||||
@ -75,7 +75,7 @@ impl Configuration {
|
||||
#[ts(export)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub struct Settings {
|
||||
/// The settings for the modeling app.
|
||||
/// The settings for the Design Studio.
|
||||
#[serde(default, skip_serializing_if = "is_default")]
|
||||
#[validate(nested)]
|
||||
pub app: AppSettings,
|
||||
@ -603,7 +603,7 @@ mouseControls = "KittyCAD"
|
||||
showDebugPanel = true
|
||||
|
||||
[settings.projects]
|
||||
defaultProjectName = "project-$nnn"
|
||||
defaultProjectName = "untitled"
|
||||
|
||||
[settings.textEditor]
|
||||
textWrapping = true
|
||||
@ -860,7 +860,7 @@ projectDirectory = "/Users/macinatormax/Documents/kittycad-modeling-projects""#;
|
||||
},
|
||||
project: ProjectSettings {
|
||||
directory: "/Users/macinatormax/Documents/kittycad-modeling-projects".into(),
|
||||
default_project_name: "project-$nnn".to_string().into()
|
||||
default_project_name: "untitled".to_string().into()
|
||||
},
|
||||
command_bar: CommandBarSettings {
|
||||
include_settings: true.into()
|
||||
|
@ -60,7 +60,7 @@ impl ProjectConfiguration {
|
||||
#[ts(export)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub struct PerProjectSettings {
|
||||
/// The settings for the modeling app.
|
||||
/// The settings for the Design Studio.
|
||||
#[serde(default)]
|
||||
#[validate(nested)]
|
||||
pub app: ProjectAppSettings,
|
||||
|
@ -75,7 +75,7 @@ pub async fn appearance(exec_state: &mut ExecState, args: Args) -> Result<KclVal
|
||||
/// This will work on any solid, including extruded solids, revolved solids, and shelled solids.
|
||||
/// ```no_run
|
||||
/// // Add color to an extruded solid.
|
||||
/// exampleSketch = startSketchOn("XZ")
|
||||
/// exampleSketch = startSketchOn(XZ)
|
||||
/// |> startProfileAt([0, 0], %)
|
||||
/// |> line(endAbsolute = [10, 0])
|
||||
/// |> line(endAbsolute = [0, 10])
|
||||
@ -89,9 +89,9 @@ pub async fn appearance(exec_state: &mut ExecState, args: Args) -> Result<KclVal
|
||||
///
|
||||
/// ```no_run
|
||||
/// // Add color to a revolved solid.
|
||||
/// sketch001 = startSketchOn('XY')
|
||||
/// sketch001 = startSketchOn(XY)
|
||||
/// |> circle( center = [15, 0], radius = 5 )
|
||||
/// |> revolve( angle = 360, axis = 'y')
|
||||
/// |> revolve( angle = 360, axis = Y)
|
||||
/// |> appearance(
|
||||
/// color = '#ff0000',
|
||||
/// metalness = 90,
|
||||
@ -102,7 +102,7 @@ pub async fn appearance(exec_state: &mut ExecState, args: Args) -> Result<KclVal
|
||||
/// ```no_run
|
||||
/// // Add color to different solids.
|
||||
/// fn cube(center) {
|
||||
/// return startSketchOn('XY')
|
||||
/// return startSketchOn(XY)
|
||||
/// |> startProfileAt([center[0] - 10, center[1] - 10], %)
|
||||
/// |> line(endAbsolute = [center[0] + 10, center[1] - 10])
|
||||
/// |> line(endAbsolute = [center[0] + 10, center[1] + 10])
|
||||
@ -122,7 +122,7 @@ pub async fn appearance(exec_state: &mut ExecState, args: Args) -> Result<KclVal
|
||||
/// ```no_run
|
||||
/// // You can set the appearance before or after you shell it will yield the same result.
|
||||
/// // This example shows setting the appearance _after_ the shell.
|
||||
/// firstSketch = startSketchOn('XY')
|
||||
/// firstSketch = startSketchOn(XY)
|
||||
/// |> startProfileAt([-12, 12], %)
|
||||
/// |> line(end = [24, 0])
|
||||
/// |> line(end = [0, -24])
|
||||
@ -145,7 +145,7 @@ pub async fn appearance(exec_state: &mut ExecState, args: Args) -> Result<KclVal
|
||||
/// ```no_run
|
||||
/// // You can set the appearance before or after you shell it will yield the same result.
|
||||
/// // This example shows setting the appearance _before_ the shell.
|
||||
/// firstSketch = startSketchOn('XY')
|
||||
/// firstSketch = startSketchOn(XY)
|
||||
/// |> startProfileAt([-12, 12], %)
|
||||
/// |> line(end = [24, 0])
|
||||
/// |> line(end = [0, -24])
|
||||
@ -168,7 +168,7 @@ pub async fn appearance(exec_state: &mut ExecState, args: Args) -> Result<KclVal
|
||||
/// ```no_run
|
||||
/// // Setting the appearance of a 3D pattern can be done _before_ or _after_ the pattern.
|
||||
/// // This example shows _before_ the pattern.
|
||||
/// exampleSketch = startSketchOn('XZ')
|
||||
/// exampleSketch = startSketchOn(XZ)
|
||||
/// |> startProfileAt([0, 0], %)
|
||||
/// |> line(end = [0, 2])
|
||||
/// |> line(end = [3, 1])
|
||||
@ -191,7 +191,7 @@ pub async fn appearance(exec_state: &mut ExecState, args: Args) -> Result<KclVal
|
||||
/// ```no_run
|
||||
/// // Setting the appearance of a 3D pattern can be done _before_ or _after_ the pattern.
|
||||
/// // This example shows _after_ the pattern.
|
||||
/// exampleSketch = startSketchOn('XZ')
|
||||
/// exampleSketch = startSketchOn(XZ)
|
||||
/// |> startProfileAt([0, 0], %)
|
||||
/// |> line(end = [0, 2])
|
||||
/// |> line(end = [3, 1])
|
||||
@ -213,7 +213,7 @@ pub async fn appearance(exec_state: &mut ExecState, args: Args) -> Result<KclVal
|
||||
///
|
||||
/// ```no_run
|
||||
/// // Color the result of a 2D pattern that was extruded.
|
||||
/// exampleSketch = startSketchOn('XZ')
|
||||
/// exampleSketch = startSketchOn(XZ)
|
||||
/// |> startProfileAt([.5, 25], %)
|
||||
/// |> line(end = [0, 5])
|
||||
/// |> line(end = [-1, 0])
|
||||
@ -238,7 +238,7 @@ pub async fn appearance(exec_state: &mut ExecState, args: Args) -> Result<KclVal
|
||||
/// // Color the result of a sweep.
|
||||
///
|
||||
/// // Create a path for the sweep.
|
||||
/// sweepPath = startSketchOn('XZ')
|
||||
/// sweepPath = startSketchOn(XZ)
|
||||
/// |> startProfileAt([0.05, 0.05], %)
|
||||
/// |> line(end = [0, 7])
|
||||
/// |> tangentialArc({
|
||||
@ -252,13 +252,13 @@ pub async fn appearance(exec_state: &mut ExecState, args: Args) -> Result<KclVal
|
||||
/// }, %)
|
||||
/// |> line(end = [0, 7])
|
||||
///
|
||||
/// pipeHole = startSketchOn('XY')
|
||||
/// pipeHole = startSketchOn(XY)
|
||||
/// |> circle(
|
||||
/// center = [0, 0],
|
||||
/// radius = 1.5,
|
||||
/// )
|
||||
///
|
||||
/// sweepSketch = startSketchOn('XY')
|
||||
/// sweepSketch = startSketchOn(XY)
|
||||
/// |> circle(
|
||||
/// center = [0, 0],
|
||||
/// radius = 2,
|
||||
|
@ -164,6 +164,22 @@ impl Args {
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn get_kw_arg_opt_typed<T>(
|
||||
&self,
|
||||
label: &str,
|
||||
ty: &RuntimeType,
|
||||
exec_state: &mut ExecState,
|
||||
) -> Result<Option<T>, KclError>
|
||||
where
|
||||
T: for<'a> FromKclValue<'a>,
|
||||
{
|
||||
if self.kw_args.labeled.get(label).is_none() {
|
||||
return Ok(None);
|
||||
};
|
||||
|
||||
self.get_kw_arg_typed(label, ty, exec_state).map(Some)
|
||||
}
|
||||
|
||||
/// Get a keyword argument. If not set, returns Err.
|
||||
pub(crate) fn get_kw_arg<'a, T>(&'a self, label: &str) -> Result<T, KclError>
|
||||
where
|
||||
@ -685,37 +701,6 @@ impl Args {
|
||||
FromArgs::from_args(self, 0)
|
||||
}
|
||||
|
||||
pub(crate) fn get_data_and_sketches<'a, T>(
|
||||
&'a self,
|
||||
exec_state: &mut ExecState,
|
||||
) -> Result<(T, Vec<Sketch>), KclError>
|
||||
where
|
||||
T: serde::de::DeserializeOwned + FromArgs<'a>,
|
||||
{
|
||||
let data: T = FromArgs::from_args(self, 0)?;
|
||||
let Some(arg1) = self.args.get(1) else {
|
||||
return Err(KclError::Semantic(KclErrorDetails {
|
||||
message: "Expected one or more sketches for second argument".to_owned(),
|
||||
source_ranges: vec![self.source_range],
|
||||
}));
|
||||
};
|
||||
let sarg = arg1
|
||||
.value
|
||||
.coerce(&RuntimeType::sketches(), exec_state)
|
||||
.ok_or(KclError::Type(KclErrorDetails {
|
||||
message: format!(
|
||||
"Expected one or more sketches for second argument, found {}",
|
||||
arg1.value.human_friendly_type()
|
||||
),
|
||||
source_ranges: vec![self.source_range],
|
||||
}))?;
|
||||
let sketches = match sarg {
|
||||
KclValue::HomArray { value, .. } => value.iter().map(|v| v.as_sketch().unwrap().clone()).collect(),
|
||||
_ => unreachable!(),
|
||||
};
|
||||
Ok((data, sketches))
|
||||
}
|
||||
|
||||
pub(crate) fn get_data_and_sketch_and_tag<'a, T>(
|
||||
&'a self,
|
||||
exec_state: &mut ExecState,
|
||||
@ -1593,50 +1578,6 @@ impl<'a> FromKclValue<'a> for super::sketch::SketchData {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> FromKclValue<'a> for super::axis_or_reference::AxisAndOrigin2d {
|
||||
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
|
||||
// Case 1: predefined planes.
|
||||
if let Some(s) = arg.as_str() {
|
||||
return match s {
|
||||
"X" | "x" => Some(Self::X),
|
||||
"Y" | "y" => Some(Self::Y),
|
||||
"-X" | "-x" => Some(Self::NegX),
|
||||
"-Y" | "-y" => Some(Self::NegY),
|
||||
_ => None,
|
||||
};
|
||||
}
|
||||
// Case 2: custom planes.
|
||||
let obj = arg.as_object()?;
|
||||
let_field_of!(obj, custom, &KclObjectFields);
|
||||
let_field_of!(custom, origin);
|
||||
let_field_of!(custom, axis);
|
||||
Some(Self::Custom { axis, origin })
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> FromKclValue<'a> for super::axis_or_reference::AxisAndOrigin3d {
|
||||
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
|
||||
// Case 1: predefined planes.
|
||||
if let Some(s) = arg.as_str() {
|
||||
return match s {
|
||||
"X" | "x" => Some(Self::X),
|
||||
"Y" | "y" => Some(Self::Y),
|
||||
"Z" | "z" => Some(Self::Z),
|
||||
"-X" | "-x" => Some(Self::NegX),
|
||||
"-Y" | "-y" => Some(Self::NegY),
|
||||
"-Z" | "-z" => Some(Self::NegZ),
|
||||
_ => None,
|
||||
};
|
||||
}
|
||||
// Case 2: custom planes.
|
||||
let obj = arg.as_object()?;
|
||||
let_field_of!(obj, custom, &KclObjectFields);
|
||||
let_field_of!(custom, origin);
|
||||
let_field_of!(custom, axis);
|
||||
Some(Self::Custom { axis, origin })
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> FromKclValue<'a> for super::fillet::EdgeReference {
|
||||
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
|
||||
let id = arg.as_uuid().map(Self::Uuid);
|
||||
@ -1647,25 +1588,27 @@ impl<'a> FromKclValue<'a> for super::fillet::EdgeReference {
|
||||
|
||||
impl<'a> FromKclValue<'a> for super::axis_or_reference::Axis2dOrEdgeReference {
|
||||
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
|
||||
let case1 = super::axis_or_reference::AxisAndOrigin2d::from_kcl_val;
|
||||
let case1 = |arg: &KclValue| {
|
||||
let obj = arg.as_object()?;
|
||||
let_field_of!(obj, direction);
|
||||
let_field_of!(obj, origin);
|
||||
Some(Self::Axis { direction, origin })
|
||||
};
|
||||
let case2 = super::fillet::EdgeReference::from_kcl_val;
|
||||
case1(arg).map(Self::Axis).or_else(|| case2(arg).map(Self::Edge))
|
||||
case1(arg).or_else(|| case2(arg).map(Self::Edge))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> FromKclValue<'a> for super::axis_or_reference::Axis3dOrEdgeReference {
|
||||
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
|
||||
let case1 = super::axis_or_reference::AxisAndOrigin3d::from_kcl_val;
|
||||
let case1 = |arg: &KclValue| {
|
||||
let obj = arg.as_object()?;
|
||||
let_field_of!(obj, direction);
|
||||
let_field_of!(obj, origin);
|
||||
Some(Self::Axis { direction, origin })
|
||||
};
|
||||
let case2 = super::fillet::EdgeReference::from_kcl_val;
|
||||
case1(arg).map(Self::Axis).or_else(|| case2(arg).map(Self::Edge))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> FromKclValue<'a> for super::mirror::Mirror2dData {
|
||||
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
|
||||
let obj = arg.as_object()?;
|
||||
let_field_of!(obj, axis);
|
||||
Some(Self { axis })
|
||||
case1(arg).or_else(|| case2(arg).map(Self::Edge))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ async fn call_map_closure(
|
||||
ctxt: &ExecutorContext,
|
||||
) -> Result<KclValue, KclError> {
|
||||
let output = map_fn
|
||||
.call(exec_state, ctxt, vec![Arg::synthetic(input)], source_range)
|
||||
.call(None, exec_state, ctxt, vec![Arg::synthetic(input)], source_range)
|
||||
.await?;
|
||||
let source_ranges = vec![source_range];
|
||||
let output = output.ok_or_else(|| {
|
||||
@ -202,7 +202,9 @@ async fn call_reduce_closure(
|
||||
) -> Result<KclValue, KclError> {
|
||||
// Call the reduce fn for this repetition.
|
||||
let reduce_fn_args = vec![Arg::synthetic(elem), Arg::synthetic(start)];
|
||||
let transform_fn_return = reduce_fn.call(exec_state, ctxt, reduce_fn_args, source_range).await?;
|
||||
let transform_fn_return = reduce_fn
|
||||
.call(None, exec_state, ctxt, reduce_fn_args, source_range)
|
||||
.await?;
|
||||
|
||||
// Unpack the returned transform object.
|
||||
let source_ranges = vec![source_range];
|
||||
|
@ -1,233 +1,21 @@
|
||||
//! Types for referencing an axis or edge.
|
||||
|
||||
use anyhow::Result;
|
||||
use kcmc::length_unit::LengthUnit;
|
||||
use kittycad_modeling_cmds::{self as kcmc};
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{errors::KclError, std::fillet::EdgeReference};
|
||||
use crate::std::fillet::EdgeReference;
|
||||
|
||||
/// A 2D axis or tagged edge.
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
|
||||
#[ts(export)]
|
||||
#[serde(untagged)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum Axis2dOrEdgeReference {
|
||||
/// 2D axis and origin.
|
||||
Axis(AxisAndOrigin2d),
|
||||
Axis { direction: [f64; 2], origin: [f64; 2] },
|
||||
/// Tagged edge.
|
||||
Edge(EdgeReference),
|
||||
}
|
||||
|
||||
/// A 2D axis and origin.
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
|
||||
#[ts(export)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum AxisAndOrigin2d {
|
||||
/// X-axis.
|
||||
#[serde(rename = "X", alias = "x")]
|
||||
X,
|
||||
/// Y-axis.
|
||||
#[serde(rename = "Y", alias = "y")]
|
||||
Y,
|
||||
/// Flip the X-axis.
|
||||
#[serde(rename = "-X", alias = "-x")]
|
||||
NegX,
|
||||
/// Flip the Y-axis.
|
||||
#[serde(rename = "-Y", alias = "-y")]
|
||||
NegY,
|
||||
Custom {
|
||||
/// The axis.
|
||||
axis: [f64; 2],
|
||||
/// The origin.
|
||||
origin: [f64; 2],
|
||||
},
|
||||
}
|
||||
|
||||
impl AxisAndOrigin2d {
|
||||
/// Get the axis and origin.
|
||||
pub fn axis_and_origin(&self) -> Result<(kcmc::shared::Point3d<f64>, kcmc::shared::Point3d<LengthUnit>), KclError> {
|
||||
let (axis, origin) = match self {
|
||||
AxisAndOrigin2d::X => ([1.0, 0.0, 0.0], [0.0, 0.0, 0.0]),
|
||||
AxisAndOrigin2d::Y => ([0.0, 1.0, 0.0], [0.0, 0.0, 0.0]),
|
||||
AxisAndOrigin2d::NegX => ([-1.0, 0.0, 0.0], [0.0, 0.0, 0.0]),
|
||||
AxisAndOrigin2d::NegY => ([0.0, -1.0, 0.0], [0.0, 0.0, 0.0]),
|
||||
AxisAndOrigin2d::Custom { axis, origin } => ([axis[0], axis[1], 0.0], [origin[0], origin[1], 0.0]),
|
||||
};
|
||||
|
||||
Ok((
|
||||
kcmc::shared::Point3d {
|
||||
x: axis[0],
|
||||
y: axis[1],
|
||||
z: axis[2],
|
||||
},
|
||||
kcmc::shared::Point3d {
|
||||
x: LengthUnit(origin[0]),
|
||||
y: LengthUnit(origin[1]),
|
||||
z: LengthUnit(origin[2]),
|
||||
},
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
/// A 3D axis or tagged edge.
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
|
||||
#[ts(export)]
|
||||
#[serde(untagged)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum Axis3dOrEdgeReference {
|
||||
/// 3D axis and origin.
|
||||
Axis(AxisAndOrigin3d),
|
||||
Axis { direction: [f64; 3], origin: [f64; 3] },
|
||||
/// Tagged edge.
|
||||
Edge(EdgeReference),
|
||||
}
|
||||
|
||||
/// A 3D axis and origin.
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
|
||||
#[ts(export)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum AxisAndOrigin3d {
|
||||
/// X-axis.
|
||||
#[serde(rename = "X", alias = "x")]
|
||||
X,
|
||||
/// Y-axis.
|
||||
#[serde(rename = "Y", alias = "y")]
|
||||
Y,
|
||||
/// Z-axis.
|
||||
#[serde(rename = "Z", alias = "z")]
|
||||
Z,
|
||||
/// Flip the X-axis.
|
||||
#[serde(rename = "-X", alias = "-x")]
|
||||
NegX,
|
||||
/// Flip the Y-axis.
|
||||
#[serde(rename = "-Y", alias = "-y")]
|
||||
NegY,
|
||||
/// Flip the Z-axis.
|
||||
#[serde(rename = "-Z", alias = "-z")]
|
||||
NegZ,
|
||||
Custom {
|
||||
/// The axis.
|
||||
axis: [f64; 3],
|
||||
/// The origin.
|
||||
origin: [f64; 3],
|
||||
},
|
||||
}
|
||||
|
||||
impl AxisAndOrigin3d {
|
||||
/// Get the axis and origin.
|
||||
pub fn axis_and_origin(&self) -> Result<(kcmc::shared::Point3d<f64>, kcmc::shared::Point3d<LengthUnit>), KclError> {
|
||||
let (axis, origin) = match self {
|
||||
AxisAndOrigin3d::X => ([1.0, 0.0, 0.0], [0.0, 0.0, 0.0]),
|
||||
AxisAndOrigin3d::Y => ([0.0, 1.0, 0.0], [0.0, 0.0, 0.0]),
|
||||
AxisAndOrigin3d::Z => ([0.0, 0.0, 1.0], [0.0, 0.0, 0.0]),
|
||||
AxisAndOrigin3d::NegX => ([-1.0, 0.0, 0.0], [0.0, 0.0, 0.0]),
|
||||
AxisAndOrigin3d::NegY => ([0.0, -1.0, 0.0], [0.0, 0.0, 0.0]),
|
||||
AxisAndOrigin3d::NegZ => ([0.0, 0.0, -1.0], [0.0, 0.0, 0.0]),
|
||||
AxisAndOrigin3d::Custom { axis, origin } => {
|
||||
([axis[0], axis[1], axis[2]], [origin[0], origin[1], origin[2]])
|
||||
}
|
||||
};
|
||||
|
||||
Ok((
|
||||
kcmc::shared::Point3d {
|
||||
x: axis[0],
|
||||
y: axis[1],
|
||||
z: axis[2],
|
||||
},
|
||||
kcmc::shared::Point3d {
|
||||
x: LengthUnit(origin[0]),
|
||||
y: LengthUnit(origin[1]),
|
||||
z: LengthUnit(origin[2]),
|
||||
},
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
use crate::std::axis_or_reference::{
|
||||
Axis2dOrEdgeReference, Axis3dOrEdgeReference, AxisAndOrigin2d, AxisAndOrigin3d,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn test_deserialize_revolve_axis_2d() {
|
||||
let data = Axis2dOrEdgeReference::Axis(AxisAndOrigin2d::X);
|
||||
let mut str_json = serde_json::to_string(&data).unwrap();
|
||||
assert_eq!(str_json, "\"X\"");
|
||||
|
||||
str_json = "\"Y\"".to_string();
|
||||
let data: Axis2dOrEdgeReference = serde_json::from_str(&str_json).unwrap();
|
||||
assert_eq!(data, Axis2dOrEdgeReference::Axis(AxisAndOrigin2d::Y));
|
||||
|
||||
str_json = "\"-Y\"".to_string();
|
||||
let data: Axis2dOrEdgeReference = serde_json::from_str(&str_json).unwrap();
|
||||
assert_eq!(data, Axis2dOrEdgeReference::Axis(AxisAndOrigin2d::NegY));
|
||||
|
||||
str_json = "\"-x\"".to_string();
|
||||
let data: Axis2dOrEdgeReference = serde_json::from_str(&str_json).unwrap();
|
||||
assert_eq!(data, Axis2dOrEdgeReference::Axis(AxisAndOrigin2d::NegX));
|
||||
|
||||
let data = Axis2dOrEdgeReference::Axis(AxisAndOrigin2d::Custom {
|
||||
axis: [0.0, -1.0],
|
||||
origin: [1.0, 0.0],
|
||||
});
|
||||
str_json = serde_json::to_string(&data).unwrap();
|
||||
assert_eq!(str_json, r#"{"custom":{"axis":[0.0,-1.0],"origin":[1.0,0.0]}}"#);
|
||||
|
||||
str_json = r#"{"custom": {"axis": [0,-1], "origin": [1,2.0]}}"#.to_string();
|
||||
let data: Axis2dOrEdgeReference = serde_json::from_str(&str_json).unwrap();
|
||||
assert_eq!(
|
||||
data,
|
||||
Axis2dOrEdgeReference::Axis(AxisAndOrigin2d::Custom {
|
||||
axis: [0.0, -1.0],
|
||||
origin: [1.0, 2.0]
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialize_revolve_axis_3d() {
|
||||
let data = Axis3dOrEdgeReference::Axis(AxisAndOrigin3d::X);
|
||||
let mut str_json = serde_json::to_string(&data).unwrap();
|
||||
assert_eq!(str_json, "\"X\"");
|
||||
|
||||
str_json = "\"Y\"".to_string();
|
||||
let data: Axis3dOrEdgeReference = serde_json::from_str(&str_json).unwrap();
|
||||
assert_eq!(data, Axis3dOrEdgeReference::Axis(AxisAndOrigin3d::Y));
|
||||
|
||||
str_json = "\"Z\"".to_string();
|
||||
let data: Axis3dOrEdgeReference = serde_json::from_str(&str_json).unwrap();
|
||||
assert_eq!(data, Axis3dOrEdgeReference::Axis(AxisAndOrigin3d::Z));
|
||||
|
||||
str_json = "\"-Y\"".to_string();
|
||||
let data: Axis3dOrEdgeReference = serde_json::from_str(&str_json).unwrap();
|
||||
assert_eq!(data, Axis3dOrEdgeReference::Axis(AxisAndOrigin3d::NegY));
|
||||
|
||||
str_json = "\"-x\"".to_string();
|
||||
let data: Axis3dOrEdgeReference = serde_json::from_str(&str_json).unwrap();
|
||||
assert_eq!(data, Axis3dOrEdgeReference::Axis(AxisAndOrigin3d::NegX));
|
||||
|
||||
str_json = "\"-z\"".to_string();
|
||||
let data: Axis3dOrEdgeReference = serde_json::from_str(&str_json).unwrap();
|
||||
assert_eq!(data, Axis3dOrEdgeReference::Axis(AxisAndOrigin3d::NegZ));
|
||||
|
||||
let data = Axis3dOrEdgeReference::Axis(AxisAndOrigin3d::Custom {
|
||||
axis: [0.0, -1.0, 0.0],
|
||||
origin: [1.0, 0.0, 0.0],
|
||||
});
|
||||
str_json = serde_json::to_string(&data).unwrap();
|
||||
assert_eq!(str_json, r#"{"custom":{"axis":[0.0,-1.0,0.0],"origin":[1.0,0.0,0.0]}}"#);
|
||||
|
||||
str_json = r#"{"custom": {"axis": [0,-1,0], "origin": [1,2.0,0]}}"#.to_string();
|
||||
let data: Axis3dOrEdgeReference = serde_json::from_str(&str_json).unwrap();
|
||||
assert_eq!(
|
||||
data,
|
||||
Axis3dOrEdgeReference::Axis(AxisAndOrigin3d::Custom {
|
||||
axis: [0.0, -1.0, 0.0],
|
||||
origin: [1.0, 2.0, 0.0]
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,8 @@ pub async fn union(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
/// Union two or more solids into a single solid.
|
||||
///
|
||||
/// ```no_run
|
||||
/// // Union two cubes using the stdlib functions.
|
||||
///
|
||||
/// fn cube(center) {
|
||||
/// return startSketchOn('XY')
|
||||
/// |> startProfileAt([center[0] - 10, center[1] - 10], %)
|
||||
@ -43,6 +45,52 @@ pub async fn union(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
///
|
||||
/// unionedPart = union([part001, part002])
|
||||
/// ```
|
||||
///
|
||||
/// ```no_run
|
||||
/// // Union two cubes using operators.
|
||||
/// // NOTE: This will not work when using codemods through the UI.
|
||||
/// // Codemods will generate the stdlib function call instead.
|
||||
///
|
||||
/// fn cube(center) {
|
||||
/// return startSketchOn('XY')
|
||||
/// |> startProfileAt([center[0] - 10, center[1] - 10], %)
|
||||
/// |> line(endAbsolute = [center[0] + 10, center[1] - 10])
|
||||
/// |> line(endAbsolute = [center[0] + 10, center[1] + 10])
|
||||
/// |> line(endAbsolute = [center[0] - 10, center[1] + 10])
|
||||
/// |> close()
|
||||
/// |> extrude(length = 10)
|
||||
/// }
|
||||
///
|
||||
/// part001 = cube([0, 0])
|
||||
/// part002 = cube([20, 10])
|
||||
///
|
||||
/// // This is the equivalent of: union([part001, part002])
|
||||
/// unionedPart = part001 + part002
|
||||
/// ```
|
||||
///
|
||||
/// ```no_run
|
||||
/// // Union two cubes using the more programmer-friendly operator.
|
||||
/// // NOTE: This will not work when using codemods through the UI.
|
||||
/// // Codemods will generate the stdlib function call instead.
|
||||
///
|
||||
/// fn cube(center) {
|
||||
/// return startSketchOn('XY')
|
||||
/// |> startProfileAt([center[0] - 10, center[1] - 10], %)
|
||||
/// |> line(endAbsolute = [center[0] + 10, center[1] - 10])
|
||||
/// |> line(endAbsolute = [center[0] + 10, center[1] + 10])
|
||||
/// |> line(endAbsolute = [center[0] - 10, center[1] + 10])
|
||||
/// |> close()
|
||||
/// |> extrude(length = 10)
|
||||
/// }
|
||||
///
|
||||
/// part001 = cube([0, 0])
|
||||
/// part002 = cube([20, 10])
|
||||
///
|
||||
/// // This is the equivalent of: union([part001, part002])
|
||||
/// // Programmers will understand `|` as a union operation, but mechanical engineers
|
||||
/// // will understand `+`, we made both work.
|
||||
/// unionedPart = part001 | part002
|
||||
/// ```
|
||||
#[stdlib {
|
||||
name = "union",
|
||||
feature_tree_operation = true,
|
||||
@ -53,7 +101,11 @@ pub async fn union(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
solids = {docs = "The solids to union."},
|
||||
}
|
||||
}]
|
||||
async fn inner_union(solids: Vec<Solid>, exec_state: &mut ExecState, args: Args) -> Result<Vec<Solid>, KclError> {
|
||||
pub(crate) async fn inner_union(
|
||||
solids: Vec<Solid>,
|
||||
exec_state: &mut ExecState,
|
||||
args: Args,
|
||||
) -> Result<Vec<Solid>, KclError> {
|
||||
// Flush the fillets for the solids.
|
||||
args.flush_batch_for_solids(exec_state, &solids).await?;
|
||||
|
||||
@ -90,6 +142,8 @@ pub async fn intersect(exec_state: &mut ExecState, args: Args) -> Result<KclValu
|
||||
/// verifying fit, and analyzing overlapping geometries in assemblies.
|
||||
///
|
||||
/// ```no_run
|
||||
/// // Intersect two cubes using the stdlib functions.
|
||||
///
|
||||
/// fn cube(center) {
|
||||
/// return startSketchOn('XY')
|
||||
/// |> startProfileAt([center[0] - 10, center[1] - 10], %)
|
||||
@ -105,6 +159,28 @@ pub async fn intersect(exec_state: &mut ExecState, args: Args) -> Result<KclValu
|
||||
///
|
||||
/// intersectedPart = intersect([part001, part002])
|
||||
/// ```
|
||||
///
|
||||
/// ```no_run
|
||||
/// // Intersect two cubes using operators.
|
||||
/// // NOTE: This will not work when using codemods through the UI.
|
||||
/// // Codemods will generate the stdlib function call instead.
|
||||
///
|
||||
/// fn cube(center) {
|
||||
/// return startSketchOn('XY')
|
||||
/// |> startProfileAt([center[0] - 10, center[1] - 10], %)
|
||||
/// |> line(endAbsolute = [center[0] + 10, center[1] - 10])
|
||||
/// |> line(endAbsolute = [center[0] + 10, center[1] + 10])
|
||||
/// |> line(endAbsolute = [center[0] - 10, center[1] + 10])
|
||||
/// |> close()
|
||||
/// |> extrude(length = 10)
|
||||
/// }
|
||||
///
|
||||
/// part001 = cube([0, 0])
|
||||
/// part002 = cube([8, 8])
|
||||
///
|
||||
/// // This is the equivalent of: intersect([part001, part002])
|
||||
/// intersectedPart = part001 & part002
|
||||
/// ```
|
||||
#[stdlib {
|
||||
name = "intersect",
|
||||
feature_tree_operation = true,
|
||||
@ -115,7 +191,11 @@ pub async fn intersect(exec_state: &mut ExecState, args: Args) -> Result<KclValu
|
||||
solids = {docs = "The solids to intersect."},
|
||||
}
|
||||
}]
|
||||
async fn inner_intersect(solids: Vec<Solid>, exec_state: &mut ExecState, args: Args) -> Result<Vec<Solid>, KclError> {
|
||||
pub(crate) async fn inner_intersect(
|
||||
solids: Vec<Solid>,
|
||||
exec_state: &mut ExecState,
|
||||
args: Args,
|
||||
) -> Result<Vec<Solid>, KclError> {
|
||||
// Flush the fillets for the solids.
|
||||
args.flush_batch_for_solids(exec_state, &solids).await?;
|
||||
|
||||
@ -145,6 +225,8 @@ pub async fn subtract(exec_state: &mut ExecState, args: Args) -> Result<KclValue
|
||||
/// and complex multi-body part modeling.
|
||||
///
|
||||
/// ```no_run
|
||||
/// // Subtract a cylinder from a cube using the stdlib functions.
|
||||
///
|
||||
/// fn cube(center) {
|
||||
/// return startSketchOn('XY')
|
||||
/// |> startProfileAt([center[0] - 10, center[1] - 10], %)
|
||||
@ -162,6 +244,30 @@ pub async fn subtract(exec_state: &mut ExecState, args: Args) -> Result<KclValue
|
||||
///
|
||||
/// subtractedPart = subtract([part001], tools=[part002])
|
||||
/// ```
|
||||
///
|
||||
/// ```no_run
|
||||
/// // Subtract a cylinder from a cube using operators.
|
||||
/// // NOTE: This will not work when using codemods through the UI.
|
||||
/// // Codemods will generate the stdlib function call instead.
|
||||
///
|
||||
/// fn cube(center) {
|
||||
/// return startSketchOn('XY')
|
||||
/// |> startProfileAt([center[0] - 10, center[1] - 10], %)
|
||||
/// |> line(endAbsolute = [center[0] + 10, center[1] - 10])
|
||||
/// |> line(endAbsolute = [center[0] + 10, center[1] + 10])
|
||||
/// |> line(endAbsolute = [center[0] - 10, center[1] + 10])
|
||||
/// |> close()
|
||||
/// |> extrude(length = 10)
|
||||
/// }
|
||||
///
|
||||
/// part001 = cube([0, 0])
|
||||
/// part002 = startSketchOn('XY')
|
||||
/// |> circle(center = [0, 0], radius = 2)
|
||||
/// |> extrude(length = 10)
|
||||
///
|
||||
/// // This is the equivalent of: subtract([part001], tools=[part002])
|
||||
/// subtractedPart = part001 - part002
|
||||
/// ```
|
||||
#[stdlib {
|
||||
name = "subtract",
|
||||
feature_tree_operation = true,
|
||||
@ -169,11 +275,11 @@ pub async fn subtract(exec_state: &mut ExecState, args: Args) -> Result<KclValue
|
||||
unlabeled_first = true,
|
||||
deprecated = true,
|
||||
args = {
|
||||
solids = {docs = "The solids to intersect."},
|
||||
solids = {docs = "The solids to use as the base to subtract from."},
|
||||
tools = {docs = "The solids to subtract."},
|
||||
}
|
||||
}]
|
||||
async fn inner_subtract(
|
||||
pub(crate) async fn inner_subtract(
|
||||
solids: Vec<Solid>,
|
||||
tools: Vec<Solid>,
|
||||
exec_state: &mut ExecState,
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user