Compare commits

..

27 Commits

Author SHA1 Message Date
c45c2e27ba make sure the nix flake never breaks (#6273)
make sure teh nix flake never breaks

Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-04-11 06:27:42 +00:00
5832890dbb Add CSG operations to the artifact graph (#6104)
* Add CSG operations to the artifact graph

* Add tool IDs for subtract

* Fix names to match modeling-cmds now that it's done

* Update output since adding CSG ops

* Update formatting

* Add extra solid ids to the graph

* Fix to not add duplicates to the graph
2025-04-11 05:16:29 +00:00
6f2e6d14b6 refactor: Change to use topLevelModule helper function (#6264) 2025-04-11 05:13:10 +00:00
0d899694b2 Remove experimental warning on whole-module imports (#6240) 2025-04-11 04:22:51 +00:00
7bd5e7365d Insert a newline between block comments and attributes (#6250)
Signed-off-by: Nick Cameron <nrc@ncameron.org>
Co-authored-by: Jess Frazelle <jessfraz@users.noreply.github.com>
2025-04-11 03:19:52 +00:00
a63e51e2ad Remove import function from std (#6241)
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2025-04-11 03:11:59 +00:00
1b8eee86a1 Fix vscode lsp bugs (#6271)
* start of shit

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* untitled test

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-04-11 12:53:05 +10:00
6d50278d34 bump kcl friends (#6272)
Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-04-10 19:01:30 -07:00
35844842de Bump modeling api & pull thru csg endpoints (#6245)
* csg-upts

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* base

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* do the id shit

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* tried to run

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* csg-upts

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* use bens samples

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* use bens samples

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* gen std

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* gen std

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fix;

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-04-10 18:30:57 -07:00
843e772094 Franknoirot/adhoc/improve e2e (#6265)
* fix: increasing timeout to reduce failures..?

* fix: removing debugging code

* Remove unnecessary pixel color check

* Only close the command palette on disconnection events

This code closes the palette on *any* network event, including it
getting established. This made tests like "Create a few projects using
the default project name" unreliable.

Also adds a block comment about how we should do something more
sophisticated than bail out in the future.

* Show a toast to explain why the user just lost their command flow

* Remove unnecessary click in test. `fill` focuses already

* Oop don't spam this disconnection toast if the palette isn't open

Honoring exhausting hook dependency checks

* Skip circle snapshot test, it's being weird

* Disable the export button if engine connection is unavailable

* Refactor useDemoCode to hopefully be more reliable

* allow weak connections to receive demo code

* revert Refactor useDemoCode to hopefully be more reliable
Commit:
2625c14783 [2625c1478]

---------

Co-authored-by: Kevin Nadro <kevin@zoo.dev>
Co-authored-by: Jace Browning <jacebrowning@gmail.com>
Co-authored-by: Andrew Varga <grizzly33@gmail.com>
2025-04-11 00:08:39 +00:00
9d0518dfeb Fix URL encoded names after rename to Zoo Design Studio (#6269) 2025-04-10 17:20:37 -04:00
d33d399c31 Repetitive structs removed for import file extensions (#6211)
* get rid of repetitive structs

Signed-off-by: Jess Frazelle <github@jessfraz.com>

fmt

Signed-off-by: Jess Frazelle <github@jessfraz.com>

get rid of more

Signed-off-by: Jess Frazelle <github@jessfraz.com>

add more

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

fix

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

await the shit

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

put it at the root

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fix;es

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fixes

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fix

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* kcl-language-server flake

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-04-10 13:57:12 -07:00
970cf7f017 skip unreliable AI tests (#6252)
skip unrealiable AI tests
2025-04-10 12:10:57 -04:00
d125efcd60 Bidirectional extrude/revolve (#6154)
* extend extrude endpoint

* revolve and mocks

* add bounds check to revolve

* kcl examples of new args

* update to 110

* fix mock

* move example to prelude

* change to camelCase

* new prelude tests

* extend just file

* missed change

* change to XY

* redo sim tests

* review changes

* redo markdown
2025-04-10 10:46:10 -04:00
4664427832 Add a sidebar action to create a share link (#6233) 2025-04-10 00:27:22 +00:00
d84b9cc875 Remove flaky pixel check from prompt-to-edit test (#6225)
remove flaky pixel check
2025-04-10 00:06:38 +00:00
0c6b6bf5d5 Fix bad merge with some KCL snapshots (#6239)
Caused by admin merge in #5803
2025-04-09 16:43:56 -04:00
d275995dfe KCL: Angled line should use keyword args (#5803)
We continue migrating KCL stdlib functions to use keyword arguments. Next up is the `angledLine` family of functions (except `angledLineThatIntersects, which will be a quick follow-up).

Before vs. after:

`angledLine({angle = 90, length = 3}, %, $edge)`
  => `angledLine(angle = 90, length = 3, tag = $edge)`

`angledLineOfXLength({angle = 90, length = 3}, %, $edge)`
  => `angledLine(angle = 90, lengthX = 3, tag = $edge)`

`angledLineOfYLength({angle = 90, length = 3}, %, $edge)`
  => `angledLine(angle = 90, lengthY = 3, tag = $edge)`

`angledLineToX({angle = 90, length = 3}, %, $edge)`
  => `angledLine(angle = 90, endAbsoluteX = 3, tag = $edge)`

`angledLineToY({angle = 90, length = 3}, %, $edge)`
  => `angledLine(angle = 90, endAbsoluteY = 3, tag = $edge)`
2025-04-09 14:55:15 -05:00
b03ca30379 Cleanup spatula example. (#6232)
* Cleanup spatula example. Naming better variables and removing unused tags

* Update kcl-samples simulation test output

* remove unused tag

* fix spacing

* Update kcl-samples simulation test output

* cleanup comments

* Update kcl-samples simulation test output

* re-add spacing

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Greg Sweeney <greg@kittycad.io>
Co-authored-by: jgomez720 <114548659+jgomez720@users.noreply.github.com>
2025-04-09 15:21:05 -04:00
e5f23a49b4 #4469 Improve toolbar ux (#5841)
* Improve ActionButtonDropdown selection

* center rectangle icon fixed

* ignore Esc key when displaying hotkeys

* add ability to escape 3 point circle tool

* remove focus from ActionButton, ActionButtonDropdown

* remove focus outline from buttons

* remember lastly selected multi action item

* Add tests for toolbar buttons

* fix sketch-tests by turning toolbar dropdown arrays into an object with an id - this got broken because dropdown now remember the last selected option so we cant rely on cant reference the first option in tests

* update other tests with open menu click
2025-04-09 14:32:52 +02:00
e78100eaac Assemblies: UX improvements around foreign file imports (#6159)
* WIP: Add point-and-click Import for geometry
Will eventually fix #6120
Right now the whole loop is there but the codemod doesn't work yet

* Better pathToNOde, log on non-working cm dispatch call

* Add workaround to updateModelingState not working

* Back to updateModelingState with a skip flag

* Better todo

* Change working from Import to Insert, cleanups

* Sister command in kclCommands to populate file options

* Improve path selector

* Unsure: move importAstMod to kclCommands onSubmit 😶

* Add e2e test

* Clean up for review

* Add native file menu entry and test

* No await yo lint said so

* WIP: UX improvements around foreign file imports
Fixes #6152

* @lrev-Dev's suggestion to remove a comment

Co-authored-by: Kurt Hutten <k.hutten@protonmail.ch>

* Update to scene.settled(cmdBar)

* Add partNNN default name for alias

* Lint

* Lint

* Fix unit tests

* Add sad path insert test
Thanks @Irev-Dev for the suggestion

* Add step insert test

* Lint

* Add test for second foreign import thru file tree click

* Add default value for local name alias

* Aligning tests

* Fix tests

* Add padding for filenames starting with a digit

---------

Co-authored-by: Kurt Hutten <k.hutten@protonmail.ch>
2025-04-09 07:47:57 -04:00
ae9d8be4e4 Don't apply numeric adjustments in arithmetic yet (#6222)
Don't apply numeric adjustments yet

Signed-off-by: Nick Cameron <nrc@ncameron.org>
2025-04-09 14:16:58 +12:00
e4f73a6d5c Continue running tests with weak network (#6223) 2025-04-09 02:13:38 +00:00
a31fd608cf Improve hovers for KCL std lib fns (#6208)
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2025-04-09 12:15:12 +12:00
a98d5aa2fb Fix to not filter out empty modules from the Feature Tree (#6224) 2025-04-08 23:56:27 +00:00
4c6ef841bb Handle PowerShell vs. Git Bash on Windows (#6207) 2025-04-08 23:47:56 +00:00
997f539a8c More numeric type propagations (#6221)
Last few numeric type propagations

Signed-off-by: Nick Cameron <nrc@ncameron.org>
2025-04-09 11:46:54 +12:00
504 changed files with 50136 additions and 45934 deletions

View File

@ -378,7 +378,7 @@ jobs:
NOTES: ${{ needs.prepare-files.outputs.notes }} NOTES: ${{ needs.prepare-files.outputs.notes }}
PUB_DATE: ${{ github.event.repository.updated_at }} PUB_DATE: ${{ github.event.repository.updated_at }}
WEBSITE_DIR: ${{ env.IS_NIGHTLY == 'true' && 'dl.zoo.dev/releases/modeling-app/nightly' || 'dl.zoo.dev/releases/modeling-app' }} WEBSITE_DIR: ${{ env.IS_NIGHTLY == 'true' && 'dl.zoo.dev/releases/modeling-app/nightly' || 'dl.zoo.dev/releases/modeling-app' }}
URL_CODED_NAME: ${{ env.IS_NIGHTLY == 'true' && 'Zoo%20Modeling%20App%20%28Nightly%29' || 'Zoo%20Modeling%20App' }} URL_CODED_NAME: ${{ env.IS_NIGHTLY == 'true' && 'Zoo%20Design%20Studio%20%28Nightly%29' || 'Zoo%20Design%20Studio' }}
run: | run: |
RELEASE_DIR=https://${WEBSITE_DIR} RELEASE_DIR=https://${WEBSITE_DIR}
jq --null-input \ jq --null-input \

55
.github/workflows/nix.yml vendored Normal file
View File

@ -0,0 +1,55 @@
name: Test Nix Flake
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
nix-flake-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: nix flake check for all platforms
run: |
nix flake check --all-systems
nix-build-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: nix build . for x86_64-linux
run: nix build .
nix-build-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: nix build . for x86_64-darwin
run: nix build .

1
.gitignore vendored
View File

@ -26,6 +26,7 @@ yarn-error.log*
.idea .idea
.vscode .vscode
.helix .helix
result
# rust # rust
rust/target rust/target

View File

@ -5,11 +5,18 @@ all: install build check
# INSTALL # INSTALL
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
CARGO ?= ~/.cargo/bin/cargo.exe export WINDOWS := true
WASM_PACK ?= ~/.cargo/bin/wasm-pack.exe ifndef MSYSTEM
export POWERSHELL := true
endif
endif
ifdef WINDOWS
CARGO ?= $(USERPROFILE)/.cargo/bin/cargo.exe
WASM_PACK ?= $(USERPROFILE)/.cargo/bin/wasm-pack.exe
else else
CARGO ?= ~/.cargo/bin/cargo CARGO ?= ~/.cargo/bin/cargo
WASM_PACK ?= ~/.cargo/bin/wasm-pack WASM_PACK ?= ~/.cargo/bin/wasm-pack
endif endif
.PHONY: install .PHONY: install
@ -17,21 +24,21 @@ install: node_modules/.yarn-integrity $(CARGO) $(WASM_PACK) ## Install dependenc
node_modules/.yarn-integrity: package.json yarn.lock node_modules/.yarn-integrity: package.json yarn.lock
yarn install yarn install
ifeq ($(OS),Windows_NT) ifdef POWERSHELL
@ type nul > $@ @ type nul > $@
else else
@ touch $@ @ touch $@
endif endif
$(CARGO): $(CARGO):
ifeq ($(OS),Windows_NT) ifdef WINDOWS
yarn install:rust:windows yarn install:rust:windows
else else
yarn install:rust yarn install:rust
endif endif
$(WASM_PACK): $(WASM_PACK):
ifeq ($(OS),Windows_NT) ifdef WINDOWS
yarn install:wasm-pack:cargo yarn install:wasm-pack:cargo
else else
yarn install:wasm-pack:sh yarn install:wasm-pack:sh
@ -57,7 +64,7 @@ build-web: install public/kcl_wasm_lib_bg.wasm build/index.html
build-desktop: install public/kcl_wasm_lib_bg.wasm .vite/build/main.js build-desktop: install public/kcl_wasm_lib_bg.wasm .vite/build/main.js
public/kcl_wasm_lib_bg.wasm: $(CARGO_SOURCES) $(RUST_SOURCES) public/kcl_wasm_lib_bg.wasm: $(CARGO_SOURCES) $(RUST_SOURCES)
ifeq ($(OS),Windows_NT) ifdef WINDOWS
yarn build:wasm:dev:windows yarn build:wasm:dev:windows
else else
yarn build:wasm:dev yarn build:wasm:dev
@ -140,8 +147,8 @@ endif
.PHONY: clean .PHONY: clean
clean: ## Delete all artifacts clean: ## Delete all artifacts
ifeq ($(OS),Windows_NT) ifdef POWERSHELL
git clean --force -d -X git clean --force -d -x --exclude=.env* --exclude=**/*.env
else else
rm -rf .vite/ build/ rm -rf .vite/ build/
rm -rf trace.zip playwright-report/ test-results/ rm -rf trace.zip playwright-report/ test-results/
@ -152,7 +159,7 @@ endif
.PHONY: help .PHONY: help
help: install help: install
ifeq ($(OS),Windows_NT) ifdef POWERSHELL
@ powershell -Command "Get-Content $(MAKEFILE_LIST) | Select-String -Pattern '^[^\s]+:.*##\s.*$$' | ForEach-Object { $$line = $$_.Line -split ':.*?##\s+'; Write-Host -NoNewline $$line[0].PadRight(30) -ForegroundColor Cyan; Write-Host $$line[1] }" @ powershell -Command "Get-Content $(MAKEFILE_LIST) | Select-String -Pattern '^[^\s]+:.*##\s.*$$' | ForEach-Object { $$line = $$_.Line -split ':.*?##\s+'; Write-Host -NoNewline $$line[0].PadRight(30) -ForegroundColor Cyan; Write-Host $$line[1] }"
else else
@ grep -E '^[^[:space:]]+:.*## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' @ grep -E '^[^[:space:]]+:.*## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

View File

@ -36,9 +36,9 @@ myAngle = -120
sketch001 = startSketchOn(XZ) sketch001 = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line(end = [8, 0]) |> line(end = [8, 0])
|> angledLine({ angle = abs(myAngle), length = 5 }, %) |> angledLine(angle = abs(myAngle), length = 5)
|> line(end = [-5, 0]) |> line(end = [-5, 0])
|> angledLine({ angle = myAngle, length = 5 }, %) |> angledLine(angle = myAngle, length = 5)
|> close() |> close()
baseExtrusion = extrude(sketch001, length = 5) baseExtrusion = extrude(sketch001, length = 5)

View File

@ -33,10 +33,7 @@ acos(num: number): number
```js ```js
sketch001 = startSketchOn(XZ) sketch001 = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> angledLine({ |> angledLine(angle = toDegrees(acos(0.5)), length = 10)
angle = toDegrees(acos(0.5)),
length = 10
}, %)
|> line(end = [5, 0]) |> line(end = [5, 0])
|> line(endAbsolute = [12, 0]) |> line(endAbsolute = [12, 0])
|> close() |> close()

View File

@ -36,7 +36,7 @@ angleToMatchLengthX(
sketch001 = startSketchOn(XZ) sketch001 = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line(end = [2, 5], tag = $seg01) |> line(end = [2, 5], tag = $seg01)
|> angledLineToX([-angleToMatchLengthX(seg01, 7, %), 10], %) |> angledLine(angle = -angleToMatchLengthX(seg01, 7, %), endAbsoluteX = 10)
|> close() |> close()
extrusion = extrude(sketch001, length = 5) extrusion = extrude(sketch001, length = 5)

View File

@ -36,10 +36,7 @@ angleToMatchLengthY(
sketch001 = startSketchOn(XZ) sketch001 = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line(end = [1, 2], tag = $seg01) |> line(end = [1, 2], tag = $seg01)
|> angledLine({ |> angledLine(angle = angleToMatchLengthY(seg01, 15, %), length = 5)
angle = angleToMatchLengthY(seg01, 15, %),
length = 5
}, %)
|> yLine(endAbsolute = 0) |> yLine(endAbsolute = 0)
|> close() |> close()

View File

@ -10,8 +10,13 @@ Draw a line segment relative to the current origin using the polar measure of so
```js ```js
angledLine( angledLine(
data: AngledLineData,
sketch: Sketch, sketch: Sketch,
angle: number,
length?: number,
lengthX?: number,
lengthY?: number,
endAbsoluteX?: number,
endAbsoluteY?: number,
tag?: TagDeclarator, tag?: TagDeclarator,
): Sketch ): Sketch
``` ```
@ -21,9 +26,14 @@ angledLine(
| Name | Type | Description | Required | | Name | Type | Description | Required |
|----------|------|-------------|----------| |----------|------|-------------|----------|
| `data` | [`AngledLineData`](/docs/kcl/types/AngledLineData) | Data to draw an angled line. | Yes | | `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | Which sketch should this path be added to? | Yes |
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | | Yes | | `angle` | [`number`](/docs/kcl/types/number) | Which angle should the line be drawn at? | Yes |
| [`tag`](/docs/kcl/types/tag) | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No | | `length` | [`number`](/docs/kcl/types/number) | Draw the line this distance along the given angle. Only one of `length`, `lengthX`, `lengthY`, `lengthAbsoluteEndX`, `lengthAbsoluteEndY` can be given. | No |
| `lengthX` | [`number`](/docs/kcl/types/number) | Draw the line this distance along the X axis. Only one of `length`, `lengthX`, `lengthY`, `lengthAbsoluteEndX`, `lengthAbsoluteEndY` can be given. | No |
| `lengthY` | [`number`](/docs/kcl/types/number) | Draw the line this distance along the Y axis. Only one of `length`, `lengthX`, `lengthY`, `lengthAbsoluteEndX`, `lengthAbsoluteEndY` can be given. | No |
| `endAbsoluteX` | [`number`](/docs/kcl/types/number) | Draw the line along the given angle until it reaches this point along the X axis. Only one of `length`, `lengthX`, `lengthY`, `lengthAbsoluteEndX`, `lengthAbsoluteEndY` can be given. | No |
| `endAbsoluteY` | [`number`](/docs/kcl/types/number) | Draw the line along the given angle until it reaches this point along the Y axis. Only one of `length`, `lengthX`, `lengthY`, `lengthAbsoluteEndX`, `lengthAbsoluteEndY` can be given. | No |
| [`tag`](/docs/kcl/types/tag) | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | Create a new tag which refers to this line | No |
### Returns ### Returns
@ -36,7 +46,7 @@ angledLine(
exampleSketch = startSketchOn(XZ) exampleSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> yLine(endAbsolute = 15) |> yLine(endAbsolute = 15)
|> angledLine({ angle = 30, length = 15 }, %) |> angledLine(angle = 30, length = 15)
|> line(end = [8, -10]) |> line(end = [8, -10])
|> yLine(endAbsolute = 0) |> yLine(endAbsolute = 0)
|> close() |> close()

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

File diff suppressed because one or more lines are too long

View File

@ -33,10 +33,7 @@ asin(num: number): number
```js ```js
sketch001 = startSketchOn(XZ) sketch001 = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> angledLine({ |> angledLine(angle = toDegrees(asin(0.5)), length = 20)
angle = toDegrees(asin(0.5)),
length = 20
}, %)
|> yLine(endAbsolute = 0) |> yLine(endAbsolute = 0)
|> close() |> close()

View File

@ -33,10 +33,7 @@ atan(num: number): number
```js ```js
sketch001 = startSketchOn(XZ) sketch001 = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> angledLine({ |> angledLine(angle = toDegrees(atan(1.25)), length = 20)
angle = toDegrees(atan(1.25)),
length = 20
}, %)
|> yLine(endAbsolute = 0) |> yLine(endAbsolute = 0)
|> close() |> close()

View File

@ -37,10 +37,7 @@ atan2(
```js ```js
sketch001 = startSketchOn(XZ) sketch001 = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> angledLine({ |> angledLine(angle = toDegrees(atan2(1.25, 2)), length = 20)
angle = toDegrees(atan2(1.25, 2)),
length = 20
}, %)
|> yLine(endAbsolute = 0) |> yLine(endAbsolute = 0)
|> close() |> close()

View File

@ -17,10 +17,10 @@ std::math::E: number = 2.71828182845904523536028747135266250_
```js ```js
exampleSketch = startSketchOn(XZ) exampleSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> angledLine({ |> angledLine(
angle = 30, angle = 30,
length = 2 * E ^ 2, length = 2 * E ^ 2,
}, %) )
|> yLine(endAbsolute = 0) |> yLine(endAbsolute = 0)
|> close() |> close()

View File

@ -17,10 +17,10 @@ std::math::TAU: number = 6.28318530717958647692528676655900577_
```js ```js
exampleSketch = startSketchOn(XZ) exampleSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> angledLine({ |> angledLine(
angle = 50, angle = 50,
length = 10 * TAU, length = 10 * TAU,
}, %) )
|> yLine(endAbsolute = 0) |> yLine(endAbsolute = 0)
|> close() |> close()

View File

@ -30,7 +30,7 @@ e(): number
```js ```js
exampleSketch = startSketchOn(XZ) exampleSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> angledLine({ angle = 30, length = 2 * e() ^ 2 }, %) |> angledLine(angle = 30, length = 2 * e() ^ 2)
|> yLine(endAbsolute = 0) |> yLine(endAbsolute = 0)
|> close() |> close()

File diff suppressed because one or more lines are too long

View File

@ -30,10 +30,10 @@ getNextAdjacentEdge(tag: TagIdentifier): Uuid
exampleSketch = startSketchOn(XZ) exampleSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line(end = [10, 0]) |> line(end = [10, 0])
|> angledLine({ angle = 60, length = 10 }, %) |> angledLine(angle = 60, length = 10)
|> angledLine({ angle = 120, length = 10 }, %) |> angledLine(angle = 120, length = 10)
|> line(end = [-10, 0]) |> line(end = [-10, 0])
|> angledLine({ angle = 240, length = 10 }, %, $referenceEdge) |> angledLine(angle = 240, length = 10, tag = $referenceEdge)
|> close() |> close()
example = extrude(exampleSketch, length = 5) example = extrude(exampleSketch, length = 5)

View File

@ -30,10 +30,10 @@ getOppositeEdge(tag: TagIdentifier): Uuid
exampleSketch = startSketchOn(XZ) exampleSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line(end = [10, 0]) |> line(end = [10, 0])
|> angledLine({ angle = 60, length = 10 }, %) |> angledLine(angle = 60, length = 10)
|> angledLine({ angle = 120, length = 10 }, %) |> angledLine(angle = 120, length = 10)
|> line(end = [-10, 0]) |> line(end = [-10, 0])
|> angledLine({ angle = 240, length = 10 }, %, $referenceEdge) |> angledLine(angle = 240, length = 10, tag = $referenceEdge)
|> close() |> close()
example = extrude(exampleSketch, length = 5) example = extrude(exampleSketch, length = 5)

View File

@ -30,10 +30,10 @@ getPreviousAdjacentEdge(tag: TagIdentifier): Uuid
exampleSketch = startSketchOn(XZ) exampleSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line(end = [10, 0]) |> line(end = [10, 0])
|> angledLine({ angle = 60, length = 10 }, %) |> angledLine(angle = 60, length = 10)
|> angledLine({ angle = 120, length = 10 }, %) |> angledLine(angle = 120, length = 10)
|> line(end = [-10, 0]) |> line(end = [-10, 0])
|> angledLine({ angle = 240, length = 10 }, %, $referenceEdge) |> angledLine(angle = 240, length = 10, tag = $referenceEdge)
|> close() |> close()
example = extrude(exampleSketch, length = 5) example = extrude(exampleSketch, length = 5)

File diff suppressed because one or more lines are too long

View File

@ -43,11 +43,7 @@ layout: manual
* [`angleToMatchLengthX`](kcl/angleToMatchLengthX) * [`angleToMatchLengthX`](kcl/angleToMatchLengthX)
* [`angleToMatchLengthY`](kcl/angleToMatchLengthY) * [`angleToMatchLengthY`](kcl/angleToMatchLengthY)
* [`angledLine`](kcl/angledLine) * [`angledLine`](kcl/angledLine)
* [`angledLineOfXLength`](kcl/angledLineOfXLength)
* [`angledLineOfYLength`](kcl/angledLineOfYLength)
* [`angledLineThatIntersects`](kcl/angledLineThatIntersects) * [`angledLineThatIntersects`](kcl/angledLineThatIntersects)
* [`angledLineToX`](kcl/angledLineToX)
* [`angledLineToY`](kcl/angledLineToY)
* [`appearance`](kcl/appearance) * [`appearance`](kcl/appearance)
* [`arc`](kcl/arc) * [`arc`](kcl/arc)
* [`arcTo`](kcl/arcTo) * [`arcTo`](kcl/arcTo)
@ -81,6 +77,7 @@ layout: manual
* [`helix`](kcl/std-helix) * [`helix`](kcl/std-helix)
* [`hole`](kcl/hole) * [`hole`](kcl/hole)
* [`hollow`](kcl/hollow) * [`hollow`](kcl/hollow)
* [`intersect`](kcl/intersect)
* [`lastSegX`](kcl/lastSegX) * [`lastSegX`](kcl/lastSegX)
* [`lastSegY`](kcl/lastSegY) * [`lastSegY`](kcl/lastSegY)
* [`legAngX`](kcl/legAngX) * [`legAngX`](kcl/legAngX)
@ -127,6 +124,7 @@ layout: manual
* [`sqrt`](kcl/sqrt) * [`sqrt`](kcl/sqrt)
* [`startProfileAt`](kcl/startProfileAt) * [`startProfileAt`](kcl/startProfileAt)
* [`startSketchOn`](kcl/startSketchOn) * [`startSketchOn`](kcl/startSketchOn)
* [`subtract`](kcl/subtract)
* [`sweep`](kcl/sweep) * [`sweep`](kcl/sweep)
* [`tangentToEnd`](kcl/tangentToEnd) * [`tangentToEnd`](kcl/tangentToEnd)
* [`tangentialArc`](kcl/tangentialArc) * [`tangentialArc`](kcl/tangentialArc)
@ -135,6 +133,7 @@ layout: manual
* [`toDegrees`](kcl/toDegrees) * [`toDegrees`](kcl/toDegrees)
* [`toRadians`](kcl/toRadians) * [`toRadians`](kcl/toRadians)
* [`translate`](kcl/translate) * [`translate`](kcl/translate)
* [`union`](kcl/union)
* [`xLine`](kcl/xLine) * [`xLine`](kcl/xLine)
* [`yLine`](kcl/yLine) * [`yLine`](kcl/yLine)
* **std::math** * **std::math**

File diff suppressed because one or more lines are too long

View File

@ -33,10 +33,7 @@ max(args: [number]): number
```js ```js
exampleSketch = startSketchOn(XZ) exampleSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> angledLine({ |> angledLine(angle = 70, length = max(15, 31, 4, 13, 22))
angle = 70,
length = max(15, 31, 4, 13, 22)
}, %)
|> line(end = [20, 0]) |> line(end = [20, 0])
|> close() |> close()

View File

@ -33,10 +33,7 @@ min(args: [number]): number
```js ```js
exampleSketch = startSketchOn(XZ) exampleSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> angledLine({ |> angledLine(angle = 70, length = min(15, 31, 4, 13, 22))
angle = 70,
length = min(15, 31, 4, 13, 22)
}, %)
|> line(end = [20, 0]) |> line(end = [20, 0])
|> close() |> close()

View File

@ -37,7 +37,7 @@ pow(
```js ```js
exampleSketch = startSketchOn(XZ) exampleSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> angledLine({ angle = 50, length = pow(5, 2) }, %) |> angledLine(angle = 50, length = pow(5, 2))
|> yLine(endAbsolute = 0) |> yLine(endAbsolute = 0)
|> close() |> close()

View File

@ -29,11 +29,8 @@ profileStart(sketch: Sketch): [number]
```js ```js
sketch001 = startSketchOn(XY) sketch001 = startSketchOn(XY)
|> startProfileAt([5, 2], %) |> startProfileAt([5, 2], %)
|> angledLine({ angle = 120, length = 50 }, %, $seg01) |> angledLine(angle = 120, length = 50, tag = $seg01)
|> angledLine({ |> angledLine(angle = segAng(seg01) + 120, length = 50)
angle = segAng(seg01) + 120,
length = 50
}, %)
|> line(end = profileStart(%)) |> line(end = profileStart(%))
|> close() |> close()
|> extrude(length = 20) |> extrude(length = 20)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -78,7 +78,7 @@ assertEqual(sum, 6, 0.00001, "1 + 2 + 3 summed is 6")
```js ```js
// Declare a function that sketches a decagon. // Declare a function that sketches a decagon.
fn decagon(radius) { fn decagon(radius) {
// Each side of the decagon is turned this many degrees from the previous angle. // Each side of the decagon is turned this many radians from the previous angle.
stepAngle = 1 / 10 * TAU stepAngle = 1 / 10 * TAU
// Start the decagon sketch at this point. // Start the decagon sketch at this point.

View File

@ -151,15 +151,9 @@ cube
sketch001 = startSketchOn(XY) sketch001 = startSketchOn(XY)
rectangleSketch = startProfileAt([-200, 23.86], sketch001) rectangleSketch = startProfileAt([-200, 23.86], sketch001)
|> angledLine([0, 73.47], %, $rectangleSegmentA001) |> angledLine(angle = 0, length = 73.47, tag = $rectangleSegmentA001)
|> angledLine([ |> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 50.61)
segAng(rectangleSegmentA001) - 90, |> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001))
50.61
], %)
|> angledLine([
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()

View File

@ -85,15 +85,9 @@ cube
sketch001 = startSketchOn(XY) sketch001 = startSketchOn(XY)
rectangleSketch = startProfileAt([-200, 23.86], sketch001) rectangleSketch = startProfileAt([-200, 23.86], sketch001)
|> angledLine([0, 73.47], %, $rectangleSegmentA001) |> angledLine(angle = 0, length = 73.47, tag = $rectangleSegmentA001)
|> angledLine([ |> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 50.61)
segAng(rectangleSegmentA001) - 90, |> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001))
50.61
], %)
|> angledLine([
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()

View File

@ -32,9 +32,9 @@ exampleSketch = startSketchOn(XZ)
|> line(end = [10, 0]) |> line(end = [10, 0])
|> line(end = [5, 10], tag = $seg01) |> line(end = [5, 10], tag = $seg01)
|> line(end = [-10, 0]) |> line(end = [-10, 0])
|> angledLine([segAng(seg01), 10], %) |> angledLine(angle = segAng(seg01), length = 10)
|> line(end = [-10, 0]) |> line(end = [-10, 0])
|> angledLine([segAng(seg01), -15], %) |> angledLine(angle = segAng(seg01), length = -15)
|> close() |> close()
example = extrude(exampleSketch, length = 4) example = extrude(exampleSketch, length = 4)

View File

@ -29,9 +29,9 @@ segLen(tag: TagIdentifier): number
```js ```js
exampleSketch = startSketchOn(XZ) exampleSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> angledLine({ angle = 60, length = 10 }, %, $thing) |> angledLine(angle = 60, length = 10, tag = $thing)
|> tangentialArc({ offset = -120, radius = 5 }, %) |> tangentialArc({ offset = -120, radius = 5 }, %)
|> angledLine({ angle = -60, length = segLen(thing) }, %) |> angledLine(angle = -60, length = segLen(thing))
|> close() |> close()
example = extrude(exampleSketch, length = 5) example = extrude(exampleSketch, length = 5)

View File

@ -33,7 +33,7 @@ sqrt(num: number): number
```js ```js
exampleSketch = startSketchOn(XZ) exampleSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> angledLine({ angle = 50, length = sqrt(2500) }, %) |> angledLine(angle = 50, length = sqrt(2500))
|> yLine(endAbsolute = 0) |> yLine(endAbsolute = 0)
|> close() |> close()

View File

@ -9,7 +9,15 @@ Create a helix.
```js ```js
helix(revolutions: number(_), angleStart: number(deg), ccw?: bool, radius?: number(mm), axis?: Axis3d | Edge, length?: number(mm), cylinder?: Solid): Helix helix(
revolutions: number(_),
angleStart: number(deg),
ccw?: bool,
radius?: number(mm),
axis?: Axis3d | Edge,
length?: number(mm),
cylinder?: Solid,
): Helix
``` ```

View File

@ -29,10 +29,10 @@ cos(@num: number(rad)): number(_)
```js ```js
exampleSketch = startSketchOn(XZ) exampleSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> angledLine({ |> angledLine(
angle = 30, angle = 30,
length = 3 / cos(toRadians(30)), length = 3 / cos(toRadians(30)),
}, %) )
|> yLine(endAbsolute = 0) |> yLine(endAbsolute = 0)
|> close() |> close()

View File

@ -6,10 +6,14 @@ layout: manual
Convert polar/sphere (azimuth, elevation, distance) coordinates tocartesian (x/y/z grid) coordinates. Convert polar/sphere (azimuth, elevation, distance) coordinates to
cartesian (x/y/z grid) coordinates.
```js ```js
polar(angle: number(deg), length: number(mm)): [number(mm); 2] polar(
angle: number(deg),
length: number(mm),
): [number(mm); 2]
``` ```

File diff suppressed because one or more lines are too long

View File

@ -29,10 +29,10 @@ tan(@num: number(rad)): number(_)
```js ```js
exampleSketch = startSketchOn(XZ) exampleSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> angledLine({ |> angledLine(
angle = 50, angle = 50,
length = 50 * tan(1/2), length = 50 * tan(1/2),
}, %) )
|> yLine(endAbsolute = 0) |> yLine(endAbsolute = 0)
|> close() |> close()

File diff suppressed because one or more lines are too long

View File

@ -6,10 +6,16 @@ layout: manual
Construct a 2-dimensional circle, of the specified radius, centered atthe provided (x, y) origin point. Construct a 2-dimensional circle, of the specified radius, centered at
the provided (x, y) origin point.
```js ```js
circle(@sketch_or_surface: Sketch | Plane | Face, center: Point2d, radius: number, tag?: tag): Sketch circle(
@sketch_or_surface: Sketch | Plane | Face,
center: Point2d,
radius: number,
tag?: tag,
): Sketch
``` ```

View File

@ -11,7 +11,10 @@ Only works on unclosed sketches for now.
Mirror occurs around a local sketch axis rather than a global axis. Mirror occurs around a local sketch axis rather than a global axis.
```js ```js
mirror2d(@sketches: [Sketch; 1+], axis: Axis2d | Edge): Sketch mirror2d(
@sketches: [Sketch; 1+],
axis: Axis2d | Edge,
): Sketch
``` ```

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -91,15 +91,9 @@ springSketch = startSketchOn(YZ)
sketch001 = startSketchOn(XY) sketch001 = startSketchOn(XY)
rectangleSketch = startProfileAt([-200, 23.86], sketch001) rectangleSketch = startProfileAt([-200, 23.86], sketch001)
|> angledLine([0, 73.47], %, $rectangleSegmentA001) |> angledLine(angle = 0, length = 73.47, tag = $rectangleSegmentA001)
|> angledLine([ |> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 50.61)
segAng(rectangleSegmentA001) - 90, |> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001))
50.61
], %)
|> angledLine([
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()

View File

@ -32,10 +32,7 @@ pillSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line(end = [20, 0]) |> line(end = [20, 0])
|> tangentialArcToRelative([0, 10], %, $arc1) |> tangentialArcToRelative([0, 10], %, $arc1)
|> angledLine({ |> angledLine(angle = tangentToEnd(arc1), length = 20)
angle = tangentToEnd(arc1),
length = 20
}, %)
|> tangentialArcToRelative([0, -10], %) |> tangentialArcToRelative([0, -10], %)
|> close() |> close()
@ -50,10 +47,7 @@ pillSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line(end = [0, 20]) |> line(end = [0, 20])
|> tangentialArcTo([10, 20], %, $arc1) |> tangentialArcTo([10, 20], %, $arc1)
|> angledLine({ |> angledLine(angle = tangentToEnd(arc1), length = 20)
angle = tangentToEnd(arc1),
length = 20
}, %)
|> tangentialArcToRelative([-10, 0], %) |> tangentialArcToRelative([-10, 0], %)
|> close() |> close()
@ -66,10 +60,7 @@ pillExtrude = extrude(pillSketch, length = 10)
rectangleSketch = startSketchOn(XZ) rectangleSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line(end = [10, 0], tag = $seg1) |> line(end = [10, 0], tag = $seg1)
|> angledLine({ |> angledLine(angle = tangentToEnd(seg1), length = 10)
angle = tangentToEnd(seg1),
length = 10
}, %)
|> line(end = [0, 10]) |> line(end = [0, 10])
|> line(end = [-20, 0]) |> line(end = [-20, 0])
|> close() |> close()
@ -83,7 +74,7 @@ rectangleExtrude = extrude(rectangleSketch, length = 10)
bottom = startSketchOn(XY) bottom = startSketchOn(XY)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> arcTo({ end = [10, 10], interior = [5, 1] }, %, $arc1) |> arcTo({ end = [10, 10], interior = [5, 1] }, %, $arc1)
|> angledLine([tangentToEnd(arc1), 20], %) |> angledLine(angle = tangentToEnd(arc1), length = 20)
|> close() |> close()
``` ```
@ -95,7 +86,7 @@ circSketch = startSketchOn(XY)
triangleSketch = startSketchOn(XY) triangleSketch = startSketchOn(XY)
|> startProfileAt([-5, 0], %) |> startProfileAt([-5, 0], %)
|> angledLine([tangentToEnd(circ), 10], %) |> angledLine(angle = tangentToEnd(circ), length = 10)
|> line(end = [-15, 0]) |> line(end = [-15, 0])
|> close() |> close()
``` ```

View File

@ -35,9 +35,9 @@ tangentialArc(
```js ```js
exampleSketch = startSketchOn(XZ) exampleSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> angledLine({ angle = 60, length = 10 }, %) |> angledLine(angle = 60, length = 10)
|> tangentialArc({ radius = 10, offset = -120 }, %) |> tangentialArc({ radius = 10, offset = -120 }, %)
|> angledLine({ angle = -60, length = 10 }, %) |> angledLine(angle = -60, length = 10)
|> close() |> close()
example = extrude(exampleSketch, length = 10) example = extrude(exampleSketch, length = 10)

View File

@ -35,7 +35,7 @@ tangentialArcTo(
```js ```js
exampleSketch = startSketchOn(XZ) exampleSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> angledLine({ angle = 60, length = 10 }, %) |> angledLine(angle = 60, length = 10)
|> tangentialArcTo([15, 15], %) |> tangentialArcTo([15, 15], %)
|> line(end = [10, -15]) |> line(end = [10, -15])
|> close() |> close()

View File

@ -35,7 +35,7 @@ tangentialArcToRelative(
```js ```js
exampleSketch = startSketchOn(XZ) exampleSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> angledLine({ angle = 45, length = 10 }, %) |> angledLine(angle = 45, length = 10)
|> tangentialArcToRelative([0, -10], %) |> tangentialArcToRelative([0, -10], %)
|> line(end = [-10, 0]) |> line(end = [-10, 0])
|> close() |> close()

View File

@ -30,7 +30,7 @@ tau(): number
```js ```js
exampleSketch = startSketchOn(XZ) exampleSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> angledLine({ angle = 50, length = 10 * tau() }, %) |> angledLine(angle = 50, length = 10 * tau())
|> yLine(endAbsolute = 0) |> yLine(endAbsolute = 0)
|> close() |> close()

View File

@ -33,10 +33,7 @@ toDegrees(num: number): number
```js ```js
exampleSketch = startSketchOn(XZ) exampleSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> angledLine({ |> angledLine(angle = 50, length = 70 * cos(toDegrees(pi() / 4)))
angle = 50,
length = 70 * cos(toDegrees(pi() / 4))
}, %)
|> yLine(endAbsolute = 0) |> yLine(endAbsolute = 0)
|> close() |> close()

View File

@ -33,10 +33,7 @@ toRadians(num: number): number
```js ```js
exampleSketch = startSketchOn(XZ) exampleSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> angledLine({ |> angledLine(angle = 50, length = 70 * cos(toRadians(45)))
angle = 50,
length = 70 * cos(toRadians(45))
}, %)
|> yLine(endAbsolute = 0) |> yLine(endAbsolute = 0)
|> close() |> close()

View File

@ -86,15 +86,9 @@ cube
sketch001 = startSketchOn(XY) sketch001 = startSketchOn(XY)
rectangleSketch = startProfileAt([-200, 23.86], sketch001) rectangleSketch = startProfileAt([-200, 23.86], sketch001)
|> angledLine([0, 73.47], %, $rectangleSegmentA001) |> angledLine(angle = 0, length = 73.47, tag = $rectangleSegmentA001)
|> angledLine([ |> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 50.61)
segAng(rectangleSegmentA001) - 90, |> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001))
50.61
], %)
|> angledLine([
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()

View File

@ -184,15 +184,17 @@ way:
```norun ```norun
startSketchOn('XZ') startSketchOn('XZ')
|> startProfileAt(origin, %) |> startProfileAt(origin, %)
|> angledLine({angle = 0, length = 191.26}, %, $rectangleSegmentA001) |> angledLine(angle = 0, length = 191.26, tag = $rectangleSegmentA001)
|> angledLine({ |> angledLine(
angle = segAng(rectangleSegmentA001) - 90, angle = segAng(rectangleSegmentA001) - 90,
length = 196.99, length = 196.99,
}, %, $rectangleSegmentB001) tag = $rectangleSegmentB001,
|> angledLine({ )
|> angledLine(
angle = segAng(rectangleSegmentA001), angle = segAng(rectangleSegmentA001),
length = -segLen(rectangleSegmentA001), length = -segLen(rectangleSegmentA001),
}, %, $rectangleSegmentC001) tag = $rectangleSegmentC001,
)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
``` ```
@ -217,15 +219,17 @@ However if the code was written like this:
fn rect(origin) { fn rect(origin) {
return startSketchOn('XZ') return startSketchOn('XZ')
|> startProfileAt(origin, %) |> startProfileAt(origin, %)
|> angledLine({angle = 0, length = 191.26}, %, $rectangleSegmentA001) |> angledLine(angle = 0, length = 191.26, tag = $rectangleSegmentA001)
|> angledLine({ |> angledLine(
angle = segAng(rectangleSegmentA001) - 90, angle = segAng(rectangleSegmentA001) - 90,
length = 196.99 length = 196.99,
}, %, $rectangleSegmentB001) tag = $rectangleSegmentB001,
|> angledLine({ )
|> angledLine(
angle = segAng(rectangleSegmentA001), angle = segAng(rectangleSegmentA001),
length = -segLen(rectangleSegmentA001) length = -segLen(rectangleSegmentA001)
}, %, $rectangleSegmentC001) tag = $rectangleSegmentC001,
)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
} }
@ -245,15 +249,17 @@ For example the following code works.
fn rect(origin) { fn rect(origin) {
return startSketchOn('XZ') return startSketchOn('XZ')
|> startProfileAt(origin, %) |> startProfileAt(origin, %)
|> angledLine({angle = 0, length = 191.26}, %, $rectangleSegmentA001) |> angledLine(angle = 0, length = 191.26, tag = $rectangleSegmentA001)
|> angledLine({ |> angledLine(
angle = segAng(rectangleSegmentA001) - 90, angle = segAng(rectangleSegmentA001) - 90,
length = 196.99 length = 196.99,
}, %, $rectangleSegmentB001) tag = $rectangleSegmentB001,
|> angledLine({ )
|> angledLine(
angle = segAng(rectangleSegmentA001), angle = segAng(rectangleSegmentA001),
length = -segLen(rectangleSegmentA001) length = -segLen(rectangleSegmentA001)
}, %, $rectangleSegmentC001) tag = $rectangleSegmentC001,
)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
} }

View File

@ -252,7 +252,7 @@ Data for an imported geometry.
| Property | Type | Description | Required | | Property | Type | Description | Required |
|----------|------|-------------|----------| |----------|------|-------------|----------|
| `type` |enum: [`ImportedGeometry`](/docs/kcl/types/ImportedGeometry)| | No | | `type` |enum: `ImportedGeometry`| | No |
| `id` |[`string`](/docs/kcl/types/string)| The ID of the imported geometry. | No | | `id` |[`string`](/docs/kcl/types/string)| The ID of the imported geometry. | No |
| `value` |`[` [`string`](/docs/kcl/types/string) `]`| The original file paths. | No | | `value` |`[` [`string`](/docs/kcl/types/string) `]`| The original file paths. | No |

View File

@ -14,15 +14,17 @@ way:
```js ```js
startSketchOn('XZ') startSketchOn('XZ')
|> startProfileAt(origin, %) |> startProfileAt(origin, %)
|> angledLine({angle = 0, length = 191.26}, %, $rectangleSegmentA001) |> angledLine(angle = 0, length = 191.26, tag = $rectangleSegmentA001)
|> angledLine({ |> angledLine(
angle = segAng(rectangleSegmentA001) - 90, angle = segAng(rectangleSegmentA001) - 90,
length = 196.99, length = 196.99,
}, %, $rectangleSegmentB001) tag = $rectangleSegmentB001,
|> angledLine({ )
|> angledLine(
angle = segAng(rectangleSegmentA001), angle = segAng(rectangleSegmentA001),
length = -segLen(rectangleSegmentA001), length = -segLen(rectangleSegmentA001),
}, %, $rectangleSegmentC001) tag = $rectangleSegmentC001,
)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
``` ```
@ -46,15 +48,16 @@ However if the code was written like this:
fn rect(origin) { fn rect(origin) {
return startSketchOn('XZ') return startSketchOn('XZ')
|> startProfileAt(origin, %) |> startProfileAt(origin, %)
|> angledLine({angle = 0, length = 191.26}, %, $rectangleSegmentA001) |> angledLine(angle = 0, length = 191.26, tag = $rectangleSegmentA001)
|> angledLine({ |> angledLine(
angle = segAng(rectangleSegmentA001) - 90, angle = segAng(rectangleSegmentA001) - 90,
length = 196.99 length = 196.99,
}, %, $rectangleSegmentB001) tag = $rectangleSegmentB001)
|> angledLine({ |> angledLine(
angle = segAng(rectangleSegmentA001), angle = segAng(rectangleSegmentA001),
length = -segLen(rectangleSegmentA001) length = -segLen(rectangleSegmentA001),
}, %, $rectangleSegmentC001) tag = $rectangleSegmentC001
)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
} }
@ -74,15 +77,15 @@ For example the following code works.
fn rect(origin) { fn rect(origin) {
return startSketchOn('XZ') return startSketchOn('XZ')
|> startProfileAt(origin, %) |> startProfileAt(origin, %)
|> angledLine({angle = 0, length = 191.26}, %, $rectangleSegmentA001) |> angledLine(angle = 0, length = 191.26, tag = $rectangleSegmentA001)
|> angledLine({ |> angledLine(
angle = segAng(rectangleSegmentA001) - 90, angle = segAng(rectangleSegmentA001) - 90,
length = 196.99 length = 196.99
}, %, $rectangleSegmentB001) , %, $rectangleSegmentB001)
|> angledLine({ |> angledLine(
angle = segAng(rectangleSegmentA001), angle = segAng(rectangleSegmentA001),
length = -segLen(rectangleSegmentA001) length = -segLen(rectangleSegmentA001)
}, %, $rectangleSegmentC001) , %, $rectangleSegmentC001)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
} }

File diff suppressed because one or more lines are too long

View File

@ -38,10 +38,10 @@ xLine(
exampleSketch = startSketchOn(XZ) exampleSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> xLine(length = 15) |> xLine(length = 15)
|> angledLine({ angle = 80, length = 15 }, %) |> angledLine(angle = 80, length = 15)
|> line(end = [8, -10]) |> line(end = [8, -10])
|> xLine(length = 10) |> xLine(length = 10)
|> angledLine({ angle = 120, length = 30 }, %) |> angledLine(angle = 120, length = 30)
|> xLine(length = -15) |> xLine(length = -15)
|> close() |> close()

View File

@ -38,7 +38,7 @@ yLine(
exampleSketch = startSketchOn(XZ) exampleSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> yLine(length = 15) |> yLine(length = 15)
|> angledLine({ angle = 30, length = 15 }, %) |> angledLine(angle = 30, length = 15)
|> line(end = [8, -10]) |> line(end = [8, -10])
|> yLine(length = -5) |> yLine(length = -5)
|> close() |> close()

View File

@ -137,7 +137,7 @@ async function doBasicSketch(
await page.waitForTimeout(100) await page.waitForTimeout(100)
} }
await page.getByRole('button', { name: 'Length: open menu' }).click() await page.getByRole('button', { name: 'constraints: open menu' }).click()
await page.getByRole('button', { name: 'Equal Length' }).click() await page.getByRole('button', { name: 'Equal Length' }).click()
// Open the code pane. // Open the code pane.

View File

@ -1144,7 +1144,7 @@ sketch001 = startSketchOn(XZ)
) )
test( test(
`Can use the import stdlib function on a local OBJ file`, `Can import a local OBJ file`,
{ tag: '@electron' }, { tag: '@electron' },
async ({ page, context }, testInfo) => { async ({ page, context }, testInfo) => {
test.fixme(orRunWhenFullSuiteEnabled()) test.fixme(orRunWhenFullSuiteEnabled())
@ -1194,7 +1194,7 @@ sketch001 = startSketchOn(XZ)
.toBeLessThan(15) .toBeLessThan(15)
}) })
await test.step(`Write the import function line`, async () => { await test.step(`Write the import function line`, async () => {
await u.codeLocator.fill(`import('cube.obj')`) await u.codeLocator.fill(`import 'cube.obj'\ncube`)
await page.waitForTimeout(800) await page.waitForTimeout(800)
}) })
await test.step(`Reset the camera before checking`, async () => { await test.step(`Reset the camera before checking`, async () => {
@ -1353,4 +1353,51 @@ sketch001 = startSketchOn(XZ)
15 15
) )
}) })
test(`test-toolbar-buttons`, async ({
page,
homePage,
toolbar,
scene,
cmdBar,
}) => {
await test.step('Load an empty file', async () => {
await page.addInitScript(async () => {
localStorage.setItem('persistCode', '')
})
await page.setBodyDimensions({ width: 1200, height: 500 })
await homePage.goToModelingScene()
// wait until scene is ready to be interacted with
await scene.connectionEstablished()
await scene.settled(cmdBar)
})
await test.step('Test toolbar button correct selection', async () => {
await toolbar.expectToolbarMode.toBe('modeling')
await toolbar.startSketchPlaneSelection()
// Click on a default plane
await page.mouse.click(700, 200)
// tools cannot be selected immediately, couldn't find an event to await instead.
await page.waitForTimeout(1000)
await toolbar.selectCenterRectangle()
await expect(page.getByTestId('center-rectangle')).toHaveAttribute(
'aria-pressed',
'true'
)
})
await test.step('Test Toolbar dropdown remembering last selection', async () => {
// Select another tool
await page.getByTestId('circle-center').click()
// center-rectangle should still be the active option in the rectangle dropdown
await expect(page.getByTestId('center-rectangle')).toBeVisible()
})
})
}) })

View File

@ -19,7 +19,7 @@ length001 = timesFive(1) * 5
sketch001 = startSketchOn(XZ) sketch001 = startSketchOn(XZ)
|> startProfileAt([20, 10], %) |> startProfileAt([20, 10], %)
|> line(end = [10, 10]) |> line(end = [10, 10])
|> angledLine([-45, length001], %) |> angledLine(angle = -45, length = length001)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
revolve001 = revolve(sketch001, axis = X) revolve001 = revolve(sketch001, axis = X)
@ -38,15 +38,9 @@ extrude001 = extrude(sketch002, length = 10)
const FEATURE_TREE_SKETCH_CODE = `sketch001 = startSketchOn(XZ) const FEATURE_TREE_SKETCH_CODE = `sketch001 = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> angledLine([0, 4], %, $rectangleSegmentA001) |> angledLine(angle = 0, length = 4, tag = $rectangleSegmentA001)
|> angledLine([ |> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 2, tag = $rectangleSegmentB001)
segAng(rectangleSegmentA001) - 90, |> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001), tag = $rectangleSegmentC001)
2
], %, $rectangleSegmentB001)
|> angledLine([
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %, $rectangleSegmentC001)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close(%) |> close(%)
extrude001 = extrude(sketch001, length = 10) extrude001 = extrude(sketch001, length = 10)

View File

@ -99,7 +99,6 @@ export class HomePageFixture {
createAndGoToProject = async (projectTitle = 'untitled') => { createAndGoToProject = async (projectTitle = 'untitled') => {
await this.projectsLoaded() await this.projectsLoaded()
await this.projectButtonNew.click() await this.projectButtonNew.click()
await this.projectTextName.click()
await this.projectTextName.fill(projectTitle) await this.projectTextName.fill(projectTitle)
await this.projectButtonContinue.click() await this.projectButtonContinue.click()
} }

View File

@ -49,7 +49,9 @@ export class SceneFixture {
constructor(page: Page) { constructor(page: Page) {
this.page = page this.page = page
this.streamWrapper = page.getByTestId('stream') this.streamWrapper = page.getByTestId('stream')
this.networkToggleConnected = page.getByTestId('network-toggle-ok') this.networkToggleConnected = page
.getByTestId('network-toggle-ok')
.or(page.getByTestId('network-toggle-other'))
this.startEditSketchBtn = page this.startEditSketchBtn = page
.getByRole('button', { name: 'Start Sketch' }) .getByRole('button', { name: 'Start Sketch' })
.or(page.getByRole('button', { name: 'Edit Sketch' })) .or(page.getByRole('button', { name: 'Edit Sketch' }))
@ -231,7 +233,7 @@ export class SceneFixture {
settled = async (cmdBar: CmdBarFixture) => { settled = async (cmdBar: CmdBarFixture) => {
const u = await getUtils(this.page) const u = await getUtils(this.page)
await expect(this.startEditSketchBtn).not.toBeDisabled() await expect(this.startEditSketchBtn).not.toBeDisabled({ timeout: 15_000 })
await expect(this.startEditSketchBtn).toBeVisible() await expect(this.startEditSketchBtn).toBeVisible()
await cmdBar.openCmdBar() await cmdBar.openCmdBar()

View File

@ -169,7 +169,7 @@ export class ToolbarFixture {
} }
selectCenterRectangle = async () => { selectCenterRectangle = async () => {
await this.page await this.page
.getByRole('button', { name: 'caret down Corner rectangle:' }) .getByRole('button', { name: 'caret down rectangles:' })
.click() .click()
await expect( await expect(
this.page.getByTestId('dropdown-center-rectangle') this.page.getByTestId('dropdown-center-rectangle')
@ -178,7 +178,7 @@ export class ToolbarFixture {
} }
selectBoolean = async (operation: 'union' | 'subtract' | 'intersect') => { selectBoolean = async (operation: 'union' | 'subtract' | 'intersect') => {
await this.page await this.page
.getByRole('button', { name: 'caret down Union: open menu' }) .getByRole('button', { name: 'caret down booleans: open menu' })
.click() .click()
const operationTestId = `dropdown-boolean-${operation}` const operationTestId = `dropdown-boolean-${operation}`
await expect(this.page.getByTestId(operationTestId)).toBeVisible() await expect(this.page.getByTestId(operationTestId)).toBeVisible()
@ -186,25 +186,19 @@ export class ToolbarFixture {
} }
selectCircleThreePoint = async () => { selectCircleThreePoint = async () => {
await this.page await this.page.getByRole('button', { name: 'caret down circles:' }).click()
.getByRole('button', { name: 'caret down Center circle:' })
.click()
await expect( await expect(
this.page.getByTestId('dropdown-circle-three-points') this.page.getByTestId('dropdown-circle-three-points')
).toBeVisible() ).toBeVisible()
await this.page.getByTestId('dropdown-circle-three-points').click() await this.page.getByTestId('dropdown-circle-three-points').click()
} }
selectArc = async () => { selectArc = async () => {
await this.page await this.page.getByRole('button', { name: 'caret down arcs:' }).click()
.getByRole('button', { name: 'caret down Tangential Arc:' })
.click()
await expect(this.page.getByTestId('dropdown-arc')).toBeVisible() await expect(this.page.getByTestId('dropdown-arc')).toBeVisible()
await this.page.getByTestId('dropdown-arc').click() await this.page.getByTestId('dropdown-arc').click()
} }
selectThreePointArc = async () => { selectThreePointArc = async () => {
await this.page await this.page.getByRole('button', { name: 'caret down arcs:' }).click()
.getByRole('button', { name: 'caret down Tangential Arc:' })
.click()
await expect( await expect(
this.page.getByTestId('dropdown-three-point-arc') this.page.getByTestId('dropdown-three-point-arc')
).toBeVisible() ).toBeVisible()

View File

@ -21,15 +21,9 @@ test.describe('Import UI tests', () => {
path.join(projectDir, 'toBeImported.kcl'), path.join(projectDir, 'toBeImported.kcl'),
`sketch001 = startSketchOn(XZ) `sketch001 = startSketchOn(XZ)
profile001 = startProfileAt([281.54, 305.81], sketch001) profile001 = startProfileAt([281.54, 305.81], sketch001)
|> angledLine([0, 123.43], %, $rectangleSegmentA001) |> angledLine(angle = 0, length = 123.43, tag = $rectangleSegmentA001)
|> angledLine([ |> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 85.99)
segAng(rectangleSegmentA001) - 90, |> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001))
85.99
], %)
|> angledLine([
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
extrude(profile001, length = 100)` extrude(profile001, length = 100)`
@ -44,15 +38,9 @@ importedCube
sketch001 = startSketchOn(XZ) sketch001 = startSketchOn(XZ)
profile001 = startProfileAt([-134.53, -56.17], sketch001) profile001 = startProfileAt([-134.53, -56.17], sketch001)
|> angledLine([0, 79.05], %, $rectangleSegmentA001) |> angledLine(angle = 0, length = 79.05, tag = $rectangleSegmentA001)
|> angledLine([ |> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 76.28)
segAng(rectangleSegmentA001) - 90, |> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001), tag = $seg01)
76.28
], %)
|> angledLine([
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %, $seg01)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)], tag = $seg02) |> line(endAbsolute = [profileStartX(%), profileStartY(%)], tag = $seg02)
|> close() |> close()
extrude001 = extrude(profile001, length = 100) extrude001 = extrude(profile001, length = 100)

View File

@ -61,6 +61,7 @@ function tomlStringOverWriteNamedViewUuids(toml: string): string {
} }
test.describe('Named view tests', () => { test.describe('Named view tests', () => {
test.skip() // TODO: Jace is working on these
test('Verify project.toml is not created', async ({ page }, testInfo) => { test('Verify project.toml is not created', async ({ page }, testInfo) => {
// Create project and load it // Create project and load it
const projectName = 'named-views' const projectName = 'named-views'

View File

@ -0,0 +1,16 @@
[settings]
modeling = { }
text_editor = { }
command_bar = { }
[settings.app.named_views.0656fb1a-9640-473e-b334-591dc70c0138]
name = "uuid1"
eye_offset = 1_378.0059
fov_y = 45
is_ortho = false
ortho_scale_enabled = true
ortho_scale_factor = 1.6
pivot_position = [ 0, 0, 0 ]
pivot_rotation = [ 0.5380994, 0.0, 0.0, 0.8428814 ]
world_coord_system = "right_handed_up_z"
version = 1

View File

@ -0,0 +1,28 @@
[settings]
modeling = { }
text_editor = { }
command_bar = { }
[settings.app.named_views.0656fb1a-9640-473e-b334-591dc70c0138]
name = "uuid1"
eye_offset = 1_378.0059
fov_y = 45
is_ortho = false
ortho_scale_enabled = true
ortho_scale_factor = 1.6
pivot_position = [ 0, 0, 0 ]
pivot_rotation = [ 0.5380994, 0.0, 0.0, 0.8428814 ]
world_coord_system = "right_handed_up_z"
version = 1
[settings.app.named_views.c810cf04-c6cc-4a4a-8b11-17bf445dcab7]
name = "uuid2"
eye_offset = 1_378.0059
fov_y = 45
is_ortho = false
ortho_scale_enabled = true
ortho_scale_factor = 1.6
pivot_position = [ 1_826.5239, 0.0, 0.0 ]
pivot_rotation = [ 0.5380994, 0.0, 0.0, 0.8428814 ]
world_coord_system = "right_handed_up_z"
version = 1

View File

@ -7,6 +7,7 @@ import { expect, test } from '@e2e/playwright/zoo-test'
* Test file menu actions that trigger something in the frontend * Test file menu actions that trigger something in the frontend
*/ */
test.describe('Native file menu', { tag: ['@electron'] }, () => { test.describe('Native file menu', { tag: ['@electron'] }, () => {
test.skip() // TODO: Reimplement native file menu tests
test.describe('Home page', () => { test.describe('Home page', () => {
test.describe('File role', () => { test.describe('File role', () => {
test('Home.File.Create project', async ({ tronApp, cmdBar, page }) => { test('Home.File.Create project', async ({ tronApp, cmdBar, page }) => {

View File

@ -1,13 +1,47 @@
import * as fsp from 'fs/promises' import * as fsp from 'fs/promises'
import path from 'path' import path from 'path'
import { executorInputPath } from '@e2e/playwright/test-utils' import type { CmdBarFixture } from '@e2e/playwright/fixtures/cmdBarFixture'
import { test } from '@e2e/playwright/zoo-test' import type { ToolbarFixture } from '@e2e/playwright/fixtures/toolbarFixture'
import {
executorInputPath,
getUtils,
testsInputPath,
} from '@e2e/playwright/test-utils'
import { expect, test } from '@e2e/playwright/zoo-test'
import type { Page } from '@playwright/test'
async function insertPartIntoAssembly(
path: string,
alias: string,
toolbar: ToolbarFixture,
cmdBar: CmdBarFixture,
page: Page
) {
await toolbar.insertButton.click()
await cmdBar.selectOption({ name: path }).click()
await cmdBar.expectState({
stage: 'arguments',
currentArgKey: 'localName',
currentArgValue: '',
headerArguments: { Path: path, LocalName: '' },
highlightedHeaderArg: 'localName',
commandName: 'Insert',
})
await page.keyboard.insertText(alias)
await cmdBar.progressCmdBar()
await cmdBar.expectState({
stage: 'review',
headerArguments: { Path: path, LocalName: alias },
commandName: 'Insert',
})
await cmdBar.progressCmdBar()
}
// test file is for testing point an click code gen functionality that's assemblies related // test file is for testing point an click code gen functionality that's assemblies related
test.describe('Point-and-click assemblies tests', () => { test.describe('Point-and-click assemblies tests', () => {
test( test(
`Insert kcl part into assembly as whole module import`, `Insert kcl parts into assembly as whole module import`,
{ tag: ['@electron'] }, { tag: ['@electron'] },
async ({ async ({
context, context,
@ -23,11 +57,14 @@ test.describe('Point-and-click assemblies tests', () => {
fail() fail()
} }
// One dumb hardcoded screen pixel value const midPoint = { x: 500, y: 250 }
const testPoint = { x: 575, y: 200 } const partPoint = { x: midPoint.x + 30, y: midPoint.y - 30 } // mid point, just off top right
const initialColor: [number, number, number] = [50, 50, 50] const defaultPlanesColor: [number, number, number] = [180, 220, 180]
const partColor: [number, number, number] = [150, 150, 150] const partColor: [number, number, number] = [100, 100, 100]
const tolerance = 50 const tolerance = 50
const u = await getUtils(page)
const gizmo = page.locator('[aria-label*=gizmo]')
const resetCameraButton = page.getByRole('button', { name: 'Reset view' })
await test.step('Setup parts and expect empty assembly scene', async () => { await test.step('Setup parts and expect empty assembly scene', async () => {
const projectName = 'assembly' const projectName = 'assembly'
@ -36,41 +73,36 @@ test.describe('Point-and-click assemblies tests', () => {
await fsp.mkdir(bracketDir, { recursive: true }) await fsp.mkdir(bracketDir, { recursive: true })
await Promise.all([ await Promise.all([
fsp.copyFile( fsp.copyFile(
executorInputPath('cylinder-inches.kcl'), executorInputPath('cylinder.kcl'),
path.join(bracketDir, 'cylinder.kcl') path.join(bracketDir, 'cylinder.kcl')
), ),
fsp.copyFile( fsp.copyFile(
executorInputPath('e2e-can-sketch-on-chamfer.kcl'), executorInputPath('e2e-can-sketch-on-chamfer.kcl'),
path.join(bracketDir, 'bracket.kcl') path.join(bracketDir, 'bracket.kcl')
), ),
fsp.copyFile(
testsInputPath('cube.step'),
path.join(bracketDir, 'cube.step')
),
fsp.writeFile(path.join(bracketDir, 'main.kcl'), ''), fsp.writeFile(path.join(bracketDir, 'main.kcl'), ''),
]) ])
}) })
await page.setBodyDimensions({ width: 1000, height: 500 }) await page.setBodyDimensions({ width: 1000, height: 500 })
await homePage.openProject(projectName) await homePage.openProject(projectName)
await scene.settled(cmdBar) await scene.settled(cmdBar)
await scene.expectPixelColor(initialColor, testPoint, tolerance) await toolbar.closePane('code')
await scene.expectPixelColor(defaultPlanesColor, midPoint, tolerance)
}) })
await test.step('Insert first part into the assembly', async () => { await test.step('Insert kcl as first part as module', async () => {
await toolbar.insertButton.click() await insertPartIntoAssembly(
await cmdBar.selectOption({ name: 'cylinder.kcl' }).click() 'cylinder.kcl',
await cmdBar.expectState({ 'cylinder',
stage: 'arguments', toolbar,
currentArgKey: 'localName', cmdBar,
currentArgValue: '', page
headerArguments: { Path: 'cylinder.kcl', LocalName: '' }, )
highlightedHeaderArg: 'localName', await toolbar.openPane('code')
commandName: 'Insert',
})
await page.keyboard.insertText('cylinder')
await cmdBar.progressCmdBar()
await cmdBar.expectState({
stage: 'review',
headerArguments: { Path: 'cylinder.kcl', LocalName: 'cylinder' },
commandName: 'Insert',
})
await cmdBar.progressCmdBar()
await editor.expectEditor.toContain( await editor.expectEditor.toContain(
` `
import "cylinder.kcl" as cylinder import "cylinder.kcl" as cylinder
@ -78,28 +110,27 @@ test.describe('Point-and-click assemblies tests', () => {
`, `,
{ shouldNormalise: true } { shouldNormalise: true }
) )
await scene.expectPixelColor(partColor, testPoint, tolerance) await scene.settled(cmdBar)
// Check scene for changes
await toolbar.closePane('code')
await u.doAndWaitForCmd(async () => {
await gizmo.click({ button: 'right' })
await resetCameraButton.click()
}, 'zoom_to_fit')
await toolbar.closePane('debug')
await scene.expectPixelColor(partColor, partPoint, tolerance)
await toolbar.openPane('code')
}) })
await test.step('Insert second part into the assembly', async () => { await test.step('Insert kcl second part as module', async () => {
await toolbar.insertButton.click() await insertPartIntoAssembly(
await cmdBar.selectOption({ name: 'bracket.kcl' }).click() 'bracket.kcl',
await cmdBar.expectState({ 'bracket',
stage: 'arguments', toolbar,
currentArgKey: 'localName', cmdBar,
currentArgValue: '', page
headerArguments: { Path: 'bracket.kcl', LocalName: '' }, )
highlightedHeaderArg: 'localName',
commandName: 'Insert',
})
await page.keyboard.insertText('bracket')
await cmdBar.progressCmdBar()
await cmdBar.expectState({
stage: 'review',
headerArguments: { Path: 'bracket.kcl', LocalName: 'bracket' },
commandName: 'Insert',
})
await cmdBar.progressCmdBar()
await editor.expectEditor.toContain( await editor.expectEditor.toContain(
` `
import "cylinder.kcl" as cylinder import "cylinder.kcl" as cylinder
@ -109,6 +140,152 @@ test.describe('Point-and-click assemblies tests', () => {
`, `,
{ shouldNormalise: true } { shouldNormalise: true }
) )
await scene.settled(cmdBar)
})
await test.step('Insert a second time and expect error', async () => {
// TODO: revisit once we have clone with #6209
await insertPartIntoAssembly(
'bracket.kcl',
'bracket',
toolbar,
cmdBar,
page
)
await editor.expectEditor.toContain(
`
import "cylinder.kcl" as cylinder
import "bracket.kcl" as bracket
import "bracket.kcl" as bracket
cylinder
bracket
bracket
`,
{ shouldNormalise: true }
)
await scene.settled(cmdBar)
await expect(page.locator('.cm-lint-marker-error')).toBeVisible()
})
}
)
test(
`Insert foreign parts into assembly as whole module import`,
{ tag: ['@electron'] },
async ({
context,
page,
homePage,
scene,
editor,
toolbar,
cmdBar,
tronApp,
}) => {
if (!tronApp) {
fail()
}
const midPoint = { x: 500, y: 250 }
const partPoint = { x: midPoint.x + 30, y: midPoint.y - 30 } // mid point, just off top right
const defaultPlanesColor: [number, number, number] = [180, 220, 180]
const partColor: [number, number, number] = [150, 150, 150]
const tolerance = 50
const complexPlmFileName = 'cube_Complex-PLM_Name_-001.sldprt'
const camelCasedSolidworksFileName = 'cubeComplexPLMName001'
await test.step('Setup parts and expect empty assembly scene', async () => {
const projectName = 'assembly'
await context.folderSetupFn(async (dir) => {
const bracketDir = path.join(dir, projectName)
await fsp.mkdir(bracketDir, { recursive: true })
await Promise.all([
fsp.copyFile(
testsInputPath('cube.step'),
path.join(bracketDir, 'cube.step')
),
fsp.copyFile(
testsInputPath('cube.sldprt'),
path.join(bracketDir, complexPlmFileName)
),
fsp.writeFile(path.join(bracketDir, 'main.kcl'), ''),
])
})
await page.setBodyDimensions({ width: 1000, height: 500 })
await homePage.openProject(projectName)
await scene.settled(cmdBar)
await toolbar.closePane('code')
await scene.expectPixelColor(defaultPlanesColor, midPoint, tolerance)
})
await test.step('Insert step part as module', async () => {
await insertPartIntoAssembly('cube.step', 'cube', toolbar, cmdBar, page)
await toolbar.openPane('code')
await editor.expectEditor.toContain(
`
import "cube.step" as cube
cube
`,
{ shouldNormalise: true }
)
await scene.settled(cmdBar)
// TODO: remove this once #5780 is fixed
await page.reload()
await scene.settled(cmdBar)
await expect(page.locator('.cm-lint-marker-error')).not.toBeVisible()
await toolbar.closePane('code')
await scene.expectPixelColor(partColor, partPoint, tolerance)
})
await test.step('Insert second step part by clicking', async () => {
await toolbar.openPane('files')
await toolbar.expectFileTreeState([
complexPlmFileName,
'cube.step',
'main.kcl',
])
await toolbar.openFile(complexPlmFileName)
// Go through the ToastInsert prompt
await page.getByText('Insert into my current file').click()
// Check getPathFilenameInVariableCase output
const parsedValueFromFile =
await cmdBar.currentArgumentInput.inputValue()
expect(parsedValueFromFile).toEqual(camelCasedSolidworksFileName)
// Continue on with the flow
await page.keyboard.insertText('cubeSw')
await cmdBar.progressCmdBar()
await cmdBar.expectState({
stage: 'review',
headerArguments: { Path: complexPlmFileName, LocalName: 'cubeSw' },
commandName: 'Insert',
})
await cmdBar.progressCmdBar()
await toolbar.closePane('files')
await toolbar.openPane('code')
await editor.expectEditor.toContain(
`
import "cube.step" as cube
import "${complexPlmFileName}" as cubeSw
cube
cubeSw
`,
{ shouldNormalise: true }
)
await scene.settled(cmdBar)
// TODO: remove this once #5780 is fixed
await page.reload()
await scene.settled(cmdBar)
await expect(page.locator('.cm-lint-marker-error')).not.toBeVisible()
await toolbar.closePane('code')
await scene.expectPixelColor(partColor, partPoint, tolerance)
}) })
} }
) )

View File

@ -210,7 +210,7 @@ test.describe('Point-and-click tests', () => {
clickCoords: { x: 570, y: 220 }, clickCoords: { x: 570, y: 220 },
cameraPos: { x: 16020, y: -2000, z: 10500 }, cameraPos: { x: 16020, y: -2000, z: 10500 },
cameraTarget: { x: -150, y: -4500, z: -80 }, cameraTarget: { x: -150, y: -4500, z: -80 },
beforeChamferSnippet: `angledLine([segAng(rectangleSegmentA001)-90,217.26],%,$seg01) beforeChamferSnippet: `angledLine(angle=segAng(rectangleSegmentA001)-90,length=217.26,tag=$seg01)
chamfer(length = 30,tags = [ chamfer(length = 30,tags = [
seg01, seg01,
getNextAdjacentEdge(yo), getNextAdjacentEdge(yo),
@ -223,9 +223,9 @@ test.describe('Point-and-click tests', () => {
'sketch002 = startSketchOn(extrude001, seg03)', 'sketch002 = startSketchOn(extrude001, seg03)',
afterRectangle1stClickSnippet: afterRectangle1stClickSnippet:
'startProfileAt([205.96, 254.59], sketch002)', 'startProfileAt([205.96, 254.59], sketch002)',
afterRectangle2ndClickSnippet: `angledLine([0,11.39],%,$rectangleSegmentA002) afterRectangle2ndClickSnippet: `angledLine(angle=0,length=11.39,tag=$rectangleSegmentA002)
|>angledLine([segAng(rectangleSegmentA002)-90,105.26],%) |>angledLine(angle=segAng(rectangleSegmentA002)-90,length=105.26)
|>angledLine([segAng(rectangleSegmentA002),-segLen(rectangleSegmentA002)],%) |>angledLine(angle=segAng(rectangleSegmentA002),length=-segLen(rectangleSegmentA002))
|>line(endAbsolute=[profileStartX(%),profileStartY(%)]) |>line(endAbsolute=[profileStartX(%),profileStartY(%)])
|>close()`, |>close()`,
}) })
@ -234,10 +234,7 @@ test.describe('Point-and-click tests', () => {
clickCoords: { x: 690, y: 250 }, clickCoords: { x: 690, y: 250 },
cameraPos: { x: 16020, y: -2000, z: 10500 }, cameraPos: { x: 16020, y: -2000, z: 10500 },
cameraTarget: { x: -150, y: -4500, z: -80 }, cameraTarget: { x: -150, y: -4500, z: -80 },
beforeChamferSnippet: `angledLine([ beforeChamferSnippet: `angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 217.26, tag = $seg01)chamfer(
segAng(rectangleSegmentA001) - 90,
217.26
], %, $seg01)chamfer(
length = 30, length = 30,
tags = [ tags = [
seg01, seg01,
@ -250,9 +247,9 @@ test.describe('Point-and-click tests', () => {
'sketch003 = startSketchOn(extrude001, seg04)', 'sketch003 = startSketchOn(extrude001, seg04)',
afterRectangle1stClickSnippet: afterRectangle1stClickSnippet:
'startProfileAt([-209.64, 255.28], sketch003)', 'startProfileAt([-209.64, 255.28], sketch003)',
afterRectangle2ndClickSnippet: `angledLine([0,11.56],%,$rectangleSegmentA003) afterRectangle2ndClickSnippet: `angledLine(angle=0,length=11.56,tag=$rectangleSegmentA003)
|>angledLine([segAng(rectangleSegmentA003)-90,106.84],%) |>angledLine(angle=segAng(rectangleSegmentA003)-90,length=106.84)
|>angledLine([segAng(rectangleSegmentA003),-segLen(rectangleSegmentA003)],%) |>angledLine(angle=segAng(rectangleSegmentA003),length=-segLen(rectangleSegmentA003))
|>line(endAbsolute=[profileStartX(%),profileStartY(%)]) |>line(endAbsolute=[profileStartX(%),profileStartY(%)])
|>close()`, |>close()`,
}) })
@ -261,7 +258,7 @@ test.describe('Point-and-click tests', () => {
clickCoords: { x: 677, y: 87 }, clickCoords: { x: 677, y: 87 },
cameraPos: { x: -6200, y: 1500, z: 6200 }, cameraPos: { x: -6200, y: 1500, z: 6200 },
cameraTarget: { x: 8300, y: 1100, z: 4800 }, cameraTarget: { x: 8300, y: 1100, z: 4800 },
beforeChamferSnippet: `angledLine([0, 268.43], %, $rectangleSegmentA001)chamfer( beforeChamferSnippet: `angledLine(angle = 0, length = 268.43, tag = $rectangleSegmentA001)chamfer(
length = 30, length = 30,
tags = [ tags = [
getNextAdjacentEdge(yo), getNextAdjacentEdge(yo),
@ -272,9 +269,9 @@ test.describe('Point-and-click tests', () => {
'sketch004 = startSketchOn(extrude001, seg05)', 'sketch004 = startSketchOn(extrude001, seg05)',
afterRectangle1stClickSnippet: afterRectangle1stClickSnippet:
'startProfileAt([82.57, 322.96], sketch004)', 'startProfileAt([82.57, 322.96], sketch004)',
afterRectangle2ndClickSnippet: `angledLine([0,11.16],%,$rectangleSegmentA004) afterRectangle2ndClickSnippet: `angledLine(angle=0,length=11.16,tag=$rectangleSegmentA004)
|>angledLine([segAng(rectangleSegmentA004)-90,103.07],%) |>angledLine(angle=segAng(rectangleSegmentA004)-90,length=103.07)
|>angledLine([segAng(rectangleSegmentA004),-segLen(rectangleSegmentA004)],%) |>angledLine(angle=segAng(rectangleSegmentA004),length=-segLen(rectangleSegmentA004))
|>line(endAbsolute=[profileStartX(%),profileStartY(%)]) |>line(endAbsolute=[profileStartX(%),profileStartY(%)])
|>close()`, |>close()`,
}) })
@ -290,9 +287,9 @@ test.describe('Point-and-click tests', () => {
'sketch005 = startSketchOn(extrude001, seg06)', 'sketch005 = startSketchOn(extrude001, seg06)',
afterRectangle1stClickSnippet: afterRectangle1stClickSnippet:
'startProfileAt([-23.43, 19.69], sketch005)', 'startProfileAt([-23.43, 19.69], sketch005)',
afterRectangle2ndClickSnippet: `angledLine([0,9.1],%,$rectangleSegmentA005) afterRectangle2ndClickSnippet: `angledLine(angle=0,length=9.1,tag=$rectangleSegmentA005)
|>angledLine([segAng(rectangleSegmentA005)-90,84.07],%) |>angledLine(angle=segAng(rectangleSegmentA005)-90,length=84.07)
|>angledLine([segAng(rectangleSegmentA005),-segLen(rectangleSegmentA005)],%) |>angledLine(angle=segAng(rectangleSegmentA005),length=-segLen(rectangleSegmentA005))
|>line(endAbsolute=[profileStartX(%),profileStartY(%)]) |>line(endAbsolute=[profileStartX(%),profileStartY(%)])
|>close()`, |>close()`,
}) })
@ -302,15 +299,9 @@ test.describe('Point-and-click tests', () => {
`@settings(defaultLengthUnit = in) `@settings(defaultLengthUnit = in)
sketch001 = startSketchOn(XZ) sketch001 = startSketchOn(XZ)
|> startProfileAt([75.8, 317.2], %) // [$startCapTag, $EndCapTag] |> startProfileAt([75.8, 317.2], %) // [$startCapTag, $EndCapTag]
|> angledLine([0, 268.43], %, $rectangleSegmentA001) |> angledLine(angle = 0, length = 268.43, tag = $rectangleSegmentA001)
|> angledLine([ |> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 217.26, tag = $seg01)
segAng(rectangleSegmentA001) - 90, |> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001), tag = $yo)
217.26
], %, $seg01)
|> angledLine([
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %, $yo)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)], tag = $seg02) |> line(endAbsolute = [profileStartX(%), profileStartY(%)], tag = $seg02)
|> close() |> close()
extrude001 = extrude(sketch001, length = 100) extrude001 = extrude(sketch001, length = 100)
@ -320,48 +311,30 @@ extrude001 = extrude(sketch001, length = 100)
|> chamfer(length = 30, tags = [getNextAdjacentEdge(yo)], tag = $seg06) |> chamfer(length = 30, tags = [getNextAdjacentEdge(yo)], tag = $seg06)
sketch005 = startSketchOn(extrude001, seg06) sketch005 = startSketchOn(extrude001, seg06)
profile004=startProfileAt([-23.43,19.69], sketch005) profile004=startProfileAt([-23.43,19.69], sketch005)
|> angledLine([0, 9.1], %, $rectangleSegmentA005) |> angledLine(angle = 0, length = 9.1, tag = $rectangleSegmentA005)
|> angledLine([segAng(rectangleSegmentA005) - 90, 84.07], %) |> angledLine(angle = segAng(rectangleSegmentA005) - 90, length = 84.07)
|> angledLine([segAng(rectangleSegmentA005), -segLen(rectangleSegmentA005)], %) |> angledLine(angle = segAng(rectangleSegmentA005), length = -segLen(rectangleSegmentA005))
|> line(endAbsolute=[profileStartX(%), profileStartY(%)]) |> line(endAbsolute=[profileStartX(%), profileStartY(%)])
|> close() |> close()
sketch004 = startSketchOn(extrude001, seg05) sketch004 = startSketchOn(extrude001, seg05)
profile003 = startProfileAt([82.57, 322.96], sketch004) profile003 = startProfileAt([82.57, 322.96], sketch004)
|> angledLine([0, 11.16], %, $rectangleSegmentA004) |> angledLine(angle = 0, length = 11.16, tag = $rectangleSegmentA004)
|> angledLine([ |> angledLine(angle = segAng(rectangleSegmentA004) - 90, length = 103.07)
segAng(rectangleSegmentA004) - 90, |> angledLine(angle = segAng(rectangleSegmentA004), length = -segLen(rectangleSegmentA004))
103.07
], %)
|> angledLine([
segAng(rectangleSegmentA004),
-segLen(rectangleSegmentA004)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
sketch003 = startSketchOn(extrude001, seg04) sketch003 = startSketchOn(extrude001, seg04)
profile002 = startProfileAt([-209.64, 255.28], sketch003) profile002 = startProfileAt([-209.64, 255.28], sketch003)
|> angledLine([0, 11.56], %, $rectangleSegmentA003) |> angledLine(angle = 0, length = 11.56, tag = $rectangleSegmentA003)
|> angledLine([ |> angledLine(angle = segAng(rectangleSegmentA003) - 90, length = 106.84)
segAng(rectangleSegmentA003) - 90, |> angledLine(angle = segAng(rectangleSegmentA003), length = -segLen(rectangleSegmentA003))
106.84
], %)
|> angledLine([
segAng(rectangleSegmentA003),
-segLen(rectangleSegmentA003)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
sketch002 = startSketchOn(extrude001, seg03) sketch002 = startSketchOn(extrude001, seg03)
profile001 = startProfileAt([205.96, 254.59], sketch002) profile001 = startProfileAt([205.96, 254.59], sketch002)
|> angledLine([0, 11.39], %, $rectangleSegmentA002) |> angledLine(angle = 0, length = 11.39, tag = $rectangleSegmentA002)
|> angledLine([ |> angledLine(angle = segAng(rectangleSegmentA002) - 90, length = 105.26)
segAng(rectangleSegmentA002) - 90, |> angledLine(angle = segAng(rectangleSegmentA002), length = -segLen(rectangleSegmentA002))
105.26
], %)
|> angledLine([
segAng(rectangleSegmentA002),
-segLen(rectangleSegmentA002)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
`, `,
@ -401,7 +374,7 @@ profile001 = startProfileAt([205.96, 254.59], sketch002)
clickCoords: { x: 570, y: 220 }, clickCoords: { x: 570, y: 220 },
cameraPos: { x: 16020, y: -2000, z: 10500 }, cameraPos: { x: 16020, y: -2000, z: 10500 },
cameraTarget: { x: -150, y: -4500, z: -80 }, cameraTarget: { x: -150, y: -4500, z: -80 },
beforeChamferSnippet: `angledLine([segAng(rectangleSegmentA001)-90,217.26],%,$seg01) beforeChamferSnippet: `angledLine(angle=segAng(rectangleSegmentA001)-90,length=217.26,tag=$seg01)
chamfer(extrude001,length=30,tags=[ chamfer(extrude001,length=30,tags=[
seg01, seg01,
getNextAdjacentEdge(yo), getNextAdjacentEdge(yo),
@ -413,9 +386,9 @@ profile001 = startProfileAt([205.96, 254.59], sketch002)
'sketch002 = startSketchOn(extrude001, seg03)', 'sketch002 = startSketchOn(extrude001, seg03)',
afterRectangle1stClickSnippet: afterRectangle1stClickSnippet:
'startProfileAt([205.96, 254.59], sketch002)', 'startProfileAt([205.96, 254.59], sketch002)',
afterRectangle2ndClickSnippet: `angledLine([0,11.39],%,$rectangleSegmentA002) afterRectangle2ndClickSnippet: `angledLine(angle=0,length=11.39,tag=$rectangleSegmentA002)
|>angledLine([segAng(rectangleSegmentA002)-90,105.26],%) |>angledLine(angle=segAng(rectangleSegmentA002)-90,length=105.26)
|>angledLine([segAng(rectangleSegmentA002),-segLen(rectangleSegmentA002)],%) |>angledLine(angle=segAng(rectangleSegmentA002),length=-segLen(rectangleSegmentA002))
|>line(endAbsolute=[profileStartX(%),profileStartY(%)]) |>line(endAbsolute=[profileStartX(%),profileStartY(%)])
|>close()`, |>close()`,
}) })
@ -423,15 +396,9 @@ profile001 = startProfileAt([205.96, 254.59], sketch002)
`@settings(defaultLengthUnit = in) `@settings(defaultLengthUnit = in)
sketch001 = startSketchOn(XZ) sketch001 = startSketchOn(XZ)
|> startProfileAt([75.8, 317.2], %) |> startProfileAt([75.8, 317.2], %)
|> angledLine([0, 268.43], %, $rectangleSegmentA001) |> angledLine(angle = 0, length = 268.43, tag = $rectangleSegmentA001)
|> angledLine([ |> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 217.26, tag = $seg01)
segAng(rectangleSegmentA001) - 90, |> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001), tag = $yo)
217.26
], %, $seg01)
|> angledLine([
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %, $yo)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)], tag = $seg02) |> line(endAbsolute = [profileStartX(%), profileStartY(%)], tag = $seg02)
|> close() |> close()
extrude001 = extrude(sketch001, length = 100) extrude001 = extrude(sketch001, length = 100)
@ -451,15 +418,9 @@ chamf = chamfer(
) )
sketch002 = startSketchOn(extrude001, seg03) sketch002 = startSketchOn(extrude001, seg03)
profile001 = startProfileAt([205.96, 254.59], sketch002) profile001 = startProfileAt([205.96, 254.59], sketch002)
|> angledLine([0, 11.39], %, $rectangleSegmentA002) |> angledLine(angle = 0, length = 11.39, tag = $rectangleSegmentA002)
|> angledLine([ |> angledLine(angle = segAng(rectangleSegmentA002) - 90, length = 105.26)
segAng(rectangleSegmentA002) - 90, |> angledLine(angle = segAng(rectangleSegmentA002), length = -segLen(rectangleSegmentA002))
105.26
], %)
|> angledLine([
segAng(rectangleSegmentA002),
-segLen(rectangleSegmentA002)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
`, `,
@ -1671,15 +1632,9 @@ sketch002 = startSketchOn(XZ)
initialCode: `@settings(defaultLengthUnit = in) initialCode: `@settings(defaultLengthUnit = in)
sketch001 = startSketchOn(YZ) sketch001 = startSketchOn(YZ)
profile001 = startProfileAt([-400, -400], sketch001) profile001 = startProfileAt([-400, -400], sketch001)
|> angledLine([0, 800], %, $rectangleSegmentA001) |> angledLine(angle = 0, length = 800, tag = $rectangleSegmentA001)
|> angledLine([ |> angledLine(angle = segAng(rectangleSegmentA001) + 90, length = 800)
segAng(rectangleSegmentA001) + 90, |> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001))
800
], %)
|> angledLine([
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
sketch002 = startSketchOn(XZ) sketch002 = startSketchOn(XZ)
@ -3482,26 +3437,29 @@ sweep001 = sweep(sketch001, path = sketch002)
const initialCode = ` const initialCode = `
sketch001 = startSketchOn(XZ) sketch001 = startSketchOn(XZ)
|> startProfileAt([-100.0, 100.0], %) |> startProfileAt([-100.0, 100.0], %)
|> angledLine([0, 200.0], %, $rectangleSegmentA001) |> angledLine(angle = 0, length = 200.0, tag = $rectangleSegmentA001)
|> angledLine([segAng(rectangleSegmentA001) - 90, 200], %, $rectangleSegmentB001) |> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 200, tag = $rectangleSegmentB001)
|> angledLine([ |> angledLine(
segAng(rectangleSegmentA001), angle=segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001) length=-segLen(rectangleSegmentA001),
], %, $rectangleSegmentC001) tag=$rectangleSegmentC001,
)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
extrude001 = extrude(sketch001, length = 200) extrude001 = extrude(sketch001, length = 200)
sketch002 = startSketchOn(extrude001, rectangleSegmentA001) sketch002 = startSketchOn(extrude001, rectangleSegmentA001)
|> startProfileAt([-66.77, 84.81], %) |> startProfileAt([-66.77, 84.81], %)
|> angledLine([180, 27.08], %, $rectangleSegmentA002) |> angledLine(angle = 180, length = 27.08, tag = $rectangleSegmentA002)
|> angledLine([ |> angledLine(
segAng(rectangleSegmentA002) - 90, angle=segAng(rectangleSegmentA002) - 90,
27.8 length=27.8,
], %, $rectangleSegmentB002) tag=$rectangleSegmentB002,
|> angledLine([ )
segAng(rectangleSegmentA002), |> angledLine(
-segLen(rectangleSegmentA002) angle=segAng(rectangleSegmentA002),
], %, $rectangleSegmentC002) length=-segLen(rectangleSegmentA002),
tag=$rectangleSegmentC002,
)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
` `
@ -3571,20 +3529,15 @@ segAng(rectangleSegmentA002),
}) => { }) => {
const initialCode = `sketch001 = startSketchOn(XZ) const initialCode = `sketch001 = startSketchOn(XZ)
|> startProfileAt([-102.57, 101.72], %) |> startProfileAt([-102.57, 101.72], %)
|> angledLine([0, 202.6], %, $rectangleSegmentA001) |> angledLine(angle = 0, length = 202.6, tag = $rectangleSegmentA001)
|> angledLine([ |> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 202.6, tag = $rectangleSegmentB001)
segAng(rectangleSegmentA001) - 90, |> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001), tag = $rectangleSegmentC001)
202.6
], %, $rectangleSegmentB001)
|> angledLine([
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %, $rectangleSegmentC001)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
extrude001 = extrude(sketch001, length = 50) extrude001 = extrude(sketch001, length = 50)
sketch002 = startSketchOn(extrude001, rectangleSegmentA001) sketch002 = startSketchOn(extrude001, rectangleSegmentA001)
|> circle(center = [-11.34, 10.0], radius = 8.69) |> circle(center = [-11.34, 10.0], radius = 8.69)
` `
await context.addInitScript((initialCode) => { await context.addInitScript((initialCode) => {
localStorage.setItem('persistCode', initialCode) localStorage.setItem('persistCode', initialCode)
@ -3601,7 +3554,7 @@ sketch002 = startSketchOn(extrude001, rectangleSegmentA001)
await page.getByText(codeToSelection).click() await page.getByText(codeToSelection).click()
await toolbar.revolveButton.click() await toolbar.revolveButton.click()
await page.getByText('Edge', { exact: true }).click() await page.getByText('Edge', { exact: true }).click()
const lineCodeToSelection = `angledLine([0, 202.6], %, $rectangleSegmentA001)` const lineCodeToSelection = `angledLine(angle = 0, length = 202.6, tag = $rectangleSegmentA001)`
await page.getByText(lineCodeToSelection).click() await page.getByText(lineCodeToSelection).click()
await cmdBar.progressCmdBar() await cmdBar.progressCmdBar()
await cmdBar.progressCmdBar() await cmdBar.progressCmdBar()
@ -3658,22 +3611,23 @@ sketch002 = startSketchOn(extrude001, rectangleSegmentA001)
toolbar, toolbar,
cmdBar, cmdBar,
}) => { }) => {
const initialCode = `sketch002 = startSketchOn(XY) const initialCode = `
|> startProfileAt([-2.02, 1.79], %) sketch002 = startSketchOn(XY)
|> xLine(length = 2.6) |> startProfileAt([-2.02, 1.79], %)
sketch001 = startSketchOn(-XY) |> xLine(length = 2.6)
|> startProfileAt([-0.48, 1.25], %) sketch001 = startSketchOn('-XY')
|> angledLine([0, 2.38], %, $rectangleSegmentA001) |> startProfileAt([-0.48, 1.25], %)
|> angledLine([segAng(rectangleSegmentA001) - 90, 2.4], %, $rectangleSegmentB001) |> angledLine(angle = 0, length = 2.38, tag = $rectangleSegmentA001)
|> angledLine([ |> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 2.4, tag = $rectangleSegmentB001)
segAng(rectangleSegmentA001), |> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001), tag = $rectangleSegmentC001)
-segLen(rectangleSegmentA001) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
], %, $rectangleSegmentC001) |> close()
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) extrude001 = extrude(sketch001, length = 5)
|> close() sketch003 = startSketchOn(extrude001, 'START')
extrude001 = extrude(sketch001, length = 5) |> circle(
sketch003 = startSketchOn(extrude001, 'START') center = [-0.69, 0.56],
|> circle(center = [-0.69, 0.56], radius = 0.28) radius = 0.28
)
` `
await context.addInitScript((initialCode) => { await context.addInitScript((initialCode) => {

View File

@ -41,15 +41,13 @@ sketch002 = startSketchOn(XZ)
extrude002 = extrude(sketch002, length = 50) extrude002 = extrude(sketch002, length = 50)
sketch003 = startSketchOn(XY) sketch003 = startSketchOn(XY)
|> startProfileAt([52.92, 157.81], %) |> startProfileAt([52.92, 157.81], %)
|> angledLine([0, 176.4], %, $rectangleSegmentA001) |> angledLine(angle = 0, length = 176.4, tag = $rectangleSegmentA001)
|> angledLine([ |> angledLine(
segAng(rectangleSegmentA001) - 90, angle = segAng(rectangleSegmentA001) - 90,
53.4 length = 53.4,
], %, $rectangleSegmentB001) tag = $rectangleSegmentB001,
|> angledLine([ )
segAng(rectangleSegmentA001), |> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001), tag = $rectangleSegmentC001)
-segLen(rectangleSegmentA001)
], %, $rectangleSegmentC001)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
extrude003 = extrude(sketch003, length = 20) extrude003 = extrude(sketch003, length = 20)
@ -70,13 +68,10 @@ test.describe('edit with AI example snapshots', () => {
body1CapCoords.x, body1CapCoords.x,
body1CapCoords.y body1CapCoords.y
) )
const yellow: [number, number, number] = [179, 179, 131]
const submittingToast = page.getByText('Submitting to Text-to-CAD API...') const submittingToast = page.getByText('Submitting to Text-to-CAD API...')
await test.step('wait for scene to load select body and check selection came through', async () => { await test.step('wait for scene to load select body and check selection came through', async () => {
await scene.expectPixelColor([134, 134, 134], body1CapCoords, 15)
await clickBody1Cap() await clickBody1Cap()
await scene.expectPixelColor(yellow, body1CapCoords, 20)
await editor.expectState({ await editor.expectState({
highlightedCode: '', highlightedCode: '',
activeLines: ['|>startProfileAt([-73.64,-42.89],%)'], activeLines: ['|>startProfileAt([-73.64,-42.89],%)'],

View File

@ -22,15 +22,9 @@ sketch002 = startSketchOn(XZ)
extrude002 = extrude(sketch002, length = 50) extrude002 = extrude(sketch002, length = 50)
sketch003 = startSketchOn(XY) sketch003 = startSketchOn(XY)
|> startProfileAt([52.92, 157.81], %) |> startProfileAt([52.92, 157.81], %)
|> angledLine([0, 176.4], %, $rectangleSegmentA001) |> angledLine(angle = 0, length = 176.4, tag = $rectangleSegmentA001)
|> angledLine([ |> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 53.4, tag = $rectangleSegmentB001)
segAng(rectangleSegmentA001) - 90, |> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001), tag = $rectangleSegmentC001)
53.4
], %, $rectangleSegmentB001)
|> angledLine([
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %, $rectangleSegmentC001)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
extrude003 = extrude(sketch003, length = 20) extrude003 = extrude(sketch003, length = 20)
@ -57,6 +51,7 @@ test.describe('Prompt-to-edit tests', { tag: '@skipWin' }, () => {
page, page,
scene, scene,
}) => { }) => {
test.fixme(orRunWhenFullSuiteEnabled())
await context.addInitScript((file) => { await context.addInitScript((file) => {
localStorage.setItem('persistCode', file) localStorage.setItem('persistCode', file)
}, file) }, file)
@ -265,6 +260,7 @@ test.describe('Prompt-to-edit tests', { tag: '@skipWin' }, () => {
page, page,
scene, scene,
}) => { }) => {
test.fixme(orRunWhenFullSuiteEnabled())
const body1CapCoords = { x: 571, y: 311 } const body1CapCoords = { x: 571, y: 311 }
const body2WallCoords = { x: 620, y: 152 } const body2WallCoords = { x: 620, y: 152 }
const [clickBody1Cap] = scene.makeMouseHelpers( const [clickBody1Cap] = scene.makeMouseHelpers(

View File

@ -68,15 +68,9 @@ test.describe('Regression tests', { tag: ['@skipWin'] }, () => {
'persistCode', 'persistCode',
`sketch001 = startSketchOn(XY) `sketch001 = startSketchOn(XY)
|> startProfileAt([82.33, 238.21], %) |> startProfileAt([82.33, 238.21], %)
|> angledLine([0, 288.63], %, $rectangleSegmentA001) |> angledLine(angle = 0, length = 288.63, tag = $rectangleSegmentA001)
|> angledLine([ |> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 197.97, tag = $rectangleSegmentB001)
segAng(rectangleSegmentA001) - 90, |> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001), tag = $rectangleSegmentC001)
197.97
], %, $rectangleSegmentB001)
|> angledLine([
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %, $rectangleSegmentC001)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
extrude001 = extrude(sketch001, length = 50) extrude001 = extrude(sketch001, length = 50)
@ -257,7 +251,7 @@ extrude001 = extrude(sketch001, length = 50)
'persistCode', 'persistCode',
`exampleSketch = startSketchOn("XZ") `exampleSketch = startSketchOn("XZ")
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> angledLine({ angle: 50, length: 45 }, %) |> angledLine(angle = 50, length = 45 )
|> yLine(endAbsolute = 0) |> yLine(endAbsolute = 0)
|> close() |> close()
|> |>
@ -313,7 +307,7 @@ extrude001 = extrude(sketch001, length = 50)
await expect(page.locator('.cm-content')) await expect(page.locator('.cm-content'))
.toContainText(`exampleSketch = startSketchOn("XZ") .toContainText(`exampleSketch = startSketchOn("XZ")
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> angledLine({ angle: 50, length: 45 }, %) |> angledLine(angle = 50, length = 45 )
|> yLine(endAbsolute = 0) |> yLine(endAbsolute = 0)
|> close() |> close()
@ -334,15 +328,9 @@ extrude001 = extrude(sketch001, length = 50)
`@settings(defaultLengthUnit = mm) `@settings(defaultLengthUnit = mm)
sketch002 = startSketchOn(XY) sketch002 = startSketchOn(XY)
profile002 = startProfileAt([72.24, -52.05], sketch002) profile002 = startProfileAt([72.24, -52.05], sketch002)
|> angledLine([0, 181.26], %, $rectangleSegmentA001) |> angledLine(angle = 0, length = 181.26, tag = $rectangleSegmentA001)
|> angledLine([ |> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 21.54)
segAng(rectangleSegmentA001) - 90, |> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001))
21.54
], %)
|> angledLine([
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
extrude002 = extrude(profile002, length = 150) extrude002 = extrude(profile002, length = 150)

View File

@ -1222,7 +1222,7 @@ profile001 = startProfileAt([${roundOff(scale * 69.6)}, ${roundOff(
fn lug = (origin, length, diameter, plane) => { fn lug = (origin, length, diameter, plane) => {
lugSketch = startSketchOn(plane) lugSketch = startSketchOn(plane)
|> startProfileAt([origin[0] + lugDiameter / 2, origin[1]], %) |> startProfileAt([origin[0] + lugDiameter / 2, origin[1]], %)
|> angledLineOfYLength({ angle = 60, length = lugHeadLength }, %) |> angledLine(angle = 60, lengthY = lugHeadLength)
|> xLine(endAbsolute = 0 + .001) |> xLine(endAbsolute = 0 + .001)
|> yLine(endAbsolute = 0) |> yLine(endAbsolute = 0)
|> close() |> close()
@ -1977,12 +1977,9 @@ profile003 = startProfileAt([206.63, -56.73], sketch001)
) )
await crnRect1point2() await crnRect1point2()
await editor.expectEditor.toContain( await editor.expectEditor.toContain(
`|> angledLine([0, 2.37], %, $rectangleSegmentA001) `|> angledLine(angle = 0, length = 2.37, tag = $rectangleSegmentA001)
|> angledLine([segAng(rectangleSegmentA001) - 90, 7.8], %) |> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 7.8)
|> angledLine([ |> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001))
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()`.replaceAll('\n', '') |> close()`.replaceAll('\n', '')
) )
@ -1995,15 +1992,9 @@ profile003 = startProfileAt([206.63, -56.73], sketch001)
await crnRect2point2() await crnRect2point2()
await page.waitForTimeout(300) await page.waitForTimeout(300)
await editor.expectEditor.toContain( await editor.expectEditor.toContain(
`|> angledLine([0, 5.49], %, $rectangleSegmentA002) `|> angledLine(angle = 0, length = 5.49, tag = $rectangleSegmentA002)
|> angledLine([ |> angledLine(angle = segAng(rectangleSegmentA002) - 90, length = 4.14)
segAng(rectangleSegmentA002) - 90, |> angledLine(angle = segAng(rectangleSegmentA002), length = -segLen(rectangleSegmentA002))
4.14
], %)
|> angledLine([
segAng(rectangleSegmentA002),
-segLen(rectangleSegmentA002)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()`.replaceAll('\n', '') |> close()`.replaceAll('\n', '')
) )
@ -2020,15 +2011,9 @@ profile003 = startProfileAt([206.63, -56.73], sketch001)
await cntrRect1point2() await cntrRect1point2()
await page.waitForTimeout(300) await page.waitForTimeout(300)
await editor.expectEditor.toContain( await editor.expectEditor.toContain(
`|> angledLine([0, 7.06], %, $rectangleSegmentA003) `|> angledLine(angle = 0, length = 7.06, tag = $rectangleSegmentA003)
|> angledLine([ |> angledLine(angle = segAng(rectangleSegmentA003) + 90, length = 4.34)
segAng(rectangleSegmentA003) + 90, |> angledLine(angle = segAng(rectangleSegmentA003), length = -segLen(rectangleSegmentA003))
4.34
], %)
|> angledLine([
segAng(rectangleSegmentA003),
-segLen(rectangleSegmentA003)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()`.replaceAll('\n', '') |> close()`.replaceAll('\n', '')
) )
@ -2042,15 +2027,9 @@ profile003 = startProfileAt([206.63, -56.73], sketch001)
await cntrRect2point2() await cntrRect2point2()
await page.waitForTimeout(300) await page.waitForTimeout(300)
await editor.expectEditor.toContain( await editor.expectEditor.toContain(
`|> angledLine([0, 3.12], %, $rectangleSegmentA004) `|> angledLine(angle = 0, length = 3.12, tag = $rectangleSegmentA004)
|> angledLine([ |> angledLine(angle = segAng(rectangleSegmentA004) + 90, length = 6.24)
segAng(rectangleSegmentA004) + 90, |> angledLine(angle = segAng(rectangleSegmentA004), length = -segLen(rectangleSegmentA004))
6.24
], %)
|> angledLine([
segAng(rectangleSegmentA004),
-segLen(rectangleSegmentA004)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()`.replaceAll('\n', '') |> close()`.replaceAll('\n', '')
) )
@ -2204,15 +2183,9 @@ profile001 = startProfileAt([6.24, 4.54], sketch001)
|> line(end = [8.61, 0.74]) |> line(end = [8.61, 0.74])
|> line(end = [10.99, -5.22]) |> line(end = [10.99, -5.22])
profile002 = startProfileAt([11.19, 5.02], sketch001) profile002 = startProfileAt([11.19, 5.02], sketch001)
|> angledLine([0, 10.78], %, $rectangleSegmentA001) |> angledLine(angle = 0, length = 10.78, tag = $rectangleSegmentA001)
|> angledLine([ |> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 4.14)
segAng(rectangleSegmentA001) - 90, |> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001))
4.14
], %)
|> angledLine([
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
profile003 = circle(sketch001, center = [6.92, -4.2], radius = 3.16) profile003 = circle(sketch001, center = [6.92, -4.2], radius = 3.16)
@ -2282,7 +2255,7 @@ profile004 = circleThreePoint(sketch001, p1 = [13.44, -6.8], p2 = [13.39, -2.07]
await rectDragTo() await rectDragTo()
await page.mouse.up() await page.mouse.up()
await editor.expectEditor.toContain( await editor.expectEditor.toContain(
`angledLine([-7, 10.27], %, $rectangleSegmentA001)` `angledLine(angle = -7, length = 10.27, tag = $rectangleSegmentA001)`
) )
}) })
@ -2322,15 +2295,9 @@ profile004 = circleThreePoint(sketch001, p1 = [13.44, -6.8], p2 = [13.39, -2.07]
await page.waitForTimeout(100) await page.waitForTimeout(100)
await rectEnd() await rectEnd()
await editor.expectEditor.toContain( await editor.expectEditor.toContain(
`|> angledLine([180, 1.97], %, $rectangleSegmentA002) `|> angledLine(angle = 180, length = 1.97, tag = $rectangleSegmentA002)
|> angledLine([ |> angledLine(angle = segAng(rectangleSegmentA002) + 90, length = 3.89)
segAng(rectangleSegmentA002) + 90, |> angledLine(angle = segAng(rectangleSegmentA002), length = -segLen(rectangleSegmentA002))
3.89
], %)
|> angledLine([
segAng(rectangleSegmentA002),
-segLen(rectangleSegmentA002)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()`.replaceAll('\n', '') |> close()`.replaceAll('\n', '')
) )
@ -2351,15 +2318,9 @@ profile001 = startProfileAt([6.24, 4.54], sketch001)
|> line(end = [8.61, 0.74]) |> line(end = [8.61, 0.74])
|> line(end = [10.99, -5.22]) |> line(end = [10.99, -5.22])
profile002 = startProfileAt([11.19, 5.02], sketch001) profile002 = startProfileAt([11.19, 5.02], sketch001)
|> angledLine([0, 10.78], %, $rectangleSegmentA001) |> angledLine(angle = 0, length = 10.78, tag = $rectangleSegmentA001)
|> angledLine([ |> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 4.14)
segAng(rectangleSegmentA001) - 90, |> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001))
4.14
], %)
|> angledLine([
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
profile003 = circle(sketch001, center = [6.92, -4.2], radius = 3.16) profile003 = circle(sketch001, center = [6.92, -4.2], radius = 3.16)
@ -2460,15 +2421,9 @@ profile001 = startProfileAt([-63.43, 193.08], sketch001)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
profile003 = startProfileAt([16.79, 38.24], sketch001) profile003 = startProfileAt([16.79, 38.24], sketch001)
|> angledLine([0, 182.82], %, $rectangleSegmentA001) |> angledLine(angle = 0, length = 182.82, tag = $rectangleSegmentA001)
|> angledLine([ |> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 105.71)
segAng(rectangleSegmentA001) - 90, |> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001))
105.71
], %)
|> angledLine([
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
profile004 = circle( profile004 = circle(
@ -2684,15 +2639,9 @@ profile002 = startProfileAt([0.75, 13.46], sketch002)
|> line(end = [4.52, 3.79]) |> line(end = [4.52, 3.79])
|> line(end = [5.98, -2.81]) |> line(end = [5.98, -2.81])
profile003 = startProfileAt([3.19, 13.3], sketch002) profile003 = startProfileAt([3.19, 13.3], sketch002)
|> angledLine([0, 6.64], %, $rectangleSegmentA001) |> angledLine(angle = 0, length = 6.64, tag = $rectangleSegmentA001)
|> angledLine([ |> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 2.81)
segAng(rectangleSegmentA001) - 90, |> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001))
2.81
], %)
|> angledLine([
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
profile004 = startProfileAt([3.15, 9.39], sketch002) profile004 = startProfileAt([3.15, 9.39], sketch002)
@ -2732,15 +2681,9 @@ profile010 = circle(
radius = 2.67 radius = 2.67
) )
profile011 = startProfileAt([5.07, -6.39], sketch003) profile011 = startProfileAt([5.07, -6.39], sketch003)
|> angledLine([0, 4.54], %, $rectangleSegmentA002) |> angledLine(angle = 0, length = 4.54, tag = $rectangleSegmentA002)
|> angledLine([ |> angledLine(angle = segAng(rectangleSegmentA002) - 90, length = 4.17)
segAng(rectangleSegmentA002) - 90, |> angledLine(angle = segAng(rectangleSegmentA002), length = -segLen(rectangleSegmentA002))
4.17
], %)
|> angledLine([
segAng(rectangleSegmentA002),
-segLen(rectangleSegmentA002)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
extrude003 = extrude(profile011, length = 2.5) extrude003 = extrude(profile011, length = 2.5)
@ -2889,7 +2832,7 @@ loft([profile001, profile002])
) )
await rect1Crn2() await rect1Crn2()
await editor.expectEditor.toContain( await editor.expectEditor.toContain(
`angledLine([0, 113.01], %, $rectangleSegmentA001)` `angledLine(angle = 0, length = 113.01, tag = $rectangleSegmentA001)`
) )
} }
) )
@ -2960,7 +2903,7 @@ loft([profile001, profile002])
) )
await rect1Crn2() await rect1Crn2()
await editor.expectEditor.toContain( await editor.expectEditor.toContain(
`angledLine([0, 106.42], %, $rectangleSegmentA001)` `angledLine(angle = 0, length = 106.42], tag = $rectangleSegmentA001)`
) )
await page.waitForTimeout(100) await page.waitForTimeout(100)
}) })

View File

@ -70,10 +70,11 @@ part001 = startSketchOn(-XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> yLine(length = baseHeight) |> yLine(length = baseHeight)
|> xLine(length = baseLen) |> xLine(length = baseLen)
|> angledLineToY({ |> angledLine(
angle = topAng, angle = topAng,
to = totalHeightHalf, endAbsoluteY = totalHeightHalf,
}, %, $seg04) tag = $seg04,
)
|> xLine(endAbsolute = totalLen, tag = $seg03) |> xLine(endAbsolute = totalLen, tag = $seg03)
|> yLine(length = -armThick, tag = $seg01) |> yLine(length = -armThick, tag = $seg01)
|> angledLineThatIntersects({ |> angledLineThatIntersects({
@ -81,11 +82,12 @@ part001 = startSketchOn(-XZ)
offset = -armThick, offset = -armThick,
intersectTag = seg04 intersectTag = seg04
}, %) }, %)
|> angledLineToY([segAng(seg04, %) + 180, turns::ZERO], %) |> angledLine(angle = segAng(seg04, %) + 180, endAbsoluteY = turns::ZERO)
|> angledLineToY({ |> angledLine(
angle = -bottomAng, angle = -bottomAng,
to = -totalHeightHalf - armThick, endAbsoluteY = -totalHeightHalf - armThick,
}, %, $seg02) tag = $seg02,
)
|> xLine(length = endAbsolute = segEndX(seg03) + 0) |> xLine(length = endAbsolute = segEndX(seg03) + 0)
|> yLine(length = -segLen(seg01, %)) |> yLine(length = -segLen(seg01, %))
|> angledLineThatIntersects({ |> angledLineThatIntersects({
@ -93,7 +95,7 @@ part001 = startSketchOn(-XZ)
offset = -armThick, offset = -armThick,
intersectTag = seg02 intersectTag = seg02
}, %) }, %)
|> angledLineToY([segAng(seg02, %) + 180, -baseHeight], %) |> angledLine(angle = segAng(seg02, %) + 180, endAbsoluteY = -baseHeight)
|> xLine(endAbsolute = turns::ZERO) |> xLine(endAbsolute = turns::ZERO)
|> close() |> close()
|> extrude(length = 4)` |> extrude(length = 4)`
@ -586,6 +588,7 @@ test(
'Draft circle should look right', 'Draft circle should look right',
{ tag: '@snapshot' }, { tag: '@snapshot' },
async ({ page, context, cmdBar, scene }) => { async ({ page, context, cmdBar, scene }) => {
test.fixme(orRunWhenFullSuiteEnabled())
const u = await getUtils(page) const u = await getUtils(page)
await page.setViewportSize({ width: 1200, height: 500 }) await page.setViewportSize({ width: 1200, height: 500 })
const PUR = 400 / 37.5 //pixeltoUnitRatio const PUR = 400 / 37.5 //pixeltoUnitRatio

View File

@ -1,5 +1,5 @@
{ {
"original_source_code": "sketch001 = startSketchOn('XZ')\nprofile001 = startProfileAt([57.81, 250.51], sketch001)\n |> line(end = [121.13, 56.63], tag = $seg02)\n |> line(end = [83.37, -34.61], tag = $seg01)\n |> line(end = [19.66, -116.4])\n |> line(end = [-221.8, -41.69])\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\nextrude001 = extrude(profile001, length = 200)\nsketch002 = startSketchOn('XZ')\n |> startProfileAt([-73.64, -42.89], %)\n |> xLine(length = 173.71)\n |> line(end = [-22.12, -94.4])\n |> xLine(length = -156.98)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\nextrude002 = extrude(sketch002, length = 50)\nsketch003 = startSketchOn(XY)\n |> startProfileAt([52.92, 157.81], %)\n |> angledLine([0, 176.4], %, $rectangleSegmentA001)\n |> angledLine([\n segAng(rectangleSegmentA001) - 90,\n 53.4\n ], %, $rectangleSegmentB001)\n |> angledLine([\n segAng(rectangleSegmentA001),\n -segLen(rectangleSegmentA001)\n ], %, $rectangleSegmentC001)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\nextrude003 = extrude(sketch003, length = 20)\n", "original_source_code": "sketch001 = startSketchOn(XZ)\nprofile001 = startProfileAt([57.81, 250.51], sketch001)\n |> line(end = [121.13, 56.63], tag = $seg02)\n |> line(end = [83.37, -34.61], tag = $seg01)\n |> line(end = [19.66, -116.4])\n |> line(end = [-221.8, -41.69])\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\nextrude001 = extrude(profile001, length = 200)\nsketch002 = startSketchOn('XZ')\n |> startProfileAt([-73.64, -42.89], %)\n |> xLine(length = 173.71)\n |> line(end = [-22.12, -94.4])\n |> xLine(length = -156.98)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\nextrude002 = extrude(sketch002, length = 50)\nsketch003 = startSketchOn(XY)\n |> startProfileAt([52.92, 157.81], %)\n |> angledLine(angle = 0, length = 176.4, tag = $rectangleSegmentA001)\n |> angledLine(angle = segAng(rectangleSegmentA001) - 90,\n length = 53.4\n ], tag = $rectangleSegmentB001)\n |> angledLine(angle = segAng(rectangleSegmentA001),\n length = -segLen(rectangleSegmentA001)\n tag = $rectangleSegmentC001)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\nextrude003 = extrude(sketch003, length = 20)\n",
"prompt": "make this neon green please, use #39FF14", "prompt": "make this neon green please, use #39FF14",
"source_ranges": [ "source_ranges": [
{ {

View File

@ -1,5 +1,5 @@
{ {
"original_source_code": "sketch001 = startSketchOn(XZ)\nprofile001 = startProfileAt([57.81, 250.51], sketch001)\n |> line(end = [121.13, 56.63], tag = $seg02)\n |> line(end = [83.37, -34.61], tag = $seg01)\n |> line(end = [19.66, -116.4])\n |> line(end = [-221.8, -41.69])\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\nextrude001 = extrude(profile001, length = 200)\nsketch002 = startSketchOn(XZ)\n |> startProfileAt([-73.64, -42.89], %)\n |> xLine(length = 173.71)\n |> line(end = [-22.12, -94.4])\n |> xLine(length = -156.98)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\nextrude002 = extrude(sketch002, length = 50)\nsketch003 = startSketchOn(XY)\n |> startProfileAt([52.92, 157.81], %)\n |> angledLine([0, 176.4], %, $rectangleSegmentA001)\n |> angledLine([\n segAng(rectangleSegmentA001) - 90,\n 53.4\n ], %, $rectangleSegmentB001)\n |> angledLine([\n segAng(rectangleSegmentA001),\n -segLen(rectangleSegmentA001)\n ], %, $rectangleSegmentC001)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\nextrude003 = extrude(sketch003, length = 20)\n", "original_source_code": "sketch001 = startSketchOn(XZ)\nprofile001 = startProfileAt([57.81, 250.51], sketch001)\n |> line(end = [121.13, 56.63], tag = $seg02)\n |> line(end = [83.37, -34.61], tag = $seg01)\n |> line(end = [19.66, -116.4])\n |> line(end = [-221.8, -41.69])\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\nextrude001 = extrude(profile001, length = 200)\nsketch002 = startSketchOn(XZ)\n |> startProfileAt([-73.64, -42.89], %)\n |> xLine(length = 173.71)\n |> line(end = [-22.12, -94.4])\n |> xLine(length = -156.98)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\nextrude002 = extrude(sketch002, length = 50)\nsketch003 = startSketchOn(XY)\n |> startProfileAt([52.92, 157.81], %)\n |> angledLine(angle = 0, 176.4], %, $rectangleSegmentA001)\n |> angledLine([\n segAng(rectangleSegmentA001) - 90,\n 53.4\n ], %, length = $rectangleSegmentB001)\n |> angledLine(\n angle = segAng(rectangleSegmentA001),\n length = -segLen(rectangleSegmentA001),\n tag = $rectangleSegmentC001)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\nextrude003 = extrude(sketch003, length = 20)\n",
"prompt": "make this neon green please, use #39FF14", "prompt": "make this neon green please, use #39FF14",
"source_ranges": [ "source_ranges": [
{ {

View File

@ -84,15 +84,15 @@ export const TEST_CODE_GIZMO = `@settings(defaultLengthUnit = in)
part001 = startSketchOn(XZ) part001 = startSketchOn(XZ)
|> startProfileAt([20, 0], %) |> startProfileAt([20, 0], %)
|> line(end = [7.13, 4 + 0]) |> line(end = [7.13, 4 + 0])
|> angledLine({ angle: 3 + 0, length: 3.14 + 0 }, %) |> angledLine(angle = 3 + 0, length = 3.14 + 0 )
|> line(endAbsolute = [20.14 + 0, -0.14 + 0]) |> line(endAbsolute = [20.14 + 0, -0.14 + 0])
|> xLine(endAbsolute = 29 + 0) |> xLine(endAbsolute = 29 + 0)
|> yLine(length = -3.14 + 0, tag = $a) |> yLine(length = -3.14 + 0, tag = $a)
|> xLine(length = 1.63) |> xLine(length = 1.63)
|> angledLineOfXLength({ angle: 3 + 0, length: 3.14 }, %) |> angledLine(angle = 3 + 0, lengthX = 3.14 )
|> angledLineOfYLength({ angle: 30, length: 3 + 0 }, %) |> angledLine(angle = 30, lengthY = 3 + 0 )
|> angledLineToX({ angle: 22.14 + 0, to: 12 }, %) |> angledLine(angle = 22.14 + 0, endAbsoluteX = 12)
|> angledLineToY({ angle: 30, to: 11.14 }, %) |> angledLine(angle = 30, endAbsoluteY = 11.14)
|> angledLineThatIntersects({ |> angledLineThatIntersects({
angle: 3.14, angle: 3.14,
intersectTag: a, intersectTag: a,

View File

@ -0,0 +1,15 @@
import { createProject } from '@e2e/playwright/test-utils'
import { test } from '@e2e/playwright/zoo-test'
test.describe('Stress test', () => {
test('Create project and load stress test', async ({
cmdBar,
scene,
page,
}, testInfo) => {
const projectName = 'stress-test-project'
// Create and load project
await createProject({ name: projectName, page })
await scene.settled(cmdBar)
})
})

View File

@ -1021,6 +1021,10 @@ export function executorInputPath(fileName: string): string {
return path.join('rust', 'kcl-lib', 'e2e', 'executor', 'inputs', fileName) return path.join('rust', 'kcl-lib', 'e2e', 'executor', 'inputs', fileName)
} }
export function testsInputPath(fileName: string): string {
return path.join('rust', 'kcl-lib', 'tests', 'inputs', fileName)
}
export async function doAndWaitForImageDiff( export async function doAndWaitForImageDiff(
page: Page, page: Page,
fn: () => Promise<unknown>, fn: () => Promise<unknown>,

View File

@ -58,7 +58,7 @@ test.describe('Testing constraints', { tag: ['@skipWin'] }, () => {
.click() .click()
await expect(page.locator('.cm-content')).toHaveText( await expect(page.locator('.cm-content')).toHaveText(
`length001 = 20sketch001 = startSketchOn(XY) |> startProfileAt([-10, -10], %) |> line(end = [20, 0]) |> angledLine([90, length001], %) |> xLine(length = -20)` `length001 = 20sketch001 = startSketchOn(XY) |> startProfileAt([-10, -10], %) |> line(end = [20, 0]) |> angledLine(angle = 90, length = length001) |> xLine(length = -20)`
) )
// Make sure we didn't pop out of sketch mode. // Make sure we didn't pop out of sketch mode.
@ -87,7 +87,7 @@ test.describe('Testing constraints', { tag: ['@skipWin'] }, () => {
|> startProfileAt([-7.54, -26.74], %) |> startProfileAt([-7.54, -26.74], %)
|> line(end = [74.36, 130.4], tag = $seg01) |> line(end = [74.36, 130.4], tag = $seg01)
|> line(end = [78.92, -120.11]) |> line(end = [78.92, -120.11])
|> angledLine([segAng(seg01), yo], %) |> angledLine(angle = segAng(seg01), length = yo)
|> line(end = [41.19, 58.97 + 5]) |> line(end = [41.19, 58.97 + 5])
part002 = startSketchOn(XZ) part002 = startSketchOn(XZ)
|> startProfileAt([299.05, 120], %) |> startProfileAt([299.05, 120], %)
@ -115,7 +115,7 @@ test.describe('Testing constraints', { tag: ['@skipWin'] }, () => {
await page.waitForTimeout(100) // this wait is needed for webkit - not sure why await page.waitForTimeout(100) // this wait is needed for webkit - not sure why
await page await page
.getByRole('button', { .getByRole('button', {
name: 'Length: open menu', name: 'constraints: open menu',
}) })
.click() .click()
await page.getByRole('button', { name: 'remove constraints' }).click() await page.getByRole('button', { name: 'remove constraints' }).click()
@ -152,7 +152,7 @@ test.describe('Testing constraints', { tag: ['@skipWin'] }, () => {
|> startProfileAt([-7.54, -26.74], %) |> startProfileAt([-7.54, -26.74], %)
|> line(end = [74.36, 130.4], tag = $seg01) |> line(end = [74.36, 130.4], tag = $seg01)
|> line(end = [78.92, -120.11]) |> line(end = [78.92, -120.11])
|> angledLine([segAng(seg01), 78.33], %) |> angledLine(angle = segAng(seg01), length = 78.33)
|> line(end = [51.19, 48.97]) |> line(end = [51.19, 48.97])
part002 = startSketchOn(XZ) part002 = startSketchOn(XZ)
|> startProfileAt([299.05, 231.45], %) |> startProfileAt([299.05, 231.45], %)
@ -189,7 +189,7 @@ test.describe('Testing constraints', { tag: ['@skipWin'] }, () => {
await page.waitForTimeout(100) await page.waitForTimeout(100)
await page await page
.getByRole('button', { .getByRole('button', {
name: 'Length: open menu', name: 'constraints: open menu',
}) })
.click() .click()
await page await page
@ -299,7 +299,7 @@ test.describe('Testing constraints', { tag: ['@skipWin'] }, () => {
await page.keyboard.up('Shift') await page.keyboard.up('Shift')
await page await page
.getByRole('button', { .getByRole('button', {
name: 'Length: open menu', name: 'constraints: open menu',
}) })
.click() .click()
await page.getByRole('button', { name: constraint }).click() await page.getByRole('button', { name: constraint }).click()
@ -420,7 +420,7 @@ test.describe('Testing constraints', { tag: ['@skipWin'] }, () => {
await page.waitForTimeout(100) await page.waitForTimeout(100)
await page await page
.getByRole('button', { .getByRole('button', {
name: 'Length: open menu', name: 'constraints: open menu',
}) })
.click() .click()
await page await page
@ -533,7 +533,7 @@ test.describe('Testing constraints', { tag: ['@skipWin'] }, () => {
await page.keyboard.up('Shift') await page.keyboard.up('Shift')
await page await page
.getByRole('button', { .getByRole('button', {
name: 'Length: open menu', name: 'constraints: open menu',
}) })
.click() .click()
await page.getByTestId('dropdown-constraint-angle').click() await page.getByTestId('dropdown-constraint-angle').click()
@ -552,7 +552,7 @@ test.describe('Testing constraints', { tag: ['@skipWin'] }, () => {
// checking activeLines assures the cursors are where they should be // checking activeLines assures the cursors are where they should be
const codeAfter = [ const codeAfter = [
'|> line(end = [74.36, 130.4], tag = $seg01)', '|> line(end = [74.36, 130.4], tag = $seg01)',
`|> angledLine([${value}, 78.33], %)`, `|> angledLine(angle = ${value}, length = 78.33)`,
] ]
if (axisSelect) codeAfter.shift() if (axisSelect) codeAfter.shift()
@ -627,7 +627,7 @@ test.describe('Testing constraints', { tag: ['@skipWin'] }, () => {
await page.mouse.click(line3.x, line3.y) await page.mouse.click(line3.x, line3.y)
await page await page
.getByRole('button', { .getByRole('button', {
name: 'Length: open menu', name: 'constraints: open menu',
}) })
.click() .click()
await page.getByTestId('dropdown-constraint-' + constraint).click() await page.getByTestId('dropdown-constraint-' + constraint).click()
@ -639,7 +639,8 @@ test.describe('Testing constraints', { tag: ['@skipWin'] }, () => {
.getByRole('button', { name: 'Add constraining value' }) .getByRole('button', { name: 'Add constraining value' })
.click() .click()
const changedCode = `|> angledLine([${value}], %)` const [ang, len] = value.split(', ')
const changedCode = `|> angledLine(angle = ${ang}, length = ${len})`
await expect(page.locator('.cm-content')).toContainText(changedCode) await expect(page.locator('.cm-content')).toContainText(changedCode)
// checking active assures the cursor is where it should be // checking active assures the cursor is where it should be
await expect(page.locator('.cm-activeLine')).toHaveText(changedCode) await expect(page.locator('.cm-activeLine')).toHaveText(changedCode)
@ -719,7 +720,7 @@ part002 = startSketchOn(XZ)
await page.mouse.click(line3.x, line3.y) await page.mouse.click(line3.x, line3.y)
await page await page
.getByRole('button', { .getByRole('button', {
name: 'Length: open menu', name: 'constraints: open menu',
}) })
.click() .click()
await page.getByTestId('dropdown-constraint-' + constraint).click() await page.getByTestId('dropdown-constraint-' + constraint).click()
@ -733,7 +734,8 @@ part002 = startSketchOn(XZ)
await expect(cmdBarKclInput).toHaveText('78.33') await expect(cmdBarKclInput).toHaveText('78.33')
await cmdBarSubmitButton.click() await cmdBarSubmitButton.click()
const changedCode = `|> angledLine([${value}], %)` const [ang, len] = value.split(', ')
const changedCode = `|> angledLine(angle = ${ang}, length = ${len})`
await expect(page.locator('.cm-content')).toContainText(changedCode) await expect(page.locator('.cm-content')).toContainText(changedCode)
// checking active assures the cursor is where it should be // checking active assures the cursor is where it should be
await expect(page.locator('.cm-activeLine')).toHaveText(changedCode) await expect(page.locator('.cm-activeLine')).toHaveText(changedCode)
@ -817,7 +819,7 @@ part002 = startSketchOn(XZ)
const activeLinesContent = await page.locator('.cm-activeLine').all() const activeLinesContent = await page.locator('.cm-activeLine').all()
const constraintMenuButton = page.getByRole('button', { const constraintMenuButton = page.getByRole('button', {
name: 'Length: open menu', name: 'constraints: open menu',
}) })
const constraintButton = page const constraintButton = page
.getByRole('button', { .getByRole('button', {
@ -848,11 +850,11 @@ part002 = startSketchOn(XZ)
test.describe('Two segment - no modal constraints', () => { test.describe('Two segment - no modal constraints', () => {
const cases = [ const cases = [
{ {
codeAfter: `|> angledLine([83, segLen(seg01)], %)`, codeAfter: `|> angledLine(angle = 83, length = segLen(seg01))`,
constraintName: 'Equal Length', constraintName: 'Equal Length',
}, },
{ {
codeAfter: `|> angledLine([segAng(seg01), 78.33], %)`, codeAfter: `|> angledLine(angle = segAng(seg01), length = 78.33)`,
constraintName: 'Parallel', constraintName: 'Parallel',
}, },
{ {
@ -905,7 +907,7 @@ part002 = startSketchOn(XZ)
await page.mouse.click(line3.x - 3, line3.y + 20) await page.mouse.click(line3.x - 3, line3.y + 20)
await page.keyboard.up('Shift') await page.keyboard.up('Shift')
const constraintMenuButton = page.getByRole('button', { const constraintMenuButton = page.getByRole('button', {
name: 'Length: open menu', name: 'constraints: open menu',
}) })
const constraintButton = page.getByRole('button', { const constraintButton = page.getByRole('button', {
name: constraintName, name: constraintName,
@ -990,7 +992,7 @@ part002 = startSketchOn(XZ)
await page.keyboard.up('Shift') await page.keyboard.up('Shift')
await page.waitForTimeout(100) await page.waitForTimeout(100)
const constraintMenuButton = page.getByRole('button', { const constraintMenuButton = page.getByRole('button', {
name: 'Length: open menu', name: 'constraints: open menu',
}) })
const constraintButton = page.getByRole('button', { const constraintButton = page.getByRole('button', {
name: constraintName, name: constraintName,
@ -1057,7 +1059,7 @@ part002 = startSketchOn(XZ)
await page await page
.getByRole('button', { .getByRole('button', {
name: 'Length: open menu', name: 'constraints: open menu',
}) })
.click() .click()
await page.waitForTimeout(500) await page.waitForTimeout(500)
@ -1129,7 +1131,7 @@ test.describe('Electron constraint tests', () => {
|> line(end = [15.1, 2.48]) |> line(end = [15.1, 2.48])
|> line(end = [3.15, -9.85], tag = $seg01) |> line(end = [3.15, -9.85], tag = $seg01)
|> line(end = [-15.17, -4.1]) |> line(end = [-15.17, -4.1])
|> angledLine([segAng(seg01), 12.35], %) |> angledLine(angle = segAng(seg01), length = 12.35)
|> line(end = [-13.02, 10.03]) |> line(end = [-13.02, 10.03])
|> close() |> close()
|> extrude(length = 4)`, |> extrude(length = 4)`,
@ -1169,7 +1171,9 @@ test.describe('Electron constraint tests', () => {
await clickOnFirstSegmentLabel() await clickOnFirstSegmentLabel()
await cmdBar.progressCmdBar() await cmdBar.progressCmdBar()
await editor.expectEditor.toContain('length001 = 15.3') await editor.expectEditor.toContain('length001 = 15.3')
await editor.expectEditor.toContain('|> angledLine([9, length001], %)') await editor.expectEditor.toContain(
'|> angledLine(angle = 9, length = length001)'
)
}) })
await test.step('Double click again and expect failure', async () => { await test.step('Double click again and expect failure', async () => {

View File

@ -259,15 +259,9 @@ test.describe(`Testing gizmo, fixture-based`, () => {
`@settings(defaultLengthUnit = in) `@settings(defaultLengthUnit = in)
const sketch002 = startSketchOn(XZ) const sketch002 = startSketchOn(XZ)
|> startProfileAt([-108.83, -57.48], %) |> startProfileAt([-108.83, -57.48], %)
|> angledLine([0, 105.13], %, $rectangleSegmentA001) |> angledLine(angle = 0, length = 105.13, tag = $rectangleSegmentA001)
|> angledLine([ |> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 77.9)
segAng(rectangleSegmentA001) - 90, |> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001))
77.9
], %)
|> angledLine([
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %)
|> close() |> close()
const sketch001 = startSketchOn(XZ) const sketch001 = startSketchOn(XZ)
|> circle(center = [818.33, 168.1], radius = 182.8) |> circle(center = [818.33, 168.1], radius = 182.8)

View File

@ -214,16 +214,16 @@ test.describe('Testing segment overlays', { tag: ['@skipWin'] }, () => {
part001 = startSketchOn(XZ) part001 = startSketchOn(XZ)
|> startProfileAt([5 + 0, 20 + 0], %) |> startProfileAt([5 + 0, 20 + 0], %)
|> line(end = [0.5, -14 + 0]) |> line(end = [0.5, -14 + 0])
|> angledLine({ angle = 3 + 0, length = 32 + 0 }, %) |> angledLine(angle = 3 + 0, length = 32 + 0)
|> line(endAbsolute = [5 + 33, 20 + 11.5 + 0]) |> line(endAbsolute = [5 + 33, 20 + 11.5 + 0])
|> xLine(endAbsolute = 5 + 9 - 5) |> xLine(endAbsolute = 5 + 9 - 5)
|> yLine(endAbsolute = 20 + -10.77, tag = $a) |> yLine(endAbsolute = 20 + -10.77, tag = $a)
|> xLine(length = 26.04) |> xLine(length = 26.04)
|> yLine(length = 21.14 + 0) |> yLine(length = 21.14 + 0)
|> angledLineOfXLength({ angle = 181 + 0, length = 23.14 }, %) |> angledLine(angle = 181 + 0, lengthX = 23.14)
|> angledLineOfYLength({ angle = -91, length = 19 + 0 }, %) |> angledLine(angle = -91, lengthY = 19 + 0)
|> angledLineToX({ angle = 3 + 0, to = 5 + 26 }, %) |> angledLine(angle = 3 + 0, endAbsoluteX = 5 + 26)
|> angledLineToY({ angle = 89, to = 20 + 9.14 + 0 }, %) |> angledLine(angle = 89, endAbsoluteY = 20 + 9.14 + 0)
|> angledLineThatIntersects({ |> angledLineThatIntersects({
angle = 4.14, angle = 4.14,
intersectTag = a, intersectTag = a,
@ -306,11 +306,9 @@ test.describe('Testing segment overlays', { tag: ['@skipWin'] }, () => {
await clickConstrained({ await clickConstrained({
hoverPos: { x: angledLine.x, y: angledLine.y }, hoverPos: { x: angledLine.x, y: angledLine.y },
constraintType: 'angle', constraintType: 'angle',
expectBeforeUnconstrained: expectBeforeUnconstrained: 'angledLine(angle = 3 + 0, length = 32 + 0)',
'angledLine({ angle = 3 + 0, length = 32 + 0 }, %)', expectAfterUnconstrained: 'angledLine(angle = 3, length = 32 + 0)',
expectAfterUnconstrained: expectFinal: 'angledLine(angle = angle001, length = 32 + 0)',
'angledLine({ angle = 3, length = 32 + 0 }, %)',
expectFinal: 'angledLine({ angle = angle001, length = 32 + 0 }, %)',
ang: ang + 180, ang: ang + 180,
locator: '[data-overlay-toolbar-index="1"]', locator: '[data-overlay-toolbar-index="1"]',
}) })
@ -319,10 +317,9 @@ test.describe('Testing segment overlays', { tag: ['@skipWin'] }, () => {
hoverPos: { x: angledLine.x, y: angledLine.y }, hoverPos: { x: angledLine.x, y: angledLine.y },
constraintType: 'length', constraintType: 'length',
expectBeforeUnconstrained: expectBeforeUnconstrained:
'angledLine({ angle = angle001, length = 32 + 0 }, %)', 'angledLine(angle = angle001, length = 32 + 0)',
expectAfterUnconstrained: expectAfterUnconstrained: 'angledLine(angle = angle001, length = 32)',
'angledLine({ angle = angle001, length = 32 }, %)', expectFinal: 'angledLine(angle = angle001, length = len001)',
expectFinal: 'angledLine({ angle = angle001, length = len001 }, %)',
ang: ang + 180, ang: ang + 180,
locator: '[data-overlay-toolbar-index="1"]', locator: '[data-overlay-toolbar-index="1"]',
}) })
@ -392,13 +389,13 @@ test.describe('Testing segment overlays', { tag: ['@skipWin'] }, () => {
part001 = startSketchOn(XZ) part001 = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line(end = [0.5, yRel001]) |> line(end = [0.5, yRel001])
|> angledLine({ angle = angle001, length = len001 }, %) |> angledLine(angle = angle001, length = len001)
|> line(endAbsolute = [33, yAbs001]) |> line(endAbsolute = [33, yAbs001])
|> xLine(endAbsolute = xAbs002) |> xLine(endAbsolute = xAbs002)
|> yLine(endAbsolute = -10.77, tag = $a) |> yLine(endAbsolute = -10.77, tag = $a)
|> xLine(length = 26.04) |> xLine(length = 26.04)
|> yLine(length = 21.14 + 0) |> yLine(length = 21.14 + 0)
|> angledLineOfXLength({ angle = 181 + 0, length = 23.14 }, %) |> angledLine(angle = 181 + 0, lengthX = 23.14)
` `
) )
}) })
@ -465,16 +462,16 @@ test.describe('Testing segment overlays', { tag: ['@skipWin'] }, () => {
part001 = startSketchOn(XZ) part001 = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line(end = [0.5, -14 + 0]) |> line(end = [0.5, -14 + 0])
|> angledLine({ angle = 3 + 0, length = 32 + 0 }, %) |> angledLine(angle = 3 + 0, length = 32 + 0)
|> line(endAbsolute = [33, 11.5 + 0]) |> line(endAbsolute = [33, 11.5 + 0])
|> xLine(endAbsolute = 9 - 5) |> xLine(endAbsolute = 9 - 5)
|> yLine(endAbsolute = -10.77, tag = $a) |> yLine(endAbsolute = -10.77, tag = $a)
|> xLine(length = 26.04) |> xLine(length = 26.04)
|> yLine(length = 21.14 + 0) |> yLine(length = 21.14 + 0)
|> angledLineOfXLength({ angle = 181 + 0, length = 23.14 }, %) |> angledLine(angle = 181 + 0, lengthX = 23.14)
|> angledLineOfYLength({ angle = -91, length = 19 + 0 }, %) |> angledLine(angle = -91, lengthY = 19 + 0)
|> angledLineToX({ angle = 3 + 0, to = 26 }, %) |> angledLine(angle = 3 + 0, endAbsoluteX = 26)
|> angledLineToY({ angle = 89, to = 9.14 + 0 }, %) |> angledLine(angle = 89, endAbsoluteY = 9.14 + 0)
|> angledLineThatIntersects({ |> angledLineThatIntersects({
angle = 4.14, angle = 4.14,
intersectTag = a, intersectTag = a,
@ -530,11 +527,9 @@ test.describe('Testing segment overlays', { tag: ['@skipWin'] }, () => {
hoverPos: { x: angledLineOfXLength.x, y: angledLineOfXLength.y }, hoverPos: { x: angledLineOfXLength.x, y: angledLineOfXLength.y },
constraintType: 'angle', constraintType: 'angle',
expectBeforeUnconstrained: expectBeforeUnconstrained:
'angledLineOfXLength({ angle = 181 + 0, length = 23.14 }, %)', 'angledLine(angle = 181 + 0, lengthX = 23.14)',
expectAfterUnconstrained: expectAfterUnconstrained: 'angledLine(angle = -179, lengthX = 23.14)',
'angledLineOfXLength({ angle = -179, length = 23.14 }, %)', expectFinal: 'angledLine(angle = angle001, lengthX = 23.14)',
expectFinal:
'angledLineOfXLength({ angle = angle001, length = 23.14 }, %)',
ang: ang + 180, ang: ang + 180,
locator: '[data-overlay-toolbar-index="7"]', locator: '[data-overlay-toolbar-index="7"]',
}) })
@ -543,11 +538,10 @@ test.describe('Testing segment overlays', { tag: ['@skipWin'] }, () => {
hoverPos: { x: angledLineOfXLength.x, y: angledLineOfXLength.y }, hoverPos: { x: angledLineOfXLength.x, y: angledLineOfXLength.y },
constraintType: 'xRelative', constraintType: 'xRelative',
expectBeforeUnconstrained: expectBeforeUnconstrained:
'angledLineOfXLength({ angle = angle001, length = 23.14 }, %)', 'angledLine(angle = angle001, lengthX = 23.14)',
expectAfterUnconstrained: expectAfterUnconstrained:
'angledLineOfXLength({ angle = angle001, length = xRel001 }, %)', 'angledLine(angle = angle001, lengthX = xRel001)',
expectFinal: expectFinal: 'angledLine(angle = angle001, lengthX = 23.14)',
'angledLineOfXLength({ angle = angle001, length = 23.14 }, %)',
steps: 7, steps: 7,
ang: ang + 180, ang: ang + 180,
locator: '[data-overlay-toolbar-index="7"]', locator: '[data-overlay-toolbar-index="7"]',
@ -561,11 +555,10 @@ test.describe('Testing segment overlays', { tag: ['@skipWin'] }, () => {
await clickUnconstrained({ await clickUnconstrained({
hoverPos: { x: angledLineOfYLength.x, y: angledLineOfYLength.y }, hoverPos: { x: angledLineOfYLength.x, y: angledLineOfYLength.y },
constraintType: 'angle', constraintType: 'angle',
expectBeforeUnconstrained: expectBeforeUnconstrained: 'angledLine(angle = -91, lengthY = 19 + 0)',
'angledLineOfYLength({ angle = -91, length = 19 + 0 }, %)',
expectAfterUnconstrained: expectAfterUnconstrained:
'angledLineOfYLength({ angle = angle002, length = 19 + 0 }, %)', 'angledLine(angle = angle002, lengthY = 19 + 0)',
expectFinal: 'angledLineOfYLength({ angle = -91, length = 19 + 0 }, %)', expectFinal: 'angledLine(angle = -91, lengthY = 19 + 0)',
ang: ang + 180, ang: ang + 180,
steps: 6, steps: 6,
locator: '[data-overlay-toolbar-index="8"]', locator: '[data-overlay-toolbar-index="8"]',
@ -574,12 +567,9 @@ test.describe('Testing segment overlays', { tag: ['@skipWin'] }, () => {
await clickConstrained({ await clickConstrained({
hoverPos: { x: angledLineOfYLength.x, y: angledLineOfYLength.y }, hoverPos: { x: angledLineOfYLength.x, y: angledLineOfYLength.y },
constraintType: 'yRelative', constraintType: 'yRelative',
expectBeforeUnconstrained: expectBeforeUnconstrained: 'angledLine(angle = -91, lengthY = 19 + 0)',
'angledLineOfYLength({ angle = -91, length = 19 + 0 }, %)', expectAfterUnconstrained: 'angledLine(angle = -91, lengthY = 19)',
expectAfterUnconstrained: expectFinal: 'angledLine(angle = -91, lengthY = yRel002)',
'angledLineOfYLength({ angle = -91, length = 19 }, %)',
expectFinal:
'angledLineOfYLength({ angle = -91, length = yRel002 }, %)',
ang: ang + 180, ang: ang + 180,
steps: 7, steps: 7,
locator: '[data-overlay-toolbar-index="8"]', locator: '[data-overlay-toolbar-index="8"]',
@ -597,16 +587,16 @@ test.describe('Testing segment overlays', { tag: ['@skipWin'] }, () => {
part001 = startSketchOn(XZ) part001 = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line(end = [0.5, -14 + 0]) |> line(end = [0.5, -14 + 0])
|> angledLine({ angle = 3 + 0, length = 32 + 0 }, %) |> angledLine(angle = 3 + 0, length = 32 + 0)
|> line(endAbsolute = [33, 11.5 + 0]) |> line(endAbsolute = [33, 11.5 + 0])
|> xLine(endAbsolute = 9 - 5) |> xLine(endAbsolute = 9 - 5)
|> yLine(endAbsolute = -10.77, tag = $a) |> yLine(endAbsolute = -10.77, tag = $a)
|> xLine(length = 26.04) |> xLine(length = 26.04)
|> yLine(length = 21.14 + 0) |> yLine(length = 21.14 + 0)
|> angledLineOfXLength({ angle = 181 + 0, length = 23.14 }, %) |> angledLine(angle = 181 + 0, lengthX = 23.14)
|> angledLineOfYLength({ angle = -91, length = 19 + 0 }, %) |> angledLine(angle = -91, lengthY = 19 + 0)
|> angledLineToX({ angle = 3 + 0, to = 26 }, %) |> angledLine(angle = 3 + 0, endAbsoluteX = 26)
|> angledLineToY({ angle = 89, to = 9.14 + 0 }, %) |> angledLine(angle = 89, endAbsoluteY = 9.14 + 0)
|> angledLineThatIntersects({ |> angledLineThatIntersects({
angle = 4.14, angle = 4.14,
intersectTag = a, intersectTag = a,
@ -646,9 +636,9 @@ test.describe('Testing segment overlays', { tag: ['@skipWin'] }, () => {
hoverPos: { x: angledLineToX.x, y: angledLineToX.y }, hoverPos: { x: angledLineToX.x, y: angledLineToX.y },
constraintType: 'angle', constraintType: 'angle',
expectBeforeUnconstrained: expectBeforeUnconstrained:
'angledLineToX({ angle = 3 + 0, to = 26 }, %)', 'angledLine(angle = 3 + 0, endAbsoluteX = 26)',
expectAfterUnconstrained: 'angledLineToX({ angle = 3, to = 26 }, %)', expectAfterUnconstrained: 'angledLine(angle = 3, endAbsoluteX = 26)',
expectFinal: 'angledLineToX({ angle = angle001, to = 26 }, %)', expectFinal: 'angledLine(angle = angle001, endAbsoluteX = 26)',
ang: ang + 180, ang: ang + 180,
locator: '[data-overlay-toolbar-index="9"]', locator: '[data-overlay-toolbar-index="9"]',
}) })
@ -657,10 +647,10 @@ test.describe('Testing segment overlays', { tag: ['@skipWin'] }, () => {
hoverPos: { x: angledLineToX.x, y: angledLineToX.y }, hoverPos: { x: angledLineToX.x, y: angledLineToX.y },
constraintType: 'xAbsolute', constraintType: 'xAbsolute',
expectBeforeUnconstrained: expectBeforeUnconstrained:
'angledLineToX({ angle = angle001, to = 26 }, %)', 'angledLine(angle = angle001, endAbsoluteX = 26)',
expectAfterUnconstrained: expectAfterUnconstrained:
'angledLineToX({ angle = angle001, to = xAbs001 }, %)', 'angledLine(angle = angle001, endAbsoluteX = xAbs001)',
expectFinal: 'angledLineToX({ angle = angle001, to = 26 }, %)', expectFinal: 'angledLine(angle = angle001, endAbsoluteX = 26)',
ang: ang + 180, ang: ang + 180,
locator: '[data-overlay-toolbar-index="9"]', locator: '[data-overlay-toolbar-index="9"]',
}) })
@ -671,11 +661,9 @@ test.describe('Testing segment overlays', { tag: ['@skipWin'] }, () => {
await clickUnconstrained({ await clickUnconstrained({
hoverPos: { x: angledLineToY.x, y: angledLineToY.y }, hoverPos: { x: angledLineToY.x, y: angledLineToY.y },
constraintType: 'angle', constraintType: 'angle',
expectBeforeUnconstrained: expectBeforeUnconstrained: 'angledLine(angle = 89, to = 9.14 + 0)',
'angledLineToY({ angle = 89, to = 9.14 + 0 }, %)', expectAfterUnconstrained: 'angledLine(angle = angle002, to = 9.14 + 0)',
expectAfterUnconstrained: expectFinal: 'angledLine(angle = 89, to = 9.14 + 0)',
'angledLineToY({ angle = angle002, to = 9.14 + 0 }, %)',
expectFinal: 'angledLineToY({ angle = 89, to = 9.14 + 0 }, %)',
steps: process.platform === 'darwin' ? 8 : 9, steps: process.platform === 'darwin' ? 8 : 9,
ang: ang + 180, ang: ang + 180,
locator: '[data-overlay-toolbar-index="10"]', locator: '[data-overlay-toolbar-index="10"]',
@ -685,9 +673,9 @@ test.describe('Testing segment overlays', { tag: ['@skipWin'] }, () => {
hoverPos: { x: angledLineToY.x, y: angledLineToY.y }, hoverPos: { x: angledLineToY.x, y: angledLineToY.y },
constraintType: 'yAbsolute', constraintType: 'yAbsolute',
expectBeforeUnconstrained: expectBeforeUnconstrained:
'angledLineToY({ angle = 89, to = 9.14 + 0 }, %)', 'angledLine(angle = 89, endAbsoluteY = 9.14 + 0)',
expectAfterUnconstrained: 'angledLineToY({ angle = 89, to = 9.14 }, %)', expectAfterUnconstrained: 'angledLine(angle = 89, endAbsoluteY = 9.14)',
expectFinal: 'angledLineToY({ angle = 89, to = yAbs001 }, %)', expectFinal: 'angledLine(angle = 89, endAbsoluteY = yAbs001)',
ang: ang + 180, ang: ang + 180,
locator: '[data-overlay-toolbar-index="10"]', locator: '[data-overlay-toolbar-index="10"]',
}) })
@ -759,16 +747,16 @@ test.describe('Testing segment overlays', { tag: ['@skipWin'] }, () => {
part001 = startSketchOn(XZ) part001 = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line(end = [0.5, -14 + 0]) |> line(end = [0.5, -14 + 0])
|> angledLine({ angle = 3 + 0, length = 32 + 0 }, %) |> angledLine(angle = 3 + 0, length = 32 + 0)
|> line(endAbsolute = [33, 11.5 + 0]) |> line(endAbsolute = [33, 11.5 + 0])
|> xLine(endAbsolute = 9 - 5) |> xLine(endAbsolute = 9 - 5)
|> yLine(endAbsolute = -10.77, tag = $a) |> yLine(endAbsolute = -10.77, tag = $a)
|> xLine(length = 26.04) |> xLine(length = 26.04)
|> yLine(length = 21.14 + 0) |> yLine(length = 21.14 + 0)
|> angledLineOfXLength({ angle = 181 + 0, length = 23.14 }, %) |> angledLine(angle = 181 + 0, lengthX = 23.14)
|> angledLineOfYLength({ angle = -91, length = 19 + 0 }, %) |> angledLine(angle = -91, lengthY = 19 + 0)
|> angledLineToX({ angle = 3 + 0, to = 26 }, %) |> angledLine(angle = 3 + 0, endAbsoluteX = 26)
|> angledLineToY({ angle = 89, to = 9.14 + 0 }, %) |> angledLine(angle = 89, endAbsoluteY = 9.14 + 0)
|> angledLineThatIntersects({ |> angledLineThatIntersects({
angle = 4.14, angle = 4.14,
intersectTag = a, intersectTag = a,
@ -1088,16 +1076,16 @@ part001 = startSketchOn(XZ)
part001 = startSketchOn(XZ) part001 = startSketchOn(XZ)
|>startProfileAt([0, 0], %) |>startProfileAt([0, 0], %)
|> line(end = [0.5, -14 + 0]) |> line(end = [0.5, -14 + 0])
|> angledLine({ angle = 3 + 0, length = 32 + 0 }, %) |> angledLine(angle = 3 + 0, length = 32 + 0)
|> line(endAbsolute = [33, 11.5 + 0]) |> line(endAbsolute = [33, 11.5 + 0])
|> xLine(endAbsolute = 9 - 5) |> xLine(endAbsolute = 9 - 5)
|> yLine(endAbsolute = -10.77, tag = $a) |> yLine(endAbsolute = -10.77, tag = $a)
|> xLine(length = 26.04) |> xLine(length = 26.04)
|> yLine(length = 21.14 + 0) |> yLine(length = 21.14 + 0)
|> angledLineOfXLength({ angle = 181 + 0, length = 23.14 }, %) |> angledLine(angle = 181 + 0, lengthX = 23.14)
|> angledLineOfYLength({ angle = -91, length = 19 + 0 }, %) |> angledLine(angle = -91, lengthY = 19 + 0)
|> angledLineToX({ angle = 3 + 0, to = 26 }, %) |> angledLine(angle = 3 + 0, endAbsoluteX = 26)
|> angledLineToY({ angle = 89, to = 9.14 + 0 }, %) |> angledLine(angle = 89, endAbsoluteY = 9.14 + 0)
|> angledLineThatIntersects({ |> angledLineThatIntersects({
angle = 4.14, angle = 4.14,
intersectTag = a, intersectTag = a,
@ -1199,7 +1187,7 @@ part001 = startSketchOn(XZ)
ang = await u.getAngle('[data-overlay-index="10"]') ang = await u.getAngle('[data-overlay-index="10"]')
await deleteSegmentSequence({ await deleteSegmentSequence({
hoverPos: { x: segmentToDelete.x, y: segmentToDelete.y }, hoverPos: { x: segmentToDelete.x, y: segmentToDelete.y },
codeToBeDeleted: 'angledLineToY({ angle = 89, to = 9.14 + 0 }, %)', codeToBeDeleted: 'angledLine(angle = 89, endAbsoluteY = 9.14 + 0)',
stdLibFnName: 'angledLineToY', stdLibFnName: 'angledLineToY',
ang: ang + 180, ang: ang + 180,
locator: '[data-overlay-toolbar-index="10"]', locator: '[data-overlay-toolbar-index="10"]',
@ -1209,7 +1197,7 @@ part001 = startSketchOn(XZ)
ang = await u.getAngle('[data-overlay-index="9"]') ang = await u.getAngle('[data-overlay-index="9"]')
await deleteSegmentSequence({ await deleteSegmentSequence({
hoverPos: { x: segmentToDelete.x, y: segmentToDelete.y }, hoverPos: { x: segmentToDelete.x, y: segmentToDelete.y },
codeToBeDeleted: 'angledLineToX({ angle = 3 + 0, to = 26 }, %)', codeToBeDeleted: 'angledLine(angle = 3 + 0, endAbsoluteX = 26)',
stdLibFnName: 'angledLineToX', stdLibFnName: 'angledLineToX',
ang: ang + 180, ang: ang + 180,
locator: '[data-overlay-toolbar-index="9"]', locator: '[data-overlay-toolbar-index="9"]',
@ -1219,8 +1207,7 @@ part001 = startSketchOn(XZ)
ang = await u.getAngle('[data-overlay-index="8"]') ang = await u.getAngle('[data-overlay-index="8"]')
await deleteSegmentSequence({ await deleteSegmentSequence({
hoverPos: { x: segmentToDelete.x, y: segmentToDelete.y }, hoverPos: { x: segmentToDelete.x, y: segmentToDelete.y },
codeToBeDeleted: codeToBeDeleted: 'angledLine(angle = -91, lengthY = 19 + 0)',
'angledLineOfYLength({ angle = -91, length = 19 + 0 }, %)',
stdLibFnName: 'angledLineOfYLength', stdLibFnName: 'angledLineOfYLength',
ang: ang + 180, ang: ang + 180,
locator: '[data-overlay-toolbar-index="8"]', locator: '[data-overlay-toolbar-index="8"]',
@ -1230,8 +1217,7 @@ part001 = startSketchOn(XZ)
ang = await u.getAngle('[data-overlay-index="7"]') ang = await u.getAngle('[data-overlay-index="7"]')
await deleteSegmentSequence({ await deleteSegmentSequence({
hoverPos: { x: segmentToDelete.x, y: segmentToDelete.y }, hoverPos: { x: segmentToDelete.x, y: segmentToDelete.y },
codeToBeDeleted: codeToBeDeleted: 'angledLine(angle = 181 + 0, lengthX = 23.14)',
'angledLineOfXLength({ angle = 181 + 0, length = 23.14 }, %)',
stdLibFnName: 'angledLineOfXLength', stdLibFnName: 'angledLineOfXLength',
ang: ang + 180, ang: ang + 180,
locator: '[data-overlay-toolbar-index="7"]', locator: '[data-overlay-toolbar-index="7"]',
@ -1314,7 +1300,7 @@ part001 = startSketchOn(XZ)
ang = await u.getAngle('[data-overlay-index="1"]') ang = await u.getAngle('[data-overlay-index="1"]')
await deleteSegmentSequence({ await deleteSegmentSequence({
hoverPos: { x: segmentToDelete.x, y: segmentToDelete.y }, hoverPos: { x: segmentToDelete.x, y: segmentToDelete.y },
codeToBeDeleted: 'angledLine({ angle = 3 + 0, length = 32 + 0 }, %)', codeToBeDeleted: 'angledLine(angle = 3 + 0, length = 32 + 0)',
stdLibFnName: 'angledLine', stdLibFnName: 'angledLine',
ang: ang + 180, ang: ang + 180,
locator: '[data-overlay-toolbar-index="1"]', locator: '[data-overlay-toolbar-index="1"]',
@ -1335,24 +1321,20 @@ part001 = startSketchOn(XZ)
test.describe('Testing delete with dependent segments', () => { test.describe('Testing delete with dependent segments', () => {
const cases = [ const cases = [
'line(end = [22, 2], tag = $seg01)', 'line(end = [22, 2], tag = $seg01)',
'angledLine([5, 23.03], %, $seg01)', 'angledLine(angle = 5, length = 23.03, tag = $seg01)',
'xLine(length = 23, tag = $seg01)', 'xLine(length = 23, tag = $seg01)',
'yLine(length = -8, tag = $seg01)', 'yLine(length = -8, tag = $seg01)',
'xLine(endAbsolute = 30, tag = $seg01)', 'xLine(endAbsolute = 30, tag = $seg01)',
'yLine(endAbsolute = -4, tag = $seg01)', 'yLine(endAbsolute = -4, tag = $seg01)',
'angledLineOfXLength([3, 30], %, $seg01)', 'angledLine(angle = 3, lengthX = 30, tag = $seg01)',
'angledLineOfXLength({ angle = 3, length = 30 }, %, $seg01)', 'angledLine(angle = 3, lengthY = 1.5, tag = $seg01)',
'angledLineOfYLength([3, 1.5], %, $seg01)', 'angledLine(angle = 3, endAbsoluteX = 30, tag = $seg01)',
'angledLineOfYLength({ angle = 3, length = 1.5 }, %, $seg01)', 'angledLine(angle = 3, endAbsoluteY = 7, tag = $seg01)',
'angledLineToX([3, 30], %, $seg01)',
'angledLineToX({ angle = 3, to = 30 }, %, $seg01)',
'angledLineToY([3, 7], %, $seg01)',
'angledLineToY({ angle = 3, to = 7 }, %, $seg01)',
] ]
for (const doesHaveTagOutsideSketch of [true, false]) { for (const doesHaveTagOutsideSketch of [true, false]) {
for (const lineOfInterest of cases) { for (const lineOfInterest of cases) {
const isObj = lineOfInterest.includes('{ angle = 3,') const isObj = lineOfInterest.includes('{ angle = 3,')
test(`${lineOfInterest.split('=')[0]}${isObj ? '-[obj-input]' : ''}${ test(`${lineOfInterest}${isObj ? '-[obj-input]' : ''}${
doesHaveTagOutsideSketch ? '-[tagOutsideSketch]' : '' doesHaveTagOutsideSketch ? '-[tagOutsideSketch]' : ''
}`, async ({ page, editor, homePage }) => { }`, async ({ page, editor, homePage }) => {
await page.addInitScript( await page.addInitScript(
@ -1364,7 +1346,7 @@ part001 = startSketchOn(XZ)
|> startProfileAt([5, 6], %) |> startProfileAt([5, 6], %)
|> ${lineToBeDeleted} |> ${lineToBeDeleted}
|> line(end = [-10, -15]) |> line(end = [-10, -15])
|> angledLine([-176, segLen(seg01)], %) |> angledLine(angle = -176, length = segLen(seg01))
${extraLine ? 'myVar = segLen(seg01)' : ''}` ${extraLine ? 'myVar = segLen(seg01)' : ''}`
) )
}, },
@ -1477,7 +1459,7 @@ part001 = startSketchOn(XZ)
}, },
{ {
before: `angledLine([5 + 0, 23.03 + 0], %, $seg01)`, before: `angledLine(angle = 5 + 0, length = 23.03 + 0, tag = $seg01)`,
after: `line(end = [22.94, 2.01], tag = $seg01)`, after: `line(end = [22.94, 2.01], tag = $seg01)`,
}, },
{ {
@ -1497,32 +1479,25 @@ part001 = startSketchOn(XZ)
after: `line(end = [0, -10], tag = $seg01)`, after: `line(end = [0, -10], tag = $seg01)`,
}, },
{ {
before: `angledLineOfXLength({ angle = 3 + 0, length = 30 + 0 }, %, $seg01)`, before: `angledLine(angle = 3 + 0, lengthX = 30 + 0, tag = $seg01)`,
after: `line(end = [30, 1.57], tag = $seg01)`, after: `line(end = [30, 1.57], tag = $seg01)`,
}, },
{ {
before: `angledLineOfYLength({ angle = 3 + 0, length = 1.5 + 0 }, %, $seg01)`, before: `angledLine(angle = 3 + 0, lengthY = 1.5 + 0, tag = $seg01)`,
after: `line(end = [28.62, 1.5], tag = $seg01)`, after: `line(end = [28.62, 1.5], tag = $seg01)`,
}, },
{ {
before: `angledLineToX({ angle = 3 + 0, to = 30 + 0 }, %, $seg01)`, before: `angledLine(angle = 3 + 0, endAbsoluteX = 30 + 0, tag = $seg01)`,
after: `line(end = [25, 1.31], tag = $seg01)`, after: `line(end = [25, 1.31], tag = $seg01)`,
}, },
{ {
before: `angledLineToY({ angle = 3 + 0, to = 7 + 0 }, %, $seg01)`, before: `angledLine(angle = 3 + 0, endAbsoluteY = 7 + 0, tag = $seg01)`,
after: `line(end = [19.08, 1], tag = $seg01)`, after: `line(end = [19.08, 1], tag = $seg01)`,
}, },
] ]
for (const { before, after } of cases) { for (const { before, after } of cases) {
const isObj = before.includes('{ angle = 3') test(before, async ({ page, editor, homePage, scene, cmdBar }) => {
test(`${before.split('=')[0]}${isObj ? '-[obj-input]' : ''}`, async ({
page,
editor,
homePage,
scene,
cmdBar,
}) => {
await page.addInitScript( await page.addInitScript(
async ({ lineToBeDeleted }) => { async ({ lineToBeDeleted }) => {
localStorage.setItem( localStorage.setItem(
@ -1532,7 +1507,7 @@ part001 = startSketchOn(XZ)
|> startProfileAt([5, 6], %) |> startProfileAt([5, 6], %)
|> ${lineToBeDeleted} |> ${lineToBeDeleted}
|> line(end = [-10, -15]) |> line(end = [-10, -15])
|> angledLine([-176, segLen(seg01)], %)` |> angledLine(angle = -176, length = segLen(seg01))`
) )
}, },
{ {

View File

@ -124,7 +124,7 @@ test.describe('Testing selections', { tag: ['@skipWin'] }, () => {
// click a segment hold shift and click an axis, see that a relevant constraint is enabled // click a segment hold shift and click an axis, see that a relevant constraint is enabled
const constrainButton = page.getByRole('button', { const constrainButton = page.getByRole('button', {
name: 'Length: open menu', name: 'constraints: open menu',
}) })
const absXButton = page.getByRole('button', { name: 'Absolute X' }) const absXButton = page.getByRole('button', { name: 'Absolute X' })
@ -308,21 +308,15 @@ part009 = startSketchOn(XY)
|> startProfileAt([pipeLargeDia - (thickness / 2), 38], %) |> startProfileAt([pipeLargeDia - (thickness / 2), 38], %)
|> line(end = [thickness, 0]) |> line(end = [thickness, 0])
|> line(end = [0, -1]) |> line(end = [0, -1])
|> angledLineToX({ |> angledLine(angle = 60, endAbsoluteX = pipeSmallDia + thickness)
angle = 60,
to = pipeSmallDia + thickness
}, %)
|> line(end = [0, -pipeLength]) |> line(end = [0, -pipeLength])
|> angledLineToX({ |> angledLine(angle = -60, endAbsoluteX = pipeLargeDia + thickness)
angle = -60,
to = pipeLargeDia + thickness
}, %)
|> line(end = [0, -1]) |> line(end = [0, -1])
|> line(end = [-thickness, 0]) |> line(end = [-thickness, 0])
|> line(end = [0, 1]) |> line(end = [0, 1])
|> angledLineToX({ angle = 120, to = pipeSmallDia }, %) |> angledLine(angle = 120, endAbsoluteX = pipeSmallDia)
|> line(end = [0, pipeLength]) |> line(end = [0, pipeLength])
|> angledLineToX({ angle = 60, to = pipeLargeDia }, %) |> angledLine(angle = 60, endAbsoluteX = pipeLargeDia)
|> close() |> close()
rev = revolve(part009, axis = Y) rev = revolve(part009, axis = Y)
sketch006 = startSketchOn(XY) sketch006 = startSketchOn(XY)
@ -332,15 +326,9 @@ profile001 = circle(
radius = 17.96 radius = 17.96
) )
profile002 = startProfileAt([86.92, -63.81], sketch006) profile002 = startProfileAt([86.92, -63.81], sketch006)
|> angledLine([0, 63.81], %, $rectangleSegmentA001) |> angledLine(angle = 0, length = 63.81, tag = $rectangleSegmentA001)
|> angledLine([ |> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 17.05)
segAng(rectangleSegmentA001) - 90, |> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001))
17.05
], %)
|> angledLine([
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
profile003 = startProfileAt([40.16, -120.48], sketch006) profile003 = startProfileAt([40.16, -120.48], sketch006)
@ -471,7 +459,7 @@ yo = startProfileAt([4.83, 12.56], part001)
|> line(end = [15.1, 2.48]) |> line(end = [15.1, 2.48])
|> line(end = [3.15, -9.85], tag = $seg01) |> line(end = [3.15, -9.85], tag = $seg01)
|> line(end = [-15.17, -4.1]) |> line(end = [-15.17, -4.1])
|> angledLine([segAng(seg01), 12.35], %, $seg02) |> angledLine(angle = segAng(seg01), length = 12.35, tag = $seg02)
|> line(end = [-13.02, 10.03]) |> line(end = [-13.02, 10.03])
|> close() |> close()
yoo = extrude(yo, length = 4) yoo = extrude(yo, length = 4)
@ -484,15 +472,9 @@ profile002 = startProfileAt([-11.08, 2.39], sketch002)
|> close() |> close()
extrude001 = extrude(profile002, length = 15) extrude001 = extrude(profile002, length = 15)
profile001 = startProfileAt([7.49, 9.96], sketch001) profile001 = startProfileAt([7.49, 9.96], sketch001)
|> angledLine([0, 5.05], %, $rectangleSegmentA001) |> angledLine(angle = 0, length = 5.05, tag = $rectangleSegmentA001)
|> angledLine([ |> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 4.81)
segAng(rectangleSegmentA001) - 90, |> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001))
4.81
], %)
|> angledLine([
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
@ -539,15 +521,15 @@ profile001 = startProfileAt([7.49, 9.96], sketch001)
part001 = startSketchOn(XZ) part001 = startSketchOn(XZ)
|> startProfileAt([20, 0], %) |> startProfileAt([20, 0], %)
|> line(end = [7.13, 4 + 0]) |> line(end = [7.13, 4 + 0])
|> angledLine({ angle = 3 + 0, length = 3.14 + 0 }, %) |> angledLine(angle = 3 + 0, length = 3.14 + 0 )
|> line(endAbsolute = [20.14 + 0, -0.14 + 0]) |> line(endAbsolute = [20.14 + 0, -0.14 + 0])
|> xLine(endAbsolute = 29 + 0) |> xLine(endAbsolute = 29 + 0)
|> yLine(length = -3.14 + 0, tag = $a) |> yLine(length = -3.14 + 0, tag = $a)
|> xLine(length = 1.63) |> xLine(length = 1.63)
|> angledLineOfXLength({ angle = 3 + 0, length = 3.14 }, %) |> angledLine(angle = 3 + 0, lengthX = 3.14)
|> angledLineOfYLength({ angle = 30, length = 3 + 0 }, %) |> angledLine(angle = 30, lengthY = 3 + 0)
|> angledLineToX({ angle = 22.14 + 0, to = 12 }, %) |> angledLine(angle = 22.14 + 0, endAbsoluteX = 12)
|> angledLineToY({ angle = 30, to = 11.14 }, %) |> angledLine(angle = 30, endAbsoluteY = 11.14)
|> angledLineThatIntersects({ |> angledLineThatIntersects({
angle = 3.14, angle = 3.14,
intersectTag = a, intersectTag = a,
@ -736,14 +718,14 @@ part001 = startSketchOn(XZ)
await checkCodeAtHoverPosition( await checkCodeAtHoverPosition(
'straightSegmentEdge', 'straightSegmentEdge',
straightSegmentEdge, straightSegmentEdge,
`angledLineToY({angle=30,to=11.14},%)`, `angledLine(angle=30,endAbsoluteY=11.14)`,
'angledLineToY({ angle = 30, to = 11.14 }, %)' 'angledLine(angle = 30, endAbsoluteY = 11.14)'
) )
await checkCodeAtHoverPosition( await checkCodeAtHoverPosition(
'straightSegmentOppositeEdge', 'straightSegmentOppositeEdge',
straightSegmentOppositeEdge, straightSegmentOppositeEdge,
`angledLineToY({angle=30,to=11.14},%)`, `angledLine(angle=30,endAbsoluteY=11.14)`,
'angledLineToY({ angle = 30, to = 11.14 }, %)' 'angledLine(angle = 30, endAbsoluteY = 11.14)'
) )
await checkCodeAtHoverPosition( await checkCodeAtHoverPosition(
'straightSegmentAdjacentEdge', 'straightSegmentAdjacentEdge',
@ -758,15 +740,9 @@ part001 = startSketchOn(XZ)
await u.codeLocator.fill(`@settings(defaultLengthUnit = in) await u.codeLocator.fill(`@settings(defaultLengthUnit = in)
sketch001 = startSketchOn(XZ) sketch001 = startSketchOn(XZ)
|> startProfileAt([75.8, 317.2], %) // [$startCapTag, $EndCapTag] |> startProfileAt([75.8, 317.2], %) // [$startCapTag, $EndCapTag]
|> angledLine([0, 268.43], %, $rectangleSegmentA001) |> angledLine(angle = 0, length = 268.43, tag = $rectangleSegmentA001)
|> angledLine([ |> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 217.26, tag = $seg01)
segAng(rectangleSegmentA001) - 90, |> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001), tag = $yo)
217.26
], %, $seg01)
|> angledLine([
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %, $yo)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)], tag = $seg02) |> line(endAbsolute = [profileStartX(%), profileStartY(%)], tag = $seg02)
|> close() |> close()
extrude001 = extrude(sketch001, length = 100) extrude001 = extrude(sketch001, length = 100)
@ -815,14 +791,14 @@ part001 = startSketchOn(XZ)
await checkCodeAtHoverPosition( await checkCodeAtHoverPosition(
'oppositeChamfer', 'oppositeChamfer',
oppositeChamfer, oppositeChamfer,
`angledLine([segAng(rectangleSegmentA001)-90,217.26],%,$seg01)chamfer(length=30,tags=[seg01,getNextAdjacentEdge(yo),getNextAdjacentEdge(seg02),getOppositeEdge(seg01)],)`, `angledLine(angle=segAng(rectangleSegmentA001)-90,length=217.26,tag=$seg01)chamfer(length=30,tags=[seg01,getNextAdjacentEdge(yo),getNextAdjacentEdge(seg02),getOppositeEdge(seg01)],)`,
' )' ' )'
) )
await checkCodeAtHoverPosition( await checkCodeAtHoverPosition(
'baseChamfer', 'baseChamfer',
baseChamfer, baseChamfer,
`angledLine([segAng(rectangleSegmentA001)-90,217.26],%,$seg01)chamfer(length=30,tags=[seg01,getNextAdjacentEdge(yo),getNextAdjacentEdge(seg02),getOppositeEdge(seg01)],)`, `angledLine(angle=segAng(rectangleSegmentA001)-90,length=217.26,tag=$seg01)chamfer(length=30,tags=[seg01,getNextAdjacentEdge(yo),getNextAdjacentEdge(seg02),getOppositeEdge(seg01)],)`,
' )' ' )'
) )
@ -860,7 +836,7 @@ part001 = startSketchOn(XZ)
await checkCodeAtHoverPosition( await checkCodeAtHoverPosition(
'adjacentChamfer2', 'adjacentChamfer2',
adjacentChamfer2, adjacentChamfer2,
`angledLine([segAng(rectangleSegmentA001),-segLen(rectangleSegmentA001)],%,$yo)chamfer(length=30,tags=[seg01,getNextAdjacentEdge(yo),getNextAdjacentEdge(seg02),getOppositeEdge(seg01)],)`, `angledLine(angle=segAng(rectangleSegmentA001),length=-segLen(rectangleSegmentA001),tag=$yo)chamfer(length=30,tags=[seg01,getNextAdjacentEdge(yo),getNextAdjacentEdge(seg02),getOppositeEdge(seg01)],)`,
' )' ' )'
) )
}) })
@ -960,7 +936,7 @@ part001 = startSketchOn(XZ)
}, },
{ {
pos: [816, 244], pos: [816, 244],
expectedCode: 'angledLine([segAng(seg01), yo], %)', expectedCode: 'angledLine(angle = segAng(seg01), length = yo)',
}, },
{ {
pos: [1107, 161], pos: [1107, 161],

View File

@ -1 +1 @@
part001 = startSketchOn('XY')yo = startProfileAt([4.83, 12.56], part001) |> line(end = [15.1, 2.48]) |> line(end = [3.15, -9.85], tag = $seg01) |> line(end = [-15.17, -4.1]) |> angledLine([segAng(seg01), 12.35], %, $seg02) |> line(end = [-13.02, 10.03]) |> close()sketch002 = startSketchOn({ plane = { origin = { x = 7.49, y = 2.4, z = 0 }, xAxis = { x = -0.3, y = 0.95, z = 0 }, yAxis = { x = 0, y = 0, z = 1 }, zAxis = { x = 0.95, y = 0.3, z = 0 } }})sketch001 = startSketchOn({ plane = { origin = { x = 0, y = 0, z = 4 }, xAxis = { x = 1, y = 0, z = 0 }, yAxis = { x = 0, y = 1, z = 0 }, zAxis = { x = 0, y = 0, z = 1 } }})profile002 = startProfileAt([-11.08, 2.39], sketch002) |> line(end = [4.89, 0.9]) |> line(end = [-0.61, -2.41]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> close()extrude001 = extrude(profile002, length = 15)profile001 = startProfileAt([7.49, 9.96], sketch001) |> angledLine([0, 5.05], %, $rectangleSegmentA001) |> angledLine([ segAng(rectangleSegmentA001) - 90, 4.81 ], %) |> angledLine([ segAng(rectangleSegmentA001), -segLen(rectangleSegmentA001) ], %) |> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> close() part001 = startSketchOn('XY')yo = startProfileAt([4.83, 12.56], part001) |> line(end = [15.1, 2.48]) |> line(end = [3.15, -9.85], tag = $seg01) |> line(end = [-15.17, -4.1]) |> angledLine(angle = segAng(seg01), 12.35], %, $seg02) |> line(end = [-13.02, 10.03]) |> close()sketch002 = startSketchOn({ plane = { origin = { x = 7.49, y = 2.4, z = 0 }, xAxis = { x = -0.3, y = 0.95, z = 0 }, yAxis = { x = 0, y = 0, z = 1 }, zAxis = { x = 0.95, y = 0.3, z = 0 } }})sketch001 = startSketchOn({ plane = { origin = { x = 0, y = 0, z = 4 }, xAxis = { x = 1, y = 0, z = 0 }, yAxis = { x = 0, y = 1, z = 0 }, zAxis = { x = 0, y = 0, z = 1 } }})profile002 = startProfileAt([-11.08, 2.39], sketch002) |> line(end = [4.89, 0.9]) |> line(end = [-0.61, -2.41]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> close()extrude001 = extrude(profile002, length = 15)profile001 = startProfileAt([7.49, 9.96], sketch001) |> angledLine(angle = 0, length = 5.05, tag = $rectangleSegmentA001) |> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 4.81 ) |> angledLine( angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001) ) |> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> close()

View File

@ -59,10 +59,11 @@ part001 = startSketchOn(-XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> yLine(length = baseHeight) |> yLine(length = baseHeight)
|> xLine(length = baseLen) |> xLine(length = baseLen)
|> angledLineToY({ |> angledLine(
angle = topAng, angle = topAng,
to = totalHeightHalf, endAbsoluteY = totalHeightHalf,
}, %, $seg04) tag = $seg04,
)
|> xLine(endAbsolute = totalLen, tag = $seg03) |> xLine(endAbsolute = totalLen, tag = $seg03)
|> yLine(length = -armThick, tag = $seg01) |> yLine(length = -armThick, tag = $seg01)
|> angledLineThatIntersects({ |> angledLineThatIntersects({
@ -70,11 +71,12 @@ part001 = startSketchOn(-XZ)
offset = -armThick, offset = -armThick,
intersectTag = seg04 intersectTag = seg04
}, %) }, %)
|> angledLineToY([segAng(seg04) + 180, turns::ZERO], %) |> angledLine(angle = segAng(seg04) + 180, endAbsoluteY = turns::ZERO)
|> angledLineToY({ |> angledLine(
angle = -bottomAng, angle = -bottomAng,
to = -totalHeightHalf - armThick, endAbsoluteY = -totalHeightHalf - armThick,
}, %, $seg02) tag = $seg02,
)
|> xLine(endAbsolute = segEndX(seg03) + 0) |> xLine(endAbsolute = segEndX(seg03) + 0)
|> yLine(length = -segLen(seg01)) |> yLine(length = -segLen(seg01))
|> angledLineThatIntersects({ |> angledLineThatIntersects({
@ -82,7 +84,7 @@ part001 = startSketchOn(-XZ)
offset = -armThick, offset = -armThick,
intersectTag = seg02 intersectTag = seg02
}, %) }, %)
|> angledLineToY([segAng(seg02) + 180, -baseHeight], %) |> angledLine(angle = segAng(seg02) + 180, endAbsoluteY = -baseHeight)
|> xLine(endAbsolute = turns::ZERO) |> xLine(endAbsolute = turns::ZERO)
|> close() |> close()
|> extrude(length = 4)` |> extrude(length = 4)`

77
flake.lock generated
View File

@ -1,6 +1,56 @@
{ {
"nodes": { "nodes": {
"naersk": {
"inputs": {
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1743800763,
"narHash": "sha256-YFKV+fxEpMgP5VsUcM6Il28lI0NlpM7+oB1XxbBAYCw=",
"owner": "nix-community",
"repo": "naersk",
"rev": "ed0232117731a4c19d3ee93aa0c382a8fe754b01",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "naersk",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": {
"lastModified": 1744157173,
"narHash": "sha256-bWSjxDwq7iVePrhmA7tY2dyMWHuNJo8knkO4y+q4ZkY=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "6a39c6e495eefabc935d8ddf66aa45d85b85fa3f",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1744157173,
"narHash": "sha256-bWSjxDwq7iVePrhmA7tY2dyMWHuNJo8knkO4y+q4ZkY=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "6a39c6e495eefabc935d8ddf66aa45d85b85fa3f",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_3": {
"locked": { "locked": {
"lastModified": 1736320768, "lastModified": 1736320768,
"narHash": "sha256-nIYdTAiKIGnFNugbomgBJR+Xv5F1ZQU+HfaBqJKroC0=", "narHash": "sha256-nIYdTAiKIGnFNugbomgBJR+Xv5F1ZQU+HfaBqJKroC0=",
@ -16,38 +66,23 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs_2": {
"locked": {
"lastModified": 1728538411,
"narHash": "sha256-f0SBJz1eZ2yOuKUr5CA9BHULGXVSn6miBuUWdTyhUhU=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b69de56fac8c2b6f8fd27f2eca01dcda8e0a4221",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": { "root": {
"inputs": { "inputs": {
"nixpkgs": "nixpkgs", "naersk": "naersk",
"nixpkgs": "nixpkgs_2",
"rust-overlay": "rust-overlay" "rust-overlay": "rust-overlay"
} }
}, },
"rust-overlay": { "rust-overlay": {
"inputs": { "inputs": {
"nixpkgs": "nixpkgs_2" "nixpkgs": "nixpkgs_3"
}, },
"locked": { "locked": {
"lastModified": 1736476219, "lastModified": 1744338850,
"narHash": "sha256-+qyv3QqdZCdZ3cSO/cbpEY6tntyYjfe1bB12mdpNFaY=", "narHash": "sha256-pwMIVmsb8fjjT92n5XFDqCsplcX70qVMMT7NulumPXs=",
"owner": "oxalica", "owner": "oxalica",
"repo": "rust-overlay", "repo": "rust-overlay",
"rev": "de30cc5963da22e9742bbbbb9a3344570ed237b9", "rev": "5e64aecc018e6f775572609e7d7485fdba6985a7",
"type": "github" "type": "github"
}, },
"original": { "original": {

136
flake.nix
View File

@ -1,84 +1,96 @@
{ {
description = "modeling-app development environment"; description = "zoo.dev modeling-app";
# Flake inputs
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
rust-overlay.url = "github:oxalica/rust-overlay"; # A helper for Rust + Nix rust-overlay.url = "github:oxalica/rust-overlay";
naersk.url = "github:nix-community/naersk";
}; };
# Flake outputs outputs = {
outputs = { self, nixpkgs, rust-overlay }: self,
let nixpkgs,
# Overlays enable you to customize the Nixpkgs attribute set rust-overlay,
overlays = [ naersk,
# Makes a `rust-bin` attribute available in Nixpkgs }: let
(import rust-overlay) overlays = [
# Provides a `rustToolchain` attribute for Nixpkgs that we can use to (import rust-overlay)
# create a Rust environment (self: super: {
(self: super: { rustToolchain = super.rust-bin.stable.latest.default.override {
rustToolchain = super. rust-bin.stable.latest.default.override { targets = ["wasm32-unknown-unknown"];
targets = [ "wasm32-unknown-unknown" ]; extensions = ["rustfmt" "llvm-tools-preview" "rust-src"];
extensions = [ "rustfmt" "llvm-tools-preview" "rust-src" ]; };
})
];
allSystems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
forAllSystems = f:
nixpkgs.lib.genAttrs allSystems (system:
f {
pkgs = import nixpkgs {
inherit overlays system;
}; };
}) system = system;
(self: super: { });
cargo-llvm-cov = super.cargo-llvm-cov.overrideAttrs(oa: { in {
doCheck = false; doInstallCheck = false; devShells = forAllSystems ({pkgs, ...}: {
}); default = pkgs.mkShell {
}) packages =
]; (with pkgs; [
# Systems supported
allSystems = [
"x86_64-linux" # 64-bit Intel/AMD Linux
"aarch64-linux" # 64-bit ARM Linux
"x86_64-darwin" # 64-bit Intel macOS
"aarch64-darwin" # 64-bit ARM macOS
];
# Helper to provide system-specific attributes
forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system: f {
pkgs = import nixpkgs { inherit overlays system; config.allowBroken = true; };
});
in
{
# Development environment output
devShells = forAllSystems ({ pkgs }: {
default = pkgs.mkShell {
# The Nix packages provided in the environment
packages = (with pkgs; [
# The package provided by our custom overlay. Includes cargo, Clippy, cargo-fmt,
# rustdoc, rustfmt, and other tools.
rustToolchain rustToolchain
cargo-llvm-cov
cargo-nextest cargo-nextest
just just
postgresql.lib postgresql.lib
openssl openssl
pkg-config pkg-config
nodejs_22 nodejs_22
yarn yarn
electron electron
playwright-driver.browsers playwright-driver.browsers
]) ++ pkgs.lib.optionals pkgs.stdenv.isDarwin (with pkgs; [ wasm-pack
python3Full
])
++ pkgs.lib.optionals pkgs.stdenv.isDarwin (with pkgs; [
libiconv libiconv
darwin.apple_sdk.frameworks.Security darwin.apple_sdk.frameworks.Security
]); ]);
TARGET_CC = "${pkgs.stdenv.cc}/bin/${pkgs.stdenv.cc.targetPrefix}cc"; TARGET_CC = "${pkgs.stdenv.cc}/bin/${pkgs.stdenv.cc.targetPrefix}cc";
LIBCLANG_PATH = "${pkgs.libclang.lib}/lib"; LIBCLANG_PATH = "${pkgs.libclang.lib}/lib";
ELECTRON_OVERRIDE_DIST_PATH = "${pkgs.electron}/bin/"; ELECTRON_OVERRIDE_DIST_PATH = "${pkgs.electron}/bin/";
PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS = true; PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS = true;
PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH = "${pkgs.playwright-driver.browsers}/chromium-1091/chrome-linux/chrome"; PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH = "${pkgs.playwright-driver.browsers}/chromium-1091/chrome-linux/chrome";
PLAYWRIGHT_BROWSERS_PATH = "${pkgs.playwright-driver.browsers}"; PLAYWRIGHT_BROWSERS_PATH = "${pkgs.playwright-driver.browsers}";
NODE_ENV = "development"; NODE_ENV = "development";
}; };
}); });
};
packages = forAllSystems ({
pkgs,
system,
}: let
naersk-lib = pkgs.callPackage naersk {
cargo = pkgs.rustToolchain;
rustc = pkgs.rustToolchain;
};
in {
kcl-language-server = naersk-lib.buildPackage {
pname = "kcl-language-server";
version = "0.1.0";
release = true;
src = ./rust;
cargoBuildOptions = opt: opt ++ ["-p" "kcl-language-server"];
buildInputs = [pkgs.openssl pkgs.pkg-config];
};
default = self.packages.${system}.kcl-language-server;
});
};
} }

View File

@ -389,6 +389,13 @@ export class LanguageServerPlugin implements PluginValue {
} }
if (insertText && insertTextFormat === 2) { if (insertText && insertTextFormat === 2) {
// We end with ${} so you can jump to the end of the snippet.
// After the last argument.
// This is not standard from the lsp so we add it here.
if (insertText.endsWith(')')) {
// We have a function its safe to insert the ${} at the end.
insertText = insertText + '${}'
}
return snippetCompletion(insertText, completion) return snippetCompletion(insertText, completion)
} }

View File

@ -31,15 +31,9 @@ fn rail8020(originStart, railHeight, railLength) {
|> xLine(length = 0.06 * railHeight, tag = $edge1) |> xLine(length = 0.06 * railHeight, tag = $edge1)
|> yLine(length = 0.087 * railHeight, tag = $edge2) |> yLine(length = 0.087 * railHeight, tag = $edge2)
|> xLine(length = -0.183 * railHeight, tag = $edge3) |> xLine(length = -0.183 * railHeight, tag = $edge3)
|> angledLineToY({ |> angledLine(angle = 45, endAbsoluteY = (1 - 0.356) / 2 * railHeight + originStart[1], tag = $edge4)
angle = 45,
to = (1 - 0.356) / 2 * railHeight + originStart[1]
}, %, $edge4)
|> xLine(length = 0.232 * railHeight, tag = $edge5) |> xLine(length = 0.232 * railHeight, tag = $edge5)
|> angledLineToY({ |> angledLine(angle = -45, endAbsoluteY = 0.087 * railHeight + originStart[1], tag = $edge6)
angle = -45,
to = 0.087 * railHeight + originStart[1]
}, %, $edge6)
|> xLine(length = -0.183 * railHeight, tag = $edge7) |> xLine(length = -0.183 * railHeight, tag = $edge7)
|> yLine(length = -0.087 * railHeight, tag = $edge8) |> yLine(length = -0.087 * railHeight, tag = $edge8)
|> xLine(length = 0.06 * railHeight) |> xLine(length = 0.06 * railHeight)
@ -75,15 +69,9 @@ fn rail8020(originStart, railHeight, railLength) {
|> yLine(length = 0.06 * railHeight, tag = $edge9) |> yLine(length = 0.06 * railHeight, tag = $edge9)
|> xLine(length = -0.087 * railHeight, tag = $edge10) |> xLine(length = -0.087 * railHeight, tag = $edge10)
|> yLine(length = -0.183 * railHeight, tag = $edge11) // edge11 |> yLine(length = -0.183 * railHeight, tag = $edge11) // edge11
|> angledLineToX({ |> angledLine(angle = 135, endAbsoluteX = ((1 - 0.356) / 2 + 0.356) * railHeight + originStart[0], tag = $edge12) // edge12
angle = 135,
to = ((1 - 0.356) / 2 + 0.356) * railHeight + originStart[0]
}, %, $edge12) // edge12
|> yLine(length = 0.232 * railHeight, tag = $edge13) // 13 |> yLine(length = 0.232 * railHeight, tag = $edge13) // 13
|> angledLineToX({ |> angledLine(angle = 45, endAbsoluteX = (1 - 0.087) * railHeight + originStart[0], tag = $edge14) // 14
angle = 45,
to = (1 - 0.087) * railHeight + originStart[0]
}, %, $edge14) // 14
|> yLine(length = -0.183 * railHeight, tag = $edge15) // 15 |> yLine(length = -0.183 * railHeight, tag = $edge15) // 15
|> xLine(length = 0.087 * railHeight, tag = $edge16) |> xLine(length = 0.087 * railHeight, tag = $edge16)
|> yLine(length = 0.06 * railHeight) |> yLine(length = 0.06 * railHeight)
@ -119,15 +107,9 @@ fn rail8020(originStart, railHeight, railLength) {
|> xLine(length = -0.06 * railHeight, tag = $edge17) |> xLine(length = -0.06 * railHeight, tag = $edge17)
|> yLine(length = -0.087 * railHeight, tag = $edge18) |> yLine(length = -0.087 * railHeight, tag = $edge18)
|> xLine(length = 0.183 * railHeight, tag = $edge19) |> xLine(length = 0.183 * railHeight, tag = $edge19)
|> angledLineToY({ |> angledLine(angle = 45, endAbsoluteY = ((1 - 0.356) / 2 + 0.356) * railHeight + originStart[1], tag = $edge20)
angle = 45,
to = ((1 - 0.356) / 2 + 0.356) * railHeight + originStart[1]
}, %, $edge20)
|> xLine(length = -0.232 * railHeight, tag = $edge21) |> xLine(length = -0.232 * railHeight, tag = $edge21)
|> angledLineToY({ |> angledLine(angle = 135, endAbsoluteY = (1 - 0.087) * railHeight + originStart[1], tag = $edge22)
angle = 135,
to = (1 - 0.087) * railHeight + originStart[1]
}, %, $edge22)
|> xLine(length = 0.183 * railHeight, tag = $edge23) |> xLine(length = 0.183 * railHeight, tag = $edge23)
|> yLine(length = 0.087 * railHeight, tag = $edge24) |> yLine(length = 0.087 * railHeight, tag = $edge24)
|> xLine(length = -0.06 * railHeight) |> xLine(length = -0.06 * railHeight)
@ -163,15 +145,9 @@ fn rail8020(originStart, railHeight, railLength) {
|> yLine(length = -0.06 * railHeight, tag = $edge25) |> yLine(length = -0.06 * railHeight, tag = $edge25)
|> xLine(length = 0.087 * railHeight, tag = $edge26) |> xLine(length = 0.087 * railHeight, tag = $edge26)
|> yLine(length = 0.183 * railHeight, tag = $edge27) |> yLine(length = 0.183 * railHeight, tag = $edge27)
|> angledLineToX({ |> angledLine(angle = 135, endAbsoluteX = (1 - 0.356) / 2 * railHeight + originStart[0], tag = $edge28)
angle = 135,
to = (1 - 0.356) / 2 * railHeight + originStart[0]
}, %, $edge28)
|> yLine(length = -0.232 * railHeight, tag = $edge29) |> yLine(length = -0.232 * railHeight, tag = $edge29)
|> angledLineToX({ |> angledLine(angle = 45, endAbsoluteX = 0.087 * railHeight + originStart[0], tag = $edge30)
angle = 45,
to = 0.087 * railHeight + originStart[0]
}, %, $edge30)
|> yLine(length = 0.183 * railHeight, tag = $edge31) |> yLine(length = 0.183 * railHeight, tag = $edge31)
|> xLine(length = -0.087 * railHeight, tag = $edge32) |> xLine(length = -0.087 * railHeight, tag = $edge32)
|> yLine(length = -0.06 * railHeight) |> yLine(length = -0.06 * railHeight)

View File

@ -86,11 +86,11 @@ export fn seatSlats(plane, length) {
fn backSlatsSketch(plane) { fn backSlatsSketch(plane) {
sketch004 = startSketchOn(plane) sketch004 = startSketchOn(plane)
|> startProfileAt([22, 38.5], %) |> startProfileAt([22, 38.5], %)
|> angledLine([173, 2], %) |> angledLine(angle = 173, length = 2)
|> line(end = [-1.74, 2.03]) |> line(end = [-1.74, 2.03])
|> angledLine([82, 6.6], %) |> angledLine(angle = 82, length = 6.6)
|> line(end = [2.23, 1.42]) |> line(end = [2.23, 1.42])
|> angledLine([-7, 2], %) |> angledLine(angle = -7, length = 2)
|> line(endAbsolute = profileStart(%)) |> line(endAbsolute = profileStart(%))
|> close() |> close()
|> patternLinear2d(instances = 2, distance = 11, axis = [-0.137, -1]) |> patternLinear2d(instances = 2, distance = 11, axis = [-0.137, -1])

View File

@ -23,7 +23,7 @@ customPlane = {
fn lug(plane, length, diameter) { fn lug(plane, length, diameter) {
lugSketch = startSketchOn(customPlane) lugSketch = startSketchOn(customPlane)
|> startProfileAt([0 + diameter / 2, 0], %) |> startProfileAt([0 + diameter / 2, 0], %)
|> angledLineOfYLength({ angle = 70, length = lugHeadLength }, %) |> angledLine(angle = 70, lengthY = lugHeadLength)
|> xLine(endAbsolute = lugDiameter / 2) |> xLine(endAbsolute = lugDiameter / 2)
|> yLine(endAbsolute = lugLength) |> yLine(endAbsolute = lugLength)
|> tangentialArc({ offset = 90, radius = fromMm(3) }, %) |> tangentialArc({ offset = 90, radius = fromMm(3) }, %)

View File

@ -23,18 +23,12 @@ tealPlane = offsetPlane(YZ, offset = -halfSize)
fn sketchRectangle(profile, color) { fn sketchRectangle(profile, color) {
return profile return profile
|> startProfileAt([-halfSize, halfSize], %) |> startProfileAt([-halfSize, halfSize], %)
|> angledLine([0, size], %, $rectangleSegmentA001) |> angledLine(angle = 0, length = size, tag = $rectangleSegmentA001)
|> angledLine([ |> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = size, tag = $rectangleSegmentB001)
segAng(rectangleSegmentA001) - 90, |> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001), tag = $rectangleSegmentC001)
size
], %, $rectangleSegmentB001)
|> angledLine([
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %, $rectangleSegmentC001)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
|> extrude(%, length = extrudeLength) |> extrude(length = extrudeLength)
|> appearance(color = color, metalness = metalConstant, roughness = roughnessConstant) |> appearance(color = color, metalness = metalConstant, roughness = roughnessConstant)
} }

Some files were not shown because too many files have changed in this diff Show More