Compare commits

..

3 Commits

621 changed files with 137159 additions and 141295 deletions

View File

@ -29,13 +29,6 @@
{ {
"name": "isNaN", "name": "isNaN",
"message": "Use Number.isNaN() instead." "message": "Use Number.isNaN() instead."
},
],
"no-restricted-syntax": [
"error",
{
"selector": "CallExpression[callee.object.name='Array'][callee.property.name='isArray']",
"message": "Use isArray() in lib/utils.ts instead of Array.isArray()."
} }
], ],
"semi": [ "semi": [

View File

@ -1,145 +0,0 @@
name: E2E Snapshot Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: write
pull-requests: write
actions: read
jobs:
check-rust-changes:
runs-on: ubuntu-latest
outputs:
rust-changed: ${{ steps.filter.outputs.rust }}
steps:
- uses: actions/checkout@v4
- id: filter
name: Check for Rust changes
uses: dorny/paths-filter@v3
with:
filters: |
rust:
- 'src/wasm-lib/**'
snapshot-tests:
runs-on: ubuntu-22.04
needs: check-rust-changes
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- name: Install dependencies
run: yarn
- name: Cache Playwright Browsers
uses: actions/cache@v4
with:
path: |
~/.cache/ms-playwright/
key: ${{ runner.os }}-playwright-${{ hashFiles('yarn.lock') }}
- name: Install Playwright Browsers
run: yarn playwright install --with-deps
- name: Download Wasm Cache
id: download-wasm
if: needs.check-rust-changes.outputs.rust-changed == 'false'
uses: dawidd6/action-download-artifact@v7
continue-on-error: true
with:
github_token: ${{secrets.GITHUB_TOKEN}}
name: wasm-bundle
workflow: build-and-store-wasm.yml
branch: main
path: src/wasm-lib/pkg
- name: copy wasm blob
if: needs.check-rust-changes.outputs.rust-changed == 'false'
run: cp src/wasm-lib/pkg/wasm_lib_bg.wasm public
continue-on-error: true
- name: Setup Rust
if: needs.check-rust-changes.outputs.rust-changed == 'true'
uses: dtolnay/rust-toolchain@stable
- name: Cache Wasm (because rust diff)
if: needs.check-rust-changes.outputs.rust-changed == 'true'
uses: Swatinem/rust-cache@v2
with:
workspaces: './src/wasm-lib'
- name: OR Cache Wasm (because wasm cache failed)
if: steps.download-wasm.outcome == 'failure'
uses: Swatinem/rust-cache@v2
with:
workspaces: './src/wasm-lib'
- name: Build Wasm (because rust diff)
if: needs.check-rust-changes.outputs.rust-changed == 'true'
run: yarn build:wasm
- name: OR Build Wasm (because wasm cache failed)
if: steps.download-wasm.outcome == 'failure'
run: yarn build:wasm
- name: build web
run: yarn tronb:vite:dev
- name: Run chrome snapshots
run: |
PLATFORM=web yarn playwright test --config=playwright.config.ts --retries="3" --update-snapshots --grep=@snapshot
env:
CI: true
NODE_ENV: development
VITE_KC_DEV_TOKEN: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
VITE_KC_SKIP_AUTH: true
token: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
snapshottoken: ${{ secrets.KITTYCAD_API_TOKEN }}
- name: check for changes
id: git-check
run: |
{
echo 'changes<<EOF'
git diff --name-only e2e/playwright/snapshot-tests.spec.ts-snapshots
echo EOF
} >> "$GITHUB_OUTPUT"
# only upload artifacts if there's actually changes
- name: Upload changes, if any
if: steps.git-check.outputs.changes != ''
uses: actions/upload-artifact@v4
with:
name: playwright-snapshots-${{ runner.os }}-${{ github.sha }}
path: ${{ steps.git-check.outputs.changes }}
- name: Upload report, if any
uses: actions/upload-artifact@v4
if: steps.git-check.outputs.changes != ''
with:
name: playwright-report-${{ runner.os }}-${{ github.sha }}
path: playwright-report/
include-hidden-files: true
retention-days: 30
- name: Fail the run if we have snapshot updates
if: steps.git-check.outputs.changes != ''
run: exit 1
# TODO: check if we could comment on the PR as well

View File

@ -1,4 +1,4 @@
name: E2E Flow Tests name: E2E Tests
on: on:
push: push:
branches: [ main ] branches: [ main ]
@ -33,7 +33,7 @@ jobs:
rust: rust:
- 'src/wasm-lib/**' - 'src/wasm-lib/**'
flow-tests: electron:
timeout-minutes: 60 timeout-minutes: 60
name: playwright:electron:${{ matrix.os }} ${{ matrix.shardIndex }} ${{ matrix.shardTotal }} name: playwright:electron:${{ matrix.os }} ${{ matrix.shardIndex }} ${{ matrix.shardTotal }}
strategy: strategy:
@ -47,29 +47,23 @@ jobs:
needs: check-rust-changes needs: check-rust-changes
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
node-version-file: '.nvmrc' node-version-file: '.nvmrc'
cache: 'yarn' cache: 'yarn'
- uses: KittyCAD/action-install-cli@main - uses: KittyCAD/action-install-cli@main
- name: Install dependencies - name: Install dependencies
shell: bash shell: bash
run: yarn run: yarn
- name: Cache Playwright Browsers - name: Cache Playwright Browsers
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
path: | path: |
~/.cache/ms-playwright/ ~/.cache/ms-playwright/
key: ${{ runner.os }}-playwright-${{ hashFiles('yarn.lock') }} key: ${{ runner.os }}-playwright-${{ hashFiles('yarn.lock') }}
- name: Install Playwright Browsers - name: Install Playwright Browsers
shell: bash shell: bash
run: yarn playwright install --with-deps run: yarn playwright install --with-deps
- name: Download Wasm Cache - name: Download Wasm Cache
id: download-wasm id: download-wasm
if: needs.check-rust-changes.outputs.rust-changed == 'false' if: needs.check-rust-changes.outputs.rust-changed == 'false'
@ -81,35 +75,29 @@ jobs:
workflow: build-and-store-wasm.yml workflow: build-and-store-wasm.yml
branch: main branch: main
path: src/wasm-lib/pkg path: src/wasm-lib/pkg
- name: copy wasm blob - name: copy wasm blob
if: needs.check-rust-changes.outputs.rust-changed == 'false' if: needs.check-rust-changes.outputs.rust-changed == 'false'
shell: bash shell: bash
run: cp src/wasm-lib/pkg/wasm_lib_bg.wasm public run: cp src/wasm-lib/pkg/wasm_lib_bg.wasm public
continue-on-error: true continue-on-error: true
- name: Setup Rust - name: Setup Rust
uses: dtolnay/rust-toolchain@stable uses: dtolnay/rust-toolchain@stable
- name: Cache Wasm (because rust diff) - name: Cache Wasm (because rust diff)
if: needs.check-rust-changes.outputs.rust-changed == 'true' if: needs.check-rust-changes.outputs.rust-changed == 'true'
uses: Swatinem/rust-cache@v2 uses: Swatinem/rust-cache@v2
with: with:
workspaces: './src/wasm-lib' workspaces: './src/wasm-lib'
- name: OR Cache Wasm (because wasm cache failed) - name: OR Cache Wasm (because wasm cache failed)
if: steps.download-wasm.outcome == 'failure' if: steps.download-wasm.outcome == 'failure'
uses: Swatinem/rust-cache@v2 uses: Swatinem/rust-cache@v2
with: with:
workspaces: './src/wasm-lib' workspaces: './src/wasm-lib'
- name: install good sed - name: install good sed
if: ${{ startsWith(matrix.os, 'macos') }} if: ${{ startsWith(matrix.os, 'macos') }}
shell: bash shell: bash
run: | run: |
brew install gnu-sed brew install gnu-sed
echo "/opt/homebrew/opt/gnu-sed/libexec/gnubin" >> $GITHUB_PATH echo "/opt/homebrew/opt/gnu-sed/libexec/gnubin" >> $GITHUB_PATH
- name: Install vector - name: Install vector
shell: bash shell: bash
# TODO: figure out what to do with this, it's failing # TODO: figure out what to do with this, it's failing
@ -127,33 +115,81 @@ jobs:
sed -i "s#GH_ACTIONS_AXIOM_TOKEN#${{secrets.GH_ACTIONS_AXIOM_TOKEN}}#g" /tmp/vector.toml sed -i "s#GH_ACTIONS_AXIOM_TOKEN#${{secrets.GH_ACTIONS_AXIOM_TOKEN}}#g" /tmp/vector.toml
cat /tmp/vector.toml cat /tmp/vector.toml
${HOME}/.vector/bin/vector --config /tmp/vector.toml & ${HOME}/.vector/bin/vector --config /tmp/vector.toml &
- name: Build Wasm (because rust diff) - name: Build Wasm (because rust diff)
if: needs.check-rust-changes.outputs.rust-changed == 'true' if: needs.check-rust-changes.outputs.rust-changed == 'true'
shell: bash shell: bash
run: yarn build:wasm run: yarn build:wasm
- name: OR Build Wasm (because wasm cache failed) - name: OR Build Wasm (because wasm cache failed)
if: steps.download-wasm.outcome == 'failure' if: steps.download-wasm.outcome == 'failure'
shell: bash shell: bash
run: yarn build:wasm run: yarn build:wasm
- name: build web - name: build web
shell: bash shell: bash
run: yarn tronb:vite:dev run: yarn tronb:vite:dev
# - name: Run ubuntu/chrome snapshots
# if: ${{ matrix.os == 'namespace-profile-ubuntu-8-cores' && matrix.shardIndex == 1 }}
# shell: bash
# # TODO: break this in its own job, for now it's not slowing down the overall execution as ubuntu is the quickest,
# # but we could do better. This forces a large 1/1 shard of all 20 snapshot tests that runs in about 3 minutes.
# run: |
# PLATFORM=web yarn playwright test --config=playwright.config.ts --retries="3" --update-snapshots --grep=@snapshot --shard=1/1
# env:
# CI: true
# NODE_ENV: development
# VITE_KC_DEV_TOKEN: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
# VITE_KC_SKIP_AUTH: true
# token: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
# snapshottoken: ${{ secrets.KITTYCAD_API_TOKEN }}
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() && (success() || failure()) }}
with:
name: playwright-report-${{ matrix.os }}-snapshot-${{ matrix.shardIndex }}-${{ github.sha }}
path: playwright-report/
include-hidden-files: true
retention-days: 30
overwrite: true
- name: Clean up test-results - name: Clean up test-results
if: ${{ !cancelled() && (success() || failure()) }} if: ${{ !cancelled() && (success() || failure()) }}
continue-on-error: true continue-on-error: true
run: rm -r test-results run: rm -r test-results
- name: check for changes
if: ${{ matrix.os == 'namespace-profile-ubuntu-8-cores' && matrix.shardIndex == 1 }}
shell: bash
id: git-check
run: |
git add .
if git status | grep -q "Changes to be committed"
then echo "modified=true" >> $GITHUB_OUTPUT
else echo "modified=false" >> $GITHUB_OUTPUT
fi
# - name: Commit changes, if any
# if: steps.git-check.outputs.modified == 'true'
# shell: bash
# run: |
# git add .
# 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
# git fetch origin
# echo ${{ github.head_ref }}
# git checkout ${{ github.head_ref }}
# git commit -am "A snapshot a day keeps the bugs away! 📷🐛 (OS: ${{matrix.os}})" || true
# git push
# git push origin ${{ github.head_ref }}
# only upload artifacts if there's actually changes
- uses: actions/upload-artifact@v4
if: steps.git-check.outputs.modified == 'true'
with:
name: playwright-report-${{ matrix.os }}-${{ matrix.shardIndex }}-${{ github.sha }}
path: playwright-report/
include-hidden-files: true
retention-days: 30
- uses: actions/download-artifact@v4 - uses: actions/download-artifact@v4
if: ${{ !cancelled() && (success() || failure()) }} if: ${{ !cancelled() && (success() || failure()) }}
continue-on-error: true continue-on-error: true
with: with:
name: test-results-${{ matrix.os }}-${{ matrix.shardIndex }}-${{ github.sha }} name: test-results-${{ matrix.os }}-${{ matrix.shardIndex }}-${{ github.sha }}
path: test-results/ path: test-results/
- name: Run playwright/electron flow (with retries) - name: Run playwright/electron flow (with retries)
id: retry id: retry
if: ${{ !cancelled() && (success() || failure()) }} if: ${{ !cancelled() && (success() || failure()) }}
@ -167,7 +203,6 @@ jobs:
VITE_KC_DEV_TOKEN: ${{ secrets.KITTYCAD_API_TOKEN_DEV }} VITE_KC_DEV_TOKEN: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
VITE_KC_SKIP_AUTH: true VITE_KC_SKIP_AUTH: true
token: ${{ secrets.KITTYCAD_API_TOKEN_DEV }} token: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
if: always() if: always()
with: with:
@ -176,7 +211,6 @@ jobs:
include-hidden-files: true include-hidden-files: true
retention-days: 30 retention-days: 30
overwrite: true overwrite: true
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
if: always() if: always()
with: with:
@ -185,3 +219,4 @@ jobs:
include-hidden-files: true include-hidden-files: true
retention-days: 30 retention-days: 30
overwrite: true overwrite: true

1
.gitignore vendored
View File

@ -25,7 +25,6 @@ yarn-error.log*
.idea .idea
.vscode .vscode
.helix
src/wasm-lib/.idea src/wasm-lib/.idea
src/wasm-lib/.vscode src/wasm-lib/.vscode

View File

@ -1,2 +0,0 @@
[editor]
auto-format = true

View File

@ -1,10 +0,0 @@
[language-server.eslint]
args = ["--stdio"]
command = "vscode-eslint-language-server"
[[language]]
name = "typescript"
auto-format = true
formatter = { command = "node_modules/.bin/prettier", args = ["--parser", "typescript"] }
language-servers = [ { name = "eslint", only-features = [ "diagnostics" ] }, "typescript-language-server" ]

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -31,12 +31,12 @@ appearance(data: AppearanceData, solid_set: SolidSet) -> SolidSet
// Add color to an extruded solid. // Add color to an extruded solid.
exampleSketch = startSketchOn("XZ") exampleSketch = startSketchOn("XZ")
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line(endAbsolute = [10, 0]) |> lineTo([10, 0], %)
|> line(endAbsolute = [0, 10]) |> lineTo([0, 10], %)
|> line(endAbsolute = [-10, 0]) |> lineTo([-10, 0], %)
|> close() |> close(%)
example = extrude(exampleSketch, length = 5) example = extrude(5, exampleSketch)
|> appearance({ |> appearance({
color = '#ff0000', color = '#ff0000',
metalness = 50, metalness = 50,
@ -65,11 +65,11 @@ sketch001 = startSketchOn('XY')
fn cube(center) { fn cube(center) {
return startSketchOn('XY') return startSketchOn('XY')
|> startProfileAt([center[0] - 10, center[1] - 10], %) |> startProfileAt([center[0] - 10, center[1] - 10], %)
|> line(endAbsolute = [center[0] + 10, center[1] - 10]) |> lineTo([center[0] + 10, center[1] - 10], %)
|> line(endAbsolute = [center[0] + 10, center[1] + 10]) |> lineTo([center[0] + 10, center[1] + 10], %)
|> line(endAbsolute = [center[0] - 10, center[1] + 10]) |> lineTo([center[0] - 10, center[1] + 10], %)
|> close() |> close(%)
|> extrude(length = 10) |> extrude(10, %)
} }
example0 = cube([0, 0]) example0 = cube([0, 0])
@ -95,11 +95,11 @@ appearance({
// This example shows setting the appearance _after_ the shell. // This example shows setting the appearance _after_ the shell.
firstSketch = startSketchOn('XY') firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %) |> startProfileAt([-12, 12], %)
|> line(end = [24, 0]) |> line([24, 0], %)
|> line(end = [0, -24]) |> line([0, -24], %)
|> line(end = [-24, 0]) |> line([-24, 0], %)
|> close() |> close(%)
|> extrude(length = 6) |> extrude(6, %)
shell({ faces = ['end'], thickness = 0.25 }, firstSketch) shell({ faces = ['end'], thickness = 0.25 }, firstSketch)
|> appearance({ |> appearance({
@ -116,11 +116,11 @@ shell({ faces = ['end'], thickness = 0.25 }, firstSketch)
// This example shows setting the appearance _before_ the shell. // This example shows setting the appearance _before_ the shell.
firstSketch = startSketchOn('XY') firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %) |> startProfileAt([-12, 12], %)
|> line(end = [24, 0]) |> line([24, 0], %)
|> line(end = [0, -24]) |> line([0, -24], %)
|> line(end = [-24, 0]) |> line([-24, 0], %)
|> close() |> close(%)
|> extrude(length = 6) |> extrude(6, %)
|> appearance({ |> appearance({
color = '#ff0000', color = '#ff0000',
metalness = 90, metalness = 90,
@ -137,12 +137,12 @@ shell({ faces = ['end'], thickness = 0.25 }, firstSketch)
// This example shows _before_ the pattern. // This example shows _before_ the pattern.
exampleSketch = startSketchOn('XZ') exampleSketch = startSketchOn('XZ')
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line(end = [0, 2]) |> line([0, 2], %)
|> line(end = [3, 1]) |> line([3, 1], %)
|> line(end = [0, -4]) |> line([0, -4], %)
|> close() |> close(%)
example = extrude(exampleSketch, length = 1) example = extrude(1, exampleSketch)
|> appearance({ |> appearance({
color = '#ff0000', color = '#ff0000',
metalness = 90, metalness = 90,
@ -162,12 +162,12 @@ example = extrude(exampleSketch, length = 1)
// This example shows _after_ the pattern. // This example shows _after_ the pattern.
exampleSketch = startSketchOn('XZ') exampleSketch = startSketchOn('XZ')
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line(end = [0, 2]) |> line([0, 2], %)
|> line(end = [3, 1]) |> line([3, 1], %)
|> line(end = [0, -4]) |> line([0, -4], %)
|> close() |> close(%)
example = extrude(exampleSketch, length = 1) example = extrude(1, exampleSketch)
|> patternLinear3d({ |> patternLinear3d({
axis = [1, 0, 1], axis = [1, 0, 1],
instances = 7, instances = 7,
@ -186,10 +186,10 @@ example = extrude(exampleSketch, length = 1)
// Color the result of a 2D pattern that was extruded. // Color the result of a 2D pattern that was extruded.
exampleSketch = startSketchOn('XZ') exampleSketch = startSketchOn('XZ')
|> startProfileAt([.5, 25], %) |> startProfileAt([.5, 25], %)
|> line(end = [0, 5]) |> line([0, 5], %)
|> line(end = [-1, 0]) |> line([-1, 0], %)
|> line(end = [0, -5]) |> line([0, -5], %)
|> close() |> close(%)
|> patternCircular2d({ |> patternCircular2d({
center = [0, 0], center = [0, 0],
instances = 13, instances = 13,
@ -197,7 +197,7 @@ exampleSketch = startSketchOn('XZ')
rotateDuplicates = true rotateDuplicates = true
}, %) }, %)
example = extrude(exampleSketch, length = 1) example = extrude(1, exampleSketch)
|> appearance({ |> appearance({
color = '#ff0000', color = '#ff0000',
metalness = 90, metalness = 90,
@ -214,11 +214,11 @@ example = extrude(exampleSketch, length = 1)
// Create a path for the sweep. // Create a path for the sweep.
sweepPath = startSketchOn('XZ') sweepPath = startSketchOn('XZ')
|> startProfileAt([0.05, 0.05], %) |> startProfileAt([0.05, 0.05], %)
|> line(end = [0, 7]) |> line([0, 7], %)
|> tangentialArc({ offset = 90, radius = 5 }, %) |> tangentialArc({ offset = 90, radius = 5 }, %)
|> line(end = [-3, 0]) |> line([-3, 0], %)
|> tangentialArc({ offset = -90, radius = 5 }, %) |> tangentialArc({ offset = -90, radius = 5 }, %)
|> line(end = [0, 7]) |> line([0, 7], %)
pipeHole = startSketchOn('XY') pipeHole = startSketchOn('XY')
|> circle({ center = [0, 0], radius = 1.5 }, %) |> circle({ center = [0, 0], radius = 1.5 }, %)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -36,12 +36,12 @@ filletRadius = 2
mountingPlateSketch = startSketchOn("XY") mountingPlateSketch = startSketchOn("XY")
|> startProfileAt([-width / 2, -length / 2], %) |> startProfileAt([-width / 2, -length / 2], %)
|> line(endAbsolute = [width / 2, -length / 2], tag = $edge1) |> lineTo([width / 2, -length / 2], %, $edge1)
|> line(endAbsolute = [width / 2, length / 2], tag = $edge2) |> lineTo([width / 2, length / 2], %, $edge2)
|> line(endAbsolute = [-width / 2, length / 2], tag = $edge3) |> lineTo([-width / 2, length / 2], %, $edge3)
|> close(tag = $edge4) |> close(%, $edge4)
mountingPlate = extrude(mountingPlateSketch, length = thickness) mountingPlate = extrude(thickness, mountingPlateSketch)
|> fillet({ |> fillet({
radius = filletRadius, radius = filletRadius,
tags = [ tags = [
@ -63,12 +63,12 @@ filletRadius = 1
mountingPlateSketch = startSketchOn("XY") mountingPlateSketch = startSketchOn("XY")
|> startProfileAt([-width / 2, -length / 2], %) |> startProfileAt([-width / 2, -length / 2], %)
|> line(endAbsolute = [width / 2, -length / 2], tag = $edge1) |> lineTo([width / 2, -length / 2], %, $edge1)
|> line(endAbsolute = [width / 2, length / 2], tag = $edge2) |> lineTo([width / 2, length / 2], %, $edge2)
|> line(endAbsolute = [-width / 2, length / 2], tag = $edge3) |> lineTo([-width / 2, length / 2], %, $edge3)
|> close(tag = $edge4) |> close(%, $edge4)
mountingPlate = extrude(mountingPlateSketch, length = thickness) mountingPlate = extrude(thickness, mountingPlateSketch)
|> fillet({ |> fillet({
radius = filletRadius, radius = filletRadius,
tolerance = 0.000001, tolerance = 0.000001,

File diff suppressed because one or more lines are too long

View File

@ -29,14 +29,14 @@ getNextAdjacentEdge(tag: TagIdentifier) -> Uuid
```js ```js
exampleSketch = startSketchOn('XZ') exampleSketch = startSketchOn('XZ')
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line(end = [10, 0]) |> line([10, 0], %)
|> angledLine({ angle = 60, length = 10 }, %) |> angledLine({ angle = 60, length = 10 }, %)
|> angledLine({ angle = 120, length = 10 }, %) |> angledLine({ angle = 120, length = 10 }, %)
|> line(end = [-10, 0]) |> line([-10, 0], %)
|> angledLine({ angle = 240, length = 10 }, %, $referenceEdge) |> angledLine({ angle = 240, length = 10 }, %, $referenceEdge)
|> close() |> close(%)
example = extrude(exampleSketch, length = 5) example = extrude(5, exampleSketch)
|> fillet({ |> fillet({
radius = 3, radius = 3,
tags = [getNextAdjacentEdge(referenceEdge)] tags = [getNextAdjacentEdge(referenceEdge)]

View File

@ -29,14 +29,14 @@ getOppositeEdge(tag: TagIdentifier) -> Uuid
```js ```js
exampleSketch = startSketchOn('XZ') exampleSketch = startSketchOn('XZ')
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line(end = [10, 0]) |> line([10, 0], %)
|> angledLine({ angle = 60, length = 10 }, %) |> angledLine({ angle = 60, length = 10 }, %)
|> angledLine({ angle = 120, length = 10 }, %) |> angledLine({ angle = 120, length = 10 }, %)
|> line(end = [-10, 0]) |> line([-10, 0], %)
|> angledLine({ angle = 240, length = 10 }, %, $referenceEdge) |> angledLine({ angle = 240, length = 10 }, %, $referenceEdge)
|> close() |> close(%)
example = extrude(exampleSketch, length = 5) example = extrude(5, exampleSketch)
|> fillet({ |> fillet({
radius = 3, radius = 3,
tags = [getOppositeEdge(referenceEdge)] tags = [getOppositeEdge(referenceEdge)]

View File

@ -29,14 +29,14 @@ getPreviousAdjacentEdge(tag: TagIdentifier) -> Uuid
```js ```js
exampleSketch = startSketchOn('XZ') exampleSketch = startSketchOn('XZ')
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line(end = [10, 0]) |> line([10, 0], %)
|> angledLine({ angle = 60, length = 10 }, %) |> angledLine({ angle = 60, length = 10 }, %)
|> angledLine({ angle = 120, length = 10 }, %) |> angledLine({ angle = 120, length = 10 }, %)
|> line(end = [-10, 0]) |> line([-10, 0], %)
|> angledLine({ angle = 240, length = 10 }, %, $referenceEdge) |> angledLine({ angle = 240, length = 10 }, %, $referenceEdge)
|> close() |> close(%)
example = extrude(exampleSketch, length = 5) example = extrude(5, exampleSketch)
|> fillet({ |> fillet({
radius = 3, radius = 3,
tags = [getPreviousAdjacentEdge(referenceEdge)] tags = [getPreviousAdjacentEdge(referenceEdge)]

View File

@ -49,7 +49,7 @@ springSketch = startSketchOn('YZ')
// Create a helix around an edge. // Create a helix around an edge.
helper001 = startSketchOn('XZ') helper001 = startSketchOn('XZ')
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line(end = [0, 10], tag = $edge001) |> line([0, 10], %, $edge001)
helixPath = helix({ helixPath = helix({
angleStart = 0, angleStart = 0,

View File

@ -30,7 +30,7 @@ helixRevolutions(data: HelixRevolutionsData, solid: Solid) -> Solid
```js ```js
part001 = startSketchOn('XY') part001 = startSketchOn('XY')
|> circle({ center = [5, 5], radius = 10 }, %) |> circle({ center = [5, 5], radius = 10 }, %)
|> extrude(length = 10) |> extrude(10, %)
|> helixRevolutions({ |> helixRevolutions({
angleStart = 0, angleStart = 0,
ccw = true, ccw = true,

File diff suppressed because one or more lines are too long

View File

@ -31,11 +31,11 @@ hollow(thickness: number, solid: Solid) -> Solid
// Hollow a basic sketch. // Hollow a basic sketch.
firstSketch = startSketchOn('XY') firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %) |> startProfileAt([-12, 12], %)
|> line(end = [24, 0]) |> line([24, 0], %)
|> line(end = [0, -24]) |> line([0, -24], %)
|> line(end = [-24, 0]) |> line([-24, 0], %)
|> close() |> close(%)
|> extrude(length = 6) |> extrude(6, %)
|> hollow(0.25, %) |> hollow(0.25, %)
``` ```
@ -45,11 +45,11 @@ firstSketch = startSketchOn('XY')
// Hollow a basic sketch. // Hollow a basic sketch.
firstSketch = startSketchOn('-XZ') firstSketch = startSketchOn('-XZ')
|> startProfileAt([-12, 12], %) |> startProfileAt([-12, 12], %)
|> line(end = [24, 0]) |> line([24, 0], %)
|> line(end = [0, -24]) |> line([0, -24], %)
|> line(end = [-24, 0]) |> line([-24, 0], %)
|> close() |> close(%)
|> extrude(length = 6) |> extrude(6, %)
|> hollow(0.5, %) |> hollow(0.5, %)
``` ```
@ -60,25 +60,25 @@ firstSketch = startSketchOn('-XZ')
size = 100 size = 100
case = startSketchOn('-XZ') case = startSketchOn('-XZ')
|> startProfileAt([-size, -size], %) |> startProfileAt([-size, -size], %)
|> line(end = [2 * size, 0]) |> line([2 * size, 0], %)
|> line(end = [0, 2 * size]) |> line([0, 2 * size], %)
|> tangentialArcTo([-size, size], %) |> tangentialArcTo([-size, size], %)
|> close() |> close(%)
|> extrude(length = 65) |> extrude(65, %)
thing1 = startSketchOn(case, 'end') thing1 = startSketchOn(case, 'end')
|> circle({ |> circle({
center = [-size / 2, -size / 2], center = [-size / 2, -size / 2],
radius = 25 radius = 25
}, %) }, %)
|> extrude(length = 50) |> extrude(50, %)
thing2 = startSketchOn(case, 'end') thing2 = startSketchOn(case, 'end')
|> circle({ |> circle({
center = [size / 2, -size / 2], center = [size / 2, -size / 2],
radius = 25 radius = 25
}, %) }, %)
|> extrude(length = 50) |> extrude(50, %)
hollow(0.5, case) hollow(0.5, case)
``` ```

View File

@ -58,6 +58,7 @@ layout: manual
* [`legAngY`](kcl/legAngY) * [`legAngY`](kcl/legAngY)
* [`legLen`](kcl/legLen) * [`legLen`](kcl/legLen)
* [`line`](kcl/line) * [`line`](kcl/line)
* [`lineTo`](kcl/lineTo)
* [`ln`](kcl/ln) * [`ln`](kcl/ln)
* [`loft`](kcl/loft) * [`loft`](kcl/loft)
* [`log`](kcl/log) * [`log`](kcl/log)

View File

@ -38,7 +38,7 @@ assertEqual(n, 3, 0.0001, "5/2 = 2.5, rounded up makes 3")
// Draw n cylinders. // Draw n cylinders.
startSketchOn('XZ') startSketchOn('XZ')
|> circle({ center = [0, 0], radius = 2 }, %) |> circle({ center = [0, 0], radius = 2 }, %)
|> extrude(length = 5) |> extrude(5, %)
|> patternTransform(n, fn(id) { |> patternTransform(n, fn(id) {
return { translate = [4 * id, 0, 0] } return { translate = [4 * id, 0, 0] }
}, %) }, %)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -34,18 +34,18 @@ loft(sketches: [Sketch], v_degree: NonZeroU32, bez_approximate_rational: bool, b
// Loft a square and a triangle. // Loft a square and a triangle.
squareSketch = startSketchOn('XY') squareSketch = startSketchOn('XY')
|> startProfileAt([-100, 200], %) |> startProfileAt([-100, 200], %)
|> line(end = [200, 0]) |> line([200, 0], %)
|> line(end = [0, -200]) |> line([0, -200], %)
|> line(end = [-200, 0]) |> line([-200, 0], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> lineTo([profileStartX(%), profileStartY(%)], %)
|> close() |> close(%)
triangleSketch = startSketchOn(offsetPlane('XY', 75)) triangleSketch = startSketchOn(offsetPlane('XY', 75))
|> startProfileAt([0, 125], %) |> startProfileAt([0, 125], %)
|> line(end = [-15, -30]) |> line([-15, -30], %)
|> line(end = [30, 0]) |> line([30, 0], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> lineTo([profileStartX(%), profileStartY(%)], %)
|> close() |> close(%)
loft([squareSketch, triangleSketch]) loft([squareSketch, triangleSketch])
``` ```
@ -56,11 +56,11 @@ loft([squareSketch, triangleSketch])
// Loft a square, a circle, and another circle. // Loft a square, a circle, and another circle.
squareSketch = startSketchOn('XY') squareSketch = startSketchOn('XY')
|> startProfileAt([-100, 200], %) |> startProfileAt([-100, 200], %)
|> line(end = [200, 0]) |> line([200, 0], %)
|> line(end = [0, -200]) |> line([0, -200], %)
|> line(end = [-200, 0]) |> line([-200, 0], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> lineTo([profileStartX(%), profileStartY(%)], %)
|> close() |> close(%)
circleSketch0 = startSketchOn(offsetPlane('XY', 75)) circleSketch0 = startSketchOn(offsetPlane('XY', 75))
|> circle({ center = [0, 100], radius = 50 }, %) |> circle({ center = [0, 100], radius = 50 }, %)
@ -81,11 +81,11 @@ loft([
// Loft a square, a circle, and another circle with options. // Loft a square, a circle, and another circle with options.
squareSketch = startSketchOn('XY') squareSketch = startSketchOn('XY')
|> startProfileAt([-100, 200], %) |> startProfileAt([-100, 200], %)
|> line(end = [200, 0]) |> line([200, 0], %)
|> line(end = [0, -200]) |> line([0, -200], %)
|> line(end = [-200, 0]) |> line([-200, 0], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> lineTo([profileStartX(%), profileStartY(%)], %)
|> close() |> close(%)
circleSketch0 = startSketchOn(offsetPlane('XY', 75)) circleSketch0 = startSketchOn(offsetPlane('XY', 75))
|> circle({ center = [0, 100], radius = 50 }, %) |> circle({ center = [0, 100], radius = 50 }, %)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -31,7 +31,7 @@ patternCircular3d(data: CircularPattern3dData, solid_set: SolidSet) -> [Solid]
exampleSketch = startSketchOn('XZ') exampleSketch = startSketchOn('XZ')
|> circle({ center = [0, 0], radius = 1 }, %) |> circle({ center = [0, 0], radius = 1 }, %)
example = extrude(exampleSketch, length = -5) example = extrude(-5, exampleSketch)
|> patternCircular3d({ |> patternCircular3d({
axis = [1, -1, 0], axis = [1, -1, 0],
center = [10, -20, 0], center = [10, -20, 0],

File diff suppressed because one or more lines are too long

View File

@ -30,12 +30,12 @@ patternLinear3d(data: LinearPattern3dData, solid_set: SolidSet) -> [Solid]
```js ```js
exampleSketch = startSketchOn('XZ') exampleSketch = startSketchOn('XZ')
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line(end = [0, 2]) |> line([0, 2], %)
|> line(end = [3, 1]) |> line([3, 1], %)
|> line(end = [0, -4]) |> line([0, -4], %)
|> close() |> close(%)
example = extrude(exampleSketch, length = 1) example = extrude(1, exampleSketch)
|> patternLinear3d({ |> patternLinear3d({
axis = [1, 0, 1], axis = [1, 0, 1],
instances = 7, instances = 7,

View File

@ -63,7 +63,7 @@ fn transform(id) {
// Sketch 4 cylinders. // Sketch 4 cylinders.
sketch001 = startSketchOn('XZ') sketch001 = startSketchOn('XZ')
|> circle({ center = [0, 0], radius = 2 }, %) |> circle({ center = [0, 0], radius = 2 }, %)
|> extrude(length = 5) |> extrude(5, %)
|> patternTransform(4, transform, %) |> patternTransform(4, transform, %)
``` ```
@ -79,7 +79,7 @@ fn transform(id) {
sketch001 = startSketchOn('XZ') sketch001 = startSketchOn('XZ')
|> circle({ center = [0, 0], radius = 2 }, %) |> circle({ center = [0, 0], radius = 2 }, %)
|> extrude(length = 5) |> extrude(5, %)
|> patternTransform(4, transform, %) |> patternTransform(4, transform, %)
``` ```
@ -97,12 +97,12 @@ fn cube(length, center) {
return startSketchOn('XY') return startSketchOn('XY')
|> startProfileAt(p0, %) |> startProfileAt(p0, %)
|> line(endAbsolute = p1) |> lineTo(p1, %)
|> line(endAbsolute = p2) |> lineTo(p2, %)
|> line(endAbsolute = p3) |> lineTo(p3, %)
|> line(endAbsolute = p0) |> lineTo(p0, %)
|> close() |> close(%)
|> extrude(length = length) |> extrude(length, %)
} }
width = 20 width = 20
@ -135,12 +135,12 @@ fn cube(length, center) {
return startSketchOn('XY') return startSketchOn('XY')
|> startProfileAt(p0, %) |> startProfileAt(p0, %)
|> line(endAbsolute = p1) |> lineTo(p1, %)
|> line(endAbsolute = p2) |> lineTo(p2, %)
|> line(endAbsolute = p3) |> lineTo(p3, %)
|> line(endAbsolute = p0) |> lineTo(p0, %)
|> close() |> close(%)
|> extrude(length = length) |> extrude(length, %)
} }
width = 20 width = 20
@ -179,7 +179,7 @@ fn layer() {
return startSketchOn("XY") return startSketchOn("XY")
// or some other plane idk // or some other plane idk
|> circle({ center = [0, 0], radius = 1 }, %, $tag1) |> circle({ center = [0, 0], radius = 1 }, %, $tag1)
|> extrude(length = h) |> extrude(h, %)
} }
// The vase is 100 layers tall. // The vase is 100 layers tall.
// The 100 layers are replica of each other, with a slight transformation applied to each. // The 100 layers are replica of each other, with a slight transformation applied to each.
@ -205,7 +205,7 @@ startSketchOn('XY')
center = [0, 0], center = [0, 0],
inscribed = false inscribed = false
}, %) }, %)
|> extrude(length = 4) |> extrude(4, %)
|> patternTransform(3, transform, %) |> patternTransform(3, transform, %)
``` ```

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -30,12 +30,12 @@ segEnd(tag: TagIdentifier) -> [number]
w = 15 w = 15
cube = startSketchOn('XY') cube = startSketchOn('XY')
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line(end = [w, 0], tag = $line1) |> line([w, 0], %, $line1)
|> line(end = [0, w], tag = $line2) |> line([0, w], %, $line2)
|> line(end = [-w, 0], tag = $line3) |> line([-w, 0], %, $line3)
|> line(end = [0, -w], tag = $line4) |> line([0, -w], %, $line4)
|> close() |> close(%)
|> extrude(length = 5) |> extrude(5, %)
fn cylinder(radius, tag) { fn cylinder(radius, tag) {
return startSketchOn('XY') return startSketchOn('XY')
@ -44,7 +44,7 @@ fn cylinder(radius, tag) {
radius = radius, radius = radius,
center = segEnd(tag) center = segEnd(tag)
}, %) }, %)
|> extrude(length = radius) |> extrude(radius, %)
} }
cylinder(1, line1) cylinder(1, line1)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -30,12 +30,12 @@ segStart(tag: TagIdentifier) -> [number]
w = 15 w = 15
cube = startSketchOn('XY') cube = startSketchOn('XY')
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line(end = [w, 0], tag = $line1) |> line([w, 0], %, $line1)
|> line(end = [0, w], tag = $line2) |> line([0, w], %, $line2)
|> line(end = [-w, 0], tag = $line3) |> line([-w, 0], %, $line3)
|> line(end = [0, -w], tag = $line4) |> line([0, -w], %, $line4)
|> close() |> close(%)
|> extrude(length = 5) |> extrude(5, %)
fn cylinder(radius, tag) { fn cylinder(radius, tag) {
return startSketchOn('XY') return startSketchOn('XY')
@ -44,7 +44,7 @@ fn cylinder(radius, tag) {
radius = radius, radius = radius,
center = segStart(tag) center = segStart(tag)
}, %) }, %)
|> extrude(length = radius) |> extrude(radius, %)
} }
cylinder(1, line1) cylinder(1, line1)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -31,11 +31,11 @@ shell(data: ShellData, solid_set: SolidSet) -> SolidSet
// Remove the end face for the extrusion. // Remove the end face for the extrusion.
firstSketch = startSketchOn('XY') firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %) |> startProfileAt([-12, 12], %)
|> line(end = [24, 0]) |> line([24, 0], %)
|> line(end = [0, -24]) |> line([0, -24], %)
|> line(end = [-24, 0]) |> line([-24, 0], %)
|> close() |> close(%)
|> extrude(length = 6) |> extrude(6, %)
// Remove the end face for the extrusion. // Remove the end face for the extrusion.
shell({ faces = ['end'], thickness = 0.25 }, firstSketch) shell({ faces = ['end'], thickness = 0.25 }, firstSketch)
@ -47,11 +47,11 @@ shell({ faces = ['end'], thickness = 0.25 }, firstSketch)
// Remove the start face for the extrusion. // Remove the start face for the extrusion.
firstSketch = startSketchOn('-XZ') firstSketch = startSketchOn('-XZ')
|> startProfileAt([-12, 12], %) |> startProfileAt([-12, 12], %)
|> line(end = [24, 0]) |> line([24, 0], %)
|> line(end = [0, -24]) |> line([0, -24], %)
|> line(end = [-24, 0]) |> line([-24, 0], %)
|> close() |> close(%)
|> extrude(length = 6) |> extrude(6, %)
// Remove the start face for the extrusion. // Remove the start face for the extrusion.
shell({ faces = ['start'], thickness = 0.25 }, firstSketch) shell({ faces = ['start'], thickness = 0.25 }, firstSketch)
@ -63,11 +63,11 @@ shell({ faces = ['start'], thickness = 0.25 }, firstSketch)
// Remove a tagged face and the end face for the extrusion. // Remove a tagged face and the end face for the extrusion.
firstSketch = startSketchOn('XY') firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %) |> startProfileAt([-12, 12], %)
|> line(end = [24, 0]) |> line([24, 0], %)
|> line(end = [0, -24]) |> line([0, -24], %)
|> line(end = [-24, 0], tag = $myTag) |> line([-24, 0], %, $myTag)
|> close() |> close(%)
|> extrude(length = 6) |> extrude(6, %)
// Remove a tagged face for the extrusion. // Remove a tagged face for the extrusion.
shell({ faces = [myTag], thickness = 0.25 }, firstSketch) shell({ faces = [myTag], thickness = 0.25 }, firstSketch)
@ -79,11 +79,11 @@ shell({ faces = [myTag], thickness = 0.25 }, firstSketch)
// Remove multiple faces at once. // Remove multiple faces at once.
firstSketch = startSketchOn('XY') firstSketch = startSketchOn('XY')
|> startProfileAt([-12, 12], %) |> startProfileAt([-12, 12], %)
|> line(end = [24, 0]) |> line([24, 0], %)
|> line(end = [0, -24]) |> line([0, -24], %)
|> line(end = [-24, 0], tag = $myTag) |> line([-24, 0], %, $myTag)
|> close() |> close(%)
|> extrude(length = 6) |> extrude(6, %)
// Remove a tagged face and the end face for the extrusion. // Remove a tagged face and the end face for the extrusion.
shell({ shell({
@ -99,25 +99,25 @@ shell({
size = 100 size = 100
case = startSketchOn('-XZ') case = startSketchOn('-XZ')
|> startProfileAt([-size, -size], %) |> startProfileAt([-size, -size], %)
|> line(end = [2 * size, 0]) |> line([2 * size, 0], %)
|> line(end = [0, 2 * size]) |> line([0, 2 * size], %)
|> tangentialArcTo([-size, size], %) |> tangentialArcTo([-size, size], %)
|> close() |> close(%)
|> extrude(length = 65) |> extrude(65, %)
thing1 = startSketchOn(case, 'end') thing1 = startSketchOn(case, 'end')
|> circle({ |> circle({
center = [-size / 2, -size / 2], center = [-size / 2, -size / 2],
radius = 25 radius = 25
}, %) }, %)
|> extrude(length = 50) |> extrude(50, %)
thing2 = startSketchOn(case, 'end') thing2 = startSketchOn(case, 'end')
|> circle({ |> circle({
center = [size / 2, -size / 2], center = [size / 2, -size / 2],
radius = 25 radius = 25
}, %) }, %)
|> extrude(length = 50) |> extrude(50, %)
// We put "case" in the shell function to shell the entire object. // We put "case" in the shell function to shell the entire object.
shell({ faces = ['start'], thickness = 5 }, case) shell({ faces = ['start'], thickness = 5 }, case)
@ -130,25 +130,25 @@ shell({ faces = ['start'], thickness = 5 }, case)
size = 100 size = 100
case = startSketchOn('XY') case = startSketchOn('XY')
|> startProfileAt([-size, -size], %) |> startProfileAt([-size, -size], %)
|> line(end = [2 * size, 0]) |> line([2 * size, 0], %)
|> line(end = [0, 2 * size]) |> line([0, 2 * size], %)
|> tangentialArcTo([-size, size], %) |> tangentialArcTo([-size, size], %)
|> close() |> close(%)
|> extrude(length = 65) |> extrude(65, %)
thing1 = startSketchOn(case, 'end') thing1 = startSketchOn(case, 'end')
|> circle({ |> circle({
center = [-size / 2, -size / 2], center = [-size / 2, -size / 2],
radius = 25 radius = 25
}, %) }, %)
|> extrude(length = 50) |> extrude(50, %)
thing2 = startSketchOn(case, 'end') thing2 = startSketchOn(case, 'end')
|> circle({ |> circle({
center = [size / 2, -size / 2], center = [size / 2, -size / 2],
radius = 25 radius = 25
}, %) }, %)
|> extrude(length = 50) |> extrude(50, %)
// We put "thing1" in the shell function to shell the end face of the object. // We put "thing1" in the shell function to shell the end face of the object.
shell({ faces = ['end'], thickness = 5 }, thing1) shell({ faces = ['end'], thickness = 5 }, thing1)
@ -164,25 +164,25 @@ shell({ faces = ['end'], thickness = 5 }, thing1)
size = 100 size = 100
case = startSketchOn('XY') case = startSketchOn('XY')
|> startProfileAt([-size, -size], %) |> startProfileAt([-size, -size], %)
|> line(end = [2 * size, 0]) |> line([2 * size, 0], %)
|> line(end = [0, 2 * size]) |> line([0, 2 * size], %)
|> tangentialArcTo([-size, size], %) |> tangentialArcTo([-size, size], %)
|> close() |> close(%)
|> extrude(length = 65) |> extrude(65, %)
thing1 = startSketchOn(case, 'end') thing1 = startSketchOn(case, 'end')
|> circle({ |> circle({
center = [-size / 2, -size / 2], center = [-size / 2, -size / 2],
radius = 25 radius = 25
}, %) }, %)
|> extrude(length = 50) |> extrude(50, %)
thing2 = startSketchOn(case, 'end') thing2 = startSketchOn(case, 'end')
|> circle({ |> circle({
center = [size / 2, -size / 2], center = [size / 2, -size / 2],
radius = 25 radius = 25
}, %) }, %)
|> extrude(length = 50) |> extrude(50, %)
// We put "thing1" and "thing2" in the shell function to shell the end face of the object. // We put "thing1" and "thing2" in the shell function to shell the end face of the object.
shell({ faces = ['end'], thickness = 5 }, [thing1, thing2]) shell({ faces = ['end'], thickness = 5 }, [thing1, thing2])

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -34,11 +34,11 @@ sweep(data: SweepData, sketch: Sketch) -> Solid
// Create a path for the sweep. // Create a path for the sweep.
sweepPath = startSketchOn('XZ') sweepPath = startSketchOn('XZ')
|> startProfileAt([0.05, 0.05], %) |> startProfileAt([0.05, 0.05], %)
|> line(end = [0, 7]) |> line([0, 7], %)
|> tangentialArc({ offset = 90, radius = 5 }, %) |> tangentialArc({ offset = 90, radius = 5 }, %)
|> line(end = [-3, 0]) |> line([-3, 0], %)
|> tangentialArc({ offset = -90, radius = 5 }, %) |> tangentialArc({ offset = -90, radius = 5 }, %)
|> line(end = [0, 7]) |> line([0, 7], %)
// Create a hole for the pipe. // Create a hole for the pipe.
pipeHole = startSketchOn('XY') pipeHole = startSketchOn('XY')

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -47,19 +47,6 @@ myObj = { a = 0, b = "thing" }
We support two different ways of getting properties from objects, you can call We support two different ways of getting properties from objects, you can call
`myObj.a` or `myObj["a"]` both work. `myObj.a` or `myObj["a"]` both work.
## Binary expressions
You can also do math! Let's show an example below:
```
myMathExpression = 3 + 1 * 2 / 3 - 7
```
You can nest expressions in parenthesis as well:
```
myMathExpression = 3 + (1 * 2 / (3 - 7))
```
## Functions ## Functions
@ -74,107 +61,21 @@ fn myFn(x) {
As you can see above `myFn` just returns whatever it is given. As you can see above `myFn` just returns whatever it is given.
KCL's early drafts used positional arguments, but we now use keyword arguments. If you declare a
function like this: ## Binary expressions
You can also do math! Let's show an example below:
``` ```
fn add(left, right) { myMathExpression = 3 + 1 * 2 / 3 - 7
return left + right
}
``` ```
You can call it like this: You can nest expressions in parenthesis as well:
``` ```
total = add(left = 1, right = 2) myMathExpression = 3 + (1 * 2 / (3 - 7))
``` ```
Functions can also declare one *unlabeled* arg. If you do want to declare an unlabeled arg, it must
be the first arg declared.
```
// The @ indicates an argument can be used without a label.
// Note that only the first argument can use @.
fn increment(@x) {
return x + 1
}
fn add(@x, delta) {
return x + delta
}
two = increment(1)
three = add(1, delta = 2)
```
## Pipelines
It can be hard to read repeated function calls, because of all the nested brackets.
```
i = 1
x = h(g(f(i)))
```
You can make this easier to read by breaking it into many declarations, but that is a bit annoying.
```
i = 1
x0 = f(i)
x1 = g(x0)
x = h(x1)
```
Instead, you can use the pipeline operator (`|>`) to simplify this.
Basically, `x |> f(%)` is a shorthand for `f(x)`. The left-hand side of the `|>` gets put into
the `%` in the right-hand side.
So, this means `x |> f(%) |> g(%)` is shorthand for `g(f(x))`. The code example above, with its
somewhat-clunky `x0` and `x1` constants could be rewritten as
```
i = 1
x = i
|> f(%)
|> g(%)
|> h(%)
```
This helps keep your code neat and avoid unnecessary declarations.
## Pipelines and keyword arguments
Say you have a long pipeline of sketch functions, like this:
```
startSketch()
|> line(%, end = [3, 4])
|> line(%, end = [10, 10])
|> line(%, end = [-13, -14])
|> close(%)
```
In this example, each function call outputs a sketch, and it gets put into the next function call via
the `%`, into the first (unlabeled) argument.
If a function call uses an unlabeled first parameter, it will default to `%` if it's not given. This
means that `|> line(%, end = [3, 4])` and `|> line(end = [3, 4])` are equivalent! So the above
could be rewritten as
```
startSketch()
|> line(end = [3, 4])
|> line(end = [10, 10])
|> line(end = [-13, -14])
|> close()
```
Note that we are still in the process of migrating KCL's standard library to use keyword arguments. So some
functions are still unfortunately using positional arguments. We're moving them over, so keep checking back.
Some functions like `angledLine`, `startProfileAt` etc are still using the old positional argument syntax.
Check the docs page for each function and look at its examples to see.
## Tags ## Tags
Tags are used to give a name (tag) to a specific path. Tags are used to give a name (tag) to a specific path.
@ -187,17 +88,17 @@ way:
``` ```
startSketchOn('XZ') startSketchOn('XZ')
|> startProfileAt(origin, %) |> startProfileAt(origin, %)
|> angledLine({angle = 0, length = 191.26}, %, $rectangleSegmentA001) |> angledLine([0, 191.26], %, $rectangleSegmentA001)
|> angledLine({ |> angledLine([
angle = segAng(rectangleSegmentA001) - 90, segAng(rectangleSegmentA001) - 90,
length = 196.99, 196.99
}, %, $rectangleSegmentB001) ], %, $rectangleSegmentB001)
|> angledLine({ |> angledLine([
angle = segAng(rectangleSegmentA001), segAng(rectangleSegmentA001),
length = -segLen(rectangleSegmentA001), -segLen(rectangleSegmentA001)
}, %, $rectangleSegmentC001) ], %, $rectangleSegmentC001)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> lineTo([profileStartX(%), profileStartY(%)], %)
|> close() |> close(%)
``` ```
### Tag Identifier ### Tag Identifier
@ -220,17 +121,17 @@ However if the code was written like this:
fn rect(origin) { fn rect(origin) {
return startSketchOn('XZ') return startSketchOn('XZ')
|> startProfileAt(origin, %) |> startProfileAt(origin, %)
|> angledLine({angle = 0, length = 191.26}, %, $rectangleSegmentA001) |> angledLine([0, 191.26], %, $rectangleSegmentA001)
|> angledLine({ |> angledLine([
angle = segAng(rectangleSegmentA001) - 90, segAng(rectangleSegmentA001) - 90,
length = 196.99 196.99
}, %, $rectangleSegmentB001) ], %, $rectangleSegmentB001)
|> angledLine({ |> angledLine([
angle = segAng(rectangleSegmentA001), segAng(rectangleSegmentA001),
length = -segLen(rectangleSegmentA001) -segLen(rectangleSegmentA001)
}, %, $rectangleSegmentC001) ], %, $rectangleSegmentC001)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> lineTo([profileStartX(%), profileStartY(%)], %)
|> close() |> close(%)
} }
rect([0, 0]) rect([0, 0])
@ -248,17 +149,17 @@ For example the following code works.
fn rect(origin) { fn rect(origin) {
return startSketchOn('XZ') return startSketchOn('XZ')
|> startProfileAt(origin, %) |> startProfileAt(origin, %)
|> angledLine({angle = 0, length = 191.26}, %, $rectangleSegmentA001) |> angledLine([0, 191.26], %, $rectangleSegmentA001)
|> angledLine({ |> angledLine([
angle = segAng(rectangleSegmentA001) - 90, segAng(rectangleSegmentA001) - 90,
length = 196.99 196.99
}, %, $rectangleSegmentB001) ], %, $rectangleSegmentB001)
|> angledLine({ |> angledLine([
angle = segAng(rectangleSegmentA001), segAng(rectangleSegmentA001),
length = -segLen(rectangleSegmentA001) -segLen(rectangleSegmentA001)
}, %, $rectangleSegmentC001) ], %, $rectangleSegmentC001)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> lineTo([profileStartX(%), profileStartY(%)], %)
|> close() |> close(%)
} }
rect([0, 0]) rect([0, 0])

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -144,7 +144,7 @@ async function doBasicSketch(
|> xLine(-segLen(seg01), %)`) |> xLine(-segLen(seg01), %)`)
} }
test.describe('Basic sketch', { tag: ['@skipWin'] }, () => { test.describe('Basic sketch', () => {
test.fixme('code pane open at start', async ({ page, homePage }) => { test.fixme('code pane open at start', async ({ page, homePage }) => {
await doBasicSketch(page, homePage, ['code']) await doBasicSketch(page, homePage, ['code'])
}) })

View File

@ -4,10 +4,7 @@ import { getUtils } from './test-utils'
import { EngineCommand } from 'lang/std/artifactGraph' import { EngineCommand } from 'lang/std/artifactGraph'
import { uuidv4 } from 'lib/utils' import { uuidv4 } from 'lib/utils'
test.describe( test.describe('Can create sketches on all planes and their back sides', () => {
'Can create sketches on all planes and their back sides',
{ tag: ['@skipWin'] },
() => {
const sketchOnPlaneAndBackSideTest = async ( const sketchOnPlaneAndBackSideTest = async (
page: Page, page: Page,
homePage: HomePageFixture, homePage: HomePageFixture,
@ -91,17 +88,11 @@ test.describe(
}) })
test('YZ', async ({ page, homePage }) => { test('YZ', async ({ page, homePage }) => {
await sketchOnPlaneAndBackSideTest(page, homePage, 'YZ', { await sketchOnPlaneAndBackSideTest(page, homePage, 'YZ', { x: 700, y: 250 }) // green plane
x: 700,
y: 250,
}) // green plane
}) })
test('XZ', async ({ page, homePage }) => { test('XZ', async ({ page, homePage }) => {
await sketchOnPlaneAndBackSideTest(page, homePage, '-XZ', { await sketchOnPlaneAndBackSideTest(page, homePage, '-XZ', { x: 700, y: 80 }) // blue plane
x: 700,
y: 80,
}) // blue plane
}) })
test('-XY', async ({ page, homePage }) => { test('-XY', async ({ page, homePage }) => {
@ -119,10 +110,6 @@ test.describe(
}) })
test('-XZ', async ({ page, homePage }) => { test('-XZ', async ({ page, homePage }) => {
await sketchOnPlaneAndBackSideTest(page, homePage, 'XZ', { await sketchOnPlaneAndBackSideTest(page, homePage, 'XZ', { x: 700, y: 427 }) // back of blue plane
x: 700, })
y: 427,
}) // back of blue plane
}) })
}
)

View File

@ -6,7 +6,7 @@ import { bracket } from 'lib/exampleKcl'
import { TEST_CODE_LONG_WITH_ERROR_OUT_OF_VIEW } from './storageStates' import { TEST_CODE_LONG_WITH_ERROR_OUT_OF_VIEW } from './storageStates'
import fsp from 'fs/promises' import fsp from 'fs/promises'
test.describe('Code pane and errors', { tag: ['@skipWin'] }, () => { test.describe('Code pane and errors', () => {
test('Typing KCL errors induces a badge on the code pane button', async ({ test('Typing KCL errors induces a badge on the code pane button', async ({
page, page,
homePage, homePage,
@ -20,11 +20,11 @@ test.describe('Code pane and errors', { tag: ['@skipWin'] }, () => {
`// Extruded Triangle `// Extruded Triangle
sketch001 = startSketchOn('XZ') sketch001 = startSketchOn('XZ')
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line(end = [10, 0]) |> line([10, 0], %)
|> line(end = [-5, 10]) |> line([-5, 10], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> lineTo([profileStartX(%), profileStartY(%)], %)
|> close() |> close(%)
extrude001 = extrude(sketch001, length = 5)` extrude001 = extrude(5, sketch001)`
) )
}) })
@ -79,10 +79,8 @@ test.describe('Code pane and errors', { tag: ['@skipWin'] }, () => {
// Delete a character to break the KCL // Delete a character to break the KCL
await editor.openPane() await editor.openPane()
await editor.scrollToText('bracketLeg1Sketch, length = thickness)') await editor.scrollToText('thickness, bracketLeg1Sketch)')
await page await page.getByText('extrude(thickness, bracketLeg1Sketch)').click()
.getByText('extrude(bracketLeg1Sketch, length = thickness)')
.click()
await page.keyboard.press('Backspace') await page.keyboard.press('Backspace')
// Ensure that a badge appears on the button // Ensure that a badge appears on the button
@ -109,7 +107,7 @@ test.describe('Code pane and errors', { tag: ['@skipWin'] }, () => {
await editor.openPane() await editor.openPane()
// Go to our problematic code again (missing closing paren!) // Go to our problematic code again (missing closing paren!)
await editor.scrollToText('extrude(bracketLeg1Sketch, length = thickness') await editor.scrollToText('extrude(thickness, bracketLeg1Sketch')
// Ensure that a badge appears on the button // Ensure that a badge appears on the button
await expect(codePaneButtonHolder).toContainText('notification') await expect(codePaneButtonHolder).toContainText('notification')

View File

@ -4,7 +4,7 @@ import { executorInputPath, getUtils } from './test-utils'
import { KCL_DEFAULT_LENGTH } from 'lib/constants' import { KCL_DEFAULT_LENGTH } from 'lib/constants'
import path from 'path' import path from 'path'
test.describe('Command bar tests', { tag: ['@skipWin'] }, () => { test.describe('Command bar tests', () => {
test('Extrude from command bar selects extrude line after', async ({ test('Extrude from command bar selects extrude line after', async ({
page, page,
homePage, homePage,
@ -14,10 +14,10 @@ test.describe('Command bar tests', { tag: ['@skipWin'] }, () => {
'persistCode', 'persistCode',
`sketch001 = startSketchOn('XY') `sketch001 = startSketchOn('XY')
|> startProfileAt([-10, -10], %) |> startProfileAt([-10, -10], %)
|> line(end = [20, 0]) |> line([20, 0], %)
|> line(end = [0, 20]) |> line([0, 20], %)
|> xLine(-20, %) |> xLine(-20, %)
|> close() |> close(%)
` `
) )
}) })
@ -32,7 +32,7 @@ test.describe('Command bar tests', { tag: ['@skipWin'] }, () => {
await u.closeDebugPanel() await u.closeDebugPanel()
// Click the line of code for xLine. // Click the line of code for xLine.
await page.getByText(`close()`).click() // TODO remove this and reinstate // await topHorzSegmentClick() await page.getByText(`close(%)`).click() // TODO remove this and reinstate // await topHorzSegmentClick()
await page.waitForTimeout(100) await page.waitForTimeout(100)
await page.getByRole('button', { name: 'Extrude' }).click() await page.getByRole('button', { name: 'Extrude' }).click()
@ -42,47 +42,7 @@ test.describe('Command bar tests', { tag: ['@skipWin'] }, () => {
await page.keyboard.press('Enter') await page.keyboard.press('Enter')
await page.waitForTimeout(200) await page.waitForTimeout(200)
await expect(page.locator('.cm-activeLine')).toHaveText( await expect(page.locator('.cm-activeLine')).toHaveText(
`extrude001 = extrude(sketch001, length = ${KCL_DEFAULT_LENGTH})` `extrude001 = extrude(${KCL_DEFAULT_LENGTH}, sketch001)`
)
})
// TODO: fix this test after the electron migration
test.fixme('Fillet from command bar', async ({ page, homePage }) => {
await page.addInitScript(async () => {
localStorage.setItem(
'persistCode',
`sketch001 = startSketchOn('XY')
|> startProfileAt([-5, -5], %)
|> line(end = [0, 10])
|> line(end = [10, 0])
|> line(end = [0, -10])
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()
extrude001 = extrude(sketch001, length = -10)`
)
})
const u = await getUtils(page)
await page.setBodyDimensions({ width: 1000, height: 500 })
await homePage.goToModelingScene()
await u.openDebugPanel()
await u.expectCmdLog('[data-message-type="execution-done"]')
await u.closeDebugPanel()
const selectSegment = () => page.getByText(`line(end = [0, -10])`).click()
await selectSegment()
await page.waitForTimeout(100)
await page.getByRole('button', { name: 'Fillet' }).click()
await page.waitForTimeout(100)
await page.keyboard.press('Enter') // skip selection
await page.waitForTimeout(100)
await page.keyboard.press('Enter') // accept default radius
await page.waitForTimeout(100)
await page.keyboard.press('Enter') // submit
await page.waitForTimeout(100)
await expect(page.locator('.cm-activeLine')).toContainText(
`fillet({ radius = ${KCL_DEFAULT_LENGTH}, tags = [seg01] }, %)`
) )
}) })
@ -167,10 +127,10 @@ test.describe('Command bar tests', { tag: ['@skipWin'] }, () => {
await expect(commandLevelArgButton).toHaveText('level: project') await expect(commandLevelArgButton).toHaveText('level: project')
}) })
test( test('Command bar keybinding works from code editor and can change a setting', async ({
'Command bar keybinding works from code editor and can change a setting', page,
{ tag: ['@skipWin'] }, homePage,
async ({ page, homePage }) => { }) => {
await page.setBodyDimensions({ width: 1200, height: 500 }) await page.setBodyDimensions({ width: 1200, height: 500 })
await homePage.goToModelingScene() await homePage.goToModelingScene()
@ -202,9 +162,10 @@ test.describe('Command bar tests', { tag: ['@skipWin'] }, () => {
await page.keyboard.press('ArrowDown') await page.keyboard.press('ArrowDown')
await page.keyboard.press('ArrowDown') await page.keyboard.press('ArrowDown')
await page.keyboard.press('ArrowDown') await page.keyboard.press('ArrowDown')
await expect( await expect(page.getByRole('option', { name: 'system' })).toHaveAttribute(
page.getByRole('option', { name: 'system' }) 'data-headlessui-state',
).toHaveAttribute('data-headlessui-state', 'active') 'active'
)
await page.keyboard.press('Enter') await page.keyboard.press('Enter')
// Check the toast appeared // Check the toast appeared
@ -213,8 +174,7 @@ test.describe('Command bar tests', { tag: ['@skipWin'] }, () => {
).toBeVisible() ).toBeVisible()
// Check that the theme changed // Check that the theme changed
await expect(page.locator('body')).not.toHaveClass(`body-bg dark`) await expect(page.locator('body')).not.toHaveClass(`body-bg dark`)
} })
)
test('Can extrude from the command bar', async ({ page, homePage }) => { test('Can extrude from the command bar', async ({ page, homePage }) => {
await page.addInitScript(async () => { await page.addInitScript(async () => {
@ -223,10 +183,10 @@ test.describe('Command bar tests', { tag: ['@skipWin'] }, () => {
`distance = sqrt(20) `distance = sqrt(20)
sketch001 = startSketchOn('XZ') sketch001 = startSketchOn('XZ')
|> startProfileAt([-6.95, 10.98], %) |> startProfileAt([-6.95, 10.98], %)
|> line(end = [25.1, 0.41]) |> line([25.1, 0.41], %)
|> line(end = [0.73, -20.93]) |> line([0.73, -20.93], %)
|> line(end = [-23.44, 0.52]) |> line([-23.44, 0.52], %)
|> close() |> close(%)
` `
) )
}) })
@ -291,7 +251,7 @@ test.describe('Command bar tests', { tag: ['@skipWin'] }, () => {
await u.waitForCmdReceive('extrude') await u.waitForCmdReceive('extrude')
await expect(page.locator('.cm-content')).toContainText( await expect(page.locator('.cm-content')).toContainText(
'extrude001 = extrude(sketch001, length = distance001)' 'extrude001 = extrude(distance001, sketch001)'
) )
}) })

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