Compare commits

...

9 Commits

Author SHA1 Message Date
8896d06028 Release KCL 39 (#5518) 2025-02-26 09:07:57 -06:00
max
1f217ef50b Fix Second-Body Extrude Selection (#5456)
* getSweepArtifactFromSelection

* update getPathToExtrudeForSegmentSelection

* update shell

* add tests and update selection

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* add support for wall and cap

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* fmt

* add CallExpressionKw

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-02-26 08:28:41 -05:00
5ef5c6280c Fix: revert the red color for runtime error back to the hue shift color (#5509)
* fix: don't use red for runtime error, use hue shift like the original error icon

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* fix: decrease font size for better layout

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-02-25 22:15:01 -06:00
aac95e1e2e Fix to add revolve about edge to the artifact graph (#5511) 2025-02-25 23:04:10 -05:00
18f4a1303c Multiple prompt-to-edit selection, plus direct editor selections (#5478)
* Add multiple selections and editor selections for promptToEdit

* remove unused

* re-enable prompt to edit tests

* add test for manual code selection

* at test for multi-selection

* clean up

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* typo

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-02-26 03:06:51 +00:00
ded97eda61 Fix kcl-samples URL and other minor things (#5508)
* Fix kcl-samples URL

* Delete debug files
2025-02-25 20:54:05 +00:00
f6b06520ee Bugfix: wait for settings loading before onboarding redirect check (#5470)
* Bugfix: wait for settings loading before onboarding redirect check

If you refresh the app while viewing a file, the settingsActor could not
have loaded the user settings before checking the onboardingStatus
setting. This uses a subscription on the settingsActor to await the
"init" state, after the user settings have loaded.

* Adjust approach to not use routeLoaders

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-02-25 14:35:19 -05:00
dcfcdc98ce Feature: Show runtime errors within files that are being imported (#5500)
* chore: dumping progress

* chore: saving progress

* fix: Got a working example of filenames piped from Rust to TS

* fix: cleaning up debugging code

* fix: TS type for filenames

* fix: rust linter errors

* fix: cargo fmt

* fix: testing code, updating KCLError class for filenames

* fix: auto fixes

* feat: display badge in project folder if there is an error in another file

* chore: skeleton ideas for badge notifications from errors in imported files

* fix: more skeleton code to test some potential implementations

* fix: addressing PR comments

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* fix: fixing the rust struct?

* fix: cargo fmt

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* feat: skeleton workflow for showing runtime errors

* chore: showBadge, adding more props

* fix: new application state to reset errors from previous execution if parse fails first

* fix: cleanup

* fix: better UI

* fix: adding comment for future

* fix: revert for production

* fix: removing unused comment

* chore: swapping JS object to typed Map

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-02-25 13:18:59 -06:00
9ab3325580 Revert "Get rid of failing cache on build-apps' setup-node" and fix wasm copy on Windows (#5505)
* Revert "Get rid of failing cache on build-apps' setup-node (#5490)"

This reverts commit 2523242bb1.

* Fix JSON backlash escape hell
2025-02-25 18:56:00 +00:00
50 changed files with 2159 additions and 131 deletions

View File

@ -29,6 +29,7 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- run: yarn install
@ -123,9 +124,11 @@ jobs:
cp prepared-files/assets/icon.ico assets/icon.ico
cp prepared-files/assets/icon.png assets/icon.png
- uses: actions/setup-node@v4
- name: Sync node version and setup cache
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn' # Set this to npm, yarn or pnpm.
- name: yarn install
# Windows is picky sometimes and fails on fetch. Step takes about ~30s

View File

@ -171,4 +171,22 @@ export class EditorFixture {
{ text, placeCursor }
)
}
async selectText(text: string) {
// First make sure the code pane is open
const wasPaneOpen = await this.checkIfPaneIsOpen()
if (!wasPaneOpen) {
await this.openPane()
}
// Use Playwright's built-in text selection on the code content
// it seems to only select whole divs, which works out to align with syntax highlighting
// for code mirror, so you can probably select "sketch002 = startSketchOn('XZ')"
// but less so for exactly "sketch002 = startS"
await this.codeContent.getByText(text).first().selectText()
// Reset pane state if needed
if (!wasPaneOpen) {
await this.closePane()
}
}
}

View File

@ -36,7 +36,7 @@ extrude003 = extrude(sketch003, length = 20)
`
test.describe('Prompt-to-edit tests', { tag: '@skipWin' }, () => {
test.fixme('Check the happy path, for basic changing color', () => {
test.describe('Check the happy path, for basic changing color', () => {
const cases = [
{
desc: 'User accepts change',
@ -70,7 +70,7 @@ test.describe('Prompt-to-edit tests', { tag: '@skipWin' }, () => {
body1CapCoords.y
)
const yellow: [number, number, number] = [179, 179, 131]
const green: [number, number, number] = [108, 152, 75]
const green: [number, number, number] = [128, 194, 88]
const notGreen: [number, number, number] = [132, 132, 132]
const body2NotGreen: [number, number, number] = [88, 88, 88]
const submittingToast = page.getByText(
@ -109,7 +109,7 @@ test.describe('Prompt-to-edit tests', { tag: '@skipWin' }, () => {
})
await test.step('verify initial change', async () => {
await scene.expectPixelColor(green, greenCheckCoords, 15)
await scene.expectPixelColor(green, greenCheckCoords, 20)
await scene.expectPixelColor(body2NotGreen, body2WallCoords, 15)
await editor.expectEditor.toContain('appearance(')
})
@ -142,7 +142,7 @@ test.describe('Prompt-to-edit tests', { tag: '@skipWin' }, () => {
}
})
test(`bad edit prompt`, async ({
test('bad edit prompt', async ({
context,
homePage,
cmdBar,
@ -195,4 +195,150 @@ test.describe('Prompt-to-edit tests', { tag: '@skipWin' }, () => {
await expect(failToast).toBeVisible()
})
})
test(`manual code selection rename`, async ({
context,
homePage,
cmdBar,
editor,
page,
scene,
}) => {
const body1CapCoords = { x: 571, y: 351 }
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' })
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: [],
})
})
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 mySketch')
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 test.step('verify rename change and accept it', async () => {
await editor.expectEditor.toContain('mySketch = startSketchOn')
await editor.expectEditor.not.toContain('sketch002 = startSketchOn')
await editor.expectEditor.toContain(
'extrude002 = extrude(mySketch, length = 50)'
)
await acceptBtn.click()
await expect(successToast).not.toBeVisible()
})
})
test('multiple body selections', async ({
context,
homePage,
cmdBar,
editor,
page,
scene,
}) => {
const body1CapCoords = { x: 571, y: 351 }
const body2WallCoords = { x: 620, y: 152 }
const [clickBody1Cap] = scene.makeMouseHelpers(
body1CapCoords.x,
body1CapCoords.y
)
const [clickBody2Cap] = scene.makeMouseHelpers(
body2WallCoords.x,
body2WallCoords.y
)
const grey: [number, number, number] = [132, 132, 132]
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' })
await test.step('select multiple bodies and fire prompt', async () => {
// Initial color check
await scene.expectPixelColor(grey, body1CapCoords, 15)
// Open command bar first (without selection)
await cmdBar.openCmdBar('promptToEdit')
// Select first body
await page.waitForTimeout(100)
await clickBody1Cap()
// Hold shift and select second body
await editor.expectState({
highlightedCode: '',
activeLines: ['|>startProfileAt([-73.64,-42.89],%)'],
diagnostics: [],
})
await page.keyboard.down('Shift')
await page.waitForTimeout(100)
await clickBody2Cap()
await editor.expectState({
highlightedCode:
'line(end=[121.13,56.63],tag=$seg02)extrude(profile001,length=200)',
activeLines: [
'|>line(end=[121.13,56.63],tag=$seg02)',
'|>startProfileAt([-73.64,-42.89],%)',
],
diagnostics: [],
})
await page.keyboard.up('Shift')
await page.waitForTimeout(100)
await cmdBar.progressCmdBar()
// Enter prompt and submit
await page
.getByTestId('cmd-bar-arg-value')
.fill('make these neon green please, use #39FF14')
await page.waitForTimeout(100)
await cmdBar.progressCmdBar()
// Wait for API response
await expect(submittingToast).toBeVisible()
await expect(submittingToast).not.toBeVisible({
timeout: 2 * 60_000,
})
await expect(successToast).toBeVisible()
})
await test.step('verify code changed', async () => {
await editor.expectEditor.toContain('appearance(')
// Accept changes
await acceptBtn.click()
await expect(successToast).not.toBeVisible()
})
})
})

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 145 KiB

After

Width:  |  Height:  |  Size: 145 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 54 KiB

1
exp
View File

@ -1 +0,0 @@
sketch001=startSketchOn('XZ')|>startProfileAt([75.8,317.2],%)//[$startCapTag,$EndCapTag]|>angledLine([0,268.43],%,$rectangleSegmentA001)|>angledLine([segAng(rectangleSegmentA001)-90,217.26],%,$seg01)|>angledLine([segAng(rectangleSegmentA001),-segLen(rectangleSegmentA001)],%,$yo)|>line(endAbsolute=[profileStartX(%),profileStartY(%)],tag=$seg02)|>close()extrude001=extrude(sketch001,length=100)|>chamfer(length=30,tags=[getOppositeEdge(seg01)],tag=$seg03)|>chamfer(length=30,tags=[seg01],tag=$seg04)|>chamfer(length=30,tags=[getNextAdjacentEdge(seg02)],tag=$seg05)|>chamfer(length=30,tags=[getNextAdjacentEdge(yo)],tag=$seg06)sketch004=startSketchOn(extrude001,seg05)profile003=startProfileAt([82.57,322.96],sketch004)|>angledLine([0,11.16],%,$rectangleSegmentA004)|>angledLine([segAng(rectangleSegmentA004)-90,103.07],%)|>angledLine([segAng(rectangleSegmentA004),-segLen(rectangleSegmentA004)],%)|>line(endAbsolute=[profileStartX(%),profileStartY(%)])|>close()sketch003=startSketchOn(extrude001,seg04)profile002=startProfileAt([-209.64,255.28],sketch003)|>angledLine([0,11.56],%,$rectangleSegmentA003)|>angledLine([segAng(rectangleSegmentA003)-90,106.84],%)|>angledLine([segAng(rectangleSegmentA003),-segLen(rectangleSegmentA003)],%)|>line(endAbsolute=[profileStartX(%),profileStartY(%)])|>close()sketch002=startSketchOn(extrude001,seg03)profile001=startProfileAt([205.96,254.59],sketch002)|>angledLine([0,11.39],%,$rectangleSegmentA002)|>angledLine([segAng(rectangleSegmentA002)-90,105.26],%)|>angledLine([segAng(rectangleSegmentA002),-segLen(rectangleSegmentA002)],%)|>line(endAbsolute=[profileStartX(%),profileStartY(%)])|>close()

1
got
View File

@ -1 +0,0 @@
sketch001=startSketchOn('XZ')|>startProfileAt([75.8,317.2],%)//[$startCapTag,$EndCapTag]|>angledLine([0,268.43],%,$rectangleSegmentA001)|>angledLine([segAng(rectangleSegmentA001)-90,217.26],%,$seg01)|>angledLine([segAng(rectangleSegmentA001),-segLen(rectangleSegmentA001)],%,$yo)|>line(endAbsolute=[profileStartX(%),profileStartY(%)],tag=$seg02)|>close()extrude001=extrude(sketch001,length=100)|>chamfer(length=30,tags=[getOppositeEdge(seg01)],tag=$seg03)|>chamfer(length=30,tags=[seg01],tag=$seg04)|>chamfer(length=30,tags=[getNextAdjacentEdge(seg02)],tag=$seg05)|>chamfer(length=30,tags=[getNextAdjacentEdge(yo)],tag=$seg06)sketch005=startSketchOn(extrude001,seg06)profile004=startProfileAt([-23.43,19.69],sketch005)|>angledLine([0,9.1],%,$rectangleSegmentA005)|>angledLine([segAng(rectangleSegmentA005)-90,84.07],%)|>angledLine([segAng(rectangleSegmentA005),-segLen(rectangleSegmentA005)],%)|>line(endAbsolute=[profileStartX(%),profileStartY(%)])|>close()sketch004=startSketchOn(extrude001,seg05)profile003=startProfileAt([82.57,322.96],sketch004)|>angledLine([0,11.16],%,$rectangleSegmentA004)|>angledLine([segAng(rectangleSegmentA004)-90,103.07],%)|>angledLine([segAng(rectangleSegmentA004),-segLen(rectangleSegmentA004)],%)|>line(endAbsolute=[profileStartX(%),profileStartY(%)])|>close()sketch003=startSketchOn(extrude001,seg04)profile002=startProfileAt([-209.64,255.28],sketch003)|>angledLine([0,11.56],%,$rectangleSegmentA003)|>angledLine([segAng(rectangleSegmentA003)-90,106.84],%)|>angledLine([segAng(rectangleSegmentA003),-segLen(rectangleSegmentA003)],%)|>line(endAbsolute=[profileStartX(%),profileStartY(%)])|>close()sketch002=startSketchOn(extrude001,seg03)profile001=startProfileAt([205.96,254.59],sketch002)|>angledLine([0,11.39],%,$rectangleSegmentA002)|>angledLine([segAng(rectangleSegmentA002)-90,105.26],%)|>angledLine([segAng(rectangleSegmentA002),-segLen(rectangleSegmentA002)],%)|>line(endAbsolute=[profileStartX(%),profileStartY(%)])|>close()

View File

@ -91,11 +91,11 @@
"fmt-check": "prettier --check ./src *.ts *.json *.js ./e2e ./packages",
"fetch:wasm": "./scripts/get-latest-wasm-bundle.sh",
"fetch:wasm:windows": "./scripts/get-latest-wasm-bundle.ps1",
"fetch:samples": "echo \"Fetching latest KCL samples...\" && curl -o public/kcl-samples-manifest-fallback.json https://raw.githubusercontent.com/KittyCAD/next/manifest.json",
"fetch:samples": "echo \"Fetching latest KCL samples...\" && curl -o public/kcl-samples-manifest-fallback.json https://raw.githubusercontent.com/KittyCAD/kcl-samples/next/manifest.json",
"build:wasm-dev": "yarn wasm-prep && (cd src/wasm-lib && wasm-pack build --dev --target web --out-dir pkg && cargo test -p kcl-lib export_bindings) && yarn isomorphic-copy-wasm && yarn fmt",
"build:wasm:nocopy": "yarn wasm-prep && cd src/wasm-lib && wasm-pack build --release --target web --out-dir pkg && cargo test -p kcl-lib export_bindings",
"build:wasm": "yarn build:wasm:nocopy && cp src/wasm-lib/pkg/wasm_lib_bg.wasm public && yarn fmt",
"build:wasm:windows": "yarn install:wasm-pack:cargo && yarn build:wasm:nocopy && copy src\\wasm-lib\\pkg\\wasm_lib_bg.wasm public && yarn fmt",
"build:wasm:windows": "yarn install:wasm-pack:cargo && yarn build:wasm:nocopy && ./scripts/copy-wasm.ps1 && yarn fmt",
"remove-importmeta": "sed -i 's/import.meta.url/window.location.origin/g' \"./src/wasm-lib/pkg/wasm_lib.js\"; sed -i '' 's/import.meta.url/window.location.origin/g' \"./src/wasm-lib/pkg/wasm_lib.js\" || echo \"sed for both mac and linux\"",
"wasm-prep": "rimraf src/wasm-lib/pkg && mkdirp src/wasm-lib/pkg && rimraf src/wasm-lib/kcl/bindings",
"lint-fix": "eslint --fix --ext .ts --ext .tsx src e2e packages/codemirror-lsp-client/src",

1
scripts/copy-wasm.ps1 Normal file
View File

@ -0,0 +1 @@
copy src\wasm-lib\pkg\wasm_lib_bg.wasm public

View File

@ -24,12 +24,7 @@ import ModelingMachineProvider from 'components/ModelingMachineProvider'
import FileMachineProvider from 'components/FileMachineProvider'
import { MachineManagerProvider } from 'components/MachineManagerProvider'
import { PATHS } from 'lib/paths'
import {
fileLoader,
homeLoader,
onboardingRedirectLoader,
telemetryLoader,
} from 'lib/routeLoaders'
import { fileLoader, homeLoader, telemetryLoader } from 'lib/routeLoaders'
import LspProvider from 'components/LspProvider'
import { KclContextProvider } from 'lang/KclProvider'
import { ASK_TO_OPEN_QUERY_PARAM, BROWSER_PROJECT_NAME } from 'lib/constants'
@ -113,11 +108,6 @@ const router = createRouter([
{
id: PATHS.FILE + 'SETTINGS',
children: [
{
loader: onboardingRedirectLoader,
index: true,
element: <></>,
},
{
path: makeUrlPathRelative(PATHS.SETTINGS),
element: <Settings />,

View File

@ -17,7 +17,9 @@ export const CommandBar = () => {
const {
context: { selectedCommand, currentArgument, commands },
} = commandBarState
const isSelectionArgument = currentArgument?.inputType === 'selection'
const isSelectionArgument =
currentArgument?.inputType === 'selection' ||
currentArgument?.inputType === 'selectionMixed'
const WrapperComponent = isSelectionArgument ? Popover : Dialog
// Close the command bar when navigating

View File

@ -1,6 +1,7 @@
import CommandArgOptionInput from './CommandArgOptionInput'
import CommandBarBasicInput from './CommandBarBasicInput'
import CommandBarSelectionInput from './CommandBarSelectionInput'
import CommandBarSelectionMixedInput from './CommandBarSelectionMixedInput'
import { CommandArgument } from 'lib/commandTypes'
import CommandBarHeader from './CommandBarHeader'
import CommandBarKclInput from './CommandBarKclInput'
@ -84,6 +85,14 @@ function ArgumentInput({
onSubmit={onSubmit}
/>
)
case 'selectionMixed':
return (
<CommandBarSelectionMixedInput
arg={arg}
stepBack={stepBack}
onSubmit={onSubmit}
/>
)
case 'kcl':
return (
<CommandBarKclInput arg={arg} stepBack={stepBack} onSubmit={onSubmit} />

View File

@ -124,7 +124,8 @@ function CommandBarHeader({ children }: React.PropsWithChildren<{}>) {
<span className="sr-only">:&nbsp;</span>
<span data-testid="header-arg-value">
{argValue ? (
arg.inputType === 'selection' ? (
arg.inputType === 'selection' ||
arg.inputType === 'selectionMixed' ? (
getSelectionTypeDisplayText(argValue as Selections)
) : arg.inputType === 'kcl' ? (
roundOff(

View File

@ -0,0 +1,135 @@
import { useEffect, useMemo, useRef, useState } from 'react'
import { CommandArgument } from 'lib/commandTypes'
import {
Selections,
canSubmitSelectionArg,
getSelectionCountByType,
getSelectionTypeDisplayText,
} from 'lib/selections'
import { useSelector } from '@xstate/react'
import { commandBarActor, useCommandBarState } from 'machines/commandBarMachine'
const selectionSelector = (snapshot: any) => snapshot?.context.selectionRanges
export default function CommandBarSelectionMixedInput({
arg,
stepBack,
onSubmit,
}: {
arg: CommandArgument<unknown> & { inputType: 'selectionMixed'; name: string }
stepBack: () => void
onSubmit: (data: unknown) => void
}) {
const inputRef = useRef<HTMLInputElement>(null)
const commandBarState = useCommandBarState()
const [hasSubmitted, setHasSubmitted] = useState(false)
const [hasAutoSkipped, setHasAutoSkipped] = useState(false)
const selection: Selections = useSelector(arg.machineActor, selectionSelector)
const selectionsByType = useMemo(() => {
return getSelectionCountByType(selection)
}, [selection])
const canSubmitSelection = useMemo<boolean>(() => {
if (!selection) return false
const isNonZeroRange = selection.graphSelections.some((sel) => {
const range = sel.codeRef.range
return range[1] - range[0] !== 0 // Non-zero range is always valid
})
if (isNonZeroRange) return true
return canSubmitSelectionArg(selectionsByType, arg)
}, [selectionsByType, selection])
useEffect(() => {
inputRef.current?.focus()
}, [selection, inputRef])
// Only auto-skip on initial mount if we have a valid selection
// different from the component CommandBarSelectionInput in the the dependency array
// is empty
useEffect(() => {
if (!hasAutoSkipped && canSubmitSelection && arg.skip) {
const argValue = commandBarState.context.argumentsToSubmit[arg.name]
if (argValue === undefined) {
handleSubmit()
setHasAutoSkipped(true)
}
}
}, [])
function handleChange() {
inputRef.current?.focus()
}
function handleSubmit(e?: React.FormEvent<HTMLFormElement>) {
e?.preventDefault()
if (!canSubmitSelection) {
setHasSubmitted(true)
return
}
onSubmit(selection)
}
const isMixedSelection = arg.inputType === 'selectionMixed'
const allowNoSelection = isMixedSelection && arg.allowNoSelection
const showSceneSelection =
isMixedSelection && arg.selectionSource?.allowSceneSelection
return (
<form id="arg-form" onSubmit={handleSubmit}>
<label
className={
'relative flex flex-col mx-4 my-4 ' +
(!hasSubmitted || canSubmitSelection || 'text-destroy-50')
}
>
{canSubmitSelection
? 'Select objects in the scene'
: 'Select code or objects in the scene'}
{showSceneSelection && (
<div className="scene-selection mt-2">
<p className="text-sm text-chalkboard-60">
Select objects in the scene
</p>
{/* Scene selection UI will be handled by the parent component */}
</div>
)}
{allowNoSelection && (
<button
type="button"
onClick={() => onSubmit(null)}
className="mt-2 px-4 py-2 rounded border border-chalkboard-30 text-chalkboard-90 dark:text-chalkboard-10 hover:bg-chalkboard-10 dark:hover:bg-chalkboard-90 transition-colors"
>
Continue without selection
</button>
)}
<span data-testid="cmd-bar-arg-name" className="sr-only">
{arg.name}
</span>
<input
id="selection"
name="selection"
ref={inputRef}
required
data-testid="cmd-bar-arg-value"
placeholder="Select an entity with your mouse"
className="absolute inset-0 w-full h-full opacity-0 cursor-default"
onKeyDown={(event) => {
if (event.key === 'Backspace') {
stepBack()
} else if (event.key === 'Escape') {
commandBarActor.send({ type: 'Close' })
}
}}
onChange={handleChange}
value={JSON.stringify(selection || {})}
/>
</label>
</form>
)
}

View File

@ -130,6 +130,8 @@ export const FileMachineProvider = ({
navigateToFile: ({ context, event }) => {
if (event.type !== 'xstate.done.actor.create-and-open-file') return
if (event.output && 'name' in event.output) {
// TODO: Technically this is not the same as the FileTree Onclick even if they are in the same page
// What is "Open file?"
commandBarActor.send({ type: 'Close' })
navigate(
`..${PATHS.FILE}/${encodeURIComponent(

View File

@ -23,6 +23,8 @@ import { FileEntry } from 'lib/project'
import { useFileSystemWatcher } from 'hooks/useFileSystemWatcher'
import { normalizeLineEndings } from 'lib/codeEditor'
import { reportRejection } from 'lib/trap'
import { useKclContext } from 'lang/KclProvider'
import { kclErrorsByFilename, KCLError } from 'lang/errors'
function getIndentationCSS(level: number) {
return `calc(1rem * ${level + 1})`
@ -158,6 +160,7 @@ const FileTreeItem = ({
level = 0,
treeSelection,
setTreeSelection,
runtimeErrors,
}: {
parentDir: FileEntry | undefined
project?: IndexLoaderData['project']
@ -177,6 +180,7 @@ const FileTreeItem = ({
level?: number
treeSelection: FileEntry | undefined
setTreeSelection: Dispatch<React.SetStateAction<FileEntry | undefined>>
runtimeErrors: Map<string, KCLError[]>
}) => {
const { send: fileSend, context: fileContext } = useFileContext()
const { onFileOpen, onFileClose } = useLspContext()
@ -186,6 +190,8 @@ const FileTreeItem = ({
const isFileOrDirHighlighted = treeSelection?.path === fileOrDir?.path
const itemRef = useRef(null)
const hasRuntimeError = runtimeErrors.has(fileOrDir.path)
// Since every file or directory gets its own FileTreeItem, we can do this.
// Because subtrees only render when they are opened, that means this
// only listens when they open. Because this acts like a useEffect, when
@ -292,7 +298,7 @@ const FileTreeItem = ({
>
{!isRenaming ? (
<button
className="flex gap-1 items-center py-0.5 rounded-none border-none p-0 m-0 text-sm w-full hover:!bg-transparent text-left !text-inherit"
className="relative flex gap-1 items-center py-0.5 rounded-none border-none p-0 m-0 text-sm w-full hover:!bg-transparent text-left !text-inherit"
style={{ paddingInlineStart: getIndentationCSS(level) }}
onClick={(e) => {
e.currentTarget.focus()
@ -300,11 +306,21 @@ const FileTreeItem = ({
}}
onKeyUp={handleKeyUp}
>
{hasRuntimeError && (
<p
className={
'absolute m-0 p-0 bottom-3 left-6 w-3 h-3 flex items-center justify-center text-[9px] font-semibold text-white bg-primary hue-rotate-90 rounded-full border border-chalkboard-10 dark:border-chalkboard-80 z-50 hover:cursor-pointer hover:scale-[2] transition-transform duration-200'
}
title={`Click to view notifications`}
>
<span>x</span>
</p>
)}
<CustomIcon
name={fileOrDir.name?.endsWith(FILE_EXT) ? 'kcl' : 'file'}
className="inline-block w-3 text-current"
/>
{fileOrDir.name}
<span className="pl-1">{fileOrDir.name}</span>
</button>
) : (
<RenameForm
@ -414,6 +430,7 @@ const FileTreeItem = ({
key={level + '-' + child.path}
treeSelection={treeSelection}
setTreeSelection={setTreeSelection}
runtimeErrors={runtimeErrors}
/>
)
)}
@ -660,6 +677,8 @@ export const FileTreeInner = ({
const loaderData = useRouteLoaderData(PATHS.FILE) as IndexLoaderData
const { send: fileSend, context: fileContext } = useFileContext()
const { send: modelingSend } = useModelingContext()
const { errors } = useKclContext()
const runtimeErrors = kclErrorsByFilename(errors)
const [lastDirectoryClicked, setLastDirectoryClicked] = useState<
FileEntry | undefined
@ -769,6 +788,7 @@ export const FileTreeInner = ({
key={fileOrDir.path}
treeSelection={treeSelection}
setTreeSelection={setTreeSelection}
runtimeErrors={runtimeErrors}
/>
)
)}

View File

@ -18,6 +18,7 @@ import { editorManager } from 'lib/singletons'
import { ContextFrom } from 'xstate'
import { settingsMachine } from 'machines/settingsMachine'
import { FeatureTreePane } from './FeatureTreePane'
import { kclErrorsByFilename } from 'lang/errors'
export type SidebarType =
| 'code'
@ -30,8 +31,10 @@ export type SidebarType =
| 'variables'
export interface BadgeInfo {
value: (props: PaneCallbackProps) => boolean | number
value: (props: PaneCallbackProps) => boolean | number | string
onClick?: MouseEventHandler<any>
className?: string
title?: string
}
/**
@ -152,6 +155,25 @@ export const sidebarPanes: SidebarPane[] = [
},
keybinding: 'Shift + F',
hide: ({ platform }) => platform === 'web',
showBadge: {
value: (context) => {
// Only compute runtime errors! Compilation errors are not tracked here.
const errors = kclErrorsByFilename(context.kclContext.errors)
return errors.size > 0 ? 'x' : ''
},
onClick: (e) => {
e.preventDefault()
// TODO: When we have generic file open
// If badge is pressed
// Open the first error in the array of errors
// Then scroll to error
// Do you automatically open the project files
// editorManager.scrollToFirstErrorDiagnosticIfExists()
},
className:
'absolute m-0 p-0 bottom-4 left-4 w-3 h-3 flex items-center justify-center text-[9px] font-semibold text-white bg-primary hue-rotate-90 rounded-full border border-chalkboard-10 dark:border-chalkboard-80 z-50 hover:cursor-pointer hover:scale-[2] transition-transform duration-200',
title: 'Project files have runtime errors',
},
},
{
id: 'variables',

View File

@ -27,8 +27,10 @@ interface ModelingSidebarProps {
}
interface BadgeInfoComputed {
value: number | boolean
value: number | boolean | string
onClick?: MouseEventHandler<any>
className?: string
title?: string
}
function getPlatformString(): 'web' | 'desktop' {
@ -116,6 +118,8 @@ export function ModelingSidebar({ paneOpacity }: ModelingSidebarProps) {
acc[pane.id] = {
value: pane.showBadge.value(paneCallbackProps),
onClick: pane.showBadge.onClick,
className: pane.showBadge.className,
title: pane.showBadge.title,
}
}
return acc
@ -125,6 +129,7 @@ export function ModelingSidebar({ paneOpacity }: ModelingSidebarProps) {
// Clear any hidden panes from the `openPanes` array
useEffect(() => {
const panesToReset: SidebarType[] = []
sidebarPanes.forEach((pane) => {
if (
pane.hide === true ||
@ -339,22 +344,31 @@ function ModelingPaneButton({
<p
id={`${paneConfig.id}-badge`}
className={
'absolute m-0 p-0 bottom-4 left-4 w-3 h-3 flex items-center justify-center text-[10px] font-semibold text-white bg-primary hue-rotate-90 rounded-full border border-chalkboard-10 dark:border-chalkboard-80 z-50 hover:cursor-pointer hover:scale-[2] transition-transform duration-200'
showBadge.className
? showBadge.className
: 'absolute m-0 p-0 bottom-4 left-4 w-3 h-3 flex items-center justify-center text-[10px] font-semibold text-white bg-primary hue-rotate-90 rounded-full border border-chalkboard-10 dark:border-chalkboard-80 z-50 hover:cursor-pointer hover:scale-[2] transition-transform duration-200'
}
onClick={showBadge.onClick}
title={`Click to view ${showBadge.value} notification${
Number(showBadge.value) > 1 ? 's' : ''
}`}
title={
showBadge.title
? showBadge.title
: `Click to view ${showBadge.value} notification${
Number(showBadge.value) > 1 ? 's' : ''
}`
}
>
<span className="sr-only">&nbsp;has&nbsp;</span>
{typeof showBadge.value === 'number' ? (
{typeof showBadge.value === 'number' ||
typeof showBadge.value === 'string' ? (
<span>{showBadge.value}</span>
) : (
<span className="sr-only">a</span>
)}
<span className="sr-only">
&nbsp;notification{Number(showBadge.value) > 1 ? 's' : ''}
</span>
{typeof showBadge.value === 'number' && (
<span className="sr-only">
&nbsp;notification{Number(showBadge.value) > 1 ? 's' : ''}
</span>
)}
</p>
)}
</div>

View File

@ -4,11 +4,12 @@ import {
useLocation,
useNavigate,
useRouteLoaderData,
redirect,
} from 'react-router-dom'
import { PATHS } from 'lib/paths'
import { markOnce } from 'lib/performance'
import { useAuthNavigation } from 'hooks/useAuthNavigation'
import { useAuthState } from 'machines/appMachine'
import { useAuthState, useSettings } from 'machines/appMachine'
import { IndexLoaderData } from 'lib/types'
import { getAppSettingsFilePath } from 'lib/desktop'
import { isDesktop } from 'lib/isDesktop'
@ -16,6 +17,9 @@ import { trap } from 'lib/trap'
import { useFileSystemWatcher } from 'hooks/useFileSystemWatcher'
import { loadAndValidateSettings } from 'lib/settings/settingsUtils'
import { settingsActor } from 'machines/appMachine'
import makeUrlPathRelative from 'lib/makeUrlPathRelative'
import { OnboardingStatus } from 'wasm-lib/kcl/bindings/OnboardingStatus'
import { SnapshotFrom } from 'xstate'
export const RouteProviderContext = createContext({})
@ -29,6 +33,7 @@ export function RouteProvider({ children }: { children: ReactNode }) {
const navigation = useNavigation()
const navigate = useNavigate()
const location = useLocation()
const settings = useSettings()
const authState = useAuthState()
useEffect(() => {
@ -43,6 +48,32 @@ export function RouteProvider({ children }: { children: ReactNode }) {
markOnce('code/willLoadHome')
} else if (isFile) {
markOnce('code/willLoadFile')
/**
* TODO: Move to XState. This block has been moved from routerLoaders
* and is borrowing the `isFile` logic from the rest of this
* telemetry-focused `useEffect`. Once `appMachine` knows about
* the current route and navigation, this can be moved into settingsMachine
* to fire as soon as the user settings have been read.
*/
const onboardingStatus: OnboardingStatus =
settings.app.onboardingStatus.current || ''
// '' is the initial state, 'completed' and 'dismissed' are the final states
const needsToOnboard =
onboardingStatus.length === 0 ||
!(onboardingStatus === 'completed' || onboardingStatus === 'dismissed')
const shouldRedirectToOnboarding = isFile && needsToOnboard
if (
shouldRedirectToOnboarding &&
settingsActor.getSnapshot().matches('idle')
) {
navigate(
(first ? location.pathname : navigation.location?.pathname) +
PATHS.ONBOARDING.INDEX +
onboardingStatus.slice(1)
)
}
}
setFirstState(false)
}, [navigation])

View File

@ -293,6 +293,13 @@ export class KclManager {
return null
}
// GOTCHA:
// When we safeParse this is tied to execution because they clicked a new file to load
// Clear all previous errors and logs because they are old since they executed a new file
// If we decouple safeParse from execution we need to move this application logic.
this._kclErrorsCallBack([])
this._logsCallBack([])
this.addDiagnostics(complilationErrorsToDiagnostics(result.errors))
this.addDiagnostics(complilationErrorsToDiagnostics(result.warnings))
if (result.errors.length > 0) {

View File

@ -1,4 +1,7 @@
import { KclError as RustKclError } from '../wasm-lib/kcl/bindings/KclError'
import {
KclError,
KclError as RustKclError,
} from '../wasm-lib/kcl/bindings/KclError'
import { CompilationError } from 'wasm-lib/kcl/bindings/CompilationError'
import { Diagnostic as CodeMirrorDiagnostic } from '@codemirror/lint'
import { posToOffset } from '@kittycad/codemirror-lsp-client'
@ -334,3 +337,34 @@ export function complilationErrorsToDiagnostics(
}
})
}
// Create an array of KCL Errors with a new formatting to
// easily map SourceRange of an error to the filename to display in the
// side bar UI. This is to indicate an error in an imported file, it isn't
// the specific code mirror error interface.
export function kclErrorsByFilename(
errors: KCLError[]
): Map<string, KCLError[]> {
const fileNameToError: Map<string, KCLError[]> = new Map()
errors.forEach((error: KCLError) => {
const filenames = error.filenames
const sourceRange: SourceRange = error.sourceRange
const fileIndex = sourceRange[2]
const modulePath: ModulePath | undefined = filenames[fileIndex]
if (modulePath) {
let stdOrLocalPath = modulePath.value
if (stdOrLocalPath) {
// Build up an array of errors per file name
const value = fileNameToError.get(stdOrLocalPath)
if (!value) {
fileNameToError.set(stdOrLocalPath, [error])
} else {
value.push(error)
fileNameToError.set(stdOrLocalPath, [error])
}
}
}
})
return fileNameToError
}

View File

@ -116,7 +116,11 @@ const runGetPathToExtrudeForSegmentSelectionTest = async (
}
if (!extrudeInSketchPipe) {
const init = expectedExtrudeNode.init
if (init.type !== 'CallExpression' && init.type !== 'PipeExpression') {
if (
init.type !== 'CallExpression' &&
init.type !== 'CallExpressionKw' &&
init.type !== 'PipeExpression'
) {
return new Error(
'Expected extrude expression is not a CallExpression or PipeExpression'
)
@ -129,25 +133,33 @@ const runGetPathToExtrudeForSegmentSelectionTest = async (
// ast
const ast = assertParse(code)
// selection
// range
const segmentRange = topLevelRange(
code.indexOf(selectedSegmentSnippet),
code.indexOf(selectedSegmentSnippet) + selectedSegmentSnippet.length
)
const selection: Selection = {
codeRef: codeRefFromRange(segmentRange, ast),
}
// executeAst and artifactGraph
await kclManager.executeAst({ ast })
const artifactGraph = engineCommandManager.artifactGraph
// find artifact
const maybeArtifact = [...artifactGraph].find(([, artifact]) => {
if (!('codeRef' in artifact && artifact.codeRef)) return false
return isOverlap(artifact.codeRef.range, segmentRange)
})
// build selection
const selection: Selection = {
codeRef: codeRefFromRange(segmentRange, ast),
artifact: maybeArtifact ? maybeArtifact[1] : undefined,
}
// get extrude expression
const pathResult = getPathToExtrudeForSegmentSelection(
ast,
selection,
artifactGraph,
dependencies
artifactGraph
)
if (err(pathResult)) return pathResult
const { pathToExtrudeNode } = pathResult
@ -234,6 +246,56 @@ extrude003 = extrude(sketch003, length = -15)`
expectedExtrudeSnippet
)
})
it('should return the correct paths for a (piped) extrude based on the other body (face)', async () => {
const code = `sketch001 = startSketchOn('XY')
|> startProfileAt([-25, -25], %)
|> yLine(50, %)
|> xLine(50, %)
|> yLine(-50, %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()
|> extrude(length = 50)
sketch002 = startSketchOn(sketch001, 'END')
|> startProfileAt([-15, -15], %)
|> yLine(30, %)
|> xLine(30, %)
|> yLine(-30, %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()
|> extrude(length = 30)`
const selectedSegmentSnippet = `xLine(30, %)`
const expectedExtrudeSnippet = `extrude(length = 30)`
await runGetPathToExtrudeForSegmentSelectionTest(
code,
selectedSegmentSnippet,
expectedExtrudeSnippet
)
})
it('should return the correct paths for a (non-piped) extrude based on the other body (face)', async () => {
const code = `sketch001 = startSketchOn('XY')
|> startProfileAt([-25, -25], %)
|> yLine(50, %)
|> xLine(50, %)
|> yLine(-50, %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()
extrude001 = extrude(sketch001, length = 50)
sketch002 = startSketchOn(extrude001, 'END')
|> startProfileAt([-15, -15], %)
|> yLine(30, %)
|> xLine(30, %)
|> yLine(-30, %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()
extrude002 = extrude(sketch002, length = 30)`
const selectedSegmentSnippet = `xLine(30, %)`
const expectedExtrudeSnippet = `extrude002 = extrude(sketch002, length = 30)`
await runGetPathToExtrudeForSegmentSelectionTest(
code,
selectedSegmentSnippet,
expectedExtrudeSnippet
)
})
it('should not return any path for missing extrusion', async () => {
const code = `sketch001 = startSketchOn('XY')
|> startProfileAt([-30, 30], %)

View File

@ -10,7 +10,6 @@ import {
Program,
VariableDeclaration,
VariableDeclarator,
sketchFromKclValue,
} from '../wasm'
import {
createCallExpressionStdLib,
@ -35,11 +34,11 @@ import {
sketchLineHelperMap,
sketchLineHelperMapKw,
} from '../std/sketch'
import { err, trap } from 'lib/trap'
import { err } from 'lib/trap'
import { Selection, Selections } from 'lib/selections'
import { KclCommandValue } from 'lib/commandTypes'
import { isArray } from 'lib/utils'
import { Artifact, getSweepFromSuspectedPath } from 'lang/std/artifactGraph'
import { Artifact, getSweepArtifactFromSelection } from 'lang/std/artifactGraph'
import { Node } from 'wasm-lib/kcl/bindings/Node'
import { findKwArg } from 'lang/util'
import { KclManager } from 'lang/KclSingleton'
@ -121,8 +120,7 @@ export function modifyAstWithEdgeTreatmentAndTag(
const result = getPathToExtrudeForSegmentSelection(
clonedAstForGetExtrude,
selection,
artifactGraph,
dependencies
artifactGraph
)
if (err(result)) return result
const { pathToSegmentNode, pathToExtrudeNode } = result
@ -279,39 +277,19 @@ function insertParametersIntoAst(
export function getPathToExtrudeForSegmentSelection(
ast: Program,
selection: Selection,
artifactGraph: ArtifactGraph,
dependencies: {
kclManager: KclManager
engineCommandManager: EngineCommandManager
editorManager: EditorManager
codeManager: CodeManager
}
artifactGraph: ArtifactGraph
): { pathToSegmentNode: PathToNode; pathToExtrudeNode: PathToNode } | Error {
const pathToSegmentNode = getNodePathFromSourceRange(
ast,
selection.codeRef?.range
)
const varDecNode = getNodeFromPath<VariableDeclaration>(
ast,
pathToSegmentNode,
'VariableDeclaration'
)
if (err(varDecNode)) return varDecNode
const sketchVar = varDecNode.node.declaration.id.name
const sketch = sketchFromKclValue(
dependencies.kclManager.variables[sketchVar],
sketchVar
)
if (trap(sketch)) return sketch
const extrusion = getSweepFromSuspectedPath(sketch.id, artifactGraph)
if (err(extrusion)) return extrusion
const sweepArtifact = getSweepArtifactFromSelection(selection, artifactGraph)
if (err(sweepArtifact)) return sweepArtifact
const pathToExtrudeNode = getNodePathFromSourceRange(
ast,
extrusion.codeRef.range
sweepArtifact.codeRef.range
)
if (err(pathToExtrudeNode)) return pathToExtrudeNode

View File

@ -13,36 +13,23 @@ import {
createLiteral,
createIdentifier,
findUniqueName,
createCallExpressionStdLib,
createObjectExpression,
createArrayExpression,
createVariableDeclaration,
createCallExpressionStdLibKw,
createLabeledArg,
} from 'lang/modifyAst'
import { KCL_DEFAULT_CONSTANT_PREFIXES } from 'lib/constants'
import { KclManager } from 'lang/KclSingleton'
import { EngineCommandManager } from 'lang/std/engineConnection'
import EditorManager from 'editor/manager'
import CodeManager from 'lang/codeManager'
export function addShell({
node,
selection,
artifactGraph,
thickness,
dependencies,
}: {
node: Node<Program>
selection: Selections
artifactGraph: ArtifactGraph
thickness: Expr
dependencies: {
kclManager: KclManager
engineCommandManager: EngineCommandManager
editorManager: EditorManager
codeManager: CodeManager
}
}): Error | { modifiedAst: Node<Program>; pathToNode: PathToNode } {
const modifiedAst = structuredClone(node)
@ -55,8 +42,7 @@ export function addShell({
const extrudeLookupResult = getPathToExtrudeForSegmentSelection(
clonedAstForGetExtrude,
graphSelection,
artifactGraph,
dependencies
artifactGraph
)
if (err(extrudeLookupResult)) {
return new Error("Couldn't find extrude")

View File

@ -18,6 +18,7 @@ import {
} from 'lang/wasm'
import { Models } from '@kittycad/lib'
import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils'
import { Selection } from 'lib/selections'
import { err } from 'lib/trap'
import { Cap, Plane, Wall } from 'wasm-lib/kcl/bindings/Artifact'
import { CapSubType } from 'wasm-lib/kcl/bindings/Artifact'
@ -79,7 +80,7 @@ interface SegmentArtifactRich extends BaseArtifact {
interface SweepArtifactRich extends BaseArtifact {
type: 'sweep'
subType: 'extrusion' | 'revolve' | 'loft' | 'sweep'
subType: 'extrusion' | 'revolve' | 'revolveAboutEdge' | 'loft' | 'sweep'
path: PathArtifact
surfaces: Array<WallArtifact | CapArtifact>
edges: Array<SweepEdge>
@ -455,6 +456,47 @@ export function getSweepFromSuspectedPath(
)
}
export function getSweepArtifactFromSelection(
selection: Selection,
artifactGraph: ArtifactGraph
): SweepArtifact | Error {
let sweepArtifact: Artifact | null = null
if (selection.artifact?.type === 'sweepEdge') {
const _artifact = getArtifactOfTypes(
{ key: selection.artifact.sweepId, types: ['sweep'] },
artifactGraph
)
if (err(_artifact)) return _artifact
sweepArtifact = _artifact
} else if (selection.artifact?.type === 'segment') {
const _pathArtifact = getArtifactOfTypes(
{ key: selection.artifact.pathId, types: ['path'] },
artifactGraph
)
if (err(_pathArtifact)) return _pathArtifact
if (!_pathArtifact.sweepId) return new Error('Path does not have a sweepId')
const _artifact = getArtifactOfTypes(
{ key: _pathArtifact.sweepId, types: ['sweep'] },
artifactGraph
)
if (err(_artifact)) return _artifact
sweepArtifact = _artifact
} else if (
selection.artifact?.type === 'cap' ||
selection.artifact?.type === 'wall'
) {
const _artifact = getArtifactOfTypes(
{ key: selection.artifact.sweepId, types: ['sweep'] },
artifactGraph
)
if (err(_artifact)) return _artifact
sweepArtifact = _artifact
}
if (!sweepArtifact) return new Error('No sweep artifact found')
return sweepArtifact
}
export function getCodeRefsByArtifactId(
id: string,
artifactGraph: ArtifactGraph

View File

@ -666,7 +666,7 @@ export const modelingMachineCommandConfig: StateMachineCommandSetConfig<
icon: 'chat',
args: {
selection: {
inputType: 'selection',
inputType: 'selectionMixed',
selectionTypes: [
'solid2d',
'segment',
@ -678,6 +678,10 @@ export const modelingMachineCommandConfig: StateMachineCommandSetConfig<
],
multiple: true,
required: true,
selectionSource: {
allowSceneSelection: true,
allowCodeSelection: true,
},
skip: true,
},
prompt: {

View File

@ -16,6 +16,7 @@ const INPUT_TYPES = [
'text',
'kcl',
'selection',
'selectionMixed',
'boolean',
] as const
export interface KclExpression {
@ -156,6 +157,23 @@ export type CommandArgumentConfig<
context: CommandBarContext
}) => Promise<boolean | string>
}
| {
inputType: 'selectionMixed'
selectionTypes: Artifact['type'][]
multiple: boolean
allowNoSelection?: boolean
validation?: ({
data,
context,
}: {
data: any
context: CommandBarContext
}) => Promise<boolean | string>
selectionSource?: {
allowSceneSelection?: boolean
allowCodeSelection?: boolean
}
}
| {
inputType: 'kcl'
createVariableByDefault?: boolean
@ -252,6 +270,23 @@ export type CommandArgument<
context: CommandBarContext
}) => Promise<boolean | string>
}
| {
inputType: 'selectionMixed'
selectionTypes: Artifact['type'][]
multiple: boolean
allowNoSelection?: boolean
validation?: ({
data,
context,
}: {
data: any
context: CommandBarContext
}) => Promise<boolean | string>
selectionSource?: {
allowSceneSelection?: boolean
allowCodeSelection?: boolean
}
}
| {
inputType: 'kcl'
createVariableByDefault?: boolean

View File

@ -187,6 +187,16 @@ export function buildCommandArgument<
selectionTypes: arg.selectionTypes,
validation: arg.validation,
} satisfies CommandArgument<O, T> & { inputType: 'selection' }
} else if (arg.inputType === 'selectionMixed') {
return {
inputType: arg.inputType,
...baseCommandArgument,
multiple: arg.multiple,
selectionTypes: arg.selectionTypes,
validation: arg.validation,
allowNoSelection: arg.allowNoSelection,
selectionSource: arg.selectionSource,
} satisfies CommandArgument<O, T> & { inputType: 'selectionMixed' }
} else if (arg.inputType === 'kcl') {
return {
inputType: arg.inputType,

View File

@ -43,15 +43,33 @@ export async function submitPromptToEditToQueue({
projectName,
}: {
prompt: string
selections: Selections
selections: Selections | null
code: string
projectName: string
token?: string
artifactGraph: ArtifactGraph
}): Promise<Models['TextToCadIteration_type'] | Error> {
// If no selection, use whole file
if (selections === null) {
const body: Models['TextToCadIterationBody_type'] = {
original_source_code: code,
prompt,
source_ranges: [], // Empty ranges indicates whole file
project_name:
projectName !== '' && projectName !== 'browser'
? projectName
: undefined,
kcl_version: kclManager.kclVersion,
}
return submitToApi(body, token)
}
// Handle manual code selections and artifact selections differently
const ranges: Models['TextToCadIterationBody_type']['source_ranges'] =
selections.graphSelections.flatMap((selection) => {
const artifact = selection.artifact
// For artifact selections, add context
const prompts: Models['TextToCadIterationBody_type']['source_ranges'] = []
if (artifact?.type === 'cap') {
@ -153,8 +171,17 @@ See later source ranges for more context. about the sweep`,
}
}
}
if (!artifact) {
// manually selected code is more likely to not have an artifact
// an example might be highlighting the variable name only in a variable declaration
prompts.push({
prompt: '',
range: convertAppRangeToApiRange(selection.codeRef.range, code),
})
}
return prompts
})
const body: Models['TextToCadIterationBody_type'] = {
original_source_code: code,
prompt,
@ -163,6 +190,15 @@ See later source ranges for more context. about the sweep`,
projectName !== '' && projectName !== 'browser' ? projectName : undefined,
kcl_version: kclManager.kclVersion,
}
return submitToApi(body, token)
}
// Helper function to handle API submission
async function submitToApi(
body: Models['TextToCadIterationBody_type'],
token?: string
): Promise<Models['TextToCadIteration_type'] | Error> {
const url = VITE_KC_API_BASE_URL + '/ml/text-to-cad/iteration'
const data: Models['TextToCadIteration_type'] | Error =
await crossPlatformFetch(

View File

@ -23,30 +23,6 @@ export const telemetryLoader: LoaderFunction = async ({
return null
}
// Redirect users to the appropriate onboarding page if they haven't completed it
export const onboardingRedirectLoader: ActionFunction = async (args) => {
const settings = getSettings()
const onboardingStatus: OnboardingStatus =
settings.app.onboardingStatus.current || ''
const notEnRouteToOnboarding = !args.request.url.includes(
PATHS.ONBOARDING.INDEX
)
// '' is the initial state, 'completed' and 'dismissed' are the final states
const hasValidOnboardingStatus =
onboardingStatus.length === 0 ||
!(onboardingStatus === 'completed' || onboardingStatus === 'dismissed')
const shouldRedirectToOnboarding =
notEnRouteToOnboarding && hasValidOnboardingStatus
if (shouldRedirectToOnboarding) {
return redirect(
makeUrlPathRelative(PATHS.ONBOARDING.INDEX) + onboardingStatus.slice(1)
)
}
return null
}
export const fileLoader: LoaderFunction = async (
routerData
): Promise<FileLoaderData | Response> => {

View File

@ -481,7 +481,9 @@ export function getSelectionTypeDisplayText(
export function canSubmitSelectionArg(
selectionsByType: 'none' | Map<ResolvedSelectionType, number>,
argument: CommandArgument<unknown> & { inputType: 'selection' }
argument: CommandArgument<unknown> & {
inputType: 'selection' | 'selectionMixed'
}
) {
return (
selectionsByType !== 'none' &&

View File

@ -295,7 +295,8 @@ export const commandBarMachine = setup({
if (
context.currentArgument &&
context.selectedCommand &&
argConfig?.inputType === 'selection' &&
(argConfig?.inputType === 'selection' ||
argConfig?.inputType === 'selectionMixed') &&
argConfig?.validation
) {
argConfig

View File

@ -1995,12 +1995,6 @@ export const modelingMachine = setup({
// Extract inputs
const ast = kclManager.ast
const { selection, thickness } = input
const dependencies = {
kclManager,
engineCommandManager,
editorManager,
codeManager,
}
// Insert the thickness variable if it exists
if (
@ -2026,7 +2020,6 @@ export const modelingMachine = setup({
'variableName' in thickness
? thickness.variableIdentifierAst
: thickness.valueAst,
dependencies,
})
if (err(shellResult)) {
return err(shellResult)

View File

@ -730,7 +730,7 @@ dependencies = [
[[package]]
name = "derive-docs"
version = "0.1.38"
version = "0.1.39"
dependencies = [
"Inflector",
"anyhow",
@ -1724,7 +1724,7 @@ dependencies = [
[[package]]
name = "kcl-lib"
version = "0.2.38"
version = "0.2.39"
dependencies = [
"anyhow",
"approx 0.5.1",
@ -1791,7 +1791,7 @@ dependencies = [
[[package]]
name = "kcl-test-server"
version = "0.1.38"
version = "0.1.39"
dependencies = [
"anyhow",
"hyper 0.14.32",

View File

@ -106,4 +106,4 @@ path = "tests/modify/main.rs"
# Local development only. Placeholder to speed up development cycle
#[package.metadata.wasm-pack.profile.release]
#wasm-opt = false
#wasm-opt = false

View File

@ -1,7 +1,7 @@
[package]
name = "derive-docs"
description = "A tool for generating documentation from Rust derive macros"
version = "0.1.38"
version = "0.1.39"
edition = "2021"
license = "MIT"
repository = "https://github.com/KittyCAD/modeling-app"

View File

@ -1,7 +1,7 @@
[package]
name = "kcl-test-server"
description = "A test server for KCL"
version = "0.1.38"
version = "0.1.39"
edition = "2021"
license = "MIT"

View File

@ -1,7 +1,7 @@
[package]
name = "kcl-lib"
description = "KittyCAD Language implementation and tools"
version = "0.2.38"
version = "0.2.39"
edition = "2021"
license = "MIT"
repository = "https://github.com/KittyCAD/modeling-app"

View File

@ -165,6 +165,7 @@ pub struct Sweep {
pub enum SweepSubType {
Extrusion,
Revolve,
RevolveAboutEdge,
Loft,
Sweep,
}
@ -751,10 +752,12 @@ fn artifacts_to_update(
}
ModelingCmd::Extrude(kcmc::Extrude { target, .. })
| ModelingCmd::Revolve(kcmc::Revolve { target, .. })
| ModelingCmd::RevolveAboutEdge(kcmc::RevolveAboutEdge { target, .. })
| ModelingCmd::Sweep(kcmc::Sweep { target, .. }) => {
let sub_type = match cmd {
ModelingCmd::Extrude(_) => SweepSubType::Extrusion,
ModelingCmd::Revolve(_) => SweepSubType::Revolve,
ModelingCmd::RevolveAboutEdge(_) => SweepSubType::RevolveAboutEdge,
ModelingCmd::Sweep(_) => SweepSubType::Sweep,
_ => unreachable!(),
};
@ -885,7 +888,7 @@ fn artifacts_to_update(
let path_sweep_id = path.sweep_id.ok_or_else(|| {
KclError::Internal(KclErrorDetails {
message:format!(
"Expected a sweep ID on the path when processing Solid3dGetExtrusionFaceInfo command, but we have none: {id:?}, {path:?}"
"Expected a sweep ID on the path when processing last path's Solid3dGetExtrusionFaceInfo command, but we have none: {id:?}, {path:?}"
),
source_ranges: vec![range],
})

View File

@ -1018,6 +1018,27 @@ mod sketch_on_face {
super::execute(TEST_NAME, true).await
}
}
mod revolve_about_edge {
const TEST_NAME: &str = "revolve_about_edge";
/// Test parsing KCL.
#[test]
fn parse() {
super::parse(TEST_NAME)
}
/// Test that parsing and unparsing KCL produces the original KCL input.
#[test]
fn unparse() {
super::unparse(TEST_NAME)
}
/// Test that KCL is executed correctly.
#[tokio::test(flavor = "multi_thread")]
async fn kcl_test_execute() {
super::execute(TEST_NAME, true).await
}
}
mod poop_chute {
const TEST_NAME: &str = "poop_chute";

View File

@ -0,0 +1,571 @@
---
source: kcl/src/simulation_tests.rs
description: Artifact commands revolve_about_edge.kcl
---
[
{
"cmdId": "[uuid]",
"range": [
0,
0,
0
],
"command": {
"type": "make_plane",
"origin": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"x_axis": {
"x": 1.0,
"y": 0.0,
"z": 0.0
},
"y_axis": {
"x": 0.0,
"y": 1.0,
"z": 0.0
},
"size": 100.0,
"clobber": false,
"hide": true
}
},
{
"cmdId": "[uuid]",
"range": [
0,
0,
0
],
"command": {
"type": "plane_set_color",
"plane_id": "[uuid]",
"color": {
"r": 0.7,
"g": 0.28,
"b": 0.28,
"a": 0.4
}
}
},
{
"cmdId": "[uuid]",
"range": [
0,
0,
0
],
"command": {
"type": "make_plane",
"origin": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"x_axis": {
"x": 0.0,
"y": 1.0,
"z": 0.0
},
"y_axis": {
"x": 0.0,
"y": 0.0,
"z": 1.0
},
"size": 100.0,
"clobber": false,
"hide": true
}
},
{
"cmdId": "[uuid]",
"range": [
0,
0,
0
],
"command": {
"type": "plane_set_color",
"plane_id": "[uuid]",
"color": {
"r": 0.28,
"g": 0.7,
"b": 0.28,
"a": 0.4
}
}
},
{
"cmdId": "[uuid]",
"range": [
0,
0,
0
],
"command": {
"type": "make_plane",
"origin": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"x_axis": {
"x": 1.0,
"y": 0.0,
"z": 0.0
},
"y_axis": {
"x": 0.0,
"y": 0.0,
"z": 1.0
},
"size": 100.0,
"clobber": false,
"hide": true
}
},
{
"cmdId": "[uuid]",
"range": [
0,
0,
0
],
"command": {
"type": "plane_set_color",
"plane_id": "[uuid]",
"color": {
"r": 0.28,
"g": 0.28,
"b": 0.7,
"a": 0.4
}
}
},
{
"cmdId": "[uuid]",
"range": [
0,
0,
0
],
"command": {
"type": "make_plane",
"origin": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"x_axis": {
"x": -1.0,
"y": 0.0,
"z": 0.0
},
"y_axis": {
"x": 0.0,
"y": 1.0,
"z": 0.0
},
"size": 100.0,
"clobber": false,
"hide": true
}
},
{
"cmdId": "[uuid]",
"range": [
0,
0,
0
],
"command": {
"type": "make_plane",
"origin": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"x_axis": {
"x": 0.0,
"y": -1.0,
"z": 0.0
},
"y_axis": {
"x": 0.0,
"y": 0.0,
"z": 1.0
},
"size": 100.0,
"clobber": false,
"hide": true
}
},
{
"cmdId": "[uuid]",
"range": [
0,
0,
0
],
"command": {
"type": "make_plane",
"origin": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"x_axis": {
"x": -1.0,
"y": 0.0,
"z": 0.0
},
"y_axis": {
"x": 0.0,
"y": 0.0,
"z": 1.0
},
"size": 100.0,
"clobber": false,
"hide": true
}
},
{
"cmdId": "[uuid]",
"range": [
0,
0,
0
],
"command": {
"type": "edge_lines_visible",
"hidden": false
}
},
{
"cmdId": "[uuid]",
"range": [
0,
0,
0
],
"command": {
"type": "set_scene_units",
"unit": "mm"
}
},
{
"cmdId": "[uuid]",
"range": [
0,
0,
0
],
"command": {
"type": "object_visible",
"object_id": "[uuid]",
"hidden": true
}
},
{
"cmdId": "[uuid]",
"range": [
0,
0,
0
],
"command": {
"type": "object_visible",
"object_id": "[uuid]",
"hidden": true
}
},
{
"cmdId": "[uuid]",
"range": [
12,
31,
0
],
"command": {
"type": "make_plane",
"origin": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"x_axis": {
"x": 1.0,
"y": 0.0,
"z": 0.0
},
"y_axis": {
"x": 0.0,
"y": 1.0,
"z": 0.0
},
"size": 60.0,
"clobber": false,
"hide": true
}
},
{
"cmdId": "[uuid]",
"range": [
37,
65,
0
],
"command": {
"type": "enable_sketch_mode",
"entity_id": "[uuid]",
"ortho": false,
"animated": false,
"adjust_camera": false,
"planar_normal": {
"x": 0.0,
"y": 0.0,
"z": 1.0
}
}
},
{
"cmdId": "[uuid]",
"range": [
37,
65,
0
],
"command": {
"type": "start_path"
}
},
{
"cmdId": "[uuid]",
"range": [
37,
65,
0
],
"command": {
"type": "move_path_pen",
"path": "[uuid]",
"to": {
"x": -25.0,
"y": 25.0,
"z": 0.0
}
}
},
{
"cmdId": "[uuid]",
"range": [
71,
107,
0
],
"command": {
"type": "extend_path",
"path": "[uuid]",
"segment": {
"type": "line",
"end": {
"x": 0.0,
"y": -50.0,
"z": 0.0
},
"relative": true
}
}
},
{
"cmdId": "[uuid]",
"range": [
120,
139,
0
],
"command": {
"type": "make_plane",
"origin": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"x_axis": {
"x": 1.0,
"y": 0.0,
"z": 0.0
},
"y_axis": {
"x": 0.0,
"y": 1.0,
"z": 0.0
},
"size": 60.0,
"clobber": false,
"hide": true
}
},
{
"cmdId": "[uuid]",
"range": [
145,
190,
0
],
"command": {
"type": "enable_sketch_mode",
"entity_id": "[uuid]",
"ortho": false,
"animated": false,
"adjust_camera": false,
"planar_normal": {
"x": 0.0,
"y": 0.0,
"z": 1.0
}
}
},
{
"cmdId": "[uuid]",
"range": [
145,
190,
0
],
"command": {
"type": "start_path"
}
},
{
"cmdId": "[uuid]",
"range": [
145,
190,
0
],
"command": {
"type": "move_path_pen",
"path": "[uuid]",
"to": {
"x": -40.0,
"y": 0.0,
"z": 0.0
}
}
},
{
"cmdId": "[uuid]",
"range": [
145,
190,
0
],
"command": {
"type": "extend_path",
"path": "[uuid]",
"segment": {
"type": "arc",
"center": {
"x": -50.0,
"y": 0.0
},
"radius": 10.0,
"start": {
"unit": "degrees",
"value": 0.0
},
"end": {
"unit": "degrees",
"value": 360.0
},
"relative": false
}
}
},
{
"cmdId": "[uuid]",
"range": [
145,
190,
0
],
"command": {
"type": "close_path",
"path_id": "[uuid]"
}
},
{
"cmdId": "[uuid]",
"range": [
196,
270,
0
],
"command": {
"type": "revolve_about_edge",
"target": "[uuid]",
"edge_id": "[uuid]",
"angle": {
"unit": "degrees",
"value": 90.0
},
"tolerance": 0.0000001
}
},
{
"cmdId": "[uuid]",
"range": [
196,
270,
0
],
"command": {
"type": "object_bring_to_front",
"object_id": "[uuid]"
}
},
{
"cmdId": "[uuid]",
"range": [
196,
270,
0
],
"command": {
"type": "solid3d_get_extrusion_face_info",
"object_id": "[uuid]",
"edge_id": "[uuid]"
}
},
{
"cmdId": "[uuid]",
"range": [
196,
270,
0
],
"command": {
"type": "solid3d_get_opposite_edge",
"object_id": "[uuid]",
"edge_id": "[uuid]",
"face_id": "[uuid]"
}
},
{
"cmdId": "[uuid]",
"range": [
196,
270,
0
],
"command": {
"type": "solid3d_get_next_adjacent_edge",
"object_id": "[uuid]",
"edge_id": "[uuid]",
"face_id": "[uuid]"
}
}
]

View File

@ -0,0 +1,6 @@
---
source: kcl/src/simulation_tests.rs
description: Artifact graph flowchart revolve_about_edge.kcl
extension: md
snapshot_kind: binary
---

View File

@ -0,0 +1,34 @@
```mermaid
flowchart LR
subgraph path2 [Path]
2["Path<br>[37, 65, 0]"]
3["Segment<br>[71, 107, 0]"]
end
subgraph path5 [Path]
5["Path<br>[145, 190, 0]"]
6["Segment<br>[145, 190, 0]"]
7[Solid2d]
end
1["Plane<br>[12, 31, 0]"]
4["Plane<br>[120, 139, 0]"]
8["Sweep RevolveAboutEdge<br>[196, 270, 0]"]
9[Wall]
10["Cap Start"]
11["Cap End"]
12["SweepEdge Opposite"]
13["SweepEdge Adjacent"]
1 --- 2
2 --- 3
4 --- 5
5 --- 6
5 ---- 8
5 --- 7
6 --- 9
6 --- 12
6 --- 13
8 --- 9
8 --- 10
8 --- 11
8 --- 12
8 --- 13
```

View File

@ -0,0 +1,376 @@
---
source: kcl/src/simulation_tests.rs
description: Result of parsing revolve_about_edge.kcl
---
{
"Ok": {
"body": [
{
"declaration": {
"end": 107,
"id": {
"end": 9,
"name": "sketch001",
"start": 0,
"type": "Identifier"
},
"init": {
"body": [
{
"arguments": [
{
"end": 30,
"raw": "'XY'",
"start": 26,
"type": "Literal",
"type": "Literal",
"value": "XY"
}
],
"callee": {
"end": 25,
"name": "startSketchOn",
"start": 12,
"type": "Identifier"
},
"end": 31,
"start": 12,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"elements": [
{
"argument": {
"end": 56,
"raw": "25",
"start": 54,
"type": "Literal",
"type": "Literal",
"value": {
"value": 25.0,
"suffix": "None"
}
},
"end": 56,
"operator": "-",
"start": 53,
"type": "UnaryExpression",
"type": "UnaryExpression"
},
{
"end": 60,
"raw": "25",
"start": 58,
"type": "Literal",
"type": "Literal",
"value": {
"value": 25.0,
"suffix": "None"
}
}
],
"end": 61,
"start": 52,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"end": 64,
"start": 63,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 51,
"name": "startProfileAt",
"start": 37,
"type": "Identifier"
},
"end": 65,
"start": 37,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"argument": {
"end": 80,
"raw": "50",
"start": 78,
"type": "Literal",
"type": "Literal",
"value": {
"value": 50.0,
"suffix": "None"
}
},
"end": 80,
"operator": "-",
"start": 77,
"type": "UnaryExpression",
"type": "UnaryExpression"
},
{
"end": 83,
"start": 82,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
},
{
"end": 106,
"start": 85,
"type": "TagDeclarator",
"type": "TagDeclarator",
"value": "rectangleSegmentB001"
}
],
"callee": {
"end": 76,
"name": "yLine",
"start": 71,
"type": "Identifier"
},
"end": 107,
"start": 71,
"type": "CallExpression",
"type": "CallExpression"
}
],
"end": 107,
"start": 12,
"type": "PipeExpression",
"type": "PipeExpression"
},
"start": 0,
"type": "VariableDeclarator"
},
"end": 107,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"declaration": {
"end": 270,
"id": {
"end": 117,
"name": "sketch002",
"start": 108,
"type": "Identifier"
},
"init": {
"body": [
{
"arguments": [
{
"end": 138,
"raw": "'XY'",
"start": 134,
"type": "Literal",
"type": "Literal",
"value": "XY"
}
],
"callee": {
"end": 133,
"name": "startSketchOn",
"start": 120,
"type": "Identifier"
},
"end": 139,
"start": 120,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"end": 186,
"properties": [
{
"end": 171,
"key": {
"end": 160,
"name": "center",
"start": 154,
"type": "Identifier"
},
"start": 154,
"type": "ObjectProperty",
"value": {
"elements": [
{
"argument": {
"end": 167,
"raw": "50",
"start": 165,
"type": "Literal",
"type": "Literal",
"value": {
"value": 50.0,
"suffix": "None"
}
},
"end": 167,
"operator": "-",
"start": 164,
"type": "UnaryExpression",
"type": "UnaryExpression"
},
{
"end": 170,
"raw": "0",
"start": 169,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
}
],
"end": 171,
"start": 163,
"type": "ArrayExpression",
"type": "ArrayExpression"
}
},
{
"end": 184,
"key": {
"end": 179,
"name": "radius",
"start": 173,
"type": "Identifier"
},
"start": 173,
"type": "ObjectProperty",
"value": {
"end": 184,
"raw": "10",
"start": 182,
"type": "Literal",
"type": "Literal",
"value": {
"value": 10.0,
"suffix": "None"
}
}
}
],
"start": 152,
"type": "ObjectExpression",
"type": "ObjectExpression"
},
{
"end": 189,
"start": 188,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 151,
"name": "circle",
"start": 145,
"type": "Identifier"
},
"end": 190,
"start": 145,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"end": 266,
"properties": [
{
"end": 223,
"key": {
"end": 218,
"name": "angle",
"start": 213,
"type": "Identifier"
},
"start": 213,
"type": "ObjectProperty",
"value": {
"end": 223,
"raw": "90",
"start": 221,
"type": "Literal",
"type": "Literal",
"value": {
"value": 90.0,
"suffix": "None"
}
}
},
{
"end": 259,
"key": {
"end": 236,
"name": "axis",
"start": 232,
"type": "Identifier"
},
"start": 232,
"type": "ObjectProperty",
"value": {
"end": 259,
"name": "rectangleSegmentB001",
"start": 239,
"type": "Identifier",
"type": "Identifier"
}
}
],
"start": 204,
"type": "ObjectExpression",
"type": "ObjectExpression"
},
{
"end": 269,
"start": 268,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 203,
"name": "revolve",
"start": 196,
"type": "Identifier"
},
"end": 270,
"start": 196,
"type": "CallExpression",
"type": "CallExpression"
}
],
"end": 270,
"start": 120,
"type": "PipeExpression",
"type": "PipeExpression"
},
"start": 108,
"type": "VariableDeclarator"
},
"end": 270,
"kind": "const",
"start": 108,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
}
],
"end": 271,
"start": 0
}
}

View File

@ -0,0 +1,9 @@
sketch001 = startSketchOn('XY')
|> startProfileAt([-25, 25], %)
|> yLine(-50, %, $rectangleSegmentB001)
sketch002 = startSketchOn('XY')
|> circle({ center = [-50, 0], radius = 10 }, %)
|> revolve({
angle = 90,
axis = rectangleSegmentB001
}, %)

View File

@ -0,0 +1,107 @@
---
source: kcl/src/simulation_tests.rs
description: Operations executed revolve_about_edge.kcl
---
[
{
"labeledArgs": {
"data": {
"value": {
"type": "String",
"value": "XY"
},
"sourceRange": [
26,
30,
0
]
}
},
"name": "startSketchOn",
"sourceRange": [
12,
31,
0
],
"type": "StdLibCall",
"unlabeledArg": null
},
{
"labeledArgs": {
"data": {
"value": {
"type": "String",
"value": "XY"
},
"sourceRange": [
134,
138,
0
]
}
},
"name": "startSketchOn",
"sourceRange": [
120,
139,
0
],
"type": "StdLibCall",
"unlabeledArg": null
},
{
"labeledArgs": {
"data": {
"value": {
"type": "Object",
"value": {
"angle": {
"type": "Number",
"value": 90.0,
"ty": {
"type": "Default",
"len": {
"type": "Mm"
},
"angle": {
"type": "Degrees"
}
}
},
"axis": {
"type": "TagIdentifier",
"value": "rectangleSegmentB001",
"artifact_id": "[uuid]"
}
}
},
"sourceRange": [
204,
266,
0
]
},
"sketch": {
"value": {
"type": "Sketch",
"value": {
"artifactId": "[uuid]"
}
},
"sourceRange": [
268,
269,
0
]
}
},
"name": "revolve",
"sourceRange": [
196,
270,
0
],
"type": "StdLibCall",
"unlabeledArg": null
}
]

View File

@ -0,0 +1,343 @@
---
source: kcl/src/simulation_tests.rs
description: Variables in memory after executing revolve_about_edge.kcl
---
{
"rectangleSegmentB001": {
"type": "TagIdentifier",
"type": "TagIdentifier",
"value": "rectangleSegmentB001",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
71,
107,
0
]
},
"from": [
-25.0,
25.0
],
"tag": {
"end": 106,
"start": 85,
"type": "TagDeclarator",
"value": "rectangleSegmentB001"
},
"to": [
-25.0,
-25.0
],
"type": "ToPoint",
"units": {
"type": "Mm"
}
},
"surface": null
},
"__meta": [
{
"sourceRange": [
85,
106,
0
]
}
]
},
"sketch001": {
"type": "Sketch",
"value": {
"type": "Sketch",
"id": "[uuid]",
"paths": [
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
71,
107,
0
]
},
"from": [
-25.0,
25.0
],
"tag": {
"end": 106,
"start": 85,
"type": "TagDeclarator",
"value": "rectangleSegmentB001"
},
"to": [
-25.0,
-25.0
],
"type": "ToPoint",
"units": {
"type": "Mm"
}
}
],
"on": {
"type": "plane",
"id": "[uuid]",
"artifactId": "[uuid]",
"value": "XY",
"origin": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"xAxis": {
"x": 1.0,
"y": 0.0,
"z": 0.0
},
"yAxis": {
"x": 0.0,
"y": 1.0,
"z": 0.0
},
"zAxis": {
"x": 0.0,
"y": 0.0,
"z": 1.0
},
"units": {
"type": "Mm"
},
"__meta": []
},
"start": {
"from": [
-25.0,
25.0
],
"to": [
-25.0,
25.0
],
"units": {
"type": "Mm"
},
"tag": null,
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
37,
65,
0
]
}
},
"tags": {
"rectangleSegmentB001": {
"type": "TagIdentifier",
"value": "rectangleSegmentB001",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
71,
107,
0
]
},
"from": [
-25.0,
25.0
],
"tag": {
"end": 106,
"start": 85,
"type": "TagDeclarator",
"value": "rectangleSegmentB001"
},
"to": [
-25.0,
-25.0
],
"type": "ToPoint",
"units": {
"type": "Mm"
}
},
"surface": null
},
"__meta": [
{
"sourceRange": [
85,
106,
0
]
}
]
}
},
"artifactId": "[uuid]",
"originalId": "[uuid]",
"units": {
"type": "Mm"
},
"__meta": [
{
"sourceRange": [
37,
65,
0
]
}
]
}
},
"sketch002": {
"type": "Solid",
"value": {
"type": "Solid",
"id": "[uuid]",
"artifactId": "[uuid]",
"value": [
{
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
145,
190,
0
],
"tag": null,
"type": "extrudeArc"
}
],
"sketch": {
"type": "Sketch",
"id": "[uuid]",
"paths": [
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
145,
190,
0
]
},
"ccw": true,
"center": [
-50.0,
0.0
],
"from": [
-40.0,
0.0
],
"radius": 10.0,
"tag": null,
"to": [
-40.0,
0.0
],
"type": "Circle",
"units": {
"type": "Mm"
}
}
],
"on": {
"type": "plane",
"id": "[uuid]",
"artifactId": "[uuid]",
"value": "XY",
"origin": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"xAxis": {
"x": 1.0,
"y": 0.0,
"z": 0.0
},
"yAxis": {
"x": 0.0,
"y": 1.0,
"z": 0.0
},
"zAxis": {
"x": 0.0,
"y": 0.0,
"z": 1.0
},
"units": {
"type": "Mm"
},
"__meta": []
},
"start": {
"from": [
-40.0,
0.0
],
"to": [
-40.0,
0.0
],
"units": {
"type": "Mm"
},
"tag": null,
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
145,
190,
0
]
}
},
"artifactId": "[uuid]",
"originalId": "[uuid]",
"units": {
"type": "Mm"
},
"__meta": [
{
"sourceRange": [
145,
190,
0
]
}
]
},
"height": 0.0,
"startCapId": "[uuid]",
"endCapId": "[uuid]",
"units": {
"type": "Mm"
},
"__meta": [
{
"sourceRange": [
145,
190,
0
]
}
]
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB