Compare commits

..

1 Commits

Author SHA1 Message Date
7711bf768c Iterate over binary ops (instead of recursing) 2025-04-08 17:15:33 -05:00
589 changed files with 62371 additions and 62747 deletions

View File

@ -207,13 +207,6 @@ jobs:
smctl.exe keypair ls smctl.exe keypair ls
C:\Windows\System32\certutil.exe -csp "DigiCert Signing Manager KSP" -key -user C:\Windows\System32\certutil.exe -csp "DigiCert Signing Manager KSP" -key -user
smksp_cert_sync.exe smksp_cert_sync.exe
smctl windows certsync
# This last line `smctl windows certsync` was added after windows codesign failures started happening
# with nightly-v25.4.10. It looks like `smksp_cert_sync.exe` used to do the sync to the local cert store,
# but stopped doing it overnight. This extra call that I randomly got from this azure-related doc page
# https://docs.digicert.com/en/digicert-keylocker/code-signing/sign-with-third-party-signing-tools/windows-applications/sign-azure-apps-with-signtool-using-ksp-library.html#sync-certificates--windows-only--618365
# seems to be doing that extra sync that we need for scripts/sign-win.js to work.
# TODO: we still need to make sign-win.js errors fail the workflow, see issue #6276
shell: cmd shell: cmd
- name: Build the app (debug) - name: Build the app (debug)
@ -385,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%20Design%20Studio%20%28Nightly%29' || 'Zoo%20Design%20Studio' }} URL_CODED_NAME: ${{ env.IS_NIGHTLY == 'true' && 'Zoo%20Modeling%20App%20%28Nightly%29' || 'Zoo%20Modeling%20App' }}
run: | run: |
RELEASE_DIR=https://${WEBSITE_DIR} RELEASE_DIR=https://${WEBSITE_DIR}
jq --null-input \ jq --null-input \

View File

@ -231,11 +231,6 @@ jobs:
env: env:
token: ${{ secrets.KITTYCAD_API_TOKEN_DEV }} token: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
snapshottoken: ${{ secrets.KITTYCAD_API_TOKEN }} snapshottoken: ${{ secrets.KITTYCAD_API_TOKEN }}
TAB_API_URL: ${{ secrets.TAB_API_URL }}
TAB_API_KEY: ${{ secrets.TAB_API_KEY }}
CI_COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
CI_PR_NUMBER: ${{ github.event.pull_request.number }}
TARGET: web
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
if: ${{ needs.conditions.outputs.should-run == 'true' && !cancelled() && (success() || failure()) }} if: ${{ needs.conditions.outputs.should-run == 'true' && !cancelled() && (success() || failure()) }}
@ -370,11 +365,6 @@ jobs:
env: env:
FAIL_ON_CONSOLE_ERRORS: true FAIL_ON_CONSOLE_ERRORS: true
token: ${{ secrets.KITTYCAD_API_TOKEN_DEV }} token: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
TAB_API_URL: ${{ secrets.TAB_API_URL }}
TAB_API_KEY: ${{ secrets.TAB_API_KEY }}
CI_COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
CI_PR_NUMBER: ${{ github.event.pull_request.number }}
TARGET: desktop
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
if: ${{ needs.conditions.outputs.should-run == 'true' && always() }} if: ${{ needs.conditions.outputs.should-run == 'true' && always() }}

View File

@ -1,55 +0,0 @@
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,7 +26,6 @@ yarn-error.log*
.idea .idea
.vscode .vscode
.helix .helix
result
# rust # rust
rust/target rust/target

View File

@ -5,18 +5,11 @@ all: install build check
# INSTALL # INSTALL
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
export WINDOWS := true CARGO ?= ~/.cargo/bin/cargo.exe
ifndef MSYSTEM WASM_PACK ?= ~/.cargo/bin/wasm-pack.exe
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
@ -24,21 +17,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
ifdef POWERSHELL ifeq ($(OS),Windows_NT)
@ type nul > $@ @ type nul > $@
else else
@ touch $@ @ touch $@
endif endif
$(CARGO): $(CARGO):
ifdef WINDOWS ifeq ($(OS),Windows_NT)
yarn install:rust:windows yarn install:rust:windows
else else
yarn install:rust yarn install:rust
endif endif
$(WASM_PACK): $(WASM_PACK):
ifdef WINDOWS ifeq ($(OS),Windows_NT)
yarn install:wasm-pack:cargo yarn install:wasm-pack:cargo
else else
yarn install:wasm-pack:sh yarn install:wasm-pack:sh
@ -64,7 +57,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)
ifdef WINDOWS ifeq ($(OS),Windows_NT)
yarn build:wasm:dev:windows yarn build:wasm:dev:windows
else else
yarn build:wasm:dev yarn build:wasm:dev
@ -147,8 +140,8 @@ endif
.PHONY: clean .PHONY: clean
clean: ## Delete all artifacts clean: ## Delete all artifacts
ifdef POWERSHELL ifeq ($(OS),Windows_NT)
git clean --force -d -x --exclude=.env* --exclude=**/*.env git clean --force -d -X
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/
@ -159,7 +152,7 @@ endif
.PHONY: help .PHONY: help
help: install help: install
ifdef POWERSHELL ifeq ($(OS),Windows_NT)
@ 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,7 +33,10 @@ acos(num: number): number
```js ```js
sketch001 = startSketchOn(XZ) sketch001 = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> angledLine(angle = toDegrees(acos(0.5)), length = 10) |> angledLine({
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)
|> angledLine(angle = -angleToMatchLengthX(seg01, 7, %), endAbsoluteX = 10) |> angledLineToX([-angleToMatchLengthX(seg01, 7, %), 10], %)
|> close() |> close()
extrusion = extrude(sketch001, length = 5) extrusion = extrude(sketch001, length = 5)

View File

@ -36,7 +36,10 @@ 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(angle = angleToMatchLengthY(seg01, 15, %), length = 5) |> angledLine({
angle = angleToMatchLengthY(seg01, 15, %),
length = 5
}, %)
|> yLine(endAbsolute = 0) |> yLine(endAbsolute = 0)
|> close() |> close()

View File

@ -10,13 +10,8 @@ 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
``` ```
@ -26,14 +21,9 @@ angledLine(
| Name | Type | Description | Required | | Name | Type | Description | Required |
|----------|------|-------------|----------| |----------|------|-------------|----------|
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | Which sketch should this path be added to? | Yes | | `data` | [`AngledLineData`](/docs/kcl/types/AngledLineData) | Data to draw an angled line. | Yes |
| `angle` | [`number`](/docs/kcl/types/number) | Which angle should the line be drawn at? | Yes | | `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | | Yes |
| `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 | | [`tag`](/docs/kcl/types/tag) | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | 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
@ -46,7 +36,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

48
docs/kcl/angledLineToX.md Normal file

File diff suppressed because one or more lines are too long

48
docs/kcl/angledLineToY.md Normal file

File diff suppressed because one or more lines are too long

View File

@ -188,9 +188,9 @@ example = extrude(exampleSketch, length = 1)
sweepPath = startSketchOn(XZ) sweepPath = startSketchOn(XZ)
|> startProfileAt([0.05, 0.05], %) |> startProfileAt([0.05, 0.05], %)
|> line(end = [0, 7]) |> line(end = [0, 7])
|> tangentialArc(angle = 90, radius = 5) |> tangentialArc({ offset = 90, radius = 5 }, %)
|> line(end = [-3, 0]) |> line(end = [-3, 0])
|> tangentialArc(angle = -90, radius = 5) |> tangentialArc({ offset = -90, radius = 5 }, %)
|> line(end = [0, 7]) |> line(end = [0, 7])
pipeHole = startSketchOn(XY) pipeHole = startSketchOn(XY)

View File

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

View File

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

View File

@ -37,7 +37,10 @@ atan2(
```js ```js
sketch001 = startSketchOn(XZ) sketch001 = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> angledLine(angle = toDegrees(atan2(1.25, 2)), length = 20) |> angledLine({
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, tag = $referenceEdge) |> angledLine({ angle = 240, length = 10 }, %, $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, tag = $referenceEdge) |> angledLine({ angle = 240, length = 10 }, %, $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, tag = $referenceEdge) |> angledLine({ angle = 240, length = 10 }, %, $referenceEdge)
|> close() |> close()
example = extrude(exampleSketch, length = 5) example = extrude(exampleSketch, length = 5)

View File

@ -65,7 +65,7 @@ case = startSketchOn(-XZ)
|> startProfileAt([-size, -size], %) |> startProfileAt([-size, -size], %)
|> line(end = [2 * size, 0]) |> line(end = [2 * size, 0])
|> line(end = [0, 2 * size]) |> line(end = [0, 2 * size])
|> tangentialArc(endAbsolute = [-size, size]) |> tangentialArcTo([-size, size], %)
|> close() |> close()
|> extrude(length = 65) |> extrude(length = 65)

80
docs/kcl/import.md Normal file

File diff suppressed because one or more lines are too long

View File

@ -43,7 +43,11 @@ 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)
@ -77,7 +81,6 @@ 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)
@ -124,14 +127,14 @@ 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)
* [`tangentialArcTo`](kcl/tangentialArcTo)
* [`tangentialArcToRelative`](kcl/tangentialArcToRelative)
* [`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,7 +33,10 @@ max(args: [number]): number
```js ```js
exampleSketch = startSketchOn(XZ) exampleSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> angledLine(angle = 70, length = max(15, 31, 4, 13, 22)) |> angledLine({
angle = 70,
length = max(15, 31, 4, 13, 22)
}, %)
|> line(end = [20, 0]) |> line(end = [20, 0])
|> close() |> close()

View File

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

View File

@ -57,7 +57,7 @@ case = startSketchOn(XY)
|> startProfileAt([-size, -size], %) |> startProfileAt([-size, -size], %)
|> line(end = [2 * size, 0]) |> line(end = [2 * size, 0])
|> line(end = [0, 2 * size]) |> line(end = [0, 2 * size])
|> tangentialArc(endAbsolute = [-size, size]) |> tangentialArcTo([-size, size], %)
|> close(%) |> close(%)
|> extrude(length = 65) |> extrude(length = 65)
@ -88,7 +88,7 @@ case = startSketchOn(XY)
|> startProfileAt([-size, -size], %) |> startProfileAt([-size, -size], %)
|> line(end = [2 * size, 0]) |> line(end = [2 * size, 0])
|> line(end = [0, 2 * size]) |> line(end = [0, 2 * size])
|> tangentialArc(endAbsolute = [-size, size]) |> tangentialArcTo([-size, size], %)
|> close(%) |> close(%)
|> extrude(length = 65) |> extrude(length = 65)

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,8 +29,11 @@ profileStart(sketch: Sketch): [number]
```js ```js
sketch001 = startSketchOn(XY) sketch001 = startSketchOn(XY)
|> startProfileAt([5, 2], %) |> startProfileAt([5, 2], %)
|> angledLine(angle = 120, length = 50, tag = $seg01) |> angledLine({ angle = 120, length = 50 }, %, $seg01)
|> angledLine(angle = segAng(seg01) + 120, length = 50) |> angledLine({
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 radians from the previous angle. // Each side of the decagon is turned this many degrees from the previous angle.
stepAngle = 1 / 10 * TAU stepAngle = 1 / 10 * TAU
// Start the decagon sketch at this point. // Start the decagon sketch at this point.

View File

@ -65,9 +65,9 @@ rotate(
sweepPath = startSketchOn(XZ) sweepPath = startSketchOn(XZ)
|> startProfileAt([0.05, 0.05], %) |> startProfileAt([0.05, 0.05], %)
|> line(end = [0, 7]) |> line(end = [0, 7])
|> tangentialArc(angle = 90, radius = 5) |> tangentialArc({ offset = 90, radius = 5 }, %)
|> line(end = [-3, 0]) |> line(end = [-3, 0])
|> tangentialArc(angle = -90, radius = 5) |> tangentialArc({ offset = -90, radius = 5 }, %)
|> line(end = [0, 7]) |> line(end = [0, 7])
// Create a hole for the pipe. // Create a hole for the pipe.
@ -90,9 +90,9 @@ sweepSketch = startSketchOn(XY)
sweepPath = startSketchOn(XZ) sweepPath = startSketchOn(XZ)
|> startProfileAt([0.05, 0.05], %) |> startProfileAt([0.05, 0.05], %)
|> line(end = [0, 7]) |> line(end = [0, 7])
|> tangentialArc(angle = 90, radius = 5) |> tangentialArc({ offset = 90, radius = 5 }, %)
|> line(end = [-3, 0]) |> line(end = [-3, 0])
|> tangentialArc(angle = -90, radius = 5) |> tangentialArc({ offset = -90, radius = 5 }, %)
|> line(end = [0, 7]) |> line(end = [0, 7])
// Create a hole for the pipe. // Create a hole for the pipe.
@ -115,9 +115,9 @@ sweepSketch = startSketchOn(XY)
sweepPath = startSketchOn(XZ) sweepPath = startSketchOn(XZ)
|> startProfileAt([0.05, 0.05], %) |> startProfileAt([0.05, 0.05], %)
|> line(end = [0, 7]) |> line(end = [0, 7])
|> tangentialArc(angle = 90, radius = 5) |> tangentialArc({ offset = 90, radius = 5 }, %)
|> line(end = [-3, 0]) |> line(end = [-3, 0])
|> tangentialArc(angle = -90, radius = 5) |> tangentialArc({ offset = -90, radius = 5 }, %)
|> line(end = [0, 7]) |> line(end = [0, 7])
// Create a hole for the pipe. // Create a hole for the pipe.
@ -151,9 +151,15 @@ cube
sketch001 = startSketchOn(XY) sketch001 = startSketchOn(XY)
rectangleSketch = startProfileAt([-200, 23.86], sketch001) rectangleSketch = startProfileAt([-200, 23.86], sketch001)
|> angledLine(angle = 0, length = 73.47, tag = $rectangleSegmentA001) |> angledLine([0, 73.47], %, $rectangleSegmentA001)
|> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 50.61) |> angledLine([
|> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001)) segAng(rectangleSegmentA001) - 90,
50.61
], %)
|> angledLine([
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
@ -162,7 +168,7 @@ circleSketch = circle(sketch001, center = [200, -30.29], radius = 32.63)
sketch002 = startSketchOn(YZ) sketch002 = startSketchOn(YZ)
sweepPath = startProfileAt([0, 0], sketch002) sweepPath = startProfileAt([0, 0], sketch002)
|> yLine(length = 231.81) |> yLine(length = 231.81)
|> tangentialArc(radius = 80, angle = -90) |> tangentialArc({ radius = 80, offset = -90 }, %)
|> xLine(length = 384.93) |> xLine(length = 384.93)
parts = sweep([rectangleSketch, circleSketch], path = sweepPath) parts = sweep([rectangleSketch, circleSketch], path = sweepPath)

View File

@ -49,9 +49,9 @@ scale(
sweepPath = startSketchOn(XZ) sweepPath = startSketchOn(XZ)
|> startProfileAt([0.05, 0.05], %) |> startProfileAt([0.05, 0.05], %)
|> line(end = [0, 7]) |> line(end = [0, 7])
|> tangentialArc(angle = 90, radius = 5) |> tangentialArc({ offset = 90, radius = 5 }, %)
|> line(end = [-3, 0]) |> line(end = [-3, 0])
|> tangentialArc(angle = -90, radius = 5) |> tangentialArc({ offset = -90, radius = 5 }, %)
|> line(end = [0, 7]) |> line(end = [0, 7])
// Create a hole for the pipe. // Create a hole for the pipe.
@ -85,9 +85,15 @@ cube
sketch001 = startSketchOn(XY) sketch001 = startSketchOn(XY)
rectangleSketch = startProfileAt([-200, 23.86], sketch001) rectangleSketch = startProfileAt([-200, 23.86], sketch001)
|> angledLine(angle = 0, length = 73.47, tag = $rectangleSegmentA001) |> angledLine([0, 73.47], %, $rectangleSegmentA001)
|> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 50.61) |> angledLine([
|> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001)) segAng(rectangleSegmentA001) - 90,
50.61
], %)
|> angledLine([
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
@ -96,7 +102,7 @@ circleSketch = circle(sketch001, center = [200, -30.29], radius = 32.63)
sketch002 = startSketchOn(YZ) sketch002 = startSketchOn(YZ)
sweepPath = startProfileAt([0, 0], sketch002) sweepPath = startProfileAt([0, 0], sketch002)
|> yLine(length = 231.81) |> yLine(length = 231.81)
|> tangentialArc(radius = 80, angle = -90) |> tangentialArc({ radius = 80, offset = -90 }, %)
|> xLine(length = 384.93) |> xLine(length = 384.93)
parts = sweep([rectangleSketch, circleSketch], path = sweepPath) parts = sweep([rectangleSketch, circleSketch], path = sweepPath)

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(angle = segAng(seg01), length = 10) |> angledLine([segAng(seg01), 10], %)
|> line(end = [-10, 0]) |> line(end = [-10, 0])
|> angledLine(angle = segAng(seg01), length = -15) |> angledLine([segAng(seg01), -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, tag = $thing) |> angledLine({ angle = 60, length = 10 }, %, $thing)
|> tangentialArc(angle = -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

@ -103,7 +103,7 @@ case = startSketchOn(-XZ)
|> startProfileAt([-size, -size], %) |> startProfileAt([-size, -size], %)
|> line(end = [2 * size, 0]) |> line(end = [2 * size, 0])
|> line(end = [0, 2 * size]) |> line(end = [0, 2 * size])
|> tangentialArc(endAbsolute = [-size, size]) |> tangentialArcTo([-size, size], %)
|> close() |> close()
|> extrude(length = 65) |> extrude(length = 65)
@ -128,7 +128,7 @@ case = startSketchOn(XY)
|> startProfileAt([-size, -size], %) |> startProfileAt([-size, -size], %)
|> line(end = [2 * size, 0]) |> line(end = [2 * size, 0])
|> line(end = [0, 2 * size]) |> line(end = [0, 2 * size])
|> tangentialArc(endAbsolute = [-size, size]) |> tangentialArcTo([-size, size], %)
|> close() |> close()
|> extrude(length = 65) |> extrude(length = 65)
@ -156,7 +156,7 @@ case = startSketchOn(XY)
|> startProfileAt([-size, -size], %) |> startProfileAt([-size, -size], %)
|> line(end = [2 * size, 0]) |> line(end = [2 * size, 0])
|> line(end = [0, 2 * size]) |> line(end = [0, 2 * size])
|> tangentialArc(endAbsolute = [-size, size]) |> tangentialArcTo([-size, size], %)
|> close() |> close()
|> extrude(length = 65) |> extrude(length = 65)

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,15 +9,7 @@ Create a helix.
```js ```js
helix( helix(revolutions: number(_), angleStart: number(deg), ccw?: bool, radius?: number(mm), axis?: Axis3d | Edge, length?: number(mm), cylinder?: Solid): 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,14 +6,10 @@ layout: manual
Convert polar/sphere (azimuth, elevation, distance) coordinates to Convert polar/sphere (azimuth, elevation, distance) coordinates tocartesian (x/y/z grid) coordinates.
cartesian (x/y/z grid) coordinates.
```js ```js
polar( polar(angle: number(deg), length: number(mm)): [number(mm); 2]
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,16 +6,10 @@ layout: manual
Construct a 2-dimensional circle, of the specified radius, centered at Construct a 2-dimensional circle, of the specified radius, centered atthe provided (x, y) origin point.
the provided (x, y) origin point.
```js ```js
circle( circle(@sketch_or_surface: Sketch | Plane | Face, center: Point2d, radius: number, tag?: tag): Sketch
@sketch_or_surface: Sketch | Plane | Face,
center: Point2d,
radius: number,
tag?: tag,
): Sketch
``` ```

View File

@ -11,10 +11,7 @@ Only works on unclosed sketches for now.
Mirror occurs around a local sketch axis rather than a global axis. Mirror occurs around a local sketch axis rather than a global axis.
```js ```js
mirror2d( mirror2d(@sketches: [Sketch; 1+], axis: Axis2d | Edge): Sketch
@sketches: [Sketch; 1+],
axis: Axis2d | Edge,
): Sketch
``` ```
@ -103,9 +100,9 @@ example = extrude(sketch001, length = 10)
sketch0011 = startSketchOn(XY) sketch0011 = startSketchOn(XY)
|> startProfileAt([6.77, 0], %) |> startProfileAt([6.77, 0], %)
|> yLine(length = 1.27) |> yLine(length = 1.27)
|> tangentialArc(endAbsolute = [5.96, 2.37]) |> tangentialArcTo([5.96, 2.37], %)
|> tangentialArc(endAbsolute = [-6.2, 2.44]) |> tangentialArcTo([-6.2, 2.44], %)
|> tangentialArc(endAbsolute = [-6.6, 1.82]) |> tangentialArcTo([-6.6, 1.82], %)
|> yLine(length = -1.82) |> yLine(length = -1.82)
|> mirror2d( axis = X ) |> mirror2d( axis = X )
|> extrude(length = 10) |> extrude(length = 10)

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -47,9 +47,9 @@ sweep(
sweepPath = startSketchOn(XZ) sweepPath = startSketchOn(XZ)
|> startProfileAt([0.05, 0.05], %) |> startProfileAt([0.05, 0.05], %)
|> line(end = [0, 7]) |> line(end = [0, 7])
|> tangentialArc(angle = 90, radius = 5) |> tangentialArc({ offset = 90, radius = 5 }, %)
|> line(end = [-3, 0]) |> line(end = [-3, 0])
|> tangentialArc(angle = -90, radius = 5) |> tangentialArc({ offset = -90, radius = 5 }, %)
|> line(end = [0, 7]) |> line(end = [0, 7])
// Create a hole for the pipe. // Create a hole for the pipe.
@ -91,9 +91,15 @@ springSketch = startSketchOn(YZ)
sketch001 = startSketchOn(XY) sketch001 = startSketchOn(XY)
rectangleSketch = startProfileAt([-200, 23.86], sketch001) rectangleSketch = startProfileAt([-200, 23.86], sketch001)
|> angledLine(angle = 0, length = 73.47, tag = $rectangleSegmentA001) |> angledLine([0, 73.47], %, $rectangleSegmentA001)
|> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 50.61) |> angledLine([
|> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001)) segAng(rectangleSegmentA001) - 90,
50.61
], %)
|> angledLine([
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
@ -102,7 +108,7 @@ circleSketch = circle(sketch001, center = [200, -30.29], radius = 32.63)
sketch002 = startSketchOn(YZ) sketch002 = startSketchOn(YZ)
sweepPath = startProfileAt([0, 0], sketch002) sweepPath = startProfileAt([0, 0], sketch002)
|> yLine(length = 231.81) |> yLine(length = 231.81)
|> tangentialArc(radius = 80, angle = -90) |> tangentialArc({ radius = 80, offset = -90 }, %)
|> xLine(length = 384.93) |> xLine(length = 384.93)
sweep([rectangleSketch, circleSketch], path = sweepPath) sweep([rectangleSketch, circleSketch], path = sweepPath)
@ -120,7 +126,7 @@ circleSketch = circle(sketch001, center = [200, -30.29], radius = 32.63)
sketch002 = startSketchOn(YZ) sketch002 = startSketchOn(YZ)
sweepPath = startProfileAt([0, 0], sketch002) sweepPath = startProfileAt([0, 0], sketch002)
|> yLine(length = 231.81) |> yLine(length = 231.81)
|> tangentialArc(radius = 80, angle = -90) |> tangentialArc({ radius = 80, offset = -90 }, %)
|> xLine(length = 384.93) |> xLine(length = 384.93)
sweep(circleSketch, path = sweepPath, sectional = true) sweep(circleSketch, path = sweepPath, sectional = true)

View File

@ -31,9 +31,12 @@ tangentToEnd(tag: TagIdentifier): number
pillSketch = startSketchOn(XZ) pillSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line(end = [20, 0]) |> line(end = [20, 0])
|> tangentialArc(end = [0, 10], tag = $arc1) |> tangentialArcToRelative([0, 10], %, $arc1)
|> angledLine(angle = tangentToEnd(arc1), length = 20) |> angledLine({
|> tangentialArc(end = [0, -10]) angle = tangentToEnd(arc1),
length = 20
}, %)
|> tangentialArcToRelative([0, -10], %)
|> close() |> close()
pillExtrude = extrude(pillSketch, length = 10) pillExtrude = extrude(pillSketch, length = 10)
@ -46,9 +49,12 @@ pillExtrude = extrude(pillSketch, length = 10)
pillSketch = startSketchOn(XZ) pillSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line(end = [0, 20]) |> line(end = [0, 20])
|> tangentialArc(endAbsolute = [10, 20], tag = $arc1) |> tangentialArcTo([10, 20], %, $arc1)
|> angledLine(angle = tangentToEnd(arc1), length = 20) |> angledLine({
|> tangentialArc(end = [-10, 0]) angle = tangentToEnd(arc1),
length = 20
}, %)
|> tangentialArcToRelative([-10, 0], %)
|> close() |> close()
pillExtrude = extrude(pillSketch, length = 10) pillExtrude = extrude(pillSketch, length = 10)
@ -60,7 +66,10 @@ 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(angle = tangentToEnd(seg1), length = 10) |> angledLine({
angle = tangentToEnd(seg1),
length = 10
}, %)
|> line(end = [0, 10]) |> line(end = [0, 10])
|> line(end = [-20, 0]) |> line(end = [-20, 0])
|> close() |> close()
@ -74,7 +83,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(angle = tangentToEnd(arc1), length = 20) |> angledLine([tangentToEnd(arc1), 20], %)
|> close() |> close()
``` ```
@ -86,7 +95,7 @@ circSketch = startSketchOn(XY)
triangleSketch = startSketchOn(XY) triangleSketch = startSketchOn(XY)
|> startProfileAt([-5, 0], %) |> startProfileAt([-5, 0], %)
|> angledLine(angle = tangentToEnd(circ), length = 10) |> angledLine([tangentToEnd(circ), 10], %)
|> line(end = [-15, 0]) |> line(end = [-15, 0])
|> close() |> close()
``` ```

File diff suppressed because one or more lines are too long

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

View File

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

View File

@ -45,9 +45,9 @@ translate(
sweepPath = startSketchOn(XZ) sweepPath = startSketchOn(XZ)
|> startProfileAt([0.05, 0.05], %) |> startProfileAt([0.05, 0.05], %)
|> line(end = [0, 7]) |> line(end = [0, 7])
|> tangentialArc(angle = 90, radius = 5) |> tangentialArc({ offset = 90, radius = 5 }, %)
|> line(end = [-3, 0]) |> line(end = [-3, 0])
|> tangentialArc(angle = -90, radius = 5) |> tangentialArc({ offset = -90, radius = 5 }, %)
|> line(end = [0, 7]) |> line(end = [0, 7])
// Create a hole for the pipe. // Create a hole for the pipe.
@ -86,9 +86,15 @@ cube
sketch001 = startSketchOn(XY) sketch001 = startSketchOn(XY)
rectangleSketch = startProfileAt([-200, 23.86], sketch001) rectangleSketch = startProfileAt([-200, 23.86], sketch001)
|> angledLine(angle = 0, length = 73.47, tag = $rectangleSegmentA001) |> angledLine([0, 73.47], %, $rectangleSegmentA001)
|> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 50.61) |> angledLine([
|> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001)) segAng(rectangleSegmentA001) - 90,
50.61
], %)
|> angledLine([
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
@ -97,7 +103,7 @@ circleSketch = circle(sketch001, center = [200, -30.29], radius = 32.63)
sketch002 = startSketchOn(YZ) sketch002 = startSketchOn(YZ)
sweepPath = startProfileAt([0, 0], sketch002) sweepPath = startProfileAt([0, 0], sketch002)
|> yLine(length = 231.81) |> yLine(length = 231.81)
|> tangentialArc(radius = 80, angle = -90) |> tangentialArc({ radius = 80, offset = -90 }, %)
|> xLine(length = 384.93) |> xLine(length = 384.93)
parts = sweep([rectangleSketch, circleSketch], path = sweepPath) parts = sweep([rectangleSketch, circleSketch], path = sweepPath)

View File

@ -184,17 +184,15 @@ way:
```norun ```norun
startSketchOn('XZ') startSketchOn('XZ')
|> startProfileAt(origin, %) |> startProfileAt(origin, %)
|> angledLine(angle = 0, length = 191.26, tag = $rectangleSegmentA001) |> angledLine({angle = 0, length = 191.26}, %, $rectangleSegmentA001)
|> angledLine( |> angledLine({
angle = segAng(rectangleSegmentA001) - 90, angle = segAng(rectangleSegmentA001) - 90,
length = 196.99, length = 196.99,
tag = $rectangleSegmentB001, }, %, $rectangleSegmentB001)
) |> angledLine({
|> angledLine(
angle = segAng(rectangleSegmentA001), angle = segAng(rectangleSegmentA001),
length = -segLen(rectangleSegmentA001), length = -segLen(rectangleSegmentA001),
tag = $rectangleSegmentC001, }, %, $rectangleSegmentC001)
)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
``` ```
@ -219,17 +217,15 @@ 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, tag = $rectangleSegmentA001) |> angledLine({angle = 0, length = 191.26}, %, $rectangleSegmentA001)
|> angledLine( |> angledLine({
angle = segAng(rectangleSegmentA001) - 90, angle = segAng(rectangleSegmentA001) - 90,
length = 196.99, length = 196.99
tag = $rectangleSegmentB001, }, %, $rectangleSegmentB001)
) |> angledLine({
|> angledLine(
angle = segAng(rectangleSegmentA001), angle = segAng(rectangleSegmentA001),
length = -segLen(rectangleSegmentA001) length = -segLen(rectangleSegmentA001)
tag = $rectangleSegmentC001, }, %, $rectangleSegmentC001)
)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
} }
@ -249,17 +245,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, tag = $rectangleSegmentA001) |> angledLine({angle = 0, length = 191.26}, %, $rectangleSegmentA001)
|> angledLine( |> angledLine({
angle = segAng(rectangleSegmentA001) - 90, angle = segAng(rectangleSegmentA001) - 90,
length = 196.99, length = 196.99
tag = $rectangleSegmentB001, }, %, $rectangleSegmentB001)
) |> angledLine({
|> angledLine(
angle = segAng(rectangleSegmentA001), angle = segAng(rectangleSegmentA001),
length = -segLen(rectangleSegmentA001) length = -segLen(rectangleSegmentA001)
tag = $rectangleSegmentC001, }, %, $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`| | No | | `type` |enum: [`ImportedGeometry`](/docs/kcl/types/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,17 +14,15 @@ way:
```js ```js
startSketchOn('XZ') startSketchOn('XZ')
|> startProfileAt(origin, %) |> startProfileAt(origin, %)
|> angledLine(angle = 0, length = 191.26, tag = $rectangleSegmentA001) |> angledLine({angle = 0, length = 191.26}, %, $rectangleSegmentA001)
|> angledLine( |> angledLine({
angle = segAng(rectangleSegmentA001) - 90, angle = segAng(rectangleSegmentA001) - 90,
length = 196.99, length = 196.99,
tag = $rectangleSegmentB001, }, %, $rectangleSegmentB001)
) |> angledLine({
|> angledLine(
angle = segAng(rectangleSegmentA001), angle = segAng(rectangleSegmentA001),
length = -segLen(rectangleSegmentA001), length = -segLen(rectangleSegmentA001),
tag = $rectangleSegmentC001, }, %, $rectangleSegmentC001)
)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
``` ```
@ -48,16 +46,15 @@ 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, tag = $rectangleSegmentA001) |> angledLine({angle = 0, length = 191.26}, %, $rectangleSegmentA001)
|> angledLine( |> angledLine({
angle = segAng(rectangleSegmentA001) - 90, angle = segAng(rectangleSegmentA001) - 90,
length = 196.99, length = 196.99
tag = $rectangleSegmentB001) }, %, $rectangleSegmentB001)
|> angledLine( |> angledLine({
angle = segAng(rectangleSegmentA001), angle = segAng(rectangleSegmentA001),
length = -segLen(rectangleSegmentA001), length = -segLen(rectangleSegmentA001)
tag = $rectangleSegmentC001 }, %, $rectangleSegmentC001)
)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
} }
@ -77,15 +74,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, tag = $rectangleSegmentA001) |> angledLine({angle = 0, length = 191.26}, %, $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: 'constraints: open menu' }).click() await page.getByRole('button', { name: 'Length: 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

@ -920,7 +920,7 @@ sketch001 = startSketchOn(XZ)
`sketch001 = startSketchOn(XZ) `sketch001 = startSketchOn(XZ)
|> startProfileAt([4.61, -14.01], %) |> startProfileAt([4.61, -14.01], %)
|> line(end = [12.73, -0.09]) |> line(end = [12.73, -0.09])
|> tangentialArc(endAbsolute = [24.95, -5.38]) |> tangentialArcTo([24.95, -5.38], %)
|> close()` |> close()`
) )
}) })
@ -969,7 +969,7 @@ sketch001 = startSketchOn(XZ)
// expect the code to have changed // expect the code to have changed
await expect(page.locator('.cm-content')).toHaveText( await expect(page.locator('.cm-content')).toHaveText(
`sketch001 = startSketchOn(XZ) |> startProfileAt([4.61, -14.01], %) |> line(end = [12.73, -0.09]) |> tangentialArc(endAbsolute = [24.95, -5.38]) |> close()extrude001 = extrude(sketch001, length = 5)` `sketch001 = startSketchOn(XZ) |> startProfileAt([4.61, -14.01], %) |> line(end = [12.73, -0.09]) |> tangentialArcTo([24.95, -5.38], %) |> close()extrude001 = extrude(sketch001, length = 5)`
) )
// Now hit undo // Now hit undo
@ -982,7 +982,7 @@ sketch001 = startSketchOn(XZ)
.toHaveText(`sketch001 = startSketchOn(XZ) .toHaveText(`sketch001 = startSketchOn(XZ)
|> startProfileAt([4.61, -14.01], %) |> startProfileAt([4.61, -14.01], %)
|> line(end = [12.73, -0.09]) |> line(end = [12.73, -0.09])
|> tangentialArc(endAbsolute = [24.95, -5.38]) |> tangentialArcTo([24.95, -5.38], %)
|> close()`) |> close()`)
}) })
@ -998,7 +998,7 @@ sketch001 = startSketchOn(XZ)
sketch001 = startSketchOn(XZ) sketch001 = startSketchOn(XZ)
|> startProfileAt([4.61, -10.01], %) |> startProfileAt([4.61, -10.01], %)
|> line(end = [12.73, -0.09]) |> line(end = [12.73, -0.09])
|> tangentialArc(endAbsolute = [24.95, -0.38]) |> tangentialArcTo([24.95, -0.38], %)
|> close() |> close()
|> extrude(length = 5)` |> extrude(length = 5)`
) )
@ -1072,7 +1072,7 @@ sketch001 = startSketchOn(XZ)
// we wait so it saves the code // we wait so it saves the code
await page.waitForTimeout(800) await page.waitForTimeout(800)
// drag tangentialArc handle // drag tangentialArcTo handle
const tangentEnd = await u.getBoundingBox('[data-overlay-index="1"]') const tangentEnd = await u.getBoundingBox('[data-overlay-index="1"]')
await page.dragAndDrop('#stream', '#stream', { await page.dragAndDrop('#stream', '#stream', {
sourcePosition: { x: tangentEnd.x + 10, y: tangentEnd.y - 5 }, sourcePosition: { x: tangentEnd.x + 10, y: tangentEnd.y - 5 },
@ -1089,7 +1089,7 @@ sketch001 = startSketchOn(XZ)
`sketch001 = startSketchOn(XZ) `sketch001 = startSketchOn(XZ)
|> startProfileAt([2.71, -2.71], %) |> startProfileAt([2.71, -2.71], %)
|> line(end = [15.4, -2.78]) |> line(end = [15.4, -2.78])
|> tangentialArc(endAbsolute = [27.6, -3.05]) |> tangentialArcTo([27.6, -3.05], %)
|> close() |> close()
|> extrude(length = 5)`, |> extrude(length = 5)`,
{ shouldNormalise: true } { shouldNormalise: true }
@ -1104,7 +1104,7 @@ sketch001 = startSketchOn(XZ)
`sketch001 = startSketchOn(XZ) `sketch001 = startSketchOn(XZ)
|> startProfileAt([2.71, -2.71], %) |> startProfileAt([2.71, -2.71], %)
|> line(end = [15.4, -2.78]) |> line(end = [15.4, -2.78])
|> tangentialArc(endAbsolute = [24.95, -0.38]) |> tangentialArcTo([24.95, -0.38], %)
|> close() |> close()
|> extrude(length = 5)`, |> extrude(length = 5)`,
{ shouldNormalise: true } { shouldNormalise: true }
@ -1119,7 +1119,7 @@ sketch001 = startSketchOn(XZ)
`sketch001 = startSketchOn(XZ) `sketch001 = startSketchOn(XZ)
|> startProfileAt([2.71, -2.71], %) |> startProfileAt([2.71, -2.71], %)
|> line(end = [12.73, -0.09]) |> line(end = [12.73, -0.09])
|> tangentialArc(endAbsolute = [24.95, -0.38]) |> tangentialArcTo([24.95, -0.38], %)
|> close() |> close()
|> extrude(length = 5)`, |> extrude(length = 5)`,
{ shouldNormalise: true } { shouldNormalise: true }
@ -1135,7 +1135,7 @@ sketch001 = startSketchOn(XZ)
`sketch001 = startSketchOn(XZ) `sketch001 = startSketchOn(XZ)
|> startProfileAt([4.61, -10.01], %) |> startProfileAt([4.61, -10.01], %)
|> line(end = [12.73, -0.09]) |> line(end = [12.73, -0.09])
|> tangentialArc(endAbsolute = [24.95, -0.38]) |> tangentialArcTo([24.95, -0.38], %)
|> close() |> close()
|> extrude(length = 5)`, |> extrude(length = 5)`,
{ shouldNormalise: true } { shouldNormalise: true }
@ -1144,7 +1144,7 @@ sketch001 = startSketchOn(XZ)
) )
test( test(
`Can import a local OBJ file`, `Can use the import stdlib function on 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'\ncube`) await u.codeLocator.fill(`import('cube.obj')`)
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,51 +1353,4 @@ 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(angle = -45, length = length001) |> angledLine([-45, length001], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
revolve001 = revolve(sketch001, axis = X) revolve001 = revolve(sketch001, axis = X)
@ -38,9 +38,15 @@ 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(angle = 0, length = 4, tag = $rectangleSegmentA001) |> angledLine([0, 4], %, $rectangleSegmentA001)
|> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 2, tag = $rectangleSegmentB001) |> angledLine([
|> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001), tag = $rectangleSegmentC001) segAng(rectangleSegmentA001) - 90,
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,6 +99,7 @@ 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,9 +49,7 @@ 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 this.networkToggleConnected = page.getByTestId('network-toggle-ok')
.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' }))
@ -233,7 +231,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({ timeout: 15_000 }) await expect(this.startEditSketchBtn).not.toBeDisabled()
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 rectangles:' }) .getByRole('button', { name: 'caret down Corner rectangle:' })
.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 booleans: open menu' }) .getByRole('button', { name: 'caret down Union: 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,19 +186,25 @@ export class ToolbarFixture {
} }
selectCircleThreePoint = async () => { selectCircleThreePoint = async () => {
await this.page.getByRole('button', { name: 'caret down circles:' }).click() await this.page
.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.getByRole('button', { name: 'caret down arcs:' }).click() await this.page
.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.getByRole('button', { name: 'caret down arcs:' }).click() await this.page
.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,9 +21,15 @@ 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(angle = 0, length = 123.43, tag = $rectangleSegmentA001) |> angledLine([0, 123.43], %, $rectangleSegmentA001)
|> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 85.99) |> angledLine([
|> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001)) segAng(rectangleSegmentA001) - 90,
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)`
@ -38,9 +44,15 @@ importedCube
sketch001 = startSketchOn(XZ) sketch001 = startSketchOn(XZ)
profile001 = startProfileAt([-134.53, -56.17], sketch001) profile001 = startProfileAt([-134.53, -56.17], sketch001)
|> angledLine(angle = 0, length = 79.05, tag = $rectangleSegmentA001) |> angledLine([0, 79.05], %, $rectangleSegmentA001)
|> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 76.28) |> angledLine([
|> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001), tag = $seg01) segAng(rectangleSegmentA001) - 90,
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

@ -1,63 +0,0 @@
import type { Reporter, TestCase, TestResult } from '@playwright/test/reporter'
class MyAPIReporter implements Reporter {
onTestEnd(test: TestCase, result: TestResult): void {
if (!process.env.TAB_API_URL || !process.env.TAB_API_KEY) {
return
}
const payload = {
// Required information
project: 'https://github.com/KittyCAD/modeling-app',
branch: process.env.GITHUB_HEAD_REF || process.env.GITHUB_REF_NAME || '',
commit: process.env.CI_COMMIT_SHA || process.env.GITHUB_SHA || '',
test: test.titlePath().slice(2).join(' '),
status: result.status,
// Optional information
duration: result.duration / 1000,
message: result.error?.stack,
target: process.env.TARGET || null,
platform: process.env.RUNNER_OS || process.platform,
// Extra test and result data
annotations: test.annotations.map((a) => a.type),
retries: result.retry,
// Extra environment variables
CI_COMMIT_SHA: process.env.CI_COMMIT_SHA || null,
CI_PR_NUMBER: process.env.CI_PR_NUMBER || null,
GITHUB_BASE_REF: process.env.GITHUB_BASE_REF || null,
GITHUB_EVENT_NAME: process.env.GITHUB_EVENT_NAME || null,
GITHUB_HEAD_REF: process.env.GITHUB_HEAD_REF || null,
GITHUB_REF_NAME: process.env.GITHUB_REF_NAME || null,
GITHUB_REF: process.env.GITHUB_REF || null,
GITHUB_SHA: process.env.GITHUB_SHA || null,
GITHUB_WORKFLOW: process.env.GITHUB_WORKFLOW || null,
RUNNER_ARCH: process.env.RUNNER_ARCH || null,
}
void (async () => {
try {
const response = await fetch(`${process.env.TAB_API_URL}/api/results`, {
method: 'POST',
headers: new Headers({
'Content-Type': 'application/json',
'X-API-Key': process.env.TAB_API_KEY || '',
}),
body: JSON.stringify(payload),
})
if (!response.ok && !process.env.CI) {
console.error(
'TAB API - Failed to send test result:',
await response.text()
)
}
} catch {
if (!process.env.CI) {
console.error('TAB API - Unable to send test result')
}
}
})()
}
}
export default MyAPIReporter

View File

@ -6,9 +6,7 @@ import type { NamedView } from '@rust/kcl-lib/bindings/NamedView'
import { import {
createProject, createProject,
orRunWhenFullSuiteEnabled, perProjectsettingsToToml,
perProjectSettingsToToml,
runningOnMac,
tomlToPerProjectSettings, tomlToPerProjectSettings,
} from '@e2e/playwright/test-utils' } from '@e2e/playwright/test-utils'
import { expect, test } from '@e2e/playwright/zoo-test' import { expect, test } from '@e2e/playwright/zoo-test'
@ -59,13 +57,10 @@ function tomlStringOverWriteNamedViewUuids(toml: string): string {
settings.settings.app.named_views = remappedNamedViews settings.settings.app.named_views = remappedNamedViews
} }
} }
return perProjectSettingsToToml(settings) return perProjectsettingsToToml(settings)
} }
test.describe('Named view tests', () => { test.describe('Named view tests', () => {
if (runningOnMac()) {
test.fixme(orRunWhenFullSuiteEnabled())
}
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'
@ -109,9 +104,6 @@ test.describe('Named view tests', () => {
PROJECT_SETTINGS_FILE_NAME PROJECT_SETTINGS_FILE_NAME
) )
const toastMessage = page.getByText('Named view uuid1 created.')
await expect(toastMessage).toBeInViewport()
// Expect project.toml to be generated on disk since a named view was created // Expect project.toml to be generated on disk since a named view was created
await expect(async () => { await expect(async () => {
let exists = await fileExists(tempProjectSettingsFilePath) let exists = await fileExists(tempProjectSettingsFilePath)
@ -137,6 +129,7 @@ test.describe('Named view tests', () => {
}, testInfo) => { }, testInfo) => {
const projectName = 'named-views' const projectName = 'named-views'
const myNamedView1 = 'uuid1' const myNamedView1 = 'uuid1'
const myNamedView2 = 'uuid2'
// Create project and go into the project // Create project and go into the project
await createProject({ name: projectName, page }) await createProject({ name: projectName, page })
@ -148,9 +141,6 @@ test.describe('Named view tests', () => {
await cmdBar.argumentInput.fill(myNamedView1) await cmdBar.argumentInput.fill(myNamedView1)
await cmdBar.progressCmdBar(false) await cmdBar.progressCmdBar(false)
let toastMessage = page.getByText('Named view uuid1 created.')
await expect(toastMessage).toBeInViewport()
// Generate file paths for project.toml // Generate file paths for project.toml
const projectDirName = testInfo.outputPath('electron-test-projects-dir') const projectDirName = testInfo.outputPath('electron-test-projects-dir')
const tempProjectSettingsFilePath = join( const tempProjectSettingsFilePath = join(
@ -179,20 +169,17 @@ test.describe('Named view tests', () => {
// Delete a named view // Delete a named view
await cmdBar.openCmdBar() await cmdBar.openCmdBar()
await cmdBar.chooseCommand('delete named view') await cmdBar.chooseCommand('delete named view')
cmdBar.selectOption({ name: myNamedView1 }) cmdBar.selectOption({ name: myNamedView2 })
await cmdBar.progressCmdBar(false) await cmdBar.progressCmdBar(false)
toastMessage = page.getByText('Named view uuid1 removed.')
await expect(toastMessage).toBeInViewport()
await expect(async () => { await expect(async () => {
// Read project.toml into memory again since we deleted a named view // Read project.toml into memory again since we deleted a named view
let tomlString = await fsp.readFile(tempProjectSettingsFilePath, 'utf-8') let tomlString = await fsp.readFile(tempProjectSettingsFilePath, 'utf-8')
// Rewrite the uuids in the named views to match snapshot otherwise they will be randomly generated from rust and break // Rewrite the uuids in the named views to match snapshot otherwise they will be randomly generated from rust and break
tomlString = tomlStringOverWriteNamedViewUuids(tomlString) tomlString = tomlStringOverWriteNamedViewUuids(tomlString)
// Write the entire tomlString to a snapshot. // // Write the entire tomlString to a snapshot.
// There are many key/value pairs to check this is a safer match. // // There are many key/value pairs to check this is a safer match.
expect(tomlString).toMatchSnapshot('verify-named-view-gets-deleted') expect(tomlString).toMatchSnapshot('verify-named-view-gets-deleted')
}).toPass() }).toPass()
}) })
@ -214,9 +201,6 @@ test.describe('Named view tests', () => {
await cmdBar.argumentInput.fill(myNamedView) await cmdBar.argumentInput.fill(myNamedView)
await cmdBar.progressCmdBar(false) await cmdBar.progressCmdBar(false)
let toastMessage = page.getByText('Named view uuid1 created.')
await expect(toastMessage).toBeInViewport()
// Generate file paths for project.toml // Generate file paths for project.toml
const projectDirName = testInfo.outputPath('electron-test-projects-dir') const projectDirName = testInfo.outputPath('electron-test-projects-dir')
const tempProjectSettingsFilePath = join( const tempProjectSettingsFilePath = join(
@ -273,19 +257,26 @@ test.describe('Named view tests', () => {
await cmdBar.argumentInput.fill(myNamedView1) await cmdBar.argumentInput.fill(myNamedView1)
await cmdBar.progressCmdBar(false) await cmdBar.progressCmdBar(false)
let toastMessage = page.getByText('Named view uuid1 created.') await page.waitForTimeout(1000)
await expect(toastMessage).toBeInViewport()
await scene.moveCameraTo({ x: 608, y: 0, z: 0 }, { x: 0, y: 0, z: 0 }) const orbitMouseStart = { x: 800, y: 130 }
await page.waitForTimeout(2500) const orbitMouseEnd = { x: 0, y: 130 }
await page.mouse.move(orbitMouseStart.x, orbitMouseStart.y)
await page.mouse.down({ button: 'middle' })
await page.mouse.move(orbitMouseEnd.x, orbitMouseEnd.y, {
steps: 3,
})
await page.mouse.up({ button: 'middle' })
await page.waitForTimeout(1000)
await cmdBar.openCmdBar() await cmdBar.openCmdBar()
await cmdBar.chooseCommand('create named view') await cmdBar.chooseCommand('create named view')
await cmdBar.argumentInput.fill(myNamedView2) await cmdBar.argumentInput.fill(myNamedView2)
await cmdBar.progressCmdBar(false) await cmdBar.progressCmdBar(false)
toastMessage = page.getByText('Named view uuid2 created.') // Wait a moment for the project.toml to get written to disk with the new view point
await expect(toastMessage).toBeInViewport() await page.waitForTimeout(1000)
// Generate paths for the project.toml // Generate paths for the project.toml
const tempProjectSettingsFilePath = join( const tempProjectSettingsFilePath = join(

View File

@ -1,16 +0,0 @@
[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

@ -1,5 +1,16 @@
[settings] [settings]
app = { }
modeling = { } modeling = { }
text_editor = { } text_editor = { }
command_bar = { } 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

@ -1,28 +0,0 @@
[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

@ -17,12 +17,12 @@ version = 1
[settings.app.named_views.c810cf04-c6cc-4a4a-8b11-17bf445dcab7] [settings.app.named_views.c810cf04-c6cc-4a4a-8b11-17bf445dcab7]
name = "uuid2" name = "uuid2"
eye_offset = 608 eye_offset = 1_378.0059
fov_y = 45 fov_y = 45
is_ortho = false is_ortho = false
ortho_scale_enabled = true ortho_scale_enabled = true
ortho_scale_factor = 1.6 ortho_scale_factor = 1.6
pivot_position = [ 0, 0, 0 ] pivot_position = [ 1_826.5239, 0.0, 0.0 ]
pivot_rotation = [ 0.5, 0.5, 0.5, 0.5 ] pivot_rotation = [ 0.5380994, 0.0, 0.0, 0.8428814 ]
world_coord_system = "right_handed_up_z" world_coord_system = "right_handed_up_z"
version = 1 version = 1

View File

@ -7,7 +7,6 @@ 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,47 +1,13 @@
import * as fsp from 'fs/promises' import * as fsp from 'fs/promises'
import path from 'path' import path from 'path'
import type { CmdBarFixture } from '@e2e/playwright/fixtures/cmdBarFixture' import { executorInputPath } from '@e2e/playwright/test-utils'
import type { ToolbarFixture } from '@e2e/playwright/fixtures/toolbarFixture' import { test } from '@e2e/playwright/zoo-test'
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 parts into assembly as whole module import`, `Insert kcl part into assembly as whole module import`,
{ tag: ['@electron'] }, { tag: ['@electron'] },
async ({ async ({
context, context,
@ -57,14 +23,11 @@ test.describe('Point-and-click assemblies tests', () => {
fail() fail()
} }
const midPoint = { x: 500, y: 250 } // One dumb hardcoded screen pixel value
const partPoint = { x: midPoint.x + 30, y: midPoint.y - 30 } // mid point, just off top right const testPoint = { x: 575, y: 200 }
const defaultPlanesColor: [number, number, number] = [180, 220, 180] const initialColor: [number, number, number] = [50, 50, 50]
const partColor: [number, number, number] = [100, 100, 100] const partColor: [number, number, number] = [150, 150, 150]
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'
@ -73,219 +36,79 @@ 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.kcl'), executorInputPath('cylinder-inches.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 toolbar.closePane('code') await scene.expectPixelColor(initialColor, testPoint, tolerance)
await scene.expectPixelColor(defaultPlanesColor, midPoint, tolerance)
}) })
await test.step('Insert kcl as first part as module', async () => { await test.step('Insert first part into the assembly', async () => {
await insertPartIntoAssembly( await toolbar.insertButton.click()
'cylinder.kcl', await cmdBar.selectOption({ name: 'cylinder.kcl' }).click()
'cylinder', await cmdBar.expectState({
toolbar, stage: 'arguments',
cmdBar, currentArgKey: 'localName',
page currentArgValue: '',
) headerArguments: { Path: 'cylinder.kcl', LocalName: '' },
await toolbar.openPane('code') highlightedHeaderArg: 'localName',
await editor.expectEditor.toContain( commandName: 'Insert',
`
import "cylinder.kcl" as cylinder
cylinder
`,
{ shouldNormalise: true }
)
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 kcl second part as module', async () => {
await insertPartIntoAssembly(
'bracket.kcl',
'bracket',
toolbar,
cmdBar,
page
)
await editor.expectEditor.toContain(
`
import "cylinder.kcl" as cylinder
import "bracket.kcl" as bracket
cylinder
bracket
`,
{ 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 page.keyboard.insertText('cylinder')
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.progressCmdBar()
await cmdBar.expectState({ await cmdBar.expectState({
stage: 'review', stage: 'review',
headerArguments: { Path: complexPlmFileName, LocalName: 'cubeSw' }, headerArguments: { Path: 'cylinder.kcl', LocalName: 'cylinder' },
commandName: 'Insert', commandName: 'Insert',
}) })
await cmdBar.progressCmdBar() await cmdBar.progressCmdBar()
await toolbar.closePane('files')
await toolbar.openPane('code')
await editor.expectEditor.toContain( await editor.expectEditor.toContain(
` `
import "cube.step" as cube import "cylinder.kcl" as cylinder
import "${complexPlmFileName}" as cubeSw cylinder
cube
cubeSw
`, `,
{ shouldNormalise: true } { shouldNormalise: true }
) )
await scene.settled(cmdBar) await scene.expectPixelColor(partColor, testPoint, tolerance)
})
// TODO: remove this once #5780 is fixed await test.step('Insert second part into the assembly', async () => {
await page.reload() await toolbar.insertButton.click()
await scene.settled(cmdBar) await cmdBar.selectOption({ name: 'bracket.kcl' }).click()
await cmdBar.expectState({
await expect(page.locator('.cm-lint-marker-error')).not.toBeVisible() stage: 'arguments',
await toolbar.closePane('code') currentArgKey: 'localName',
await scene.expectPixelColor(partColor, partPoint, tolerance) currentArgValue: '',
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(
`
import "cylinder.kcl" as cylinder
import "bracket.kcl" as bracket
cylinder
bracket
`,
{ shouldNormalise: true }
)
}) })
} }
) )

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(angle=segAng(rectangleSegmentA001)-90,length=217.26,tag=$seg01) beforeChamferSnippet: `angledLine([segAng(rectangleSegmentA001)-90,217.26],%,$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(angle=0,length=11.39,tag=$rectangleSegmentA002) afterRectangle2ndClickSnippet: `angledLine([0,11.39],%,$rectangleSegmentA002)
|>angledLine(angle=segAng(rectangleSegmentA002)-90,length=105.26) |>angledLine([segAng(rectangleSegmentA002)-90,105.26],%)
|>angledLine(angle=segAng(rectangleSegmentA002),length=-segLen(rectangleSegmentA002)) |>angledLine([segAng(rectangleSegmentA002),-segLen(rectangleSegmentA002)],%)
|>line(endAbsolute=[profileStartX(%),profileStartY(%)]) |>line(endAbsolute=[profileStartX(%),profileStartY(%)])
|>close()`, |>close()`,
}) })
@ -234,7 +234,10 @@ 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(angle = segAng(rectangleSegmentA001) - 90, length = 217.26, tag = $seg01)chamfer( beforeChamferSnippet: `angledLine([
segAng(rectangleSegmentA001) - 90,
217.26
], %, $seg01)chamfer(
length = 30, length = 30,
tags = [ tags = [
seg01, seg01,
@ -247,9 +250,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(angle=0,length=11.56,tag=$rectangleSegmentA003) afterRectangle2ndClickSnippet: `angledLine([0,11.56],%,$rectangleSegmentA003)
|>angledLine(angle=segAng(rectangleSegmentA003)-90,length=106.84) |>angledLine([segAng(rectangleSegmentA003)-90,106.84],%)
|>angledLine(angle=segAng(rectangleSegmentA003),length=-segLen(rectangleSegmentA003)) |>angledLine([segAng(rectangleSegmentA003),-segLen(rectangleSegmentA003)],%)
|>line(endAbsolute=[profileStartX(%),profileStartY(%)]) |>line(endAbsolute=[profileStartX(%),profileStartY(%)])
|>close()`, |>close()`,
}) })
@ -258,7 +261,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(angle = 0, length = 268.43, tag = $rectangleSegmentA001)chamfer( beforeChamferSnippet: `angledLine([0, 268.43], %, $rectangleSegmentA001)chamfer(
length = 30, length = 30,
tags = [ tags = [
getNextAdjacentEdge(yo), getNextAdjacentEdge(yo),
@ -269,9 +272,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(angle=0,length=11.16,tag=$rectangleSegmentA004) afterRectangle2ndClickSnippet: `angledLine([0,11.16],%,$rectangleSegmentA004)
|>angledLine(angle=segAng(rectangleSegmentA004)-90,length=103.07) |>angledLine([segAng(rectangleSegmentA004)-90,103.07],%)
|>angledLine(angle=segAng(rectangleSegmentA004),length=-segLen(rectangleSegmentA004)) |>angledLine([segAng(rectangleSegmentA004),-segLen(rectangleSegmentA004)],%)
|>line(endAbsolute=[profileStartX(%),profileStartY(%)]) |>line(endAbsolute=[profileStartX(%),profileStartY(%)])
|>close()`, |>close()`,
}) })
@ -287,9 +290,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(angle=0,length=9.1,tag=$rectangleSegmentA005) afterRectangle2ndClickSnippet: `angledLine([0,9.1],%,$rectangleSegmentA005)
|>angledLine(angle=segAng(rectangleSegmentA005)-90,length=84.07) |>angledLine([segAng(rectangleSegmentA005)-90,84.07],%)
|>angledLine(angle=segAng(rectangleSegmentA005),length=-segLen(rectangleSegmentA005)) |>angledLine([segAng(rectangleSegmentA005),-segLen(rectangleSegmentA005)],%)
|>line(endAbsolute=[profileStartX(%),profileStartY(%)]) |>line(endAbsolute=[profileStartX(%),profileStartY(%)])
|>close()`, |>close()`,
}) })
@ -299,9 +302,15 @@ 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(angle = 0, length = 268.43, tag = $rectangleSegmentA001) |> angledLine([0, 268.43], %, $rectangleSegmentA001)
|> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 217.26, tag = $seg01) |> angledLine([
|> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001), tag = $yo) segAng(rectangleSegmentA001) - 90,
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)
@ -311,30 +320,48 @@ 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(angle = 0, length = 9.1, tag = $rectangleSegmentA005) |> angledLine([0, 9.1], %, $rectangleSegmentA005)
|> angledLine(angle = segAng(rectangleSegmentA005) - 90, length = 84.07) |> angledLine([segAng(rectangleSegmentA005) - 90, 84.07], %)
|> angledLine(angle = segAng(rectangleSegmentA005), length = -segLen(rectangleSegmentA005)) |> angledLine([segAng(rectangleSegmentA005), -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(angle = 0, length = 11.16, tag = $rectangleSegmentA004) |> angledLine([0, 11.16], %, $rectangleSegmentA004)
|> angledLine(angle = segAng(rectangleSegmentA004) - 90, length = 103.07) |> angledLine([
|> angledLine(angle = segAng(rectangleSegmentA004), length = -segLen(rectangleSegmentA004)) segAng(rectangleSegmentA004) - 90,
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(angle = 0, length = 11.56, tag = $rectangleSegmentA003) |> angledLine([0, 11.56], %, $rectangleSegmentA003)
|> angledLine(angle = segAng(rectangleSegmentA003) - 90, length = 106.84) |> angledLine([
|> angledLine(angle = segAng(rectangleSegmentA003), length = -segLen(rectangleSegmentA003)) segAng(rectangleSegmentA003) - 90,
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(angle = 0, length = 11.39, tag = $rectangleSegmentA002) |> angledLine([0, 11.39], %, $rectangleSegmentA002)
|> angledLine(angle = segAng(rectangleSegmentA002) - 90, length = 105.26) |> angledLine([
|> angledLine(angle = segAng(rectangleSegmentA002), length = -segLen(rectangleSegmentA002)) segAng(rectangleSegmentA002) - 90,
105.26
], %)
|> angledLine([
segAng(rectangleSegmentA002),
-segLen(rectangleSegmentA002)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
`, `,
@ -374,7 +401,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(angle=segAng(rectangleSegmentA001)-90,length=217.26,tag=$seg01) beforeChamferSnippet: `angledLine([segAng(rectangleSegmentA001)-90,217.26],%,$seg01)
chamfer(extrude001,length=30,tags=[ chamfer(extrude001,length=30,tags=[
seg01, seg01,
getNextAdjacentEdge(yo), getNextAdjacentEdge(yo),
@ -386,9 +413,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(angle=0,length=11.39,tag=$rectangleSegmentA002) afterRectangle2ndClickSnippet: `angledLine([0,11.39],%,$rectangleSegmentA002)
|>angledLine(angle=segAng(rectangleSegmentA002)-90,length=105.26) |>angledLine([segAng(rectangleSegmentA002)-90,105.26],%)
|>angledLine(angle=segAng(rectangleSegmentA002),length=-segLen(rectangleSegmentA002)) |>angledLine([segAng(rectangleSegmentA002),-segLen(rectangleSegmentA002)],%)
|>line(endAbsolute=[profileStartX(%),profileStartY(%)]) |>line(endAbsolute=[profileStartX(%),profileStartY(%)])
|>close()`, |>close()`,
}) })
@ -396,9 +423,15 @@ 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(angle = 0, length = 268.43, tag = $rectangleSegmentA001) |> angledLine([0, 268.43], %, $rectangleSegmentA001)
|> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 217.26, tag = $seg01) |> angledLine([
|> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001), tag = $yo) segAng(rectangleSegmentA001) - 90,
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)
@ -418,9 +451,15 @@ 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(angle = 0, length = 11.39, tag = $rectangleSegmentA002) |> angledLine([0, 11.39], %, $rectangleSegmentA002)
|> angledLine(angle = segAng(rectangleSegmentA002) - 90, length = 105.26) |> angledLine([
|> angledLine(angle = segAng(rectangleSegmentA002), length = -segLen(rectangleSegmentA002)) segAng(rectangleSegmentA002) - 90,
105.26
], %)
|> angledLine([
segAng(rectangleSegmentA002),
-segLen(rectangleSegmentA002)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
`, `,
@ -550,7 +589,7 @@ openSketch = startSketchOn(XY)
|> startProfileAt([-5, 0], %) |> startProfileAt([-5, 0], %)
|> line(endAbsolute = [0, 5]) |> line(endAbsolute = [0, 5])
|> xLine(length = 5) |> xLine(length = 5)
|> tangentialArc(endAbsolute = [10, 0]) |> tangentialArcTo([10, 0], %)
` `
const viewPortSize = { width: 1000, height: 500 } const viewPortSize = { width: 1000, height: 500 }
await page.setBodyDimensions(viewPortSize) await page.setBodyDimensions(viewPortSize)
@ -634,8 +673,8 @@ openSketch = startSketchOn(XY)
// Wait for enter sketch mode to complete // Wait for enter sketch mode to complete
await page.waitForTimeout(500) await page.waitForTimeout(500)
await editor.expectState({ await editor.expectState({
activeLines: [`|>tangentialArc(endAbsolute=[10,0])`], activeLines: [`|>tangentialArcTo([10,0],%)`],
highlightedCode: 'tangentialArc(endAbsolute=[10,0])', highlightedCode: 'tangentialArcTo([10,0],%)',
diagnostics: [], diagnostics: [],
}) })
}) })
@ -1624,7 +1663,7 @@ profile001 = circle(sketch001, center = [0, 0], radius = 500)
sketch002 = startSketchOn(XZ) sketch002 = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> xLine(length = -500) |> xLine(length = -500)
|> tangentialArc(endAbsolute = [-2000, 500])`, |> tangentialArcTo([-2000, 500], %)`,
}, },
{ {
targetType: 'rectangle', targetType: 'rectangle',
@ -1632,15 +1671,21 @@ 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(angle = 0, length = 800, tag = $rectangleSegmentA001) |> angledLine([0, 800], %, $rectangleSegmentA001)
|> angledLine(angle = segAng(rectangleSegmentA001) + 90, length = 800) |> angledLine([
|> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001)) segAng(rectangleSegmentA001) + 90,
800
], %)
|> angledLine([
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
sketch002 = startSketchOn(XZ) sketch002 = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> xLine(length = -500) |> xLine(length = -500)
|> tangentialArc(endAbsolute = [-2000, 500])`, |> tangentialArcTo([-2000, 500], %)`,
}, },
] ]
sweepCases.map(({ initialCode, targetType, testPoint }) => { sweepCases.map(({ initialCode, targetType, testPoint }) => {
@ -3437,29 +3482,26 @@ 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(angle = 0, length = 200.0, tag = $rectangleSegmentA001) |> angledLine([0, 200.0], %, $rectangleSegmentA001)
|> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 200, tag = $rectangleSegmentB001) |> angledLine([segAng(rectangleSegmentA001) - 90, 200], %, $rectangleSegmentB001)
|> angledLine( |> angledLine([
angle=segAng(rectangleSegmentA001), segAng(rectangleSegmentA001),
length=-segLen(rectangleSegmentA001), -segLen(rectangleSegmentA001)
tag=$rectangleSegmentC001, ], %, $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(angle = 180, length = 27.08, tag = $rectangleSegmentA002) |> angledLine([180, 27.08], %, $rectangleSegmentA002)
|> angledLine( |> angledLine([
angle=segAng(rectangleSegmentA002) - 90, segAng(rectangleSegmentA002) - 90,
length=27.8, 27.8
tag=$rectangleSegmentB002, ], %, $rectangleSegmentB002)
) |> angledLine([
|> angledLine( segAng(rectangleSegmentA002),
angle=segAng(rectangleSegmentA002), -segLen(rectangleSegmentA002)
length=-segLen(rectangleSegmentA002), ], %, $rectangleSegmentC002)
tag=$rectangleSegmentC002,
)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
` `
@ -3529,15 +3571,20 @@ tag=$rectangleSegmentC002,
}) => { }) => {
const initialCode = `sketch001 = startSketchOn(XZ) const initialCode = `sketch001 = startSketchOn(XZ)
|> startProfileAt([-102.57, 101.72], %) |> startProfileAt([-102.57, 101.72], %)
|> angledLine(angle = 0, length = 202.6, tag = $rectangleSegmentA001) |> angledLine([0, 202.6], %, $rectangleSegmentA001)
|> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 202.6, tag = $rectangleSegmentB001) |> angledLine([
|> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001), tag = $rectangleSegmentC001) segAng(rectangleSegmentA001) - 90,
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)
@ -3554,7 +3601,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(angle = 0, length = 202.6, tag = $rectangleSegmentA001)` const lineCodeToSelection = `angledLine([0, 202.6], %, $rectangleSegmentA001)`
await page.getByText(lineCodeToSelection).click() await page.getByText(lineCodeToSelection).click()
await cmdBar.progressCmdBar() await cmdBar.progressCmdBar()
await cmdBar.progressCmdBar() await cmdBar.progressCmdBar()
@ -3611,23 +3658,22 @@ sketch002 = startSketchOn(extrude001, rectangleSegmentA001)
toolbar, toolbar,
cmdBar, cmdBar,
}) => { }) => {
const initialCode = ` const initialCode = `sketch002 = startSketchOn(XY)
sketch002 = startSketchOn(XY) |> startProfileAt([-2.02, 1.79], %)
|> startProfileAt([-2.02, 1.79], %) |> xLine(length = 2.6)
|> xLine(length = 2.6) sketch001 = startSketchOn(-XY)
sketch001 = startSketchOn('-XY') |> startProfileAt([-0.48, 1.25], %)
|> startProfileAt([-0.48, 1.25], %) |> angledLine([0, 2.38], %, $rectangleSegmentA001)
|> angledLine(angle = 0, length = 2.38, tag = $rectangleSegmentA001) |> angledLine([segAng(rectangleSegmentA001) - 90, 2.4], %, $rectangleSegmentB001)
|> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 2.4, tag = $rectangleSegmentB001) |> angledLine([
|> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001), tag = $rectangleSegmentC001) segAng(rectangleSegmentA001),
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) -segLen(rectangleSegmentA001)
|> close() ], %, $rectangleSegmentC001)
extrude001 = extrude(sketch001, length = 5) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
sketch003 = startSketchOn(extrude001, 'START') |> close()
|> circle( extrude001 = extrude(sketch001, length = 5)
center = [-0.69, 0.56], sketch003 = startSketchOn(extrude001, 'START')
radius = 0.28 |> circle(center = [-0.69, 0.56], radius = 0.28)
)
` `
await context.addInitScript((initialCode) => { await context.addInitScript((initialCode) => {

View File

@ -41,13 +41,15 @@ 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(angle = 0, length = 176.4, tag = $rectangleSegmentA001) |> angledLine([0, 176.4], %, $rectangleSegmentA001)
|> angledLine( |> angledLine([
angle = segAng(rectangleSegmentA001) - 90, segAng(rectangleSegmentA001) - 90,
length = 53.4, 53.4
tag = $rectangleSegmentB001, ], %, $rectangleSegmentB001)
) |> angledLine([
|> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001), tag = $rectangleSegmentC001) 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)
@ -68,10 +70,13 @@ 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,9 +22,15 @@ 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(angle = 0, length = 176.4, tag = $rectangleSegmentA001) |> angledLine([0, 176.4], %, $rectangleSegmentA001)
|> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 53.4, tag = $rectangleSegmentB001) |> angledLine([
|> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001), tag = $rectangleSegmentC001) segAng(rectangleSegmentA001) - 90,
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)
@ -51,7 +57,6 @@ 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)
@ -260,7 +265,6 @@ 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,9 +68,15 @@ 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(angle = 0, length = 288.63, tag = $rectangleSegmentA001) |> angledLine([0, 288.63], %, $rectangleSegmentA001)
|> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 197.97, tag = $rectangleSegmentB001) |> angledLine([
|> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001), tag = $rectangleSegmentC001) segAng(rectangleSegmentA001) - 90,
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)
@ -251,7 +257,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()
|> |>
@ -307,7 +313,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()
@ -328,9 +334,15 @@ 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(angle = 0, length = 181.26, tag = $rectangleSegmentA001) |> angledLine([0, 181.26], %, $rectangleSegmentA001)
|> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 21.54) |> angledLine([
|> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001)) segAng(rectangleSegmentA001) - 90,
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

@ -63,7 +63,7 @@ test.describe('Sketch tests', { tag: ['@skipWin'] }, () => {
part002 = startSketchOn(-XZ) part002 = startSketchOn(-XZ)
${startProfileAt3} ${startProfileAt3}
|> xLine(length = width / 4) |> xLine(length = width / 4)
|> tangentialArc(endAbsolute = [width / 2, 0]) |> tangentialArcTo([width / 2, 0], %)
|> xLine(length = -width / 4 + wireRadius) |> xLine(length = -width / 4 + wireRadius)
|> yLine(length = wireOffset) |> yLine(length = wireOffset)
|> arc({ |> arc({
@ -119,7 +119,7 @@ test.describe('Sketch tests', { tag: ['@skipWin'] }, () => {
sketch001 = startSketchOn(XZ) sketch001 = startSketchOn(XZ)
|> startProfileAt([2.61, -4.01], %) |> startProfileAt([2.61, -4.01], %)
|> xLine(length = 8.73) |> xLine(length = 8.73)
|> tangentialArc(endAbsolute = [8.33, -1.31])` |> tangentialArcTo([8.33, -1.31], %)`
) )
}) })
@ -130,7 +130,7 @@ sketch001 = startSketchOn(XZ)
await expect(async () => { await expect(async () => {
await page.mouse.click(700, 200) await page.mouse.click(700, 200)
await page.getByText('tangentialArc(endAbsolute = [8.33, -1.31])').click() await page.getByText('tangentialArcTo([8.33, -1.31], %)').click()
await expect( await expect(
page.getByRole('button', { name: 'Edit Sketch' }) page.getByRole('button', { name: 'Edit Sketch' })
).toBeEnabled({ timeout: 2000 }) ).toBeEnabled({ timeout: 2000 })
@ -139,7 +139,7 @@ sketch001 = startSketchOn(XZ)
await page.waitForTimeout(600) // wait for animation await page.waitForTimeout(600) // wait for animation
await page.getByText('tangentialArc(endAbsolute = [8.33, -1.31])').click() await page.getByText('tangentialArcTo([8.33, -1.31], %)').click()
await page.keyboard.press('End') await page.keyboard.press('End')
await page.keyboard.down('Shift') await page.keyboard.down('Shift')
await page.keyboard.press('ArrowUp') await page.keyboard.press('ArrowUp')
@ -212,7 +212,7 @@ sketch001 = startProfileAt([12.34, -12.34], sketch002)
`sketch001 = startSketchOn(XZ) `sketch001 = startSketchOn(XZ)
|> startProfileAt([4.61, -14.01], %) |> startProfileAt([4.61, -14.01], %)
|> line(end = [12.73, -0.09]) |> line(end = [12.73, -0.09])
|> tangentialArc(endAbsolute = [24.95, -5.38]) |> tangentialArcTo([24.95, -5.38], %)
|> arcTo({ |> arcTo({
interior = [20.18, -1.7], interior = [20.18, -1.7],
end = [11.82, -1.16] end = [11.82, -1.16]
@ -262,7 +262,7 @@ sketch001 = startProfileAt([12.34, -12.34], sketch002)
await expect(u.codeLocator).toHaveText(`sketch001 = startSketchOn(XZ) await expect(u.codeLocator).toHaveText(`sketch001 = startSketchOn(XZ)
|> startProfileAt([4.61, -14.01], %) |> startProfileAt([4.61, -14.01], %)
|> line(end = [12.73, -0.09]) |> line(end = [12.73, -0.09])
|> tangentialArc(endAbsolute = [24.95, -5.38]) |> tangentialArcTo([24.95, -5.38], %)
|> arcTo({ |> arcTo({
interior = [20.18, -1.7], interior = [20.18, -1.7],
end = [11.82, -1.16] end = [11.82, -1.16]
@ -326,7 +326,7 @@ sketch001 = startProfileAt([12.34, -12.34], sketch002)
prevContent = await page.locator('.cm-content').innerText() prevContent = await page.locator('.cm-content').innerText()
} }
// drag tangentialArc handle // drag tangentialArcTo handle
const tangentEnd = await u.getBoundingBox('[data-overlay-index="1"]') const tangentEnd = await u.getBoundingBox('[data-overlay-index="1"]')
await page.mouse.move(tangentEnd.x, tangentEnd.y - 5) await page.mouse.move(tangentEnd.x, tangentEnd.y - 5)
await page.mouse.down() await page.mouse.down()
@ -407,7 +407,7 @@ sketch001 = startProfileAt([12.34, -12.34], sketch002)
.toHaveText(`sketch001 = startSketchOn(XZ) .toHaveText(`sketch001 = startSketchOn(XZ)
|> startProfileAt([6.44, -12.07], %) |> startProfileAt([6.44, -12.07], %)
|> line(end = [14.72, 1.97]) |> line(end = [14.72, 1.97])
|> tangentialArc(endAbsolute = [26.92, -3.32]) |> tangentialArcTo([26.92, -3.32], %)
|> arcTo({ |> arcTo({
interior = [18.11, -3.73], interior = [18.11, -3.73],
end = [9.77, -3.19] end = [9.77, -3.19]
@ -577,7 +577,7 @@ sketch001 = startSketchOn(XZ)
sketch001 = startSketchOn(XZ) sketch001 = startSketchOn(XZ)
|> startProfileAt([4.61, -10.01], %) |> startProfileAt([4.61, -10.01], %)
|> line(end = [12.73, -0.09]) |> line(end = [12.73, -0.09])
|> tangentialArc(endAbsolute = [24.95, -0.38]) |> tangentialArcTo([24.95, -0.38], %)
|> close() |> close()
|> extrude(length = 5)` |> extrude(length = 5)`
) )
@ -646,7 +646,7 @@ sketch001 = startSketchOn(XZ)
await expect(page.locator('.cm-content')).not.toHaveText(prevContent) await expect(page.locator('.cm-content')).not.toHaveText(prevContent)
prevContent = await page.locator('.cm-content').innerText() prevContent = await page.locator('.cm-content').innerText()
// drag tangentialArc handle // drag tangentialArcTo handle
const tangentEnd = await u.getBoundingBox('[data-overlay-index="1"]') const tangentEnd = await u.getBoundingBox('[data-overlay-index="1"]')
await page.dragAndDrop('#stream', '#stream', { await page.dragAndDrop('#stream', '#stream', {
sourcePosition: { x: tangentEnd.x + 10, y: tangentEnd.y - 5 }, sourcePosition: { x: tangentEnd.x + 10, y: tangentEnd.y - 5 },
@ -663,7 +663,7 @@ sketch001 = startSketchOn(XZ)
`sketch001 = startSketchOn(XZ) `sketch001 = startSketchOn(XZ)
|> startProfileAt([7.12, -12.68], %) |> startProfileAt([7.12, -12.68], %)
|> line(end = [12.68, -1.09]) |> line(end = [12.68, -1.09])
|> tangentialArc(endAbsolute = [24.89, 0.68]) |> tangentialArcTo([24.89, 0.68], %)
|> close() |> close()
|> extrude(length = 5)`, |> extrude(length = 5)`,
{ shouldNormalise: true } { shouldNormalise: true }
@ -685,7 +685,7 @@ sketch001 = startSketchOn(XZ)
sketch001 = startSketchOn(XZ) sketch001 = startSketchOn(XZ)
|> startProfileAt([4.61, -14.01], %) |> startProfileAt([4.61, -14.01], %)
|> line(end = [12.73, -0.09]) |> line(end = [12.73, -0.09])
|> tangentialArc(endAbsolute = [24.95, -5.38]) |> tangentialArcTo([24.95, -5.38], %)
|> close() |> close()
|> revolve(axis = X)` |> revolve(axis = X)`
) )
@ -757,7 +757,7 @@ sketch001 = startSketchOn(XZ)
await expect(page.locator('.cm-content')).not.toHaveText(prevContent) await expect(page.locator('.cm-content')).not.toHaveText(prevContent)
prevContent = await page.locator('.cm-content').innerText() prevContent = await page.locator('.cm-content').innerText()
// drag tangentialArc handle // drag tangentialArcTo handle
const tangentEnd = await u.getBoundingBox('[data-overlay-index="1"]') const tangentEnd = await u.getBoundingBox('[data-overlay-index="1"]')
await page.mouse.move(tangentEnd.x, tangentEnd.y - 5) await page.mouse.move(tangentEnd.x, tangentEnd.y - 5)
await page.mouse.down() await page.mouse.down()
@ -771,7 +771,7 @@ sketch001 = startSketchOn(XZ)
`sketch001 = startSketchOn(XZ) `sketch001 = startSketchOn(XZ)
|> startProfileAt([6.44, -12.07], %) |> startProfileAt([6.44, -12.07], %)
|> line(end = [14.72, 1.97]) |> line(end = [14.72, 1.97])
|> tangentialArc(endAbsolute = [24.95, -5.38]) |> tangentialArcTo([24.95, -5.38], %)
|> line(end = [1.97, 2.06]) |> line(end = [1.97, 2.06])
|> close() |> close()
|> revolve(axis = X)`, |> revolve(axis = X)`,
@ -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]], %)
|> angledLine(angle = 60, lengthY = lugHeadLength) |> angledLineOfYLength({ angle = 60, length = lugHeadLength }, %)
|> xLine(endAbsolute = 0 + .001) |> xLine(endAbsolute = 0 + .001)
|> yLine(endAbsolute = 0) |> yLine(endAbsolute = 0)
|> close() |> close()
@ -1653,7 +1653,7 @@ profile003 = startProfileAt([206.63, -56.73], sketch001)
await page.waitForTimeout(600) await page.waitForTimeout(600)
}) })
const codeFromTangentialArc = ` |> tangentialArc(endAbsolute = [39.49, 88.22])` const codeFromTangentialArc = ` |> tangentialArcTo([39.49, 88.22], %)`
await test.step('check that tangential tool does not snap to other profile starts', async () => { await test.step('check that tangential tool does not snap to other profile starts', async () => {
await toolbar.tangentialArcBtn.click() await toolbar.tangentialArcBtn.click()
await page.waitForTimeout(1000) await page.waitForTimeout(1000)
@ -1675,7 +1675,7 @@ profile003 = startProfileAt([206.63, -56.73], sketch001)
// check pixel is now gray at tanArcLocation to verify code has executed // check pixel is now gray at tanArcLocation to verify code has executed
await scene.expectPixelColor([26, 26, 26], tanArcLocation, 15) await scene.expectPixelColor([26, 26, 26], tanArcLocation, 15)
await editor.expectEditor.not.toContain( await editor.expectEditor.not.toContain(
`tangentialArc(endAbsolute = [39.49, 88.22])` `tangentialArcTo([39.49, 88.22], %)`
) )
}) })
@ -1876,7 +1876,7 @@ profile003 = startProfileAt([206.63, -56.73], sketch001)
await endArcStartLine() await endArcStartLine()
await editor.expectEditor.toContain( await editor.expectEditor.toContain(
`|> tangentialArc(endAbsolute = [16.61, 4.14])` `|> tangentialArcTo([16.61, 4.14], %)`
) )
// Add a three-point arc segment // Add a three-point arc segment
@ -1977,9 +1977,12 @@ profile003 = startProfileAt([206.63, -56.73], sketch001)
) )
await crnRect1point2() await crnRect1point2()
await editor.expectEditor.toContain( await editor.expectEditor.toContain(
`|> angledLine(angle = 0, length = 2.37, tag = $rectangleSegmentA001) `|> angledLine([0, 2.37], %, $rectangleSegmentA001)
|> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 7.8) |> angledLine([segAng(rectangleSegmentA001) - 90, 7.8], %)
|> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001)) |> angledLine([
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()`.replaceAll('\n', '') |> close()`.replaceAll('\n', '')
) )
@ -1992,9 +1995,15 @@ 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(angle = 0, length = 5.49, tag = $rectangleSegmentA002) `|> angledLine([0, 5.49], %, $rectangleSegmentA002)
|> angledLine(angle = segAng(rectangleSegmentA002) - 90, length = 4.14) |> angledLine([
|> angledLine(angle = segAng(rectangleSegmentA002), length = -segLen(rectangleSegmentA002)) segAng(rectangleSegmentA002) - 90,
4.14
], %)
|> angledLine([
segAng(rectangleSegmentA002),
-segLen(rectangleSegmentA002)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()`.replaceAll('\n', '') |> close()`.replaceAll('\n', '')
) )
@ -2011,9 +2020,15 @@ 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(angle = 0, length = 7.06, tag = $rectangleSegmentA003) `|> angledLine([0, 7.06], %, $rectangleSegmentA003)
|> angledLine(angle = segAng(rectangleSegmentA003) + 90, length = 4.34) |> angledLine([
|> angledLine(angle = segAng(rectangleSegmentA003), length = -segLen(rectangleSegmentA003)) segAng(rectangleSegmentA003) + 90,
4.34
], %)
|> angledLine([
segAng(rectangleSegmentA003),
-segLen(rectangleSegmentA003)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()`.replaceAll('\n', '') |> close()`.replaceAll('\n', '')
) )
@ -2027,9 +2042,15 @@ 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(angle = 0, length = 3.12, tag = $rectangleSegmentA004) `|> angledLine([0, 3.12], %, $rectangleSegmentA004)
|> angledLine(angle = segAng(rectangleSegmentA004) + 90, length = 6.24) |> angledLine([
|> angledLine(angle = segAng(rectangleSegmentA004), length = -segLen(rectangleSegmentA004)) segAng(rectangleSegmentA004) + 90,
6.24
], %)
|> angledLine([
segAng(rectangleSegmentA004),
-segLen(rectangleSegmentA004)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()`.replaceAll('\n', '') |> close()`.replaceAll('\n', '')
) )
@ -2183,9 +2204,15 @@ 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(angle = 0, length = 10.78, tag = $rectangleSegmentA001) |> angledLine([0, 10.78], %, $rectangleSegmentA001)
|> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 4.14) |> angledLine([
|> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001)) segAng(rectangleSegmentA001) - 90,
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)
@ -2255,7 +2282,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(angle = -7, length = 10.27, tag = $rectangleSegmentA001)` `angledLine([-7, 10.27], %, $rectangleSegmentA001)`
) )
}) })
@ -2295,9 +2322,15 @@ 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(angle = 180, length = 1.97, tag = $rectangleSegmentA002) `|> angledLine([180, 1.97], %, $rectangleSegmentA002)
|> angledLine(angle = segAng(rectangleSegmentA002) + 90, length = 3.89) |> angledLine([
|> angledLine(angle = segAng(rectangleSegmentA002), length = -segLen(rectangleSegmentA002)) segAng(rectangleSegmentA002) + 90,
3.89
], %)
|> angledLine([
segAng(rectangleSegmentA002),
-segLen(rectangleSegmentA002)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()`.replaceAll('\n', '') |> close()`.replaceAll('\n', '')
) )
@ -2318,9 +2351,15 @@ 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(angle = 0, length = 10.78, tag = $rectangleSegmentA001) |> angledLine([0, 10.78], %, $rectangleSegmentA001)
|> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 4.14) |> angledLine([
|> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001)) segAng(rectangleSegmentA001) - 90,
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)
@ -2416,14 +2455,20 @@ sketch001 = startSketchOn(XZ)
profile001 = startProfileAt([-63.43, 193.08], sketch001) profile001 = startProfileAt([-63.43, 193.08], sketch001)
|> line(end = [168.52, 149.87]) |> line(end = [168.52, 149.87])
|> line(end = [190.29, -39.18]) |> line(end = [190.29, -39.18])
|> tangentialArc(endAbsolute = [319.63, 129.65]) |> tangentialArcTo([319.63, 129.65], %)
|> line(end = [-217.65, -21.76]) |> line(end = [-217.65, -21.76])
|> 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(angle = 0, length = 182.82, tag = $rectangleSegmentA001) |> angledLine([0, 182.82], %, $rectangleSegmentA001)
|> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 105.71) |> angledLine([
|> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001)) segAng(rectangleSegmentA001) - 90,
105.71
], %)
|> angledLine([
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
profile004 = circle( profile004 = circle(
@ -2639,9 +2684,15 @@ 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(angle = 0, length = 6.64, tag = $rectangleSegmentA001) |> angledLine([0, 6.64], %, $rectangleSegmentA001)
|> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 2.81) |> angledLine([
|> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001)) segAng(rectangleSegmentA001) - 90,
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)
@ -2681,9 +2732,15 @@ profile010 = circle(
radius = 2.67 radius = 2.67
) )
profile011 = startProfileAt([5.07, -6.39], sketch003) profile011 = startProfileAt([5.07, -6.39], sketch003)
|> angledLine(angle = 0, length = 4.54, tag = $rectangleSegmentA002) |> angledLine([0, 4.54], %, $rectangleSegmentA002)
|> angledLine(angle = segAng(rectangleSegmentA002) - 90, length = 4.17) |> angledLine([
|> angledLine(angle = segAng(rectangleSegmentA002), length = -segLen(rectangleSegmentA002)) segAng(rectangleSegmentA002) - 90,
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)
@ -2832,7 +2889,7 @@ loft([profile001, profile002])
) )
await rect1Crn2() await rect1Crn2()
await editor.expectEditor.toContain( await editor.expectEditor.toContain(
`angledLine(angle = 0, length = 113.01, tag = $rectangleSegmentA001)` `angledLine([0, 113.01], %, $rectangleSegmentA001)`
) )
} }
) )
@ -2903,7 +2960,7 @@ loft([profile001, profile002])
) )
await rect1Crn2() await rect1Crn2()
await editor.expectEditor.toContain( await editor.expectEditor.toContain(
`angledLine(angle = 0, length = 106.42], tag = $rectangleSegmentA001)` `angledLine([0, 106.42], %, $rectangleSegmentA001)`
) )
await page.waitForTimeout(100) await page.waitForTimeout(100)
}) })

View File

@ -70,11 +70,10 @@ part001 = startSketchOn(-XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> yLine(length = baseHeight) |> yLine(length = baseHeight)
|> xLine(length = baseLen) |> xLine(length = baseLen)
|> angledLine( |> angledLineToY({
angle = topAng, angle = topAng,
endAbsoluteY = totalHeightHalf, to = totalHeightHalf,
tag = $seg04, }, %, $seg04)
)
|> xLine(endAbsolute = totalLen, tag = $seg03) |> xLine(endAbsolute = totalLen, tag = $seg03)
|> yLine(length = -armThick, tag = $seg01) |> yLine(length = -armThick, tag = $seg01)
|> angledLineThatIntersects({ |> angledLineThatIntersects({
@ -82,12 +81,11 @@ part001 = startSketchOn(-XZ)
offset = -armThick, offset = -armThick,
intersectTag = seg04 intersectTag = seg04
}, %) }, %)
|> angledLine(angle = segAng(seg04, %) + 180, endAbsoluteY = turns::ZERO) |> angledLineToY([segAng(seg04, %) + 180, turns::ZERO], %)
|> angledLine( |> angledLineToY({
angle = -bottomAng, angle = -bottomAng,
endAbsoluteY = -totalHeightHalf - armThick, to = -totalHeightHalf - armThick,
tag = $seg02, }, %, $seg02)
)
|> xLine(length = endAbsolute = segEndX(seg03) + 0) |> xLine(length = endAbsolute = segEndX(seg03) + 0)
|> yLine(length = -segLen(seg01, %)) |> yLine(length = -segLen(seg01, %))
|> angledLineThatIntersects({ |> angledLineThatIntersects({
@ -95,7 +93,7 @@ part001 = startSketchOn(-XZ)
offset = -armThick, offset = -armThick,
intersectTag = seg02 intersectTag = seg02
}, %) }, %)
|> angledLine(angle = segAng(seg02, %) + 180, endAbsoluteY = -baseHeight) |> angledLineToY([segAng(seg02, %) + 180, -baseHeight], %)
|> xLine(endAbsolute = turns::ZERO) |> xLine(endAbsolute = turns::ZERO)
|> close() |> close()
|> extrude(length = 4)` |> extrude(length = 4)`
@ -588,7 +586,6 @@ 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
@ -684,7 +681,7 @@ test.describe(
await page.mouse.click(startXPx + PUR * 30, 500 - PUR * 20) await page.mouse.click(startXPx + PUR * 30, 500 - PUR * 20)
code += ` code += `
|> tangentialArc(endAbsolute = [551.2, -62.01])` |> tangentialArcTo([551.2, -62.01], %)`
await expect(u.codeLocator).toHaveText(code) await expect(u.codeLocator).toHaveText(code)
// click tangential arc tool again to unequip it // click tangential arc tool again to unequip it
@ -778,7 +775,7 @@ test.describe(
await page.mouse.click(startXPx + PUR * 30, 500 - PUR * 20) await page.mouse.click(startXPx + PUR * 30, 500 - PUR * 20)
code += ` code += `
|> tangentialArc(endAbsolute = [551.2, -62.01])` |> tangentialArcTo([551.2, -62.01], %)`
await expect(u.codeLocator).toHaveText(code) await expect(u.codeLocator).toHaveText(code)
await page await page

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(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", "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",
"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(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", "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",
"prompt": "make this neon green please, use #39FF14", "prompt": "make this neon green please, use #39FF14",
"source_ranges": [ "source_ranges": [
{ {
@ -30,4 +30,4 @@
} }
], ],
"kcl_version": "0.2.57" "kcl_version": "0.2.57"
} }

View File

@ -84,21 +84,21 @@ 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)
|> angledLine(angle = 3 + 0, lengthX = 3.14 ) |> angledLineOfXLength({ angle: 3 + 0, length: 3.14 }, %)
|> angledLine(angle = 30, lengthY = 3 + 0 ) |> angledLineOfYLength({ angle: 30, length: 3 + 0 }, %)
|> angledLine(angle = 22.14 + 0, endAbsoluteX = 12) |> angledLineToX({ angle: 22.14 + 0, to: 12 }, %)
|> angledLine(angle = 30, endAbsoluteY = 11.14) |> angledLineToY({ angle: 30, to: 11.14 }, %)
|> angledLineThatIntersects({ |> angledLineThatIntersects({
angle: 3.14, angle: 3.14,
intersectTag: a, intersectTag: a,
offset: 0 offset: 0
}, %) }, %)
|> tangentialArc(endAbsolute = [13.14 + 0, 13.14]) |> tangentialArcTo([13.14 + 0, 13.14], %)
|> close() |> close()
|> extrude(length = 5 + 7) |> extrude(length = 5 + 7)
` `

View File

@ -1,15 +0,0 @@
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,10 +1021,6 @@ 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>,
@ -1140,7 +1136,7 @@ export function tomlToPerProjectSettings(
return TOML.parse(toml) return TOML.parse(toml)
} }
export function perProjectSettingsToToml( export function perProjectsettingsToToml(
settings: DeepPartial<ProjectConfiguration> settings: DeepPartial<ProjectConfiguration>
) { ) {
// eslint-disable-next-line no-restricted-syntax // eslint-disable-next-line no-restricted-syntax

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(angle = 90, length = length001) |> xLine(length = -20)` `length001 = 20sketch001 = startSketchOn(XY) |> startProfileAt([-10, -10], %) |> line(end = [20, 0]) |> angledLine([90, 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(angle = segAng(seg01), length = yo) |> angledLine([segAng(seg01), 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: 'constraints: open menu', name: 'Length: 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(angle = segAng(seg01), length = 78.33) |> angledLine([segAng(seg01), 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: 'constraints: open menu', name: 'Length: 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: 'constraints: open menu', name: 'Length: 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: 'constraints: open menu', name: 'Length: 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: 'constraints: open menu', name: 'Length: 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(angle = ${value}, length = 78.33)`, `|> angledLine([${value}, 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: 'constraints: open menu', name: 'Length: open menu',
}) })
.click() .click()
await page.getByTestId('dropdown-constraint-' + constraint).click() await page.getByTestId('dropdown-constraint-' + constraint).click()
@ -639,8 +639,7 @@ test.describe('Testing constraints', { tag: ['@skipWin'] }, () => {
.getByRole('button', { name: 'Add constraining value' }) .getByRole('button', { name: 'Add constraining value' })
.click() .click()
const [ang, len] = value.split(', ') const changedCode = `|> angledLine([${value}], %)`
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)
@ -720,7 +719,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: 'constraints: open menu', name: 'Length: open menu',
}) })
.click() .click()
await page.getByTestId('dropdown-constraint-' + constraint).click() await page.getByTestId('dropdown-constraint-' + constraint).click()
@ -734,8 +733,7 @@ part002 = startSketchOn(XZ)
await expect(cmdBarKclInput).toHaveText('78.33') await expect(cmdBarKclInput).toHaveText('78.33')
await cmdBarSubmitButton.click() await cmdBarSubmitButton.click()
const [ang, len] = value.split(', ') const changedCode = `|> angledLine([${value}], %)`
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)
@ -819,7 +817,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: 'constraints: open menu', name: 'Length: open menu',
}) })
const constraintButton = page const constraintButton = page
.getByRole('button', { .getByRole('button', {
@ -850,11 +848,11 @@ part002 = startSketchOn(XZ)
test.describe('Two segment - no modal constraints', () => { test.describe('Two segment - no modal constraints', () => {
const cases = [ const cases = [
{ {
codeAfter: `|> angledLine(angle = 83, length = segLen(seg01))`, codeAfter: `|> angledLine([83, segLen(seg01)], %)`,
constraintName: 'Equal Length', constraintName: 'Equal Length',
}, },
{ {
codeAfter: `|> angledLine(angle = segAng(seg01), length = 78.33)`, codeAfter: `|> angledLine([segAng(seg01), 78.33], %)`,
constraintName: 'Parallel', constraintName: 'Parallel',
}, },
{ {
@ -907,7 +905,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: 'constraints: open menu', name: 'Length: open menu',
}) })
const constraintButton = page.getByRole('button', { const constraintButton = page.getByRole('button', {
name: constraintName, name: constraintName,
@ -992,7 +990,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: 'constraints: open menu', name: 'Length: open menu',
}) })
const constraintButton = page.getByRole('button', { const constraintButton = page.getByRole('button', {
name: constraintName, name: constraintName,
@ -1059,7 +1057,7 @@ part002 = startSketchOn(XZ)
await page await page
.getByRole('button', { .getByRole('button', {
name: 'constraints: open menu', name: 'Length: open menu',
}) })
.click() .click()
await page.waitForTimeout(500) await page.waitForTimeout(500)
@ -1131,7 +1129,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(angle = segAng(seg01), length = 12.35) |> angledLine([segAng(seg01), 12.35], %)
|> line(end = [-13.02, 10.03]) |> line(end = [-13.02, 10.03])
|> close() |> close()
|> extrude(length = 4)`, |> extrude(length = 4)`,
@ -1171,9 +1169,7 @@ 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( await editor.expectEditor.toContain('|> angledLine([9, length001], %)')
'|> 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,9 +259,15 @@ 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(angle = 0, length = 105.13, tag = $rectangleSegmentA001) |> angledLine([0, 105.13], %, $rectangleSegmentA001)
|> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 77.9) |> angledLine([
|> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001)) segAng(rectangleSegmentA001) - 90,
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,22 +214,22 @@ 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)
|> angledLine(angle = 181 + 0, lengthX = 23.14) |> angledLineOfXLength({ angle = 181 + 0, length = 23.14 }, %)
|> angledLine(angle = -91, lengthY = 19 + 0) |> angledLineOfYLength({ angle = -91, length = 19 + 0 }, %)
|> angledLine(angle = 3 + 0, endAbsoluteX = 5 + 26) |> angledLineToX({ angle = 3 + 0, to = 5 + 26 }, %)
|> angledLine(angle = 89, endAbsoluteY = 20 + 9.14 + 0) |> angledLineToY({ angle = 89, to = 20 + 9.14 + 0 }, %)
|> angledLineThatIntersects({ |> angledLineThatIntersects({
angle = 4.14, angle = 4.14,
intersectTag = a, intersectTag = a,
offset = 9 offset = 9
}, %) }, %)
|> tangentialArc(endAbsolute = [5 + 3.14 + 13, 20 + 3.14]) |> tangentialArcTo([5 + 3.14 + 13, 20 + 3.14], %)
` `
) )
}) })
@ -306,9 +306,11 @@ 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: 'angledLine(angle = 3 + 0, length = 32 + 0)', expectBeforeUnconstrained:
expectAfterUnconstrained: 'angledLine(angle = 3, length = 32 + 0)', 'angledLine({ angle = 3 + 0, length = 32 + 0 }, %)',
expectFinal: 'angledLine(angle = angle001, length = 32 + 0)', expectAfterUnconstrained:
'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"]',
}) })
@ -317,9 +319,10 @@ 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: 'angledLine(angle = angle001, length = 32)', expectAfterUnconstrained:
expectFinal: 'angledLine(angle = angle001, length = len001)', 'angledLine({ angle = angle001, length = 32 }, %)',
expectFinal: 'angledLine({ angle = angle001, length = len001 }, %)',
ang: ang + 180, ang: ang + 180,
locator: '[data-overlay-toolbar-index="1"]', locator: '[data-overlay-toolbar-index="1"]',
}) })
@ -389,13 +392,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)
|> angledLine(angle = 181 + 0, lengthX = 23.14) |> angledLineOfXLength({ angle = 181 + 0, length = 23.14 }, %)
` `
) )
}) })
@ -462,22 +465,22 @@ 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)
|> angledLine(angle = 181 + 0, lengthX = 23.14) |> angledLineOfXLength({ angle = 181 + 0, length = 23.14 }, %)
|> angledLine(angle = -91, lengthY = 19 + 0) |> angledLineOfYLength({ angle = -91, length = 19 + 0 }, %)
|> angledLine(angle = 3 + 0, endAbsoluteX = 26) |> angledLineToX({ angle = 3 + 0, to = 26 }, %)
|> angledLine(angle = 89, endAbsoluteY = 9.14 + 0) |> angledLineToY({ angle = 89, to = 9.14 + 0 }, %)
|> angledLineThatIntersects({ |> angledLineThatIntersects({
angle = 4.14, angle = 4.14,
intersectTag = a, intersectTag = a,
offset = 9 offset = 9
}, %) }, %)
|> tangentialArc(endAbsolute = [3.14 + 13, 3.14]) |> tangentialArcTo([3.14 + 13, 3.14], %)
` `
) )
localStorage.setItem('disableAxis', 'true') localStorage.setItem('disableAxis', 'true')
@ -527,9 +530,11 @@ 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:
'angledLine(angle = 181 + 0, lengthX = 23.14)', 'angledLineOfXLength({ angle = 181 + 0, length = 23.14 }, %)',
expectAfterUnconstrained: 'angledLine(angle = -179, lengthX = 23.14)', expectAfterUnconstrained:
expectFinal: 'angledLine(angle = angle001, lengthX = 23.14)', 'angledLineOfXLength({ angle = -179, length = 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"]',
}) })
@ -538,10 +543,11 @@ 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:
'angledLine(angle = angle001, lengthX = 23.14)', 'angledLineOfXLength({ angle = angle001, length = 23.14 }, %)',
expectAfterUnconstrained: expectAfterUnconstrained:
'angledLine(angle = angle001, lengthX = xRel001)', 'angledLineOfXLength({ angle = angle001, length = xRel001 }, %)',
expectFinal: 'angledLine(angle = angle001, lengthX = 23.14)', expectFinal:
'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"]',
@ -555,10 +561,11 @@ 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: 'angledLine(angle = -91, lengthY = 19 + 0)', expectBeforeUnconstrained:
'angledLineOfYLength({ angle = -91, length = 19 + 0 }, %)',
expectAfterUnconstrained: expectAfterUnconstrained:
'angledLine(angle = angle002, lengthY = 19 + 0)', 'angledLineOfYLength({ angle = angle002, length = 19 + 0 }, %)',
expectFinal: 'angledLine(angle = -91, lengthY = 19 + 0)', expectFinal: 'angledLineOfYLength({ angle = -91, length = 19 + 0 }, %)',
ang: ang + 180, ang: ang + 180,
steps: 6, steps: 6,
locator: '[data-overlay-toolbar-index="8"]', locator: '[data-overlay-toolbar-index="8"]',
@ -567,9 +574,12 @@ 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: 'angledLine(angle = -91, lengthY = 19 + 0)', expectBeforeUnconstrained:
expectAfterUnconstrained: 'angledLine(angle = -91, lengthY = 19)', 'angledLineOfYLength({ angle = -91, length = 19 + 0 }, %)',
expectFinal: 'angledLine(angle = -91, lengthY = yRel002)', expectAfterUnconstrained:
'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"]',
@ -587,22 +597,22 @@ 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)
|> angledLine(angle = 181 + 0, lengthX = 23.14) |> angledLineOfXLength({ angle = 181 + 0, length = 23.14 }, %)
|> angledLine(angle = -91, lengthY = 19 + 0) |> angledLineOfYLength({ angle = -91, length = 19 + 0 }, %)
|> angledLine(angle = 3 + 0, endAbsoluteX = 26) |> angledLineToX({ angle = 3 + 0, to = 26 }, %)
|> angledLine(angle = 89, endAbsoluteY = 9.14 + 0) |> angledLineToY({ angle = 89, to = 9.14 + 0 }, %)
|> angledLineThatIntersects({ |> angledLineThatIntersects({
angle = 4.14, angle = 4.14,
intersectTag = a, intersectTag = a,
offset = 9 offset = 9
}, %) }, %)
|> tangentialArc(endAbsolute = [3.14 + 13, 1.14]) |> tangentialArcTo([3.14 + 13, 1.14], %)
` `
) )
localStorage.setItem('disableAxis', 'true') localStorage.setItem('disableAxis', 'true')
@ -636,9 +646,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:
'angledLine(angle = 3 + 0, endAbsoluteX = 26)', 'angledLineToX({ angle = 3 + 0, to = 26 }, %)',
expectAfterUnconstrained: 'angledLine(angle = 3, endAbsoluteX = 26)', expectAfterUnconstrained: 'angledLineToX({ angle = 3, to = 26 }, %)',
expectFinal: 'angledLine(angle = angle001, endAbsoluteX = 26)', expectFinal: 'angledLineToX({ angle = angle001, to = 26 }, %)',
ang: ang + 180, ang: ang + 180,
locator: '[data-overlay-toolbar-index="9"]', locator: '[data-overlay-toolbar-index="9"]',
}) })
@ -647,10 +657,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:
'angledLine(angle = angle001, endAbsoluteX = 26)', 'angledLineToX({ angle = angle001, to = 26 }, %)',
expectAfterUnconstrained: expectAfterUnconstrained:
'angledLine(angle = angle001, endAbsoluteX = xAbs001)', 'angledLineToX({ angle = angle001, to = xAbs001 }, %)',
expectFinal: 'angledLine(angle = angle001, endAbsoluteX = 26)', expectFinal: 'angledLineToX({ angle = angle001, to = 26 }, %)',
ang: ang + 180, ang: ang + 180,
locator: '[data-overlay-toolbar-index="9"]', locator: '[data-overlay-toolbar-index="9"]',
}) })
@ -661,9 +671,11 @@ 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: 'angledLine(angle = 89, to = 9.14 + 0)', expectBeforeUnconstrained:
expectAfterUnconstrained: 'angledLine(angle = angle002, to = 9.14 + 0)', 'angledLineToY({ angle = 89, to = 9.14 + 0 }, %)',
expectFinal: 'angledLine(angle = 89, to = 9.14 + 0)', expectAfterUnconstrained:
'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"]',
@ -673,9 +685,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:
'angledLine(angle = 89, endAbsoluteY = 9.14 + 0)', 'angledLineToY({ angle = 89, to = 9.14 + 0 }, %)',
expectAfterUnconstrained: 'angledLine(angle = 89, endAbsoluteY = 9.14)', expectAfterUnconstrained: 'angledLineToY({ angle = 89, to = 9.14 }, %)',
expectFinal: 'angledLine(angle = 89, endAbsoluteY = yAbs001)', expectFinal: 'angledLineToY({ angle = 89, to = yAbs001 }, %)',
ang: ang + 180, ang: ang + 180,
locator: '[data-overlay-toolbar-index="10"]', locator: '[data-overlay-toolbar-index="10"]',
}) })
@ -735,7 +747,11 @@ test.describe('Testing segment overlays', { tag: ['@skipWin'] }, () => {
locator: '[data-overlay-toolbar-index="11"]', locator: '[data-overlay-toolbar-index="11"]',
}) })
}) })
test('for segment [tangentialArc]', async ({ page, editor, homePage }) => { test('for segment [tangentialArcTo]', async ({
page,
editor,
homePage,
}) => {
await page.addInitScript(async () => { await page.addInitScript(async () => {
localStorage.setItem( localStorage.setItem(
'persistCode', 'persistCode',
@ -743,22 +759,22 @@ 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)
|> angledLine(angle = 181 + 0, lengthX = 23.14) |> angledLineOfXLength({ angle = 181 + 0, length = 23.14 }, %)
|> angledLine(angle = -91, lengthY = 19 + 0) |> angledLineOfYLength({ angle = -91, length = 19 + 0 }, %)
|> angledLine(angle = 3 + 0, endAbsoluteX = 26) |> angledLineToX({ angle = 3 + 0, to = 26 }, %)
|> angledLine(angle = 89, endAbsoluteY = 9.14 + 0) |> angledLineToY({ angle = 89, to = 9.14 + 0 }, %)
|> angledLineThatIntersects({ |> angledLineThatIntersects({
angle = 4.14, angle = 4.14,
intersectTag = a, intersectTag = a,
offset = 9 offset = 9
}, %) }, %)
|> tangentialArc(endAbsolute = [3.14 + 13, -3.14]) |> tangentialArcTo([3.14 + 13, -3.14], %)
` `
) )
localStorage.setItem('disableAxis', 'true') localStorage.setItem('disableAxis', 'true')
@ -783,29 +799,28 @@ test.describe('Testing segment overlays', { tag: ['@skipWin'] }, () => {
const clickUnconstrained = _clickUnconstrained(page, editor) const clickUnconstrained = _clickUnconstrained(page, editor)
const clickConstrained = _clickConstrained(page, editor) const clickConstrained = _clickConstrained(page, editor)
const tangentialArc = await u.getBoundingBox('[data-overlay-index="12"]') const tangentialArcTo = await u.getBoundingBox(
'[data-overlay-index="12"]'
)
let ang = await u.getAngle('[data-overlay-index="12"]') let ang = await u.getAngle('[data-overlay-index="12"]')
console.log('tangentialArc') console.log('tangentialArcTo')
await clickConstrained({ await clickConstrained({
hoverPos: { x: tangentialArc.x, y: tangentialArc.y }, hoverPos: { x: tangentialArcTo.x, y: tangentialArcTo.y },
constraintType: 'xAbsolute', constraintType: 'xAbsolute',
expectBeforeUnconstrained: expectBeforeUnconstrained: 'tangentialArcTo([3.14 + 13, -3.14], %)',
'tangentialArc(endAbsolute = [3.14 + 13, -3.14])', expectAfterUnconstrained: 'tangentialArcTo([16.14, -3.14], %)',
expectAfterUnconstrained: 'tangentialArc(endAbsolute = [16.14, -3.14])', expectFinal: 'tangentialArcTo([xAbs001, -3.14], %)',
expectFinal: 'tangentialArc(endAbsolute = [xAbs001, -3.14])',
ang: ang + 180, ang: ang + 180,
steps: 6, steps: 6,
locator: '[data-overlay-toolbar-index="12"]', locator: '[data-overlay-toolbar-index="12"]',
}) })
console.log('tangentialArc2') console.log('tangentialArcTo2')
await clickUnconstrained({ await clickUnconstrained({
hoverPos: { x: tangentialArc.x, y: tangentialArc.y }, hoverPos: { x: tangentialArcTo.x, y: tangentialArcTo.y },
constraintType: 'yAbsolute', constraintType: 'yAbsolute',
expectBeforeUnconstrained: expectBeforeUnconstrained: 'tangentialArcTo([xAbs001, -3.14], %)',
'tangentialArc(endAbsolute = [xAbs001, -3.14])', expectAfterUnconstrained: 'tangentialArcTo([xAbs001, yAbs001], %)',
expectAfterUnconstrained: expectFinal: 'tangentialArcTo([xAbs001, -3.14], %)',
'tangentialArc(endAbsolute = [xAbs001, yAbs001])',
expectFinal: 'tangentialArc(endAbsolute = [xAbs001, -3.14])',
ang: ang + 180, ang: ang + 180,
steps: 10, steps: 10,
locator: '[data-overlay-toolbar-index="12"]', locator: '[data-overlay-toolbar-index="12"]',
@ -1073,22 +1088,22 @@ 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)
|> angledLine(angle = 181 + 0, lengthX = 23.14) |> angledLineOfXLength({ angle = 181 + 0, length = 23.14 }, %)
|> angledLine(angle = -91, lengthY = 19 + 0) |> angledLineOfYLength({ angle = -91, length = 19 + 0 }, %)
|> angledLine(angle = 3 + 0, endAbsoluteX = 26) |> angledLineToX({ angle = 3 + 0, to = 26 }, %)
|> angledLine(angle = 89, endAbsoluteY = 9.14 + 0) |> angledLineToY({ angle = 89, to = 9.14 + 0 }, %)
|> angledLineThatIntersects({ |> angledLineThatIntersects({
angle = 4.14, angle = 4.14,
intersectTag = a, intersectTag = a,
offset = 9 offset = 9
}, %) }, %)
|> tangentialArc(endAbsolute = [3.14 + 13, 1.14]) |> tangentialArcTo([3.14 + 13, 1.14], %)
|> arcTo({ |> arcTo({
interior = [16.25, 5.12], interior = [16.25, 5.12],
end = [21.61, 4.15] end = [21.61, 4.15]
@ -1158,8 +1173,8 @@ part001 = startSketchOn(XZ)
ang = await u.getAngle('[data-overlay-index="12"]') ang = await u.getAngle('[data-overlay-index="12"]')
await deleteSegmentSequence({ await deleteSegmentSequence({
hoverPos: { x: segmentToDelete.x, y: segmentToDelete.y }, hoverPos: { x: segmentToDelete.x, y: segmentToDelete.y },
codeToBeDeleted: 'tangentialArc(endAbsolute = [3.14 + 13, 1.14])', codeToBeDeleted: 'tangentialArcTo([3.14 + 13, 1.14], %)',
stdLibFnName: 'tangentialArc', stdLibFnName: 'tangentialArcTo',
ang: ang + 180, ang: ang + 180,
steps: 6, steps: 6,
locator: '[data-overlay-toolbar-index="12"]', locator: '[data-overlay-toolbar-index="12"]',
@ -1184,7 +1199,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: 'angledLine(angle = 89, endAbsoluteY = 9.14 + 0)', codeToBeDeleted: 'angledLineToY({ angle = 89, to = 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"]',
@ -1194,7 +1209,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: 'angledLine(angle = 3 + 0, endAbsoluteX = 26)', codeToBeDeleted: 'angledLineToX({ angle = 3 + 0, to = 26 }, %)',
stdLibFnName: 'angledLineToX', stdLibFnName: 'angledLineToX',
ang: ang + 180, ang: ang + 180,
locator: '[data-overlay-toolbar-index="9"]', locator: '[data-overlay-toolbar-index="9"]',
@ -1204,7 +1219,8 @@ 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: 'angledLine(angle = -91, lengthY = 19 + 0)', codeToBeDeleted:
'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"]',
@ -1214,7 +1230,8 @@ 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: 'angledLine(angle = 181 + 0, lengthX = 23.14)', codeToBeDeleted:
'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"]',
@ -1297,7 +1314,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"]',
@ -1318,20 +1335,24 @@ 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(angle = 5, length = 23.03, tag = $seg01)', 'angledLine([5, 23.03], %, $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)',
'angledLine(angle = 3, lengthX = 30, tag = $seg01)', 'angledLineOfXLength([3, 30], %, $seg01)',
'angledLine(angle = 3, lengthY = 1.5, tag = $seg01)', 'angledLineOfXLength({ angle = 3, length = 30 }, %, $seg01)',
'angledLine(angle = 3, endAbsoluteX = 30, tag = $seg01)', 'angledLineOfYLength([3, 1.5], %, $seg01)',
'angledLine(angle = 3, endAbsoluteY = 7, tag = $seg01)', 'angledLineOfYLength({ angle = 3, length = 1.5 }, %, $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}${isObj ? '-[obj-input]' : ''}${ test(`${lineOfInterest.split('=')[0]}${isObj ? '-[obj-input]' : ''}${
doesHaveTagOutsideSketch ? '-[tagOutsideSketch]' : '' doesHaveTagOutsideSketch ? '-[tagOutsideSketch]' : ''
}`, async ({ page, editor, homePage }) => { }`, async ({ page, editor, homePage }) => {
await page.addInitScript( await page.addInitScript(
@ -1343,7 +1364,7 @@ part001 = startSketchOn(XZ)
|> startProfileAt([5, 6], %) |> startProfileAt([5, 6], %)
|> ${lineToBeDeleted} |> ${lineToBeDeleted}
|> line(end = [-10, -15]) |> line(end = [-10, -15])
|> angledLine(angle = -176, length = segLen(seg01)) |> angledLine([-176, segLen(seg01)], %)
${extraLine ? 'myVar = segLen(seg01)' : ''}` ${extraLine ? 'myVar = segLen(seg01)' : ''}`
) )
}, },
@ -1456,7 +1477,7 @@ part001 = startSketchOn(XZ)
}, },
{ {
before: `angledLine(angle = 5 + 0, length = 23.03 + 0, tag = $seg01)`, before: `angledLine([5 + 0, 23.03 + 0], %, $seg01)`,
after: `line(end = [22.94, 2.01], tag = $seg01)`, after: `line(end = [22.94, 2.01], tag = $seg01)`,
}, },
{ {
@ -1476,25 +1497,32 @@ part001 = startSketchOn(XZ)
after: `line(end = [0, -10], tag = $seg01)`, after: `line(end = [0, -10], tag = $seg01)`,
}, },
{ {
before: `angledLine(angle = 3 + 0, lengthX = 30 + 0, tag = $seg01)`, before: `angledLineOfXLength({ angle = 3 + 0, length = 30 + 0 }, %, $seg01)`,
after: `line(end = [30, 1.57], tag = $seg01)`, after: `line(end = [30, 1.57], tag = $seg01)`,
}, },
{ {
before: `angledLine(angle = 3 + 0, lengthY = 1.5 + 0, tag = $seg01)`, before: `angledLineOfYLength({ angle = 3 + 0, length = 1.5 + 0 }, %, $seg01)`,
after: `line(end = [28.62, 1.5], tag = $seg01)`, after: `line(end = [28.62, 1.5], tag = $seg01)`,
}, },
{ {
before: `angledLine(angle = 3 + 0, endAbsoluteX = 30 + 0, tag = $seg01)`, before: `angledLineToX({ angle = 3 + 0, to = 30 + 0 }, %, $seg01)`,
after: `line(end = [25, 1.31], tag = $seg01)`, after: `line(end = [25, 1.31], tag = $seg01)`,
}, },
{ {
before: `angledLine(angle = 3 + 0, endAbsoluteY = 7 + 0, tag = $seg01)`, before: `angledLineToY({ angle = 3 + 0, to = 7 + 0 }, %, $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) {
test(before, async ({ page, editor, homePage, scene, cmdBar }) => { const isObj = before.includes('{ angle = 3')
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(
@ -1504,7 +1532,7 @@ part001 = startSketchOn(XZ)
|> startProfileAt([5, 6], %) |> startProfileAt([5, 6], %)
|> ${lineToBeDeleted} |> ${lineToBeDeleted}
|> line(end = [-10, -15]) |> line(end = [-10, -15])
|> angledLine(angle = -176, length = segLen(seg01))` |> angledLine([-176, 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: 'constraints: open menu', name: 'Length: open menu',
}) })
const absXButton = page.getByRole('button', { name: 'Absolute X' }) const absXButton = page.getByRole('button', { name: 'Absolute X' })
@ -308,15 +308,21 @@ 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])
|> angledLine(angle = 60, endAbsoluteX = pipeSmallDia + thickness) |> angledLineToX({
angle = 60,
to = pipeSmallDia + thickness
}, %)
|> line(end = [0, -pipeLength]) |> line(end = [0, -pipeLength])
|> angledLine(angle = -60, endAbsoluteX = pipeLargeDia + thickness) |> angledLineToX({
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])
|> angledLine(angle = 120, endAbsoluteX = pipeSmallDia) |> angledLineToX({ angle = 120, to = pipeSmallDia }, %)
|> line(end = [0, pipeLength]) |> line(end = [0, pipeLength])
|> angledLine(angle = 60, endAbsoluteX = pipeLargeDia) |> angledLineToX({ angle = 60, to = pipeLargeDia }, %)
|> close() |> close()
rev = revolve(part009, axis = Y) rev = revolve(part009, axis = Y)
sketch006 = startSketchOn(XY) sketch006 = startSketchOn(XY)
@ -326,9 +332,15 @@ profile001 = circle(
radius = 17.96 radius = 17.96
) )
profile002 = startProfileAt([86.92, -63.81], sketch006) profile002 = startProfileAt([86.92, -63.81], sketch006)
|> angledLine(angle = 0, length = 63.81, tag = $rectangleSegmentA001) |> angledLine([0, 63.81], %, $rectangleSegmentA001)
|> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 17.05) |> angledLine([
|> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001)) segAng(rectangleSegmentA001) - 90,
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)
@ -459,7 +471,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(angle = segAng(seg01), length = 12.35, tag = $seg02) |> angledLine([segAng(seg01), 12.35], %, $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)
@ -472,9 +484,15 @@ 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(angle = 0, length = 5.05, tag = $rectangleSegmentA001) |> angledLine([0, 5.05], %, $rectangleSegmentA001)
|> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 4.81) |> angledLine([
|> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001)) segAng(rectangleSegmentA001) - 90,
4.81
], %)
|> angledLine([
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
@ -521,21 +539,21 @@ 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)
|> angledLine(angle = 3 + 0, lengthX = 3.14) |> angledLineOfXLength({ angle = 3 + 0, length = 3.14 }, %)
|> angledLine(angle = 30, lengthY = 3 + 0) |> angledLineOfYLength({ angle = 30, length = 3 + 0 }, %)
|> angledLine(angle = 22.14 + 0, endAbsoluteX = 12) |> angledLineToX({ angle = 22.14 + 0, to = 12 }, %)
|> angledLine(angle = 30, endAbsoluteY = 11.14) |> angledLineToY({ angle = 30, to = 11.14 }, %)
|> angledLineThatIntersects({ |> angledLineThatIntersects({
angle = 3.14, angle = 3.14,
intersectTag = a, intersectTag = a,
offset = 0 offset = 0
}, %) }, %)
|> tangentialArc(endAbsolute = [13.14 + 0, 13.14]) |> tangentialArcTo([13.14 + 0, 13.14], %)
|> close() |> close()
|> extrude(length = 5 + 7) |> extrude(length = 5 + 7)
` `
@ -574,7 +592,7 @@ part001 = startSketchOn(XZ)
const extrusionTopCap: Coords2d = [800, 240] const extrusionTopCap: Coords2d = [800, 240]
const flatExtrusionFace: Coords2d = [960, 160] const flatExtrusionFace: Coords2d = [960, 160]
const tangentialArc: Coords2d = [840, 160] const tangentialArcTo: Coords2d = [840, 160]
const close: Coords2d = [720, 200] const close: Coords2d = [720, 200]
const nothing: Coords2d = [600, 200] const nothing: Coords2d = [600, 200]
const closeEdge: Coords2d = [744, 233] const closeEdge: Coords2d = [744, 233]
@ -671,28 +689,28 @@ part001 = startSketchOn(XZ)
) )
await checkCodeAtHoverPosition( await checkCodeAtHoverPosition(
'tangentialArc', 'tangentialArcTo',
tangentialArc, tangentialArcTo,
'tangentialArc(endAbsolute=[13.14+0,13.14])extrude(length=5+7)', 'tangentialArcTo([13.14+0,13.14],%)extrude(length=5+7)',
'tangentialArc(endAbsolute = [13.14 + 0, 13.14])' 'tangentialArcTo([13.14 + 0, 13.14], %)'
) )
await checkCodeAtHoverPosition( await checkCodeAtHoverPosition(
'tangentialArcEdge', 'tangentialArcEdge',
tangentialArcEdge, tangentialArcEdge,
`tangentialArc(endAbsolute=[13.14+0,13.14])`, `tangentialArcTo([13.14+0,13.14],%)`,
'tangentialArc(endAbsolute = [13.14 + 0, 13.14])' 'tangentialArcTo([13.14 + 0, 13.14], %)'
) )
await checkCodeAtHoverPosition( await checkCodeAtHoverPosition(
'tangentialArcOppositeEdge', 'tangentialArcOppositeEdge',
tangentialArcOppositeEdge, tangentialArcOppositeEdge,
`tangentialArc(endAbsolute=[13.14+0,13.14])`, `tangentialArcTo([13.14+0,13.14],%)`,
'tangentialArc(endAbsolute = [13.14 + 0, 13.14])' 'tangentialArcTo([13.14 + 0, 13.14], %)'
) )
await checkCodeAtHoverPosition( await checkCodeAtHoverPosition(
'tangentialArcAdjacentEdge', 'tangentialArcAdjacentEdge',
tangentialArcAdjacentEdge, tangentialArcAdjacentEdge,
`tangentialArc(endAbsolute=[13.14+0,13.14])`, `tangentialArcTo([13.14+0,13.14],%)`,
'tangentialArc(endAbsolute = [13.14 + 0, 13.14])' 'tangentialArcTo([13.14 + 0, 13.14], %)'
) )
await checkCodeAtHoverPosition( await checkCodeAtHoverPosition(
@ -718,14 +736,14 @@ part001 = startSketchOn(XZ)
await checkCodeAtHoverPosition( await checkCodeAtHoverPosition(
'straightSegmentEdge', 'straightSegmentEdge',
straightSegmentEdge, straightSegmentEdge,
`angledLine(angle=30,endAbsoluteY=11.14)`, `angledLineToY({angle=30,to=11.14},%)`,
'angledLine(angle = 30, endAbsoluteY = 11.14)' 'angledLineToY({ angle = 30, to = 11.14 }, %)'
) )
await checkCodeAtHoverPosition( await checkCodeAtHoverPosition(
'straightSegmentOppositeEdge', 'straightSegmentOppositeEdge',
straightSegmentOppositeEdge, straightSegmentOppositeEdge,
`angledLine(angle=30,endAbsoluteY=11.14)`, `angledLineToY({angle=30,to=11.14},%)`,
'angledLine(angle = 30, endAbsoluteY = 11.14)' 'angledLineToY({ angle = 30, to = 11.14 }, %)'
) )
await checkCodeAtHoverPosition( await checkCodeAtHoverPosition(
'straightSegmentAdjacentEdge', 'straightSegmentAdjacentEdge',
@ -740,9 +758,15 @@ 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(angle = 0, length = 268.43, tag = $rectangleSegmentA001) |> angledLine([0, 268.43], %, $rectangleSegmentA001)
|> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 217.26, tag = $seg01) |> angledLine([
|> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001), tag = $yo) segAng(rectangleSegmentA001) - 90,
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)
@ -791,14 +815,14 @@ part001 = startSketchOn(XZ)
await checkCodeAtHoverPosition( await checkCodeAtHoverPosition(
'oppositeChamfer', 'oppositeChamfer',
oppositeChamfer, oppositeChamfer,
`angledLine(angle=segAng(rectangleSegmentA001)-90,length=217.26,tag=$seg01)chamfer(length=30,tags=[seg01,getNextAdjacentEdge(yo),getNextAdjacentEdge(seg02),getOppositeEdge(seg01)],)`, `angledLine([segAng(rectangleSegmentA001)-90,217.26],%,$seg01)chamfer(length=30,tags=[seg01,getNextAdjacentEdge(yo),getNextAdjacentEdge(seg02),getOppositeEdge(seg01)],)`,
' )' ' )'
) )
await checkCodeAtHoverPosition( await checkCodeAtHoverPosition(
'baseChamfer', 'baseChamfer',
baseChamfer, baseChamfer,
`angledLine(angle=segAng(rectangleSegmentA001)-90,length=217.26,tag=$seg01)chamfer(length=30,tags=[seg01,getNextAdjacentEdge(yo),getNextAdjacentEdge(seg02),getOppositeEdge(seg01)],)`, `angledLine([segAng(rectangleSegmentA001)-90,217.26],%,$seg01)chamfer(length=30,tags=[seg01,getNextAdjacentEdge(yo),getNextAdjacentEdge(seg02),getOppositeEdge(seg01)],)`,
' )' ' )'
) )
@ -836,7 +860,7 @@ part001 = startSketchOn(XZ)
await checkCodeAtHoverPosition( await checkCodeAtHoverPosition(
'adjacentChamfer2', 'adjacentChamfer2',
adjacentChamfer2, adjacentChamfer2,
`angledLine(angle=segAng(rectangleSegmentA001),length=-segLen(rectangleSegmentA001),tag=$yo)chamfer(length=30,tags=[seg01,getNextAdjacentEdge(yo),getNextAdjacentEdge(seg02),getOppositeEdge(seg01)],)`, `angledLine([segAng(rectangleSegmentA001),-segLen(rectangleSegmentA001)],%,$yo)chamfer(length=30,tags=[seg01,getNextAdjacentEdge(yo),getNextAdjacentEdge(seg02),getOppositeEdge(seg01)],)`,
' )' ' )'
) )
}) })
@ -936,11 +960,11 @@ part001 = startSketchOn(XZ)
}, },
{ {
pos: [816, 244], pos: [816, 244],
expectedCode: 'angledLine(angle = segAng(seg01), length = yo)', expectedCode: 'angledLine([segAng(seg01), yo], %)',
}, },
{ {
pos: [1107, 161], pos: [1107, 161],
expectedCode: 'tangentialArc(endAbsolute = [167.95, -28.85])', expectedCode: 'tangentialArcTo([167.95, -28.85], %)',
}, },
] as const ] as const
await page.addInitScript( await page.addInitScript(

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(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() 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()

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