Compare commits

...

42 Commits

Author SHA1 Message Date
32572c8ae7 Update grammar
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2025-03-23 19:29:12 +13:00
e0e707ad85 Doc comments on parameters
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2025-03-22 10:38:18 +13:00
0913d3ebdc Support calling KCL std KW fns, and move circle to KCL std
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2025-03-21 22:26:23 +13:00
c545ad71c6 Rebasing and fixes
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2025-03-20 20:23:27 +13:00
a70718687f Add Point2D/3D to std
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2025-03-20 20:23:27 +13:00
85cd29424e Tests for type coercion and subtyping
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2025-03-20 20:23:27 +13:00
df1ff68a6d code motion: factor our execution::types module
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2025-03-20 20:23:26 +13:00
2678d1014e Treat Helix and Face as primitive types
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2025-03-20 20:23:26 +13:00
cd59691663 type aliases
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2025-03-20 20:23:24 +13:00
d7369d8a95 parse union and fancy array types
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2025-03-20 20:21:35 +13:00
ce98218bf0 Create main.kcl (#5898)
* Create main.kcl

* Update kcl-samples simulation test output

* Update kcl-samples simulation test output

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Josh Gomez <114548659+jgomez720@users.noreply.github.com>
2025-03-19 23:28:07 -07:00
2d43399703 Update pipe flange assembly (#5893)
* update pipe flange assy and small change to walkie talkie

* update header in globals.kcl

* Update kcl-samples simulation test output

* Update kcl-samples simulation test output

* Update output after merge

---------

Co-authored-by: jgomez720 <114548659+jgomez720@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-03-20 03:49:06 +00:00
461a2c3ab2 Support comments on attributes (#5850)
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2025-03-20 16:23:20 +13:00
79be72c5f0 Fix a couple of panics (#5900)
* Ensure batches in the engine are cleared between scenes

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* Avoid panicking reading arguments out of bounds

Signed-off-by: Nick Cameron <nrc@ncameron.org>

---------

Signed-off-by: Nick Cameron <nrc@ncameron.org>
2025-03-20 02:59:16 +00:00
9ddb4e629f Stub csg functions for front end (#5899)
* initial placeholder csg functions

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

* updates

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

* generate docs

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

* generate docs

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

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-03-20 02:26:57 +00:00
25e8e7081b Fix workflow to commit all generated kcl-samples files (#5896) 2025-03-20 01:10:54 +00:00
c5164cbee3 Fix electron renderer topLevelAwait in electron-forge (#5895)
* Fix electron renderer topLevelAwait

* Actually we need both for both cases, adding back plus comments
2025-03-19 20:54:35 -04:00
809b333248 bump kcl and friends before tomorrow release (#5897)
Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-03-19 17:12:02 -07:00
a933646667 Fix e2e workflow when only kcl-samples changes (#5894) 2025-03-19 19:46:44 -04:00
98a68f5cd9 Step file unfuck ci (#5891)
* remove the files

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

* remove step shit from kcl-samples

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

* updates

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

* updates

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

* updates

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

* updates

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

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-03-19 16:43:10 -07:00
33dc254e43 Fix yarn build:wasm to format generated files (#5889) 2025-03-19 23:29:27 +00:00
b54295f2f7 get common edge (#5869)
* get common edge

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

* fmt

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

* updates

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

* add get common edge

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

* docs

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

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-03-20 09:12:27 +11:00
a7e09a89ef Improve snapshot testing (#5856)
* Improve snapshot testing

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

---------

Signed-off-by: Nick Cameron <nrc@ncameron.org>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-03-19 15:06:27 -07:00
4b6166dc4f fix no profile errors (#5877)
* fix no profile errors

* add test and tweak a couple things

* quick fix

* fix animation

* add another test

* Use actor.getSnapshot in the debug function

So we don't have to rebuild that listener every time that the state
changes.

* try fix tests

---------

Co-authored-by: Frank Noirot <frankjohnson1993@gmail.com>
2025-03-20 08:30:11 +11:00
e7d00f148b transform after fillet bug fix (#5882)
* fixes

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

* updates

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

* updates

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

* rotate

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

* updates

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

* updates

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

* its not jsut translate

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

* its not jsut translate

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

* fix

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

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-03-19 12:28:56 -07:00
d19a7df7e8 Tag and name end and start caps (#5874)
* initial commit

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

* updates

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

* update for revolve

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

* updates

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

* fixes

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

* fixes

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

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-03-19 19:18:19 +00:00
45fae52afc bump kcl friends (#5887)
* bump kcl friends

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

* update lock

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

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-03-19 11:22:36 -07:00
270f173aad fix unwrap causing panic (#5886)
updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-03-19 10:19:19 -07:00
ddcff1ba63 Fix the dev target dependency name (#5879) 2025-03-19 16:49:15 +00:00
max
cb1b08d6b6 Add modelingWorkflows module with resilient update pattern for adding features (#5821)
* rule them all

* swap AST updater

* add test

* yellow colour fix

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-03-19 17:48:29 +01:00
533fa749b2 Add ability to create named constant without code (#5840)
* Add support for forcing kcl input create variable

* Command palette padding tweak

* Make traverse function work for ExpressionStatements

* Add utilities for getting earliest safe index in AST

* Fix the insertIndex logic to not be based on the selection anymore

* Add workflow to create a named constant

* Fix bug with nameEndInDigits matcher

* Tweak command config

* Add a three-dot menu to feature tree pane to create parameters

* Add E2E test for create parameter flow

* Remove edit flow oops

* Fix tsc error

* Fix E2E test

* Update named constant position in edit flow test

* Add tags into consideration for safe insert index

Per @Irev-dev's helpful feedback, with unit tests!
2025-03-19 15:58:53 +00:00
af492d2cb6 Add 9 test fixmes (#5872)
* Add 4 test fixmes

* Add 3 more test fixmes

* Another one

* Last one yo
2025-03-19 07:58:55 -04:00
26fba71abf Revolve changed to kw args (#5873)
* initial port

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

* updates

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

* more fixes

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

* fix e2e

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

* more fixes

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

* updates

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

* update js side

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

* updates

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

* fixes

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

* fix;

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

* cleanup

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

* updates

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

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-03-18 20:34:44 -07:00
859bfc7b28 move export to the rust side to make the interface way more clean (#5855)
* move export

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

testing

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

remove debugs

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

fix main

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

updates

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

fices

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

get rid of logs

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

* Convert async actions anti-pattern to fromPromise actors

* Fix tsc by removing a generic type

* updates

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

* updates

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

* cleanup

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

* cleanup

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

* Update rustContext.ts

* fix

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

* fix;

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

* cleanup

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

* remove weird file

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

* fix

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

* updates

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

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
Co-authored-by: Frank Noirot <frankjohnson1993@gmail.com>
2025-03-18 20:25:51 -07:00
3b1d1307c4 transform a sketch (#5867)
* transform a sketch

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

* updates

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

* fix test

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

* updates

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

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* updates

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

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* updates

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

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-03-18 16:36:48 -07:00
f5a2c84ce2 Revolve around sketch line (#5870)
* show we can revolve around paths

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

* show we can revolve around paths

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

* updates

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

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-03-18 13:51:24 -07:00
cccb71fd30 Set initial window size depending on screen size (#5845)
* set initial electron window size to be almost full screen with some space left

* refine initial window size and position

* slightly larger

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-03-18 15:39:04 -04:00
44be072d04 Fix deep links and double clicks on second instance (#5865)
* Deep links or double clicks don't work on second instance on Windows
Fixes #5864

* A snapshot a day keeps the bugs away! 📷🐛

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-03-18 15:17:21 -04:00
86beb6ebf1 Improve local setup instructions (#5860)
* Fix overwrite confirmation on existing wasm-pack

* Recommend using local .env for overrides
2025-03-18 14:39:02 -04:00
6d72104faa fix unused vars and imports (#5852)
* update eslintrc, and fix most of the errors

* more

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

* fix last one

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

* fixes

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

* updates

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

* A snapshot a day keeps the bugs away! 📷🐛

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
Co-authored-by: Jess Frazelle <github@jessfraz.com>
Co-authored-by: Jess Frazelle <jessfraz@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-03-18 09:52:10 -07:00
f2c5661710 Use less Namespace resources by shifting ubuntu to AWS (#5847)
* Attempt: Hourly tests on ubuntu only

* Attempt: Hourly tests on ubuntu only through os exlusion rules

* Attempt: Hourly tests on ubuntu only through dummy boolean key

* Clean up for PR

* Draft: Use less namespace vCPUs for e2e

* All on gh, just to see

* Disable concurrency, bump to 45min step retry timeout

* 2 workers for non-windows machineis

* Step retry down to 3

* Change to ubuntu aws, change macos to macos-latest-large

* Fix name for ubuntu aws, back to 10 step retry

* Back to 4 shards to see the diff

* Snaptshots on ubuntu aws

* Cleaning up to get closer to a review-able state

* Should be ready for review

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-03-18 09:44:54 -04:00
ecb2359bc5 Fix tsc errors (#5857)
fix tsc errors
2025-03-18 08:56:08 -04:00
1069 changed files with 280274 additions and 722935 deletions

View File

@ -22,6 +22,13 @@
"rules": {
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-misused-promises": "error",
"@typescript-eslint/no-unused-vars": ["error", {
"varsIgnorePattern": "^_",
"argsIgnorePattern": "^_",
"ignoreRestSiblings": true,
"vars": "all",
"args": "none"
}],
"jsx-a11y/click-events-have-key-events": "off",
"jsx-a11y/no-autofocus": "off",
"jsx-a11y/no-noninteractive-element-interactions": "off",

View File

@ -100,9 +100,14 @@ jobs:
shell: bash
run: |
set -euo pipefail
cd rust
pushd rust
just overwrite-sim-test kcl_samples
git add kcl-lib/tests
popd
git add \
rust/kcl-lib/tests \
public/kcl-samples/manifest.json \
public/kcl-samples/README.md \
public/kcl-samples/screenshots
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git remote set-url origin https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git

View File

@ -75,7 +75,7 @@ jobs:
prepare-wasm:
# seperate job on Ubuntu to build or fetch the wasm blob once on the fastest runner
runs-on: namespace-profile-ubuntu-8-cores
runs-on: runs-on=${{ github.run_id }}/family=i7ie.2xlarge/image=ubuntu22-full-x64
needs: conditions
steps:
- uses: actions/checkout@v4
@ -163,7 +163,7 @@ jobs:
snapshots:
name: playwright:snapshots:ubuntu
runs-on: namespace-profile-ubuntu-8-cores
runs-on: runs-on=${{ github.run_id }}/family=i7ie.2xlarge/image=ubuntu22-full-x64
needs: [conditions, prepare-wasm]
steps:
- uses: actions/create-github-app-token@v1
@ -237,19 +237,14 @@ jobs:
- uses: actions/upload-artifact@v4
if: ${{ needs.conditions.outputs.should-run == 'true' && !cancelled() && (success() || failure()) }}
with:
name: playwright-report-snapshots-${{ matrix.os }}-snapshot-${{ matrix.shardIndex }}-${{ github.sha }}
name: playwright-report-ubuntu-snapshot-${{ github.sha }}
path: playwright-report/
include-hidden-files: true
retention-days: 30
overwrite: true
- name: Clean up test-results
if: ${{ needs.conditions.outputs.should-run == 'true' && !cancelled() && (success() || failure()) }}
continue-on-error: true
run: rm -r test-results
- name: check for changes
if: ${{ needs.conditions.outputs.should-run == 'true' && matrix.os == 'namespace-profile-ubuntu-8-cores' && matrix.shardIndex == 1 && github.ref != 'refs/heads/main' }}
if: ${{ needs.conditions.outputs.should-run == 'true' && github.ref != 'refs/heads/main' }}
shell: bash
id: git-check
run: |
@ -270,31 +265,26 @@ jobs:
git fetch origin
echo ${{ github.head_ref }}
git checkout ${{ github.head_ref }}
git commit -m "A snapshot a day keeps the bugs away! 📷🐛 (OS: ${{matrix.os}})" || true
git commit -m "A snapshot a day keeps the bugs away! 📷🐛" || true
git push
git push origin ${{ github.head_ref }}
# only upload artifacts if there's actually changes
- uses: actions/upload-artifact@v4
if: ${{ needs.conditions.outputs.should-run == 'true' && steps.git-check.outputs.modified == 'true' }}
with:
name: playwright-report-ubuntu-${{ github.sha }}
path: playwright-report/
include-hidden-files: true
retention-days: 30
electron:
needs: [conditions, prepare-wasm]
timeout-minutes: 60
name: playwright:electron:${{ matrix.os }} ${{ matrix.shardIndex }} ${{ matrix.shardTotal }}
env:
OS_NAME: ${{ contains(matrix.os, 'ubuntu') && 'ubuntu' || (contains(matrix.os, 'windows') && 'windows' || 'macos') }}
name: playwright:electron:${{ contains(matrix.os, 'ubuntu') && 'ubuntu' || (contains(matrix.os, 'windows') && 'windows' || 'macos') }}:${{ matrix.shardIndex }}:${{ matrix.shardTotal }}
strategy:
fail-fast: false
matrix:
# TODO: enable namespace-profile-windows-8-cores once available
os: [namespace-profile-ubuntu-8-cores, namespace-profile-macos-8-cores, windows-16-cores]
shardIndex: [1, 2, 3, 4, 5, 6, 7, 8]
shardTotal: [8]
# TODO: enable namespace-profile-windows-latest once available
os:
- "runs-on=${{ github.run_id }}/family=i7ie.2xlarge/image=ubuntu22-full-x64"
- namespace-profile-macos-8-cores
- windows-latest
shardIndex: [1, 2, 3, 4]
shardTotal: [4]
# Disable macos and windows tests on hourly e2e tests since we only care
# about server side changes.
# Technique from https://github.com/joaomcteixeira/python-project-skeleton/pull/31/files
@ -303,7 +293,7 @@ jobs:
exclude:
- os: namespace-profile-macos-8-cores
isScheduled: true
- os: windows-16-cores
- os: windows-latest
isScheduled: true
# TODO: add ref here for main and latest release tag
runs-on: ${{ matrix.os }}
@ -335,6 +325,7 @@ jobs:
run: yarn
- name: Cache Playwright Browsers
if: needs.conditions.outputs.should-run == 'true'
uses: actions/cache@v4
with:
path: |
@ -342,6 +333,7 @@ jobs:
key: ${{ runner.os }}-playwright-${{ hashFiles('yarn.lock') }}
- name: Install Playwright Browsers
if: needs.conditions.outputs.should-run == 'true'
run: yarn playwright install --with-deps
- name: Build web
@ -361,7 +353,7 @@ jobs:
if: ${{ needs.conditions.outputs.should-run == 'true' && !cancelled() && (success() || failure()) }}
continue-on-error: true
with:
name: test-results-${{ matrix.os }}-${{ matrix.shardIndex }}-${{ github.sha }}
name: test-results-${{ env.OS_NAME }}-${{ matrix.shardIndex }}-${{ github.sha }}
path: test-results/
- name: Run playwright/electron flow (with retries)
@ -370,8 +362,8 @@ jobs:
uses: nick-fields/retry@v3.0.2
with:
shell: bash
command: .github/ci-cd-scripts/playwright-electron.sh ${{matrix.shardIndex}} ${{matrix.shardTotal}} ${{matrix.os}}
timeout_minutes: 30
command: .github/ci-cd-scripts/playwright-electron.sh ${{matrix.shardIndex}} ${{matrix.shardTotal}} ${{ env.OS_NAME }}
timeout_minutes: 45
max_attempts: 15
env:
CI: true
@ -384,7 +376,7 @@ jobs:
- uses: actions/upload-artifact@v4
if: ${{ needs.conditions.outputs.should-run == 'true' && always() }}
with:
name: test-results-${{ matrix.os }}-${{ matrix.shardIndex }}-${{ github.sha }}
name: test-results-${{ env.OS_NAME }}-${{ matrix.shardIndex }}-${{ github.sha }}
path: test-results/
include-hidden-files: true
retention-days: 30
@ -393,7 +385,7 @@ jobs:
- uses: actions/upload-artifact@v4
if: ${{ needs.conditions.outputs.should-run == 'true' && always() }}
with:
name: playwright-report-${{ matrix.os }}-${{ matrix.shardIndex }}-${{ github.sha }}
name: playwright-report-${{ env.OS_NAME }}-${{ matrix.shardIndex }}-${{ github.sha }}
path: playwright-report/
include-hidden-files: true
retention-days: 30

View File

@ -4,7 +4,7 @@ KCL_WASM_LIB_FILES := $(wildcard rust/**/*.rs)
TS_SRC := $(wildcard src/**/*.tsx) $(wildcard src/**/*.ts)
XSTATE_TYPEGENS := $(wildcard src/machines/*.typegen.ts)
dev: node_modules public/wasm_lib_bg.wasm $(XSTATE_TYPEGENS)
dev: node_modules public/kcl_wasm_lib_bg.wasm $(XSTATE_TYPEGENS)
yarn start
# I'm sorry this is so specific to my setup you may as well ignore this.

View File

@ -105,7 +105,7 @@ Finally, to run the web app only, run:
yarn start
```
If you're not a Zoo employee you won't be able to access the dev environment, you should copy everything from `.env.production` to `.env.development` to make it point to production instead, then when you navigate to `localhost:3000` the easiest way to sign in is to paste `localStorage.setItem('TOKEN_PERSIST_KEY', "your-token-from-https://zoo.dev/account/api-tokens")` replacing the with a real token from https://zoo.dev/account/api-tokens of course, then navigate to localhost:3000 again. Note that navigating to `localhost:3000/signin` removes your token so you will need to set the token again.
If you're not a Zoo employee you won't be able to access the dev environment, you should copy everything from `.env.production` to `.env.development.local` to make it point to production instead, then when you navigate to `localhost:3000` the easiest way to sign in is to paste `localStorage.setItem('TOKEN_PERSIST_KEY', "your-token-from-https://zoo.dev/account/api-tokens")` replacing the with a real token from https://zoo.dev/account/api-tokens of course, then navigate to `localhost:3000` again. Note that navigating to `localhost:3000/signin` removes your token so you will need to set the token again.
### Development environment variables
@ -122,7 +122,7 @@ Third-Party Cookies".
## Desktop
To spin up the desktop app, `yarn install` and `yarn build:wasm` need to have been done before hand then
To spin up the desktop app, `yarn install` and `yarn build:wasm` need to have been done before hand then:
```
yarn tron:start
@ -130,13 +130,13 @@ yarn tron:start
This will start the application and hot-reload on changes.
Devtools can be opened with the usual Cmd-Opt-I (Mac) or Ctrl-Shift-I (Linux and Windows).
Devtools can be opened with the usual Command-Option-I (macOS) or Ctrl-Shift-I (Linux and Windows).
To package the app for your platform with electron-builder, run `yarn tronb:package:dev` (or `yarn tronb:package:prod` to point to the .env.production variables)
To package the app for your platform with electron-builder, run `yarn tronb:package:dev` (or `yarn tronb:package:prod` to point to the .env.production variables).
## Checking out commits / Bisecting
Which commands from setup are one off vs need to be run every time?
Which commands from setup are one off vs. need to be run every time?
The following will need to be run when checking out a new commit and guarantees the build is not stale:

View File

@ -54,7 +54,7 @@ example = extrude(exampleSketch, length = 5)
// Add color to a revolved solid.
sketch001 = startSketchOn('XY')
|> circle(center = [15, 0], radius = 5)
|> revolve({ angle = 360, axis = 'y' }, %)
|> revolve(angle = 360, axis = 'y')
|> appearance(color = '#ff0000', metalness = 90, roughness = 90)
```
@ -184,7 +184,6 @@ example = extrude(exampleSketch, length = 1)
```js
// Color the result of a sweep.
// Create a path for the sweep.
sweepPath = startSketchOn('XZ')
|> startProfileAt([0.05, 0.05], %)

File diff suppressed because one or more lines are too long

View File

@ -15,7 +15,7 @@ std::math::E: number = 2.71828182845904523536028747135266250_
### Examples
```js
exampleSketch = startSketchOn("XZ")
exampleSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %)
|> angledLine({
angle = 30,

View File

@ -17,7 +17,7 @@ std::math::PI: number = 3.14159265358979323846264338327950288_
```js
circumference = 70
exampleSketch = startSketchOn("XZ")
exampleSketch = startSketchOn(XZ)
|> circle(center = [0, 0], radius = circumference/ (2 * PI))
example = extrude(exampleSketch, length = 5)

View File

@ -15,7 +15,7 @@ std::math::TAU: number = 6.28318530717958647692528676655900577_
### Examples
```js
exampleSketch = startSketchOn("XZ")
exampleSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %)
|> angledLine({
angle = 50,

View File

@ -12,6 +12,8 @@ You can provide more than one sketch to extrude, and they will all be extruded i
extrude(
sketches: [Sketch],
length: number,
tagStart?: TagDeclarator,
tagEnd?: TagDeclarator,
): [Solid]
```
@ -22,6 +24,8 @@ extrude(
|----------|------|-------------|----------|
| `sketches` | [`[Sketch]`](/docs/kcl/types/Sketch) | Which sketch or sketches should be extruded | Yes |
| `length` | [`number`](/docs/kcl/types/number) | How far to extrude the given sketches | Yes |
| `tagStart` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | A named tag for the face at the start of the extrusion, i.e. the original sketch | No |
| `tagEnd` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | A named tag for the face at the end of the extrusion, i.e. the new face created by extruding the original sketch | No |
### Returns

54
docs/kcl/getCommonEdge.md Normal file

File diff suppressed because one or more lines are too long

View File

@ -22,8 +22,12 @@ layout: manual
* [`string`](kcl/types/string)
* [`tag`](kcl/types/tag)
* **std**
* [`Face`](kcl/types/Face)
* [`HALF_TURN`](kcl/consts/std-HALF_TURN)
* [`Helix`](kcl/types/Helix)
* [`Plane`](kcl/types/Plane)
* [`Point2d`](kcl/types/Point2d)
* [`Point3d`](kcl/types/Point3d)
* [`QUARTER_TURN`](kcl/consts/std-QUARTER_TURN)
* [`Sketch`](kcl/types/Sketch)
* [`Solid`](kcl/types/Solid)
@ -57,7 +61,6 @@ layout: manual
* [`bezierCurve`](kcl/bezierCurve)
* [`ceil`](kcl/ceil)
* [`chamfer`](kcl/chamfer)
* [`circle`](kcl/circle)
* [`circleThreePoint`](kcl/circleThreePoint)
* [`close`](kcl/close)
* [`cm`](kcl/cm)
@ -65,6 +68,7 @@ layout: manual
* [`fillet`](kcl/fillet)
* [`floor`](kcl/floor)
* [`ft`](kcl/ft)
* [`getCommonEdge`](kcl/getCommonEdge)
* [`getNextAdjacentEdge`](kcl/getNextAdjacentEdge)
* [`getOppositeEdge`](kcl/getOppositeEdge)
* [`getPreviousAdjacentEdge`](kcl/getPreviousAdjacentEdge)
@ -141,3 +145,5 @@ layout: manual
* [`cos`](kcl/std-math-cos)
* [`sin`](kcl/std-math-sin)
* [`tan`](kcl/std-math-tan)
* **std::sketch**
* [`circle`](kcl/std-sketch-circle)

50
docs/kcl/intersect.md Normal file

File diff suppressed because one or more lines are too long

View File

@ -15,6 +15,8 @@ loft(
bezApproximateRational: bool,
baseCurveIndex?: integer,
tolerance?: number,
tagStart?: TagDeclarator,
tagEnd?: TagDeclarator,
): Solid
```
@ -28,6 +30,8 @@ loft(
| `bezApproximateRational` | [`bool`](/docs/kcl/types/bool) | Attempt to approximate rational curves (such as arcs) using a bezier. This will remove banding around interpolations between arcs and non-arcs. It may produce errors in other scenarios Over time, this field won't be necessary. | Yes |
| `baseCurveIndex` | `integer` | This can be set to override the automatically determined topological base curve, which is usually the first section encountered. | No |
| `tolerance` | [`number`](/docs/kcl/types/number) | Tolerance for the loft operation. | No |
| `tagStart` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | A named tag for the face at the start of the loft, i.e. the original sketch | No |
| `tagEnd` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | A named tag for the face at the end of the loft, i.e. the last sketch | No |
### Returns

View File

@ -52,7 +52,6 @@ fn sum(arr):
sumSoFar = add(sumSoFar, i)
return sumSoFar */
// We use `assertEqual` to check that our `sum` function gives the
// expected result. It's good to check your work!
assertEqual(sum([1, 2, 3]), 6, 0.00001, "1 + 2 + 3 summed is 6")
@ -114,7 +113,6 @@ fn decagon(radius):
fullDecagon = partialDecagon // it's now full
return fullDecagon */
// Use the `decagon` function declared above, to sketch a decagon with radius 5.
decagon(5.0)
|> close()

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,10 +1,10 @@
---
title: "scale"
excerpt: "Scale a solid."
excerpt: "Scale a solid or a sketch."
layout: manual
---
Scale a solid.
Scale a solid or a sketch.
By default the transform is applied in local sketch axis, therefore the origin will not move.
@ -12,10 +12,10 @@ If you want to apply the transform in global space, set `global` to `true`. The
```js
scale(
solids: SolidOrImportedGeometry,
objects: SolidOrSketchOrImportedGeometry,
scale: [number],
global?: bool,
): SolidOrImportedGeometry
): SolidOrSketchOrImportedGeometry
```
@ -23,13 +23,13 @@ scale(
| Name | Type | Description | Required |
|----------|------|-------------|----------|
| `solids` | [`SolidOrImportedGeometry`](/docs/kcl/types/SolidOrImportedGeometry) | The solid or set of solids to scale. | Yes |
| `objects` | [`SolidOrSketchOrImportedGeometry`](/docs/kcl/types/SolidOrSketchOrImportedGeometry) | The solid, sketch, or set of solids or sketches to scale. | Yes |
| `scale` | [`[number]`](/docs/kcl/types/number) | The scale factor for the x, y, and z axes. | Yes |
| `global` | [`bool`](/docs/kcl/types/bool) | If true, the transform is applied in global space. The origin of the model will move. By default, the transform is applied in local sketch axis, therefore the origin will not move. | No |
### Returns
[`SolidOrImportedGeometry`](/docs/kcl/types/SolidOrImportedGeometry) - Data for a solid or an imported geometry.
[`SolidOrSketchOrImportedGeometry`](/docs/kcl/types/SolidOrSketchOrImportedGeometry) - Data for a solid or an imported geometry.
### Examples
@ -37,7 +37,6 @@ scale(
```js
// Scale a pipe.
// Create a path for the sweep.
sweepPath = startSketchOn('XZ')
|> startProfileAt([0.05, 0.05], %)

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@ Compute the cosine of a number (in radians).
```js
cos(num: number(rad)): number(_)
cos(@num: number(rad)): number(_)
```
@ -27,7 +27,7 @@ cos(num: number(rad)): number(_)
### Examples
```js
exampleSketch = startSketchOn("XZ")
exampleSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %)
|> angledLine({
angle = 30,

View File

@ -9,7 +9,7 @@ Compute the sine of a number (in radians).
```js
sin(num: number(rad)): number(_)
sin(@num: number(rad)): number(_)
```
@ -27,7 +27,7 @@ sin(num: number(rad)): number(_)
### Examples
```js
exampleSketch = startSketchOn("XZ")
exampleSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %)
|> angledLine({
angle = 50,

View File

@ -9,7 +9,7 @@ Compute the tangent of a number (in radians).
```js
tan(num: number(rad)): number(_)
tan(@num: number(rad)): number(_)
```
@ -27,7 +27,7 @@ tan(num: number(rad)): number(_)
### Examples
```js
exampleSketch = startSketchOn("XZ")
exampleSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %)
|> angledLine({
angle = 50,

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

56
docs/kcl/subtract.md Normal file

File diff suppressed because one or more lines are too long

View File

@ -16,6 +16,8 @@ sweep(
path: SweepPath,
sectional?: bool,
tolerance?: number,
tagStart?: TagDeclarator,
tagEnd?: TagDeclarator,
): [Solid]
```
@ -28,6 +30,8 @@ sweep(
| `path` | [`SweepPath`](/docs/kcl/types/SweepPath) | The path to sweep the sketch along | Yes |
| `sectional` | [`bool`](/docs/kcl/types/bool) | If true, the sweep will be broken up into sub-sweeps (extrusions, revolves, sweeps) based on the trajectory path components. | No |
| `tolerance` | [`number`](/docs/kcl/types/number) | Tolerance for this operation | No |
| `tagStart` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | A named tag for the face at the start of the sweep, i.e. the original sketch | No |
| `tagEnd` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | A named tag for the face at the end of the sweep | No |
### Returns
@ -39,7 +43,6 @@ sweep(
```js
// Create a pipe using a sweep.
// Create a path for the sweep.
sweepPath = startSketchOn('XZ')
|> startProfileAt([0.05, 0.05], %)
@ -64,7 +67,6 @@ sweepSketch = startSketchOn('XY')
```js
// Create a spring by sweeping around a helix path.
// Create a helix around the Z axis.
helixPath = helix(
angleStart = 0,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,28 +1,12 @@
---
title: "Face"
title: "std::Face"
excerpt: "A face."
layout: manual
---
A face.
**Type:** `object`
## Properties
| Property | Type | Description | Required |
|----------|------|-------------|----------|
| `id` |[`string`](/docs/kcl/types/string)| The id of the face. | No |
| `artifactId` |[`ArtifactId`](/docs/kcl/types/ArtifactId)| The artifact ID. | No |
| `value` |[`string`](/docs/kcl/types/string)| The tag of the face. | No |
| `xAxis` |[`Point3d`](/docs/kcl/types/Point3d)| What should the face's X axis be? | No |
| `yAxis` |[`Point3d`](/docs/kcl/types/Point3d)| What should the face's Y axis be? | No |
| `zAxis` |[`Point3d`](/docs/kcl/types/Point3d)| The z-axis (normal). | No |
| `solid` |[`Solid`](/docs/kcl/types/Solid)| The solid the face is on. | No |
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No |

View File

@ -1,26 +1,12 @@
---
title: "Helix"
title: "std::Helix"
excerpt: "A helix."
layout: manual
---
A helix.
**Type:** `object`
## Properties
| Property | Type | Description | Required |
|----------|------|-------------|----------|
| `value` |[`string`](/docs/kcl/types/string)| The id of the helix. | No |
| `artifactId` |[`ArtifactId`](/docs/kcl/types/ArtifactId)| The artifact ID. | No |
| `revolutions` |[`number`](/docs/kcl/types/number)| Number of revolutions. | No |
| `angleStart` |[`number`](/docs/kcl/types/number)| Start angle (in degrees). | No |
| `ccw` |`boolean`| Is the helix rotation counter clockwise? | No |
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No |

View File

@ -188,7 +188,7 @@ Any KCL value.
| Property | Type | Description | Required |
|----------|------|-------------|----------|
| `type` |enum: [`Face`](/docs/kcl/types/Face)| | No |
| `value` |[`Face`](/docs/kcl/types/Face)| A face. | No |
| `value` |[`Face`](/docs/kcl/types/Face)| | No |
----
@ -236,7 +236,7 @@ Any KCL value.
| Property | Type | Description | Required |
|----------|------|-------------|----------|
| `type` |enum: [`Helix`](/docs/kcl/types/Helix)| | No |
| `value` |[`Helix`](/docs/kcl/types/Helix)| A helix. | No |
| `value` |[`Helix`](/docs/kcl/types/Helix)| | No |
----

17
docs/kcl/types/Point2d.md Normal file
View File

@ -0,0 +1,17 @@
---
title: "std::Point2d"
excerpt: "A point in two dimensional space."
layout: manual
---
A point in two dimensional space.
```kcl
type Point2d = [number; 2]
```
[`Point2d`](/docs/kcl/types/Point2d) is an alias for a two-element array of [number](/docs/kcl/types/number)s. To write a value
with type [`Point2d`](/docs/kcl/types/Point2d), use an array, e.g., `[0, 0]` or `[5.0, 3.14]`.

View File

@ -1,22 +1,17 @@
---
title: "Point3d"
excerpt: ""
title: "std::Point3d"
excerpt: "A point in three dimensional space."
layout: manual
---
A point in three dimensional space.
**Type:** `object`
```kcl
type Point3d = [number; 3]
```
[`Point3d`](/docs/kcl/types/Point3d) is an alias for a three-element array of [number](/docs/kcl/types/number)s. To write a value
with type [`Point3d`](/docs/kcl/types/Point3d), use an array, e.g., `[0, 0, 0]` or `[5.0, 3.14, 6.8]`.
## Properties
| Property | Type | Description | Required |
|----------|------|-------------|----------|
| `x` |[`number`](/docs/kcl/types/number)| | No |
| `y` |[`number`](/docs/kcl/types/number)| | No |
| `z` |[`number`](/docs/kcl/types/number)| | No |

View File

@ -17,7 +17,7 @@ mySketch = startSketchOn('XY')
|> close()
```
The `mySketch` variable will be an executed `Sketch` object. Executed being past
The `mySketch` variable will be an executed [`Sketch`](/docs/kcl/types/Sketch) object. Executed being past
tense, because the engine has already executed the commands to create the sketch.
The previous sketch commands will never be executed again, in this case.

View File

@ -18,7 +18,7 @@ myPart = startSketchOn('XY')
|> extrude(length = 6)
```
The `myPart` variable will be an executed `Solid` object. Executed being past
The `myPart` variable will be an executed [`Solid`](/docs/kcl/types/Solid) object. Executed being past
tense, because the engine has already executed the commands to create the solid.
The previous solid commands will never be executed again, in this case.

View File

@ -0,0 +1,66 @@
---
title: "SolidOrSketchOrImportedGeometry"
excerpt: "Data for a solid or an imported geometry."
layout: manual
---
Data for a solid or an imported geometry.
**This schema accepts exactly one of the following:**
Data for an imported geometry.
**Type:** `object`
## Properties
| Property | Type | Description | Required |
|----------|------|-------------|----------|
| `type` |enum: `importedGeometry`| | 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 |
----
**Type:** `[object, array]`
`[` [`Solid`](/docs/kcl/types/Solid) `]`
## Properties
| Property | Type | Description | Required |
|----------|------|-------------|----------|
| `type` |enum: `solidSet`| | No |
----
**Type:** `[object, array]`
`[` [`Sketch`](/docs/kcl/types/Sketch) `]`
## Properties
| Property | Type | Description | Required |
|----------|------|-------------|----------|
| `type` |enum: `sketchSet`| | No |
----

View File

@ -22,7 +22,6 @@ A path to sweep along.
----
A helix.
[`Helix`](/docs/kcl/types/Helix)

50
docs/kcl/union.md Normal file

File diff suppressed because one or more lines are too long

View File

@ -2,7 +2,7 @@ import { test, expect } from './zoo-test'
import * as fsp from 'fs/promises'
import { executorInputPath, getUtils } from './test-utils'
import { KCL_DEFAULT_LENGTH } from 'lib/constants'
import path from 'path'
import path, { join } from 'path'
test.describe('Command bar tests', { tag: ['@skipWin'] }, () => {
test('Extrude from command bar selects extrude line after', async ({
@ -487,4 +487,53 @@ test.describe('Command bar tests', { tag: ['@skipWin'] }, () => {
await toolbar.expectFileTreeState(['main.kcl', 'test.kcl'])
})
})
test(`Can add a named parameter or constant`, async ({
page,
homePage,
context,
cmdBar,
scene,
editor,
}) => {
const projectName = 'test'
const beforeKclCode = `a = 5
b = a * a
c = 3 + a`
await context.folderSetupFn(async (dir) => {
const testProject = join(dir, projectName)
await fsp.mkdir(testProject, { recursive: true })
await fsp.writeFile(join(testProject, 'main.kcl'), beforeKclCode, 'utf-8')
})
await homePage.openProject(projectName)
// TODO: you probably shouldn't need an engine connection to add a parameter,
// but you do because all modeling commands have that requirement
await scene.settled(cmdBar)
await test.step(`Go through the command palette flow`, async () => {
await cmdBar.cmdBarOpenBtn.click()
await cmdBar.chooseCommand('create parameter')
await cmdBar.expectState({
stage: 'arguments',
commandName: 'Create parameter',
currentArgKey: 'value',
currentArgValue: '5',
headerArguments: {
Value: '',
},
highlightedHeaderArg: 'value',
})
await cmdBar.argumentInput.locator('[contenteditable]').fill(`b - 5`)
// TODO: we have no loading indicator for the KCL argument input calculation
await page.waitForTimeout(100)
await cmdBar.progressCmdBar()
await cmdBar.expectState({
stage: 'commandBarClosed',
})
})
await editor.expectEditor.toContain(
`a = 5b = a * amyParameter001 = b - 5c = 3 + a`
)
})
})

View File

@ -100,7 +100,8 @@ test(
try {
const outputGltf = await fsp.readFile(firstFileFullPath)
return outputGltf.byteLength
} catch (e) {
} catch (error: unknown) {
void error
return 0
}
},
@ -179,7 +180,8 @@ test(
try {
const outputGltf = await fsp.readFile(secondFileFullPath)
return outputGltf.byteLength
} catch (e) {
} catch (error: unknown) {
void error
return 0
}
},

View File

@ -726,10 +726,10 @@ test.describe('Editor tests', { tag: ['@skipWin'] }, () => {
|> line(end = [2, 0])
|> line(end = [0, -10])
|> close()
|> revolve({
axis: revolveAxis,
angle: 90
}, %)
|> revolve(
axis = revolveAxis,
angle = 90
)
`
)
})

View File

@ -21,7 +21,7 @@ sketch001 = startSketchOn('XZ')
|> angledLine([-45, length001], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()
revolve001 = revolve({ axis = "X" }, sketch001)
revolve001 = revolve(sketch001, axis = "X")
triangle()
|> extrude(length = 30)
plane001 = offsetPlane('XY', offset = 10)
@ -126,7 +126,7 @@ test.describe('Feature Tree pane', () => {
await testViewSource({
operationName: 'Revolve',
operationIndex: 0,
expectedActiveLine: 'revolve001 = revolve({ axis = "X" }, sketch001)',
expectedActiveLine: 'revolve001 = revolve(sketch001, axis = "X")',
})
await testViewSource({
operationName: 'Triangle',
@ -231,10 +231,10 @@ test.describe('Feature Tree pane', () => {
|> circle(center = [0, 0], radius = 5)
renamedExtrude = extrude(sketch001, length = ${initialInput})`
const newConstantName = 'distance001'
const expectedCode = `sketch001 = startSketchOn('XZ')
const expectedCode = `${newConstantName} = 23
sketch001 = startSketchOn('XZ')
|> circle(center = [0, 0], radius = 5)
${newConstantName} = 23
renamedExtrude = extrude(sketch001, length = ${newConstantName})`
renamedExtrude = extrude(sketch001, length = ${newConstantName})`
await context.folderSetupFn(async (dir) => {
const testDir = join(dir, 'test-sample')

View File

@ -1197,7 +1197,7 @@ test.describe('Undo and redo do not keep history when navigating between files',
`cloned file has an incremented name and same contents`,
{ tag: '@electron' },
async ({ page, context, homePage }, testInfo) => {
const { panesOpen, createNewFile, cloneFile } = await getUtils(page, test)
const { panesOpen, cloneFile } = await getUtils(page, test)
const { dir } = await context.folderSetupFn(async (dir) => {
const finalDir = join(dir, 'testDefault')

View File

@ -152,9 +152,15 @@ export class EditorFixture {
}
replaceCode = async (findCode: string, replaceCode: string) => {
const lines = await this.page.locator('.cm-line').all()
let code = (await Promise.all(lines.map((c) => c.textContent()))).join('\n')
if (!lines) return
code = code.replace(findCode, replaceCode)
if (!findCode) {
// nuke everything
code = replaceCode
} else {
if (!lines) return
code = code.replace(findCode, replaceCode)
}
await this.codeContent.fill(code)
}
checkIfPaneIsOpen() {

View File

@ -3,25 +3,15 @@
import type {
BrowserContext,
ElectronApplication,
Fixtures as PlaywrightFixtures,
TestInfo,
Page,
} from '@playwright/test'
import {
_electron as electron,
PlaywrightTestArgs,
PlaywrightWorkerArgs,
} from '@playwright/test'
import { _electron as electron } from '@playwright/test'
import * as TOML from '@iarna/toml'
import {
TEST_SETTINGS_KEY,
TEST_SETTINGS_CORRUPTED,
TEST_SETTINGS,
TEST_SETTINGS_DEFAULT_THEME,
} from '../storageStates'
import { SETTINGS_FILE_NAME, PROJECT_SETTINGS_FILE_NAME } from 'lib/constants'
import { TEST_SETTINGS } from '../storageStates'
import { SETTINGS_FILE_NAME } from 'lib/constants'
import { getUtils, setup } from '../test-utils'
import fsp from 'fs/promises'
import fs from 'node:fs'
@ -31,7 +21,6 @@ import { EditorFixture } from './editorFixture'
import { ToolbarFixture } from './toolbarFixture'
import { SceneFixture } from './sceneFixture'
import { HomePageFixture } from './homePageFixture'
import { unsafeTypedKeys } from 'lib/utils'
import { DeepPartial } from 'lib/types'
import { Settings } from '@rust/kcl-lib/bindings/Settings'
@ -278,13 +267,14 @@ export class ElectronZoo {
if (fs.existsSync(this.projectDirName)) {
await fsp.rm(this.projectDirName, { recursive: true })
}
} catch (e) {
console.error(e)
} catch (_e) {
console.error(_e)
}
try {
await fsp.mkdir(this.projectDirName)
} catch (e) {
} catch (error: unknown) {
void error
// Not a problem if it already exists.
}

View File

@ -850,159 +850,157 @@ openSketch = startSketchOn('XY')
})
})
test(`Shift-click to select and deselect sketch segments`, async ({
page,
homePage,
scene,
editor,
}) => {
// Locators
const firstPointLocation = { x: 200, y: 100 }
const secondPointLocation = { x: 800, y: 100 }
const thirdPointLocation = { x: 800, y: 400 }
const fristSegmentLocation = { x: 750, y: 100 }
const secondSegmentLocation = { x: 800, y: 150 }
const planeLocation = { x: 700, y: 200 }
test.fixme(
`Shift-click to select and deselect sketch segments`,
async ({ page, homePage, scene, editor }) => {
// Locators
const firstPointLocation = { x: 200, y: 100 }
const secondPointLocation = { x: 800, y: 100 }
const thirdPointLocation = { x: 800, y: 400 }
const fristSegmentLocation = { x: 750, y: 100 }
const secondSegmentLocation = { x: 800, y: 150 }
const planeLocation = { x: 700, y: 200 }
// Click helpers
const [clickFirstPoint] = scene.makeMouseHelpers(
firstPointLocation.x,
firstPointLocation.y
)
const [clickSecondPoint] = scene.makeMouseHelpers(
secondPointLocation.x,
secondPointLocation.y
)
const [clickThirdPoint] = scene.makeMouseHelpers(
thirdPointLocation.x,
thirdPointLocation.y
)
const [clickFirstSegment] = scene.makeMouseHelpers(
fristSegmentLocation.x,
fristSegmentLocation.y
)
const [clickSecondSegment] = scene.makeMouseHelpers(
secondSegmentLocation.x,
secondSegmentLocation.y
)
const [clickPlane] = scene.makeMouseHelpers(
planeLocation.x,
planeLocation.y
)
// Colors
const edgeColorWhite: [number, number, number] = [220, 220, 220]
const edgeColorBlue: [number, number, number] = [20, 20, 200]
const backgroundColor: [number, number, number] = [30, 30, 30]
const tolerance = 40
const timeout = 150
// Setup
await test.step(`Initial test setup`, async () => {
await page.setBodyDimensions({ width: 1000, height: 500 })
await homePage.goToModelingScene()
// Wait for the scene and stream to load
await scene.expectPixelColor(
backgroundColor,
secondPointLocation,
tolerance
// Click helpers
const [clickFirstPoint] = scene.makeMouseHelpers(
firstPointLocation.x,
firstPointLocation.y
)
const [clickSecondPoint] = scene.makeMouseHelpers(
secondPointLocation.x,
secondPointLocation.y
)
const [clickThirdPoint] = scene.makeMouseHelpers(
thirdPointLocation.x,
thirdPointLocation.y
)
const [clickFirstSegment] = scene.makeMouseHelpers(
fristSegmentLocation.x,
fristSegmentLocation.y
)
const [clickSecondSegment] = scene.makeMouseHelpers(
secondSegmentLocation.x,
secondSegmentLocation.y
)
const [clickPlane] = scene.makeMouseHelpers(
planeLocation.x,
planeLocation.y
)
})
await test.step('Select and deselect a single sketch segment', async () => {
await test.step('Get into sketch mode', async () => {
await editor.closePane()
await page.waitForTimeout(timeout)
await page.getByRole('button', { name: 'Start Sketch' }).click()
await page.waitForTimeout(timeout)
await clickPlane()
await page.waitForTimeout(1000)
})
await test.step('Draw sketch', async () => {
await clickFirstPoint()
await page.waitForTimeout(timeout)
await clickSecondPoint()
await page.waitForTimeout(timeout)
await clickThirdPoint()
await page.waitForTimeout(timeout)
})
await test.step('Deselect line tool', async () => {
const btnLine = page.getByTestId('line')
const btnLineAriaPressed = await btnLine.getAttribute('aria-pressed')
if (btnLineAriaPressed === 'true') {
await btnLine.click()
}
await page.waitForTimeout(timeout)
})
await test.step('Select the first segment', async () => {
await page.waitForTimeout(timeout)
await clickFirstSegment()
await page.waitForTimeout(timeout)
// Colors
const edgeColorWhite: [number, number, number] = [220, 220, 220]
const edgeColorBlue: [number, number, number] = [20, 20, 200]
const backgroundColor: [number, number, number] = [30, 30, 30]
const tolerance = 40
const timeout = 150
// Setup
await test.step(`Initial test setup`, async () => {
await page.setBodyDimensions({ width: 1000, height: 500 })
await homePage.goToModelingScene()
// Wait for the scene and stream to load
await scene.expectPixelColor(
edgeColorBlue,
fristSegmentLocation,
tolerance
)
await scene.expectPixelColor(
edgeColorWhite,
secondSegmentLocation,
backgroundColor,
secondPointLocation,
tolerance
)
})
await test.step('Select the second segment (Shift-click)', async () => {
await page.keyboard.down('Shift')
await page.waitForTimeout(timeout)
await clickSecondSegment()
await page.waitForTimeout(timeout)
await page.keyboard.up('Shift')
await scene.expectPixelColor(
edgeColorBlue,
fristSegmentLocation,
tolerance
)
await scene.expectPixelColor(
edgeColorBlue,
secondSegmentLocation,
tolerance
)
await test.step('Select and deselect a single sketch segment', async () => {
await test.step('Get into sketch mode', async () => {
await editor.closePane()
await page.waitForTimeout(timeout)
await page.getByRole('button', { name: 'Start Sketch' }).click()
await page.waitForTimeout(timeout)
await clickPlane()
await page.waitForTimeout(1000)
})
await test.step('Draw sketch', async () => {
await clickFirstPoint()
await page.waitForTimeout(timeout)
await clickSecondPoint()
await page.waitForTimeout(timeout)
await clickThirdPoint()
await page.waitForTimeout(timeout)
})
await test.step('Deselect line tool', async () => {
const btnLine = page.getByTestId('line')
const btnLineAriaPressed = await btnLine.getAttribute('aria-pressed')
if (btnLineAriaPressed === 'true') {
await btnLine.click()
}
await page.waitForTimeout(timeout)
})
await test.step('Select the first segment', async () => {
await page.waitForTimeout(timeout)
await clickFirstSegment()
await page.waitForTimeout(timeout)
await scene.expectPixelColor(
edgeColorBlue,
fristSegmentLocation,
tolerance
)
await scene.expectPixelColor(
edgeColorWhite,
secondSegmentLocation,
tolerance
)
})
await test.step('Select the second segment (Shift-click)', async () => {
await page.keyboard.down('Shift')
await page.waitForTimeout(timeout)
await clickSecondSegment()
await page.waitForTimeout(timeout)
await page.keyboard.up('Shift')
await scene.expectPixelColor(
edgeColorBlue,
fristSegmentLocation,
tolerance
)
await scene.expectPixelColor(
edgeColorBlue,
secondSegmentLocation,
tolerance
)
})
await test.step('Deselect the first segment', async () => {
await page.keyboard.down('Shift')
await page.waitForTimeout(timeout)
await clickFirstSegment()
await page.waitForTimeout(timeout)
await page.keyboard.up('Shift')
await scene.expectPixelColor(
edgeColorWhite,
fristSegmentLocation,
tolerance
)
await scene.expectPixelColor(
edgeColorBlue,
secondSegmentLocation,
tolerance
)
})
await test.step('Deselect the second segment', async () => {
await page.keyboard.down('Shift')
await page.waitForTimeout(timeout)
await clickSecondSegment()
await page.waitForTimeout(timeout)
await page.keyboard.up('Shift')
await scene.expectPixelColor(
edgeColorWhite,
fristSegmentLocation,
tolerance
)
await scene.expectPixelColor(
edgeColorWhite,
secondSegmentLocation,
tolerance
)
})
})
await test.step('Deselect the first segment', async () => {
await page.keyboard.down('Shift')
await page.waitForTimeout(timeout)
await clickFirstSegment()
await page.waitForTimeout(timeout)
await page.keyboard.up('Shift')
await scene.expectPixelColor(
edgeColorWhite,
fristSegmentLocation,
tolerance
)
await scene.expectPixelColor(
edgeColorBlue,
secondSegmentLocation,
tolerance
)
})
await test.step('Deselect the second segment', async () => {
await page.keyboard.down('Shift')
await page.waitForTimeout(timeout)
await clickSecondSegment()
await page.waitForTimeout(timeout)
await page.keyboard.up('Shift')
await scene.expectPixelColor(
edgeColorWhite,
fristSegmentLocation,
tolerance
)
await scene.expectPixelColor(
edgeColorWhite,
secondSegmentLocation,
tolerance
)
})
})
})
}
)
test(`Offset plane point-and-click`, async ({
context,
@ -1880,6 +1878,119 @@ fillet04 = fillet(extrude001, radius = 5, tags = [getOppositeEdge(seg02)])
})
})
test(`Fillet with large radius should update code even if engine fails`, async ({
context,
page,
homePage,
scene,
editor,
toolbar,
cmdBar,
}) => {
// Create a cube with small edges that will cause some fillets to fail
const initialCode = `sketch001 = startSketchOn('XY')
profile001 = startProfileAt([0, 0], sketch001)
|> yLine(length = -1)
|> xLine(length = -10)
|> yLine(length = 10)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()
extrude001 = extrude(profile001, length = 5)
`
const taggedSegment = `yLine(length = -1, tag = $seg01)`
const filletExpression = `fillet(radius = 1000, tags = [getNextAdjacentEdge(seg01)])`
// Locators
const edgeLocation = { x: 659, y: 313 }
const bodyLocation = { x: 594, y: 313 }
// Colors
const edgeColorWhite: [number, number, number] = [248, 248, 248]
const edgeColorYellow: [number, number, number] = [251, 251, 120] // Mac:B=251,251,90 Ubuntu:240,241,180, Windows:240,241,180
const backgroundColor: [number, number, number] = [30, 30, 30]
const bodyColor: [number, number, number] = [155, 155, 155]
const lowTolerance = 20
const highTolerance = 70
// Setup
await test.step(`Initial test setup`, async () => {
await context.addInitScript((initialCode) => {
localStorage.setItem('persistCode', initialCode)
}, initialCode)
await page.setBodyDimensions({ width: 1000, height: 500 })
await homePage.goToModelingScene()
// verify modeling scene is loaded
await scene.expectPixelColor(backgroundColor, edgeLocation, lowTolerance)
// wait for stream to load
await scene.expectPixelColor(bodyColor, bodyLocation, highTolerance)
})
// Test
await test.step('Select edges and apply oversized fillet', async () => {
await test.step(`Select the edge`, async () => {
await scene.expectPixelColor(edgeColorWhite, edgeLocation, lowTolerance)
const [clickOnTheEdge] = scene.makeMouseHelpers(
edgeLocation.x,
edgeLocation.y
)
await clickOnTheEdge()
await scene.expectPixelColor(
edgeColorYellow,
edgeLocation,
highTolerance // Ubuntu color mismatch can require high tolerance
)
})
await test.step(`Apply fillet`, async () => {
await page.waitForTimeout(100)
await toolbar.filletButton.click()
await cmdBar.expectState({
commandName: 'Fillet',
highlightedHeaderArg: 'selection',
currentArgKey: 'selection',
currentArgValue: '',
headerArguments: {
Selection: '',
Radius: '',
},
stage: 'arguments',
})
await cmdBar.progressCmdBar()
await cmdBar.expectState({
commandName: 'Fillet',
highlightedHeaderArg: 'radius',
currentArgKey: 'radius',
currentArgValue: '5',
headerArguments: {
Selection: '1 sweepEdge',
Radius: '',
},
stage: 'arguments',
})
// Set a large radius (1000)
await cmdBar.currentArgumentInput.locator('.cm-content').fill('1000')
await cmdBar.progressCmdBar()
await cmdBar.expectState({
commandName: 'Fillet',
headerArguments: {
Selection: '1 sweepEdge',
Radius: '1000',
},
stage: 'review',
})
// Apply fillet with large radius
await cmdBar.progressCmdBar()
})
})
await test.step('Verify code is updated regardless of execution errors', async () => {
await editor.expectEditor.toContain(taggedSegment)
await editor.expectEditor.toContain(filletExpression)
})
})
test(`Chamfer point-and-click`, async ({
context,
page,
@ -1906,7 +2017,6 @@ extrude001 = extrude(sketch001, length = -12)
// Locators
const firstEdgeLocation = { x: 600, y: 193 }
const secondEdgeLocation = { x: 600, y: 383 }
const bodyLocation = { x: 630, y: 290 }
const [clickOnFirstEdge] = scene.makeMouseHelpers(
firstEdgeLocation.x,
firstEdgeLocation.y
@ -1919,7 +2029,6 @@ extrude001 = extrude(sketch001, length = -12)
// Colors
const edgeColorWhite: [number, number, number] = [248, 248, 248]
const edgeColorYellow: [number, number, number] = [251, 251, 40] // Mac:B=67 Ubuntu:B=12
const bodyColor: [number, number, number] = [155, 155, 155]
const chamferColor: [number, number, number] = [168, 168, 168]
const backgroundColor: [number, number, number] = [30, 30, 30]
const lowTolerance = 20
@ -2812,7 +2921,7 @@ segAng(rectangleSegmentA002),
await cmdBar.progressCmdBar()
await cmdBar.progressCmdBar()
const newCodeToFind = `revolve001 = revolve({ angle = 360, axis = 'X' }, sketch002)`
const newCodeToFind = `revolve001 = revolve(sketch002, angle = 360, axis = 'X')`
expect(editor.expectEditor.toContain(newCodeToFind)).toBeTruthy()
})
test('revolve surface around edge from an extruded solid2d', async ({
@ -2862,7 +2971,7 @@ radius = 8.69
await page.getByText(lineCodeToSelection).click()
await cmdBar.progressCmdBar()
const newCodeToFind = `revolve001 = revolve({angle = 360, axis = getOppositeEdge(rectangleSegmentA001)}, sketch002) `
const newCodeToFind = `revolve001 = revolve(sketch002, angle = 360, axis = getOppositeEdge(rectangleSegmentA001)) `
expect(editor.expectEditor.toContain(newCodeToFind)).toBeTruthy()
})
test('revolve sketch circle around line segment from startProfileAt sketch', async ({
@ -2913,7 +3022,7 @@ radius = 8.69
await page.getByText(lineCodeToSelection).click()
await cmdBar.progressCmdBar()
const newCodeToFind = `revolve001 = revolve({ angle = 360, axis = seg01 }, sketch003)`
const newCodeToFind = `revolve001 = revolve(sketch003, angle = 360, axis = seg01)`
expect(editor.expectEditor.toContain(newCodeToFind)).toBeTruthy()
})
})

View File

@ -539,7 +539,8 @@ test.describe('Can export from electron app', () => {
try {
const outputGltf = await fsp.readFile(filepath)
return outputGltf.byteLength
} catch (e) {
} catch (error: unknown) {
void error
return 0
}
},

View File

@ -196,64 +196,60 @@ test.describe('Prompt-to-edit tests', { tag: '@skipWin' }, () => {
})
})
test(`manual code selection rename`, async ({
context,
homePage,
cmdBar,
editor,
page,
scene,
}) => {
const body1CapCoords = { x: 571, y: 311 }
test.fixme(
`manual code selection rename`,
async ({ context, homePage, cmdBar, editor, page, scene }) => {
const body1CapCoords = { x: 571, y: 311 }
await context.addInitScript((file) => {
localStorage.setItem('persistCode', file)
}, file)
await homePage.goToModelingScene()
await scene.waitForExecutionDone()
await context.addInitScript((file) => {
localStorage.setItem('persistCode', file)
}, file)
await homePage.goToModelingScene()
await scene.waitForExecutionDone()
const submittingToast = page.getByText('Submitting to Text-to-CAD API...')
const successToast = page.getByText('Prompt to edit successful')
const acceptBtn = page.getByRole('button', { name: 'checkmark Accept' })
const submittingToast = page.getByText('Submitting to Text-to-CAD API...')
const successToast = page.getByText('Prompt to edit successful')
const acceptBtn = page.getByRole('button', { name: 'checkmark Accept' })
await test.step('wait for scene to load and select code in editor', async () => {
// Find and select the text "sketch002" in the editor
await editor.selectText('sketch002')
await test.step('wait for scene to load and select code in editor', async () => {
// Find and select the text "sketch002" in the editor
await editor.selectText('sketch002')
// Verify the selection was made
await editor.expectState({
highlightedCode: '',
activeLines: ["sketch002 = startSketchOn('XZ')"],
diagnostics: [],
// Verify the selection was made
await editor.expectState({
highlightedCode: '',
activeLines: ["sketch002 = startSketchOn('XZ')"],
diagnostics: [],
})
})
})
await test.step('fire off edit prompt', async () => {
await scene.expectPixelColor([134, 134, 134], body1CapCoords, 15)
await cmdBar.openCmdBar('promptToEdit')
await page
.getByTestId('cmd-bar-arg-value')
.fill('Please rename to mySketch001')
await page.waitForTimeout(100)
await cmdBar.progressCmdBar()
await expect(submittingToast).toBeVisible()
await expect(submittingToast).not.toBeVisible({
timeout: 2 * 60_000,
await test.step('fire off edit prompt', async () => {
await scene.expectPixelColor([134, 134, 134], body1CapCoords, 15)
await cmdBar.openCmdBar('promptToEdit')
await page
.getByTestId('cmd-bar-arg-value')
.fill('Please rename to mySketch001')
await page.waitForTimeout(100)
await cmdBar.progressCmdBar()
await expect(submittingToast).toBeVisible()
await expect(submittingToast).not.toBeVisible({
timeout: 2 * 60_000,
})
await expect(successToast).toBeVisible()
})
await expect(successToast).toBeVisible()
})
await test.step('verify rename change and accept it', async () => {
await editor.expectEditor.toContain('mySketch001 = startSketchOn')
await editor.expectEditor.not.toContain('sketch002 = startSketchOn')
await editor.expectEditor.toContain(
'extrude002 = extrude(mySketch001, length = 50)'
)
await test.step('verify rename change and accept it', async () => {
await editor.expectEditor.toContain('mySketch001 = startSketchOn')
await editor.expectEditor.not.toContain('sketch002 = startSketchOn')
await editor.expectEditor.toContain(
'extrude002 = extrude(mySketch001, length = 50)'
)
await acceptBtn.click()
await expect(successToast).not.toBeVisible()
})
})
await acceptBtn.click()
await expect(successToast).not.toBeVisible()
})
}
)
test('multiple body selections', async ({
context,

View File

@ -405,8 +405,9 @@ extrude001 = extrude(sketch001, length = 50)
await expect(successToastMessage).toBeVisible()
}
)
// We updated this test such that you can have multiple exports going at once.
test(
'ensure you can not export while an export is already going',
'ensure you CAN export while an export is already going',
{ tag: ['@skipLinux', '@skipWin'] },
async ({ page, homePage }) => {
const u = await getUtils(page)
@ -441,22 +442,13 @@ extrude001 = extrude(sketch001, length = 50)
const alreadyExportingToastMessage = page.getByText(`Already exporting`)
const successToastMessage = page.getByText(`Exported successfully`)
await test.step('Blocked second export', async () => {
await test.step('second export', async () => {
await clickExportButton(page)
await expect(exportingToastMessage).toBeVisible()
await clickExportButton(page)
await test.step('The second export is blocked', async () => {
// Find the toast.
// Look out for the toast message
await Promise.all([
expect(exportingToastMessage.first()).toBeVisible(),
expect(alreadyExportingToastMessage).toBeVisible(),
])
})
await test.step('The first export still succeeds', async () => {
await Promise.all([
expect(exportingToastMessage).not.toBeVisible({ timeout: 15_000 }),
@ -486,12 +478,12 @@ extrude001 = extrude(sketch001, length = 50)
expect(alreadyExportingToastMessage).not.toBeVisible(),
])
await expect(successToastMessage).toBeVisible()
await expect(successToastMessage).toHaveCount(2)
})
}
)
test(
test.fixme(
`Network health indicator only appears in modeling view`,
{ tag: '@electron' },
async ({ context, page }, testInfo) => {

View File

@ -14,7 +14,8 @@ try {
// prefer env vars over secrets file
secrets[key] = process.env[key] || (value as any).replaceAll('"', '')
})
} catch (err) {
} catch (error: unknown) {
void error
// probably running in CI
console.warn(
`Error reading ${secretsPath}; environment variables will be used`

View File

@ -187,7 +187,7 @@ sketch001 = startProfileAt([12.34, -12.34], sketch002)
page.getByRole('button', { name: 'Start Sketch' })
).toBeVisible()
})
test.describe('Can edit segments by dragging their handles', () => {
test.fixme('Can edit segments by dragging their handles', () => {
const doEditSegmentsByDraggingHandle = async (
page: Page,
homePage: HomePageFixture,
@ -666,7 +666,7 @@ sketch001 = startProfileAt([12.34, -12.34], sketch002)
|> line(end = [12.73, -0.09])
|> tangentialArcTo([24.95, -5.38], %)
|> close()
|> revolve({ axis = "X",}, %)`
|> revolve(axis = "X")`
)
})
@ -753,7 +753,7 @@ sketch001 = startProfileAt([12.34, -12.34], sketch002)
|> tangentialArcTo([24.95, -5.38], %)
|> line(end = [1.97, 2.06])
|> close()
|> revolve({ axis = "X" }, %)`)
|> revolve(axis = "X")`)
})
test('Can add multiple sketches', async ({ page, homePage }) => {
const u = await getUtils(page)
@ -1200,7 +1200,7 @@ profile001 = startProfileAt([${roundOff(scale * 69.6)}, ${roundOff(
|> xLine(endAbsolute = 0 + .001)
|> yLine(endAbsolute = 0)
|> close()
|> revolve({ axis = "Y" }, %)
|> revolve(axis = "Y")
return lugSketch
}
@ -1454,7 +1454,7 @@ test.describe(`Sketching with offset planes`, () => {
})
test.describe('multi-profile sketching', () => {
test(
test.fixme(
`test it removes half-finished expressions when changing tools in sketch mode`,
{ tag: ['@skipWin'] },
async ({ context, page, scene, toolbar, editor, homePage, cmdBar }) => {
@ -1662,6 +1662,96 @@ profile003 = startProfileAt([206.63, -56.73], sketch001)
})
}
)
test('can enter sketch mode for sketch with no profiles', async ({
scene,
toolbar,
editor,
cmdBar,
page,
homePage,
}) => {
await page.addInitScript(async () => {
localStorage.setItem(
'persistCode',
`sketch001 = startSketchOn('XY')
`
)
})
await page.setBodyDimensions({ width: 1000, height: 500 })
await homePage.goToModelingScene()
await scene.connectionEstablished()
await scene.settled(cmdBar)
await expect(
page.getByRole('button', { name: 'Start Sketch' })
).not.toBeDisabled()
// open feature tree and double click the first sketch
await (await toolbar.getFeatureTreeOperation('Sketch', 0)).dblclick()
await page.waitForTimeout(600)
// click in the scene twice to add a segment
const [startProfile1] = scene.makeMouseHelpers(658, 140)
const [segment1Clk] = scene.makeMouseHelpers(701, 200)
// wait for line to be aria pressed
await expect
.poll(async () => toolbar.lineBtn.getAttribute('aria-pressed'))
.toBe('true')
await startProfile1()
await editor.expectEditor.toContain(`profile001 = startProfileAt`)
await segment1Clk()
await editor.expectEditor.toContain(`|> line(end`)
})
test('can delete all profiles in sketch mode and user can still equip a tool and draw something', async ({
scene,
toolbar,
editor,
page,
homePage,
}) => {
await page.setBodyDimensions({ width: 1000, height: 500 })
await homePage.goToModelingScene()
await scene.connectionEstablished()
await expect(
page.getByRole('button', { name: 'Start Sketch' })
).not.toBeDisabled()
const [selectXZPlane] = scene.makeMouseHelpers(650, 150)
await toolbar.startSketchPlaneSelection()
await selectXZPlane()
// timeout wait for engine animation is unavoidable
await page.waitForTimeout(600)
await editor.expectEditor.toContain(`sketch001 = startSketchOn('XZ')`)
const [startProfile1] = scene.makeMouseHelpers(568, 70)
const [segment1Clk] = scene.makeMouseHelpers(701, 78)
const [segment2Clk] = scene.makeMouseHelpers(745, 189)
await test.step('add two segments', async () => {
await startProfile1()
await editor.expectEditor.toContain(
`profile001 = startProfileAt([4.61, 12.21], sketch001)`
)
await segment1Clk()
await editor.expectEditor.toContain(`|> line(end`)
await segment2Clk()
await editor.expectEditor.toContain(`|> line(end = [2.98, -7.52])`)
})
await test.step('delete all profiles', async () => {
await editor.replaceCode('', "sketch001 = startSketchOn('XZ')\n")
await page.waitForTimeout(600) // wait for deferred execution
})
await test.step('equip circle and draw it', async () => {
await toolbar.circleBtn.click()
await page.mouse.click(700, 200)
await page.mouse.click(750, 200)
await editor.expectEditor.toContain('circle(sketch001, center = [')
})
})
test('Can add multiple profiles to a sketch (all tool types)', async ({
scene,
toolbar,
@ -2570,10 +2660,11 @@ profile006 = startProfileAt([9.65, 3.82], sketch002)
|> line(end = [2.13, -5.57])
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()
revolve001 = revolve({
revolve001 = revolve(
profile004,
angle = 45,
axis = getNextAdjacentEdge(seg01)
}, profile004)
)
extrude002 = extrude(profile006, length = 4)
sketch003 = startSketchOn('-XZ')
profile007 = startProfileAt([4.8, 7.55], sketch003)
@ -2608,7 +2699,7 @@ profile011 = startProfileAt([5.07, -6.39], sketch003)
|> close()
extrude003 = extrude(profile011, length = 2.5)
// TODO this breaks the test,
// revolve002 = revolve({ angle = 45, axis = seg02 }, profile008)
// revolve002 = revolve(profile008, angle = 45, axis = seg02)
`
)
})
@ -2626,11 +2717,6 @@ extrude003 = extrude(profile011, length = 2.5)
{ x: 834, y: -680, z: 534 },
{ x: -54, y: -476, z: 148 }
)
const camPositionForSelectingSketchOnCapProfiles = () =>
scene.moveCameraTo(
{ x: 404, y: 690, z: 38 },
{ x: 16, y: -140, z: -10 }
)
const wallSelectionOptions = [
{
title: 'select wall segment',
@ -2653,29 +2739,6 @@ extrude003 = extrude(profile011, length = 2.5)
selectClick: scene.makeMouseHelpers(836, 103)[0],
},
] as const
const capSelectionOptions = [
{
title: 'select cap segment',
selectClick: scene.makeMouseHelpers(688, 91)[0],
},
{
title: 'select cap solid 2d',
selectClick: scene.makeMouseHelpers(733, 204)[0],
},
// TODO keeps failing
// {
// title: 'select cap circle',
// selectClick: scene.makeMouseHelpers(679, 290)[0],
// },
{
title: 'select cap extrude wall',
selectClick: scene.makeMouseHelpers(649, 402)[0],
},
{
title: 'select cap extrude cap',
selectClick: scene.makeMouseHelpers(693, 408)[0],
},
] as const
const verifyWallProfilesAreDrawn = async () =>
test.step('verify wall profiles are drawn', async () => {
@ -2697,44 +2760,6 @@ extrude003 = extrude(profile011, length = 2.5)
])
})
const verifyCapProfilesAreDrawn = async () =>
test.step('verify cap profiles are drawn', async () => {
// open polygon
await scene.expectPixelColor(
TEST_COLORS.WHITE,
// TEST_COLORS.BLUE, // When entering via the circle, it's selected and therefore blue
{ x: 620, y: 58 },
15
)
// revolved profile
await scene.expectPixelColor(
TEST_COLORS.WHITE,
{ x: 641, y: 110 },
15
)
// closed polygon
await scene.expectPixelColor(
TEST_COLORS.WHITE,
{ x: 632, y: 200 },
15
)
// extruded profile
await scene.expectPixelColor(
TEST_COLORS.WHITE,
{ x: 628, y: 410 },
15
)
// circle
await scene.expectPixelColor(
[
TEST_COLORS.WHITE,
TEST_COLORS.BLUE, // When entering via the circle, it's selected and therefore blue
],
{ x: 681, y: 303 },
15
)
})
await test.step('select wall profiles', async () => {
for (const { title, selectClick } of wallSelectionOptions) {
await test.step(title, async () => {

View File

@ -7,12 +7,7 @@ import { spawn } from 'child_process'
import { KCL_DEFAULT_LENGTH } from 'lib/constants'
import JSZip from 'jszip'
import path from 'path'
import {
IS_PLAYWRIGHT_KEY,
TEST_SETTINGS,
TEST_SETTINGS_KEY,
} from './storageStates'
import * as TOML from '@iarna/toml'
import { TEST_SETTINGS, TEST_SETTINGS_KEY } from './storageStates'
import { SceneFixture } from './fixtures/sceneFixture'
import { CmdBarFixture } from './fixtures/cmdBarFixture'

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 KiB

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 145 KiB

After

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 128 KiB

After

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 68 KiB

View File

@ -1,4 +1,3 @@
import { MouseControlType } from '@rust/kcl-lib/bindings/MouseControlType'
import { Settings } from '@rust/kcl-lib/bindings/Settings'
import { SaveSettingsPayload } from 'lib/settings/settingsTypes'
import { Themes } from 'lib/theme'
@ -143,10 +142,10 @@ sketch001 = startSketchOn(box, revolveAxis)
|> line(end = [2, 0])
|> line(end = [0, -10])
|> close()
|> revolve({
axis: revolveAxis,
angle: 90
}, %)
|> revolve(
axis = revolveAxis,
angle = 90
)
sketch001 = startSketchOn('XZ')
|> startProfileAt([0.0, 0.0], %)

View File

@ -3,7 +3,7 @@ import { commonPoints, getUtils } from './test-utils'
import { EngineCommand } from 'lang/std/artifactGraph'
import { uuidv4 } from 'lib/utils'
test.describe('Test network and connection issues', () => {
test.fixme('Test network and connection issues', () => {
test(
'simulate network down and network little widget',
{ tag: '@skipLocalEngine' },

View File

@ -2,15 +2,12 @@ import {
expect,
BrowserContext,
TestInfo,
_electron as electron,
ElectronApplication,
Locator,
Page,
} from '@playwright/test'
import { test } from './zoo-test'
import { EngineCommand } from 'lang/std/artifactGraph'
import fsp from 'fs/promises'
import fsSync from 'fs'
import path from 'path'
import pixelMatch from 'pixelmatch'
import { PNG } from 'pngjs'
@ -24,14 +21,11 @@ import {
IS_PLAYWRIGHT_KEY,
} from './storageStates'
import * as TOML from '@iarna/toml'
import { SaveSettingsPayload } from 'lib/settings/settingsTypes'
import { SETTINGS_FILE_NAME } from 'lib/constants'
import { isErrorWhitelisted } from './lib/console-error-whitelist'
import { isArray } from 'lib/utils'
import { reportRejection } from 'lib/trap'
import { DeepPartial } from 'lib/types'
import { Configuration } from 'lang/wasm'
import { Settings } from '@rust/kcl-lib/bindings/Settings'
const toNormalizedCode = (text: string) => {
return text.replace(/\s+/g, '')
@ -928,10 +922,6 @@ export async function setup(
// await page.reload()
}
let electronApp: ElectronApplication | undefined = undefined
let context: BrowserContext | undefined = undefined
let page: Page | undefined = undefined
function failOnConsoleErrors(page: Page, testInfo?: TestInfo) {
// enabled for chrome for now
if (page.context().browser()?.browserType().name() === 'chromium') {

View File

@ -4,7 +4,6 @@ import { bracket } from 'lib/exampleKcl'
import * as fsp from 'fs/promises'
import { join } from 'path'
import { FILE_EXT } from 'lib/constants'
import { UnitLength_type } from '@kittycad/lib/dist/types/src/models'
test.describe('Testing in-app sample loading', () => {
/**
@ -49,8 +48,6 @@ test.describe('Testing in-app sample loading', () => {
})
const warningText = page.getByText('Overwrite current file and units?')
const confirmButton = page.getByRole('button', { name: 'Submit command' })
const unitsToast = (unit: UnitLength_type) =>
page.getByText(`Set default unit to "${unit}" for this project`)
await test.step(`Precondition: check the initial code`, async () => {
await u.openKclCodePanel()
@ -125,8 +122,6 @@ test.describe('Testing in-app sample loading', () => {
page.getByRole('listitem').filter({
has: page.getByRole('button', { name }),
})
const unitsToast = (unit: UnitLength_type) =>
page.getByText(`Set default unit to "${unit}" for this project`)
await test.step(`Test setup`, async () => {
await page.setBodyDimensions({ width: 1200, height: 500 })

View File

@ -1386,7 +1386,8 @@ profile001 = startProfileAt([56.37, 120.33], sketch001)
page.getByRole('button', { name: 'Edit Sketch' })
).toBeVisible()
return true
} catch (_) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (_e) {
return false
}
})

View File

@ -323,7 +323,7 @@ part009 = startSketchOn('XY')
|> line(end = [0, pipeLength])
|> angledLineToX({ angle = 60, to = pipeLargeDia }, %)
|> close()
rev = revolve({ axis = 'y' }, part009)
rev = revolve(part009, axis = 'y')
sketch006 = startSketchOn('XY')
profile001 = circle(
sketch006,
@ -353,6 +353,7 @@ profile003 = startProfileAt([40.16, -120.48], sketch006)
await page.setBodyDimensions({ width: 1000, height: 500 })
await homePage.goToModelingScene()
await scene.connectionEstablished()
await scene.settled(cmdBar)
const camPosition1 = async () => {
@ -364,7 +365,6 @@ profile003 = startProfileAt([40.16, -120.48], sketch006)
await camPosition1()
const revolve = { x: 635, y: 253 }
const parentExtrude = { x: 915, y: 133 }
const solid2d = { x: 770, y: 167 }
const individualProfile = { x: 694, y: 432 }
@ -380,7 +380,7 @@ profile003 = startProfileAt([40.16, -120.48], sketch006)
await page.waitForTimeout(200)
await expect(u.codeLocator).not.toContainText(
`rev = revolve({ axis: 'y' }, part009)`
`rev = revolve(part009, axis: 'y')`
)
// FIXME (commented section below), this test would select a wall that had a sketch on it, and delete the underlying extrude
@ -452,19 +452,15 @@ profile003 = startProfileAt([40.16, -120.48], sketch006)
await page.waitForTimeout(200)
await expect(u.codeLocator).not.toContainText(codeToBeDeletedSnippet)
})
test('parent Solid should be select and deletable and uses custom planes to position children', async ({
page,
homePage,
scene,
cmdBar,
editor,
}) => {
test.setTimeout(90_000)
const u = await getUtils(page)
await page.addInitScript(async () => {
localStorage.setItem(
'persistCode',
`part001 = startSketchOn('XY')
test.fixme(
'parent Solid should be select and deletable and uses custom planes to position children',
async ({ page, homePage, scene, cmdBar, editor }) => {
test.setTimeout(90_000)
const u = await getUtils(page)
await page.addInitScript(async () => {
localStorage.setItem(
'persistCode',
`part001 = startSketchOn('XY')
yo = startProfileAt([4.83, 12.56], part001)
|> line(end = [15.1, 2.48])
|> line(end = [3.15, -9.85], tag = $seg01)
@ -495,34 +491,35 @@ profile001 = startProfileAt([7.49, 9.96], sketch001)
|> close()
`
)
}, KCL_DEFAULT_LENGTH)
await page.setBodyDimensions({ width: 1000, height: 500 })
await homePage.goToModelingScene()
await scene.settled(cmdBar)
const extrudeWall = { x: 575, y: 238 }
// DELETE with selection on face of parent
await page.mouse.click(extrudeWall.x, extrudeWall.y)
await page.waitForTimeout(100)
await expect(page.locator('.cm-activeLine')).toHaveText(
'|> line(end = [-15.17, -4.1])'
)
}, KCL_DEFAULT_LENGTH)
await page.setBodyDimensions({ width: 1000, height: 500 })
await u.openAndClearDebugPanel()
await page.keyboard.press('Delete')
await u.expectCmdLog('[data-message-type="execution-done"]', 10_000)
await page.waitForTimeout(200)
await homePage.goToModelingScene()
await scene.settled(cmdBar)
const extrudeWall = { x: 575, y: 238 }
// DELETE with selection on face of parent
await page.mouse.click(extrudeWall.x, extrudeWall.y)
await page.waitForTimeout(100)
await expect(page.locator('.cm-activeLine')).toHaveText(
'|> line(end = [-15.17, -4.1])'
)
await u.openAndClearDebugPanel()
await page.keyboard.press('Delete')
await u.expectCmdLog('[data-message-type="execution-done"]', 10_000)
await page.waitForTimeout(200)
await editor.expectEditor.not.toContain(`yoo = extrude(yo, length = 4)`, {
shouldNormalise: true,
})
await editor.expectEditor.toContain(`startSketchOn({plane={origin`, {
shouldNormalise: true,
})
await editor.snapshot()
})
await editor.expectEditor.not.toContain(`yoo = extrude(yo, length = 4)`, {
shouldNormalise: true,
})
await editor.expectEditor.toContain(`startSketchOn({plane={origin`, {
shouldNormalise: true,
})
await editor.snapshot()
}
)
test('Hovering over 3d features highlights code, clicking puts the cursor in the right place and sends selection id to engine', async ({
page,
homePage,

View File

@ -7,7 +7,7 @@ import {
createProject,
tomlToSettings,
} from './test-utils'
import { SaveSettingsPayload, SettingsLevel } from 'lib/settings/settingsTypes'
import { SettingsLevel } from 'lib/settings/settingsTypes'
import { SETTINGS_FILE_NAME, PROJECT_SETTINGS_FILE_NAME } from 'lib/constants'
import {
TEST_SETTINGS_KEY,
@ -15,7 +15,6 @@ import {
TEST_SETTINGS,
TEST_SETTINGS_DEFAULT_THEME,
} from './storageStates'
import * as TOML from '@iarna/toml'
import { DeepPartial } from 'lib/types'
import { Settings } from '@rust/kcl-lib/bindings/Settings'
@ -978,72 +977,63 @@ fn cube`
/**
* This test assumes that the default value of the "highlight edges" setting is "on".
*/
test(`Toggle stream settings multiple times`, async ({
page,
scene,
homePage,
context,
toolbar,
cmdBar,
}, testInfo) => {
await context.folderSetupFn(async (dir) => {
const projectDir = join(dir, 'project-000')
await fsp.mkdir(projectDir, { recursive: true })
await fsp.copyFile(
executorInputPath('cube.kcl'),
join(projectDir, 'main.kcl')
test.fixme(
`Toggle stream settings multiple times`,
async ({ page, scene, homePage, context, toolbar, cmdBar }, testInfo) => {
await context.folderSetupFn(async (dir) => {
const projectDir = join(dir, 'project-000')
await fsp.mkdir(projectDir, { recursive: true })
await fsp.copyFile(
executorInputPath('cube.kcl'),
join(projectDir, 'main.kcl')
)
})
await test.step(`First snapshot`, async () => {
await homePage.openProject('project-000')
await toolbar.closePane('code')
await expect(toolbar.startSketchBtn).toBeEnabled({ timeout: 20_000 })
await scene.clickNoWhere()
})
const toast = (value: boolean) =>
page.getByText(
`Set highlight edges to "${String(value)}" as a user default`
)
await test.step(`Toggle highlightEdges off`, async () => {
await cmdBar.openCmdBar()
await cmdBar.chooseCommand('Settings · modeling · highlight edges')
await cmdBar.selectOption({ name: 'off' }).click()
const falseToast = toast(false)
await expect(falseToast).toBeVisible()
await falseToast.waitFor({ state: 'detached' })
})
await expect(scene.streamWrapper).not.toHaveScreenshot(
'toggle-settings-initial.png',
{
maxDiffPixels: 15,
mask: [page.getByTestId('model-state-indicator')],
}
)
})
await test.step(`First snapshot`, async () => {
await homePage.openProject('project-000')
await toolbar.closePane('code')
await expect(toolbar.startSketchBtn).toBeEnabled({ timeout: 20_000 })
await scene.clickNoWhere()
})
await test.step(`Toggle highlightEdges on`, async () => {
await cmdBar.openCmdBar()
await cmdBar.chooseCommand('Settings · modeling · highlight edges')
await cmdBar.selectOption({ name: 'on' }).click()
const trueToast = toast(true)
await expect(trueToast).toBeVisible()
await trueToast.waitFor({ state: 'detached' })
})
const toast = (value: boolean) =>
page.getByText(
`Set highlight edges to "${String(value)}" as a user default`
await expect(scene.streamWrapper).toHaveScreenshot(
'toggle-settings-initial.png',
{
maxDiffPixels: 15,
mask: [page.getByTestId('model-state-indicator')],
}
)
const initialPath = testInfo.snapshotPath('toggle-settings-initial.png')
const initialScreenshot = await scene.streamWrapper.screenshot({
path: initialPath,
mask: [page.getByTestId('model-state-indicator')],
})
await test.step(`Toggle highlightEdges off`, async () => {
await cmdBar.openCmdBar()
await cmdBar.chooseCommand('Settings · modeling · highlight edges')
await cmdBar.selectOption({ name: 'off' }).click()
const falseToast = toast(false)
await expect(falseToast).toBeVisible()
await falseToast.waitFor({ state: 'detached' })
})
await expect(scene.streamWrapper).not.toHaveScreenshot(
'toggle-settings-initial.png',
{
maxDiffPixels: 15,
mask: [page.getByTestId('model-state-indicator')],
}
)
await test.step(`Toggle highlightEdges on`, async () => {
await cmdBar.openCmdBar()
await cmdBar.chooseCommand('Settings · modeling · highlight edges')
await cmdBar.selectOption({ name: 'on' }).click()
const trueToast = toast(true)
await expect(trueToast).toBeVisible()
await trueToast.waitFor({ state: 'detached' })
})
await expect(scene.streamWrapper).toHaveScreenshot(
'toggle-settings-initial.png',
{
maxDiffPixels: 15,
mask: [page.getByTestId('model-state-indicator')],
}
)
})
}
)
})

View File

@ -619,7 +619,7 @@ async function sendPromptFromCommandBar(page: Page, promptStr: string) {
})
}
test(
test.fixme(
'Text-to-CAD functionality',
{ tag: '@electron' },
async ({ context, page }, testInfo) => {

View File

@ -1,6 +1,6 @@
/* eslint-disable react-hooks/rules-of-hooks */
import { test as playwrightTestFn, ElectronApplication } from '@playwright/test'
import { test as playwrightTestFn } from '@playwright/test'
import {
fixturesBasedOnProcessEnvPlatform,
@ -8,8 +8,6 @@ import {
ElectronZoo,
} from './fixtures/fixtureSetup'
import { Settings } from '@rust/kcl-lib/bindings/Settings'
import { DeepPartial } from 'lib/types'
export { expect } from '@playwright/test'
declare module '@playwright/test' {

View File

@ -36,6 +36,7 @@
"@xstate/inspect": "^0.8.0",
"@xstate/react": "^4.1.1",
"bonjour-service": "^1.3.0",
"bson": "^6.10.3",
"chokidar": "^4.0.1",
"codemirror": "^6.0.1",
"decamelize": "^6.0.0",
@ -71,7 +72,7 @@
"scripts": {
"install:rust": "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none && source \"$HOME/.cargo/env\" && (cd rust && (rustup show active-toolchain || rustup toolchain install))",
"install:rust:windows": "winget install Microsoft.VisualStudio.2022.Community --silent --override \"--wait --quiet --add ProductLang En-us --add Microsoft.VisualStudio.Workload.NativeDesktop --includeRecommended\" && winget install Rustlang.Rustup",
"install:wasm-pack:sh": ". $HOME/.cargo/env && curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh -s -- -y",
"install:wasm-pack:sh": ". $HOME/.cargo/env && curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh -s -- -f",
"install:wasm-pack:cargo": "cargo install wasm-pack",
"install:tools:windows": "winget install jqlang.jq MikeFarah.yq GitHub.cli",
"start": "vite --port=3000 --host=0.0.0.0",
@ -87,12 +88,13 @@
"simpleserver:ci": "yarn pretest && http-server ./public --cors -p 3000 &",
"simpleserver:bg": "yarn pretest && http-server ./public --cors -p 3000 &",
"simpleserver:stop": "kill-port 3000",
"fmt": "prettier --write ./src *.ts *.json *.js ./e2e ./packages ./rust/kcl-language-server",
"fmt": "prettier --write ./src *.ts *.json *.js ./e2e ./packages ./rust/kcl-language-server ./rust/kcl-lib/bindings ./rust/kcl-wasm-lib/pkg",
"fmt:generated": "prettier --write *.ts *.json *.js ./rust/kcl-lib/bindings ./rust/kcl-wasm-lib/pkg",
"fmt-check": "prettier --check ./src *.ts *.json *.js ./e2e ./packages ./rust/kcl-language-server",
"fetch:wasm": "./scripts/get-latest-wasm-bundle.sh",
"fetch:wasm:windows": "./scripts/get-latest-wasm-bundle.ps1",
"fetch:samples": "rm -rf public/kcl-samples* && curl -L -o public/kcl-samples.zip https://github.com/KittyCAD/kcl-samples/archive/refs/heads/achalmers/kw-args-xylineto.zip && unzip -o public/kcl-samples.zip -d public && mv public/kcl-samples-* public/kcl-samples",
"build:wasm-dev": "yarn wasm-prep && (cd rust && wasm-pack build kcl-wasm-lib --dev --target web --out-dir pkg && cargo test -p kcl-lib export_bindings) && yarn isomorphic-copy-wasm && yarn fmt",
"build:wasm-dev": "yarn wasm-prep && (cd rust && wasm-pack build kcl-wasm-lib --dev --target web --out-dir pkg && cargo test -p kcl-lib export_bindings) && yarn isomorphic-copy-wasm && yarn fmt:generated",
"build:wasm": "./scripts/build-wasm.sh",
"build:wasm:windows": "./scripts/build-wasm.ps1",
"remove-importmeta": "sed -i 's/import.meta.url/window.location.origin/g' \"./rust/kcl-wasm-lib/pkg/kcl_wasm_lib.js\"; sed -i '' 's/import.meta.url/window.location.origin/g' \"./rust/kcl-wasm-lib/pkg/kcl_wasm_lib.js\" || echo \"sed for both mac and linux\"",
@ -212,6 +214,7 @@
"typescript-eslint": "^8.26.1",
"vite": "^5.4.12",
"vite-plugin-package-version": "^1.1.0",
"vite-plugin-top-level-await": "^1.5.0",
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^1.6.1",
"vitest-webgl-canvas-mock": "^1.1.0",

View File

@ -20,7 +20,7 @@ statement[@isGroup=Statement] {
ImportStatement { kw<"import"> ImportItems ImportFrom String } |
FunctionDeclaration { kw<"export">? kw<"fn"> VariableDefinition Equals? ParamList Arrow? Body } |
VariableDeclaration { kw<"export">? (kw<"var"> | kw<"let"> | kw<"const">)? VariableDefinition Equals expression } |
TypeDeclaration { kw<"export">? kw<"type"> identifier } |
TypeDeclaration { kw<"export">? kw<"type"> identifier ("=" type)? } |
ReturnStatement { kw<"return"> expression } |
ExpressionStatement { expression } |
Annotation { AnnotationName AnnotationList? }
@ -75,11 +75,8 @@ LabeledArgument { ArgumentLabel Equals expression }
ArgumentList { "(" commaSep<LabeledArgument | expression> ")" }
type[@isGroup=Type] {
@specialize[@name=PrimitiveType]<
identifier,
"bool" | "number" | "string" | "tag" | "Sketch" | "SketchSurface" | "Solid" | "Plane"
> |
ArrayType { type !member "[" "]" } |
PrimitiveType { identifier } |
ArrayType { "[" type !member (";" Number "+"?)? "]" } |
ObjectType { "{" commaSep<ObjectProperty { PropertyName ":" type }> "}" }
}
@ -137,7 +134,7 @@ commaSep1NoTrailingComma<term> { term ("," term)* }
"(" ")"
"{" "}"
"[" "]"
"," "?" ":" "." ".."
"," "?" ":" "." ".." ";"
}
@external propSource kclHighlight from "./highlight"

View File

@ -1,4 +1,5 @@
import { defineConfig, devices } from '@playwright/test'
import { platform } from 'os'
/**
* See https://playwright.dev/docs/test-configuration.
@ -13,7 +14,7 @@ export default defineConfig({
/* Do not retry */
retries: 0,
/* Different amount of parallelism on CI and local. */
workers: 1,
workers: platform() === 'win32' ? 1 : 2,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: [
['dot'],

View File

@ -23,78 +23,80 @@ KCL samples conform to a set of style guidelines to ensure consistency and reada
When you submit a PR to add or modify KCL samples, images and STEP files will be generated and added to the repository automatically.
---
#### [80-20-rail](80-20-rail/main.kcl) ([step](step/80-20-rail.step)) ([screenshot](screenshots/80-20-rail.png))
#### [80-20-rail](80-20-rail/main.kcl) ([screenshot](screenshots/80-20-rail.png))
[![80-20-rail](screenshots/80-20-rail.png)](80-20-rail/main.kcl)
#### [a-parametric-bearing-pillow-block](a-parametric-bearing-pillow-block/main.kcl) ([step](step/a-parametric-bearing-pillow-block.step)) ([screenshot](screenshots/a-parametric-bearing-pillow-block.png))
#### [a-parametric-bearing-pillow-block](a-parametric-bearing-pillow-block/main.kcl) ([screenshot](screenshots/a-parametric-bearing-pillow-block.png))
[![a-parametric-bearing-pillow-block](screenshots/a-parametric-bearing-pillow-block.png)](a-parametric-bearing-pillow-block/main.kcl)
#### [ball-bearing](ball-bearing/main.kcl) ([step](step/ball-bearing.step)) ([screenshot](screenshots/ball-bearing.png))
#### [ball-bearing](ball-bearing/main.kcl) ([screenshot](screenshots/ball-bearing.png))
[![ball-bearing](screenshots/ball-bearing.png)](ball-bearing/main.kcl)
#### [bench](bench/main.kcl) ([step](step/bench.step)) ([screenshot](screenshots/bench.png))
#### [bench](bench/main.kcl) ([screenshot](screenshots/bench.png))
[![bench](screenshots/bench.png)](bench/main.kcl)
#### [bracket](bracket/main.kcl) ([step](step/bracket.step)) ([screenshot](screenshots/bracket.png))
#### [bracket](bracket/main.kcl) ([screenshot](screenshots/bracket.png))
[![bracket](screenshots/bracket.png)](bracket/main.kcl)
#### [car-wheel-assembly](car-wheel-assembly/main.kcl) ([step](step/car-wheel-assembly.step)) ([screenshot](screenshots/car-wheel-assembly.png))
#### [car-wheel-assembly](car-wheel-assembly/main.kcl) ([screenshot](screenshots/car-wheel-assembly.png))
[![car-wheel-assembly](screenshots/car-wheel-assembly.png)](car-wheel-assembly/main.kcl)
#### [color-cube](color-cube/main.kcl) ([step](step/color-cube.step)) ([screenshot](screenshots/color-cube.png))
#### [color-cube](color-cube/main.kcl) ([screenshot](screenshots/color-cube.png))
[![color-cube](screenshots/color-cube.png)](color-cube/main.kcl)
#### [cycloidal-gear](cycloidal-gear/main.kcl) ([step](step/cycloidal-gear.step)) ([screenshot](screenshots/cycloidal-gear.png))
#### [cycloidal-gear](cycloidal-gear/main.kcl) ([screenshot](screenshots/cycloidal-gear.png))
[![cycloidal-gear](screenshots/cycloidal-gear.png)](cycloidal-gear/main.kcl)
#### [dodecahedron](dodecahedron/main.kcl) ([step](step/dodecahedron.step)) ([screenshot](screenshots/dodecahedron.png))
#### [dodecahedron](dodecahedron/main.kcl) ([screenshot](screenshots/dodecahedron.png))
[![dodecahedron](screenshots/dodecahedron.png)](dodecahedron/main.kcl)
#### [enclosure](enclosure/main.kcl) ([step](step/enclosure.step)) ([screenshot](screenshots/enclosure.png))
#### [enclosure](enclosure/main.kcl) ([screenshot](screenshots/enclosure.png))
[![enclosure](screenshots/enclosure.png)](enclosure/main.kcl)
#### [exhaust-manifold](exhaust-manifold/main.kcl) ([step](step/exhaust-manifold.step)) ([screenshot](screenshots/exhaust-manifold.png))
#### [exhaust-manifold](exhaust-manifold/main.kcl) ([screenshot](screenshots/exhaust-manifold.png))
[![exhaust-manifold](screenshots/exhaust-manifold.png)](exhaust-manifold/main.kcl)
#### [flange](flange/main.kcl) ([step](step/flange.step)) ([screenshot](screenshots/flange.png))
#### [flange](flange/main.kcl) ([screenshot](screenshots/flange.png))
[![flange](screenshots/flange.png)](flange/main.kcl)
#### [focusrite-scarlett-mounting-bracket](focusrite-scarlett-mounting-bracket/main.kcl) ([step](step/focusrite-scarlett-mounting-bracket.step)) ([screenshot](screenshots/focusrite-scarlett-mounting-bracket.png))
#### [focusrite-scarlett-mounting-bracket](focusrite-scarlett-mounting-bracket/main.kcl) ([screenshot](screenshots/focusrite-scarlett-mounting-bracket.png))
[![focusrite-scarlett-mounting-bracket](screenshots/focusrite-scarlett-mounting-bracket.png)](focusrite-scarlett-mounting-bracket/main.kcl)
#### [food-service-spatula](food-service-spatula/main.kcl) ([step](step/food-service-spatula.step)) ([screenshot](screenshots/food-service-spatula.png))
#### [food-service-spatula](food-service-spatula/main.kcl) ([screenshot](screenshots/food-service-spatula.png))
[![food-service-spatula](screenshots/food-service-spatula.png)](food-service-spatula/main.kcl)
#### [french-press](french-press/main.kcl) ([step](step/french-press.step)) ([screenshot](screenshots/french-press.png))
#### [french-press](french-press/main.kcl) ([screenshot](screenshots/french-press.png))
[![french-press](screenshots/french-press.png)](french-press/main.kcl)
#### [gear](gear/main.kcl) ([step](step/gear.step)) ([screenshot](screenshots/gear.png))
#### [gear](gear/main.kcl) ([screenshot](screenshots/gear.png))
[![gear](screenshots/gear.png)](gear/main.kcl)
#### [gear-rack](gear-rack/main.kcl) ([step](step/gear-rack.step)) ([screenshot](screenshots/gear-rack.png))
#### [gear-rack](gear-rack/main.kcl) ([screenshot](screenshots/gear-rack.png))
[![gear-rack](screenshots/gear-rack.png)](gear-rack/main.kcl)
#### [gridfinity-baseplate](gridfinity-baseplate/main.kcl) ([step](step/gridfinity-baseplate.step)) ([screenshot](screenshots/gridfinity-baseplate.png))
#### [gridfinity-baseplate](gridfinity-baseplate/main.kcl) ([screenshot](screenshots/gridfinity-baseplate.png))
[![gridfinity-baseplate](screenshots/gridfinity-baseplate.png)](gridfinity-baseplate/main.kcl)
#### [gridfinity-baseplate-magnets](gridfinity-baseplate-magnets/main.kcl) ([step](step/gridfinity-baseplate-magnets.step)) ([screenshot](screenshots/gridfinity-baseplate-magnets.png))
#### [gridfinity-baseplate-magnets](gridfinity-baseplate-magnets/main.kcl) ([screenshot](screenshots/gridfinity-baseplate-magnets.png))
[![gridfinity-baseplate-magnets](screenshots/gridfinity-baseplate-magnets.png)](gridfinity-baseplate-magnets/main.kcl)
#### [gridfinity-bins](gridfinity-bins/main.kcl) ([step](step/gridfinity-bins.step)) ([screenshot](screenshots/gridfinity-bins.png))
#### [gridfinity-bins](gridfinity-bins/main.kcl) ([screenshot](screenshots/gridfinity-bins.png))
[![gridfinity-bins](screenshots/gridfinity-bins.png)](gridfinity-bins/main.kcl)
#### [gridfinity-bins-stacking-lip](gridfinity-bins-stacking-lip/main.kcl) ([step](step/gridfinity-bins-stacking-lip.step)) ([screenshot](screenshots/gridfinity-bins-stacking-lip.png))
#### [gridfinity-bins-stacking-lip](gridfinity-bins-stacking-lip/main.kcl) ([screenshot](screenshots/gridfinity-bins-stacking-lip.png))
[![gridfinity-bins-stacking-lip](screenshots/gridfinity-bins-stacking-lip.png)](gridfinity-bins-stacking-lip/main.kcl)
#### [hex-nut](hex-nut/main.kcl) ([step](step/hex-nut.step)) ([screenshot](screenshots/hex-nut.png))
#### [hex-nut](hex-nut/main.kcl) ([screenshot](screenshots/hex-nut.png))
[![hex-nut](screenshots/hex-nut.png)](hex-nut/main.kcl)
#### [i-beam](i-beam/main.kcl) ([step](step/i-beam.step)) ([screenshot](screenshots/i-beam.png))
#### [i-beam](i-beam/main.kcl) ([screenshot](screenshots/i-beam.png))
[![i-beam](screenshots/i-beam.png)](i-beam/main.kcl)
#### [kitt](kitt/main.kcl) ([step](step/kitt.step)) ([screenshot](screenshots/kitt.png))
#### [keyboard](keyboard/main.kcl) ([screenshot](screenshots/keyboard.png))
[![keyboard](screenshots/keyboard.png)](keyboard/main.kcl)
#### [kitt](kitt/main.kcl) ([screenshot](screenshots/kitt.png))
[![kitt](screenshots/kitt.png)](kitt/main.kcl)
#### [lego](lego/main.kcl) ([step](step/lego.step)) ([screenshot](screenshots/lego.png))
#### [lego](lego/main.kcl) ([screenshot](screenshots/lego.png))
[![lego](screenshots/lego.png)](lego/main.kcl)
#### [mounting-plate](mounting-plate/main.kcl) ([step](step/mounting-plate.step)) ([screenshot](screenshots/mounting-plate.png))
#### [mounting-plate](mounting-plate/main.kcl) ([screenshot](screenshots/mounting-plate.png))
[![mounting-plate](screenshots/mounting-plate.png)](mounting-plate/main.kcl)
#### [multi-axis-robot](multi-axis-robot/main.kcl) ([step](step/multi-axis-robot.step)) ([screenshot](screenshots/multi-axis-robot.png))
#### [multi-axis-robot](multi-axis-robot/main.kcl) ([screenshot](screenshots/multi-axis-robot.png))
[![multi-axis-robot](screenshots/multi-axis-robot.png)](multi-axis-robot/main.kcl)
#### [pipe](pipe/main.kcl) ([step](step/pipe.step)) ([screenshot](screenshots/pipe.png))
#### [pipe](pipe/main.kcl) ([screenshot](screenshots/pipe.png))
[![pipe](screenshots/pipe.png)](pipe/main.kcl)
#### [pipe-flange-assembly](pipe-flange-assembly/main.kcl) ([step](step/pipe-flange-assembly.step)) ([screenshot](screenshots/pipe-flange-assembly.png))
#### [pipe-flange-assembly](pipe-flange-assembly/main.kcl) ([screenshot](screenshots/pipe-flange-assembly.png))
[![pipe-flange-assembly](screenshots/pipe-flange-assembly.png)](pipe-flange-assembly/main.kcl)
#### [pipe-with-bend](pipe-with-bend/main.kcl) ([step](step/pipe-with-bend.step)) ([screenshot](screenshots/pipe-with-bend.png))
#### [pipe-with-bend](pipe-with-bend/main.kcl) ([screenshot](screenshots/pipe-with-bend.png))
[![pipe-with-bend](screenshots/pipe-with-bend.png)](pipe-with-bend/main.kcl)
#### [poopy-shoe](poopy-shoe/main.kcl) ([step](step/poopy-shoe.step)) ([screenshot](screenshots/poopy-shoe.png))
#### [poopy-shoe](poopy-shoe/main.kcl) ([screenshot](screenshots/poopy-shoe.png))
[![poopy-shoe](screenshots/poopy-shoe.png)](poopy-shoe/main.kcl)
#### [router-template-cross-bar](router-template-cross-bar/main.kcl) ([step](step/router-template-cross-bar.step)) ([screenshot](screenshots/router-template-cross-bar.png))
#### [router-template-cross-bar](router-template-cross-bar/main.kcl) ([screenshot](screenshots/router-template-cross-bar.png))
[![router-template-cross-bar](screenshots/router-template-cross-bar.png)](router-template-cross-bar/main.kcl)
#### [router-template-slate](router-template-slate/main.kcl) ([step](step/router-template-slate.step)) ([screenshot](screenshots/router-template-slate.png))
#### [router-template-slate](router-template-slate/main.kcl) ([screenshot](screenshots/router-template-slate.png))
[![router-template-slate](screenshots/router-template-slate.png)](router-template-slate/main.kcl)
#### [sheet-metal-bracket](sheet-metal-bracket/main.kcl) ([step](step/sheet-metal-bracket.step)) ([screenshot](screenshots/sheet-metal-bracket.png))
#### [sheet-metal-bracket](sheet-metal-bracket/main.kcl) ([screenshot](screenshots/sheet-metal-bracket.png))
[![sheet-metal-bracket](screenshots/sheet-metal-bracket.png)](sheet-metal-bracket/main.kcl)
#### [socket-head-cap-screw](socket-head-cap-screw/main.kcl) ([step](step/socket-head-cap-screw.step)) ([screenshot](screenshots/socket-head-cap-screw.png))
#### [socket-head-cap-screw](socket-head-cap-screw/main.kcl) ([screenshot](screenshots/socket-head-cap-screw.png))
[![socket-head-cap-screw](screenshots/socket-head-cap-screw.png)](socket-head-cap-screw/main.kcl)
#### [walkie-talkie](walkie-talkie/main.kcl) ([step](step/walkie-talkie.step)) ([screenshot](screenshots/walkie-talkie.png))
#### [walkie-talkie](walkie-talkie/main.kcl) ([screenshot](screenshots/walkie-talkie.png))
[![walkie-talkie](screenshots/walkie-talkie.png)](walkie-talkie/main.kcl)
#### [washer](washer/main.kcl) ([step](step/washer.step)) ([screenshot](screenshots/washer.png))
#### [washer](washer/main.kcl) ([screenshot](screenshots/washer.png))
[![washer](screenshots/washer.png)](washer/main.kcl)

View File

@ -41,7 +41,7 @@ ballsSketch = startSketchOn("XY")
|> close()
// Revolve the ball to make a sphere and pattern around the inside wall
balls = revolve({ axis = "X" }, ballsSketch)
balls = revolve(ballsSketch, axis = "X")
|> patternCircular3d(
arcDegrees = 360,
axis = [0, 0, 1],
@ -66,7 +66,7 @@ chainSketch = startSketchOn("XY")
|> close()
// Revolve the chain sketch
chainHead = revolve({ axis = "X" }, chainSketch)
chainHead = revolve(chainSketch, axis = "X")
|> patternCircular3d(
arcDegrees = 360,
axis = [0, 0, 1],
@ -86,7 +86,7 @@ linkSketch = startSketchOn("XZ")
)
// Revolve the link sketch
linkRevolve = revolve({ axis = 'Y', angle = 360 / nBalls }, linkSketch)
linkRevolve = revolve(linkSketch, axis = 'Y', angle = 360 / nBalls)
|> patternCircular3d(
arcDegrees = 360,
axis = [0, 0, 1],

View File

@ -82,5 +82,5 @@ brakeCaliperSketch = startSketchOn('XY')
|> close()
// Revolve the brake caliper sketch
revolve({ axis = "Y", angle = -70 }, brakeCaliperSketch)
revolve(brakeCaliperSketch, axis = "Y", angle = -70)
|> appearance(color = "#c82d2d", metalness = 90, roughness = 90)

View File

@ -40,5 +40,5 @@ tireSketch = startSketchOn("XY")
|> close()
// Revolve the sketch to create the tire
revolve({ axis = "Y" }, tireSketch)
revolve(tireSketch, axis = "Y")
|> appearance(color = "#0f0f0f", roughness = 80)

View File

@ -74,7 +74,7 @@ wheelCenterInner = startSketchOn('XY')
|> yLine(endAbsolute = 0)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()
|> revolve({ axis = 'y' }, %)
|> revolve(axis = 'y')
|> appearance(color = "#ffffff", metalness = 0, roughness = 0)
wheelCenterOuter = startSketchOn('XY')
@ -88,7 +88,7 @@ wheelCenterOuter = startSketchOn('XY')
|> yLine(endAbsolute = -wheelWidth / 20)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()
|> revolve({ axis = 'y' }, %)
|> revolve(axis = 'y')
|> appearance(color = "#ffffff", metalness = 0, roughness = 0)
// Write a function that defines the spoke geometry, patterns and extrudes it
@ -193,5 +193,5 @@ startSketchOn('XY')
|> xLine(length = wheelWidth * 0.03)
|> yLine(length = wheelWidth * 0.05)
|> close()
|> revolve({ axis = 'y' }, %)
|> revolve(axis = 'y')
|> appearance(color = "#ffffff", metalness = 0, roughness = 0)

View File

@ -34,7 +34,7 @@ fn lug(plane, length, diameter) {
|> xLine(endAbsolute = lugThreadDiameter)
|> yLine(endAbsolute = 0)
|> close()
|> revolve({ axis = "Y" }, %)
|> revolve(axis = "Y")
|> appearance(color = "#dbcd70", roughness = 90, metalness = 90)
return lugSketch
}

View File

@ -4,7 +4,7 @@
// Set units
@settings(defaultLengthUnit = in)
import 'car-wheel.kcl' as carWheel
import 'car-wheel.kcl' as carWheel
import 'car-rotor.kcl' as carRotor
import "brake-caliper.kcl" as brakeCaliper
import 'lug-nut.kcl' as lugNut

View File

@ -23,7 +23,7 @@ sketch001 = startSketchOn('XZ')
], %, $rectangleSegmentC001)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()
|> revolve({ angle = 360, axis = 'Y' }, %)
|> revolve(angle = 360, axis = 'Y')
// Create an angled plane to sketch the supports
plane001 = {
@ -135,7 +135,7 @@ sketch005 = startSketchOn('XZ')
|> xLine(endAbsolute = 0.15)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()
|> revolve({ axis = 'y' }, %)
|> revolve(axis = 'y')
// Plunger and stem
sketch006 = startSketchOn('XZ')
@ -148,7 +148,7 @@ sketch006 = startSketchOn('XZ')
|> tangentialArc({ radius = 0.6, offset = -90 }, %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()
|> revolve({ axis = 'y' }, %)
|> revolve(axis = 'y')
// Spiral plate
sketch007 = startSketchOn(offsetPlane('XY', offset = 1.12))
@ -210,7 +210,7 @@ sketch011 = startSketchOn('XZ')
}, %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()
|> revolve({ axis = 'y' }, %)
|> revolve(axis = 'y')
// Draw and extrude handle
sketch012 = startSketchOn(offsetPlane('XZ', offset = handleThickness / 2))

View File

@ -55,7 +55,7 @@ axis000 = {
}
// create a single corner of the bin
singleCorner = revolve({ angle = -90, axis = axis000 }, face(offsetPlane("YZ", offset = cornerRadius)))
singleCorner = revolve(face(offsetPlane("YZ", offset = cornerRadius)), angle = -90, axis = axis000)
// create the corners of the bin
corners = patternCircular3d(

View File

@ -52,7 +52,7 @@ axis000 = {
}
// create a single corner of the bin
singleCorner = revolve({ angle = -90, axis = axis000 }, face(offsetPlane("YZ", offset = cornerRadius)))
singleCorner = revolve(face(offsetPlane("YZ", offset = cornerRadius)), angle = -90, axis = axis000)
// create the corners of the bin
corners = patternCircular3d(

View File

@ -75,7 +75,7 @@ axis000 = {
}
// create a single corner of the bin
singleCorner = revolve({ angle = -90, axis = axis000 }, face(offsetPlane("YZ", offset = cornerRadius + binTol)))
singleCorner = revolve(face(offsetPlane("YZ", offset = cornerRadius + binTol)), angle = -90, axis = axis000)
// create the corners of the bin
corners = patternCircular3d(
@ -291,10 +291,10 @@ axis001 = {
}
// create a single corner of the bin
lipSingleLengthCorner = revolve({ angle = -90, axis = axis001 }, lipFace(plane000))
lipSingleLengthCorner = revolve(lipFace(plane000), angle = -90, axis = axis001)
// create a single corner of the bin
lipSingleWidthCorner = revolve({ angle = 90, axis = axis001 }, lipFace(plane002))
lipSingleWidthCorner = revolve(lipFace(plane002), angle = 90, axis = axis001)
// create the corners of the bin
lipCorners000 = patternCircular3d(

View File

@ -68,7 +68,7 @@ axis000 = {
}
// create a single corner of the bin
singleCorner = revolve({ angle = -90, axis = axis000 }, face(offsetPlane("YZ", offset = cornerRadius + binTol)))
singleCorner = revolve(face(offsetPlane("YZ", offset = cornerRadius + binTol)), angle = -90, axis = axis000)
// create the corners of the bin
corners = patternCircular3d(

View File

@ -0,0 +1,233 @@
// Zoo Keyboard
// A custom keyboard with Zoo brand lettering
// Set Units
@settings(defaultLengthUnit = in)
// Define constants
baseColor = "#0f0f0f"
highlightColor1 = "#b0b0b0"
highlightColor2 = "#23af93"
keyHeight = 0.8
keyDepth = 0.1
spacing = 0.1
row1 = spacing * 3
row2 = row1 + keyHeight + spacing
row3 = row2 + keyHeight + spacing
row4 = row3 + keyHeight + spacing
row5 = row4 + keyHeight + spacing
row6 = row5 + keyHeight + spacing
// Sketch the side profile of the keyboard base and extrude to total width
sketch001 = startSketchOn('YZ')
|> startProfileAt([0, 0], %)
|> line(end = [-0.14, 0.68], tag = $seg01)
|> angledLine([7, row6 + 3 * spacing + keyHeight], %, $seg02)
|> line(endAbsolute = [5.13, 0], tag = $seg03)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)], tag = $seg04)
|> close()
|> extrude(length = 13.6)
|> appearance(color = baseColor)
|> fillet(
radius = .6,
tags = [
getOppositeEdge(seg01),
getOppositeEdge(seg03),
seg01,
seg03
],
)
// Create a short cylindrical foot at each corner of the keyboard
sketch003 = startSketchOn(sketch001, seg04)
profile001 = circle(sketch003, center = [0.75, 0.75], radius = 0.4)
profile003 = circle(sketch003, center = [4.4, 0.75], radius = 0.4)
profile004 = circle(sketch003, center = [0.73, 13.6 - .75], radius = 0.4)
profile005 = circle(sketch003, center = [4.4, 13.6 - .75], radius = 0.4)
extrude(
[
profile001,
profile003,
profile004,
profile005
],
length = .15,
)
// Define the plane to sketch keyboard keys on
plane001 = {
plane = {
origin = [0.0, 0.0, 0.7],
xAxis = [1.0, 0.0, 0.0],
yAxis = [0.0, 1.0, sin(toRadians(7))],
zAxis = [0.0, 0.0, 1.0]
}
}
// Create a function to build a key. Parameterize for position, width, height, number of instances, and appearance color.
fn keyFn(originStart, keyWidth, keyHeight, repeats, color) {
sketch002 = startSketchOn(plane001)
profile002 = startProfileAt([originStart[0], originStart[1]], sketch002)
|> arc({
angleStart = 180,
angleEnd = 270,
radius = 0.1
}, %)
|> angledLine([0, keyWidth - .2], %, $rectangleSegmentA001)
|> tangentialArc({ radius = 0.1, offset = 90 }, %)
|> angledLine([
segAng(rectangleSegmentA001) + 90,
keyHeight - .2
], %, $rectangleSegmentB001)
|> tangentialArc({ radius = 0.1, offset = 90 }, %)
|> angledLine([
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %, $rectangleSegmentC001)
|> tangentialArc({ radius = 0.1, offset = 90 }, %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)], tag = $rectangleSegmentD001)
|> close()
|> extrude(length = keyDepth)
|> appearance(color = color)
// Repeat key when desired. This will default to zero
|> patternLinear3d(
%,
instances = repeats + 1,
distance = keyWidth + spacing,
axis = [1, 0, 0],
)
return sketch001
}
// Build the first row of keys
keyFn([0.3, row1], 1.1, keyHeight, 0, highlightColor2)
keyFn([1.5, row1], 0.8, keyHeight, 2, highlightColor1)
keyFn([spacing * 7 + 3.5, row1], 5.2, keyHeight, 0, highlightColor2)
keyFn([spacing * 8 + 8.7, row1], 0.8, keyHeight, 0, highlightColor1)
keyFn([spacing * 8 + 9.6, row1], 0.8, keyHeight, 0, highlightColor1)
keyFn([spacing * 10 + 10.3, row1], 1.1, keyHeight, 0, highlightColor1)
keyFn([spacing * 12 + 10.3 + 1, row1], 0.8, keyHeight, 0, highlightColor2)
// Build the second row of keys
keyFn([spacing * 3, row2], 1.7, keyHeight, 0, highlightColor2)
keyFn([spacing * 4 + 1.7, row2], 0.8, keyHeight, 9, highlightColor1)
keyFn([spacing * 14 + 1.7 + 0.8 * 10, row2], 2.2, keyHeight, 0, highlightColor2)
// Build the third row of keys
keyFn([spacing * 3, row3], 1.1 + .1, keyHeight, 0, highlightColor1)
keyFn([spacing * 4 + 1.1 + .1, row3], 0.8, keyHeight, 10, highlightColor1)
keyFn([spacing * 3 + 11.1 + .1, row3], 1.4 + .4, keyHeight, 0, highlightColor2)
// Build the fourth row of keys
keyFn([spacing * 3, row4], 0.9, keyHeight, 0, highlightColor1)
keyFn([spacing * 4 + 0.9, row4], 0.8, keyHeight, 11, highlightColor1)
keyFn([spacing * 3 + 11.8, row4], 1.2, keyHeight, 0, highlightColor1)
// Build the fifth row of keys
keyFn([spacing * 3, row5], 0.8, keyHeight, 12, highlightColor1)
keyFn([spacing * 3 + 11.7, row5], 1.3, keyHeight, 0, highlightColor2)
// Build the sixth row of keys
keyFn([spacing * 3, row6], 1.1, keyHeight * .6, 0, highlightColor2)
keyFn([spacing * 4 + 1.1, row6], 0.8, keyHeight * .6, 11, highlightColor1)
keyFn([spacing * 3 + 12, row6], 1, keyHeight * .6, 0, highlightColor2)
// Create a plane to sketch ZOO brand letters on
plane002 = {
plane = {
origin = [0.0, 0.0, .81],
xAxis = [1.0, 0.0, 0.0],
yAxis = [0.0, 1.0, sin(toRadians(7))],
zAxis = [0.0, 0.0, 1.0]
}
}
// Define a function to draw the ZOO 'Z'
fn z(origin, scale, depth) {
z = startSketchOn(plane002)
|> startProfileAt([
0 + origin[0],
0.15 * scale + origin[1]
], %)
|> yLine(length = -0.15 * scale)
|> xLine(length = 0.15 * scale)
|> angledLineToX({
angle = 47.15,
to = 0.3 * scale + origin[0]
}, %, $seg1)
|> yLine(endAbsolute = 0 + origin[1], tag = $seg3)
|> xLine(length = 0.63 * scale)
|> yLine(length = 0.225 * scale)
|> xLine(length = -0.57 * scale)
|> angledLineToX({
angle = 47.15,
to = 0.93 * scale + origin[0]
}, %)
|> yLine(length = 0.15 * scale)
|> xLine(length = -0.15 * scale)
|> angledLine({
angle = 47.15,
length = -segLen(seg1)
}, %, $seg2)
|> yLine(length = segLen(seg3))
|> xLine(endAbsolute = 0 + origin[0])
|> yLine(length = -0.225 * scale)
|> angledLineThatIntersects({
angle = 0,
intersectTag = seg2,
offset = 0
}, %)
|> close()
|> extrude(length = -depth)
|> appearance(color = baseColor)
return z
}
// Define a function to draw the ZOO 'O'
fn o(origin, scale, depth) {
oSketch001 = startSketchOn(plane002)
|> startProfileAt([
.788 * scale + origin[0],
.921 * scale + origin[1]
], %)
|> arc({
angleStart = 47.15 + 6,
angleEnd = 47.15 - 6 + 180,
radius = .525 * scale
}, %)
|> angledLine({ angle = 47.15, length = .24 * scale }, %)
|> arc({
angleStart = 47.15 - 11 + 180,
angleEnd = 47.15 + 11,
radius = .288 * scale
}, %)
|> close()
|> extrude(length = -depth)
|> appearance(color = baseColor)
o = startSketchOn(plane002)
|> startProfileAt([
.16 * scale + origin[0],
.079 * scale + origin[1]
], %)
|> arc({
angleStart = 47.15 + 6 - 180,
angleEnd = 47.15 - 6,
radius = .525 * scale
}, %)
|> angledLine({ angle = 47.15, length = -.24 * scale }, %)
|> arc({
angleStart = 47.15 - 11,
angleEnd = 47.15 + 11 - 180,
radius = .288 * scale
}, %)
|> close()
|> extrude(length = -depth)
|> appearance(color = baseColor)
return o
}
// Place the Z logo on the Z key. Place the O logo on the O and P keys
z([2.3, 1.3], .4, 0.03)
o([8.71, row4 + .08], 0.4, 0.03)
o([8.71 + 0.9, row4 + .08], 0.4, 0.03)

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