offsetPlane kwargs (#5367)

Previously: `offsetPlane('XY', 75)`
Now: `offsetPlane('XY', offset = 75)`

Pairs with this KCL-samples PR: https://github.com/KittyCAD/kcl-samples/pull/163
This commit is contained in:
Adam Chalmers
2025-02-13 13:37:02 -06:00
committed by GitHub
parent 5d02a27122
commit 78b42ea191
21 changed files with 320 additions and 297 deletions

View File

@ -40,7 +40,7 @@ squareSketch = startSketchOn('XY')
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
triangleSketch = startSketchOn(offsetPlane('XY', 75)) triangleSketch = startSketchOn(offsetPlane('XY', offset = 75))
|> startProfileAt([0, 125], %) |> startProfileAt([0, 125], %)
|> line(end = [-15, -30]) |> line(end = [-15, -30])
|> line(end = [30, 0]) |> line(end = [30, 0])
@ -62,10 +62,10 @@ squareSketch = startSketchOn('XY')
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
circleSketch0 = startSketchOn(offsetPlane('XY', 75)) circleSketch0 = startSketchOn(offsetPlane('XY', offset = 75))
|> circle({ center = [0, 100], radius = 50 }, %) |> circle({ center = [0, 100], radius = 50 }, %)
circleSketch1 = startSketchOn(offsetPlane('XY', 150)) circleSketch1 = startSketchOn(offsetPlane('XY', offset = 150))
|> circle({ center = [0, 100], radius = 20 }, %) |> circle({ center = [0, 100], radius = 20 }, %)
loft([ loft([
@ -87,10 +87,10 @@ squareSketch = startSketchOn('XY')
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
circleSketch0 = startSketchOn(offsetPlane('XY', 75)) circleSketch0 = startSketchOn(offsetPlane('XY', offset = 75))
|> circle({ center = [0, 100], radius = 50 }, %) |> circle({ center = [0, 100], radius = 50 }, %)
circleSketch1 = startSketchOn(offsetPlane('XY', 150)) circleSketch1 = startSketchOn(offsetPlane('XY', offset = 150))
|> circle({ center = [0, 100], radius = 20 }, %) |> circle({ center = [0, 100], radius = 20 }, %)
loft( loft(

View File

@ -17,8 +17,8 @@ offsetPlane(std_plane: StandardPlane, offset: number) -> Plane
| Name | Type | Description | Required | | Name | Type | Description | Required |
|----------|------|-------------|----------| |----------|------|-------------|----------|
| `std_plane` | [`StandardPlane`](/docs/kcl/types/StandardPlane) | One of the standard planes. | Yes | | `std_plane` | [`StandardPlane`](/docs/kcl/types/StandardPlane) | Which standard plane (e.g. XY) should this new plane be created from? | Yes |
| `offset` | `number` | | Yes | | `offset` | `number` | Distance from the standard plane this new plane will be created at. | Yes |
### Returns ### Returns
@ -37,7 +37,7 @@ squareSketch = startSketchOn('XY')
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
circleSketch = startSketchOn(offsetPlane('XY', 150)) circleSketch = startSketchOn(offsetPlane('XY', offset = 150))
|> circle({ center = [0, 100], radius = 50 }, %) |> circle({ center = [0, 100], radius = 50 }, %)
loft([squareSketch, circleSketch]) loft([squareSketch, circleSketch])
@ -55,7 +55,7 @@ squareSketch = startSketchOn('XZ')
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
circleSketch = startSketchOn(offsetPlane('XZ', 150)) circleSketch = startSketchOn(offsetPlane('XZ', offset = 150))
|> circle({ center = [0, 100], radius = 50 }, %) |> circle({ center = [0, 100], radius = 50 }, %)
loft([squareSketch, circleSketch]) loft([squareSketch, circleSketch])
@ -73,7 +73,7 @@ squareSketch = startSketchOn('YZ')
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
circleSketch = startSketchOn(offsetPlane('YZ', 150)) circleSketch = startSketchOn(offsetPlane('YZ', offset = 150))
|> circle({ center = [0, 100], radius = 50 }, %) |> circle({ center = [0, 100], radius = 50 }, %)
loft([squareSketch, circleSketch]) loft([squareSketch, circleSketch])
@ -91,7 +91,7 @@ squareSketch = startSketchOn('-XZ')
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
circleSketch = startSketchOn(offsetPlane('-XZ', -150)) circleSketch = startSketchOn(offsetPlane('-XZ', offset = -150))
|> circle({ center = [0, 100], radius = 50 }, %) |> circle({ center = [0, 100], radius = 50 }, %)
loft([squareSketch, circleSketch]) loft([squareSketch, circleSketch])
@ -106,7 +106,7 @@ startSketchOn("XY")
|> circle({ radius = 10, center = [0, 0] }, %) |> circle({ radius = 10, center = [0, 0] }, %)
// Triangle on the plane 4 units above // Triangle on the plane 4 units above
startSketchOn(offsetPlane("XY", 4)) startSketchOn(offsetPlane("XY", offset = 4))
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line(end = [10, 0]) |> line(end = [10, 0])
|> line(end = [0, 10]) |> line(end = [0, 10])

View File

@ -122973,9 +122973,9 @@
"unpublished": false, "unpublished": false,
"deprecated": false, "deprecated": false,
"examples": [ "examples": [
"// Loft a square and a triangle.\nsquareSketch = startSketchOn('XY')\n |> startProfileAt([-100, 200], %)\n |> line(end = [200, 0])\n |> line(end = [0, -200])\n |> line(end = [-200, 0])\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n\ntriangleSketch = startSketchOn(offsetPlane('XY', 75))\n |> startProfileAt([0, 125], %)\n |> line(end = [-15, -30])\n |> line(end = [30, 0])\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n\nloft([squareSketch, triangleSketch])", "// Loft a square and a triangle.\nsquareSketch = startSketchOn('XY')\n |> startProfileAt([-100, 200], %)\n |> line(end = [200, 0])\n |> line(end = [0, -200])\n |> line(end = [-200, 0])\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n\ntriangleSketch = startSketchOn(offsetPlane('XY', offset = 75))\n |> startProfileAt([0, 125], %)\n |> line(end = [-15, -30])\n |> line(end = [30, 0])\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n\nloft([squareSketch, triangleSketch])",
"// Loft a square, a circle, and another circle.\nsquareSketch = startSketchOn('XY')\n |> startProfileAt([-100, 200], %)\n |> line(end = [200, 0])\n |> line(end = [0, -200])\n |> line(end = [-200, 0])\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n\ncircleSketch0 = startSketchOn(offsetPlane('XY', 75))\n |> circle({ center = [0, 100], radius = 50 }, %)\n\ncircleSketch1 = startSketchOn(offsetPlane('XY', 150))\n |> circle({ center = [0, 100], radius = 20 }, %)\n\nloft([\n squareSketch,\n circleSketch0,\n circleSketch1\n])", "// Loft a square, a circle, and another circle.\nsquareSketch = startSketchOn('XY')\n |> startProfileAt([-100, 200], %)\n |> line(end = [200, 0])\n |> line(end = [0, -200])\n |> line(end = [-200, 0])\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n\ncircleSketch0 = startSketchOn(offsetPlane('XY', offset = 75))\n |> circle({ center = [0, 100], radius = 50 }, %)\n\ncircleSketch1 = startSketchOn(offsetPlane('XY', offset = 150))\n |> circle({ center = [0, 100], radius = 20 }, %)\n\nloft([\n squareSketch,\n circleSketch0,\n circleSketch1\n])",
"// Loft a square, a circle, and another circle with options.\nsquareSketch = startSketchOn('XY')\n |> startProfileAt([-100, 200], %)\n |> line(end = [200, 0])\n |> line(end = [0, -200])\n |> line(end = [-200, 0])\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n\ncircleSketch0 = startSketchOn(offsetPlane('XY', 75))\n |> circle({ center = [0, 100], radius = 50 }, %)\n\ncircleSketch1 = startSketchOn(offsetPlane('XY', 150))\n |> circle({ center = [0, 100], radius = 20 }, %)\n\nloft(\n [\n squareSketch,\n circleSketch0,\n circleSketch1\n],\n baseCurveIndex = 0,\n bezApproximateRational = false,\n tolerance = 0.000001,\n vDegree = 2,\n)" "// Loft a square, a circle, and another circle with options.\nsquareSketch = startSketchOn('XY')\n |> startProfileAt([-100, 200], %)\n |> line(end = [200, 0])\n |> line(end = [0, -200])\n |> line(end = [-200, 0])\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n\ncircleSketch0 = startSketchOn(offsetPlane('XY', offset = 75))\n |> circle({ center = [0, 100], radius = 50 }, %)\n\ncircleSketch1 = startSketchOn(offsetPlane('XY', offset = 150))\n |> circle({ center = [0, 100], radius = 20 }, %)\n\nloft(\n [\n squareSketch,\n circleSketch0,\n circleSketch1\n],\n baseCurveIndex = 0,\n bezApproximateRational = false,\n tolerance = 0.000001,\n vDegree = 2,\n)"
] ]
}, },
{ {
@ -134124,7 +134124,7 @@
"summary": "Offset a plane by a distance along its normal.", "summary": "Offset a plane by a distance along its normal.",
"description": "For example, if you offset the 'XZ' plane by 10, the new plane will be parallel to the 'XZ' plane and 10 units away from it.", "description": "For example, if you offset the 'XZ' plane by 10, the new plane will be parallel to the 'XZ' plane and 10 units away from it.",
"tags": [], "tags": [],
"keywordArguments": false, "keywordArguments": true,
"args": [ "args": [
{ {
"name": "std_plane", "name": "std_plane",
@ -134180,7 +134180,8 @@
}, },
"required": true, "required": true,
"includeInSnippet": true, "includeInSnippet": true,
"labelRequired": true "description": "Which standard plane (e.g. XY) should this new plane be created from?",
"labelRequired": false
}, },
{ {
"name": "offset", "name": "offset",
@ -134193,6 +134194,7 @@
}, },
"required": true, "required": true,
"includeInSnippet": true, "includeInSnippet": true,
"description": "Distance from the standard plane this new plane will be created at.",
"labelRequired": true "labelRequired": true
} }
], ],
@ -134446,11 +134448,11 @@
"unpublished": false, "unpublished": false,
"deprecated": false, "deprecated": false,
"examples": [ "examples": [
"// Loft a square and a circle on the `XY` plane using offset.\nsquareSketch = startSketchOn('XY')\n |> startProfileAt([-100, 200], %)\n |> line(end = [200, 0])\n |> line(end = [0, -200])\n |> line(end = [-200, 0])\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n\ncircleSketch = startSketchOn(offsetPlane('XY', 150))\n |> circle({ center = [0, 100], radius = 50 }, %)\n\nloft([squareSketch, circleSketch])", "// Loft a square and a circle on the `XY` plane using offset.\nsquareSketch = startSketchOn('XY')\n |> startProfileAt([-100, 200], %)\n |> line(end = [200, 0])\n |> line(end = [0, -200])\n |> line(end = [-200, 0])\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n\ncircleSketch = startSketchOn(offsetPlane('XY', offset = 150))\n |> circle({ center = [0, 100], radius = 50 }, %)\n\nloft([squareSketch, circleSketch])",
"// Loft a square and a circle on the `XZ` plane using offset.\nsquareSketch = startSketchOn('XZ')\n |> startProfileAt([-100, 200], %)\n |> line(end = [200, 0])\n |> line(end = [0, -200])\n |> line(end = [-200, 0])\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n\ncircleSketch = startSketchOn(offsetPlane('XZ', 150))\n |> circle({ center = [0, 100], radius = 50 }, %)\n\nloft([squareSketch, circleSketch])", "// Loft a square and a circle on the `XZ` plane using offset.\nsquareSketch = startSketchOn('XZ')\n |> startProfileAt([-100, 200], %)\n |> line(end = [200, 0])\n |> line(end = [0, -200])\n |> line(end = [-200, 0])\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n\ncircleSketch = startSketchOn(offsetPlane('XZ', offset = 150))\n |> circle({ center = [0, 100], radius = 50 }, %)\n\nloft([squareSketch, circleSketch])",
"// Loft a square and a circle on the `YZ` plane using offset.\nsquareSketch = startSketchOn('YZ')\n |> startProfileAt([-100, 200], %)\n |> line(end = [200, 0])\n |> line(end = [0, -200])\n |> line(end = [-200, 0])\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n\ncircleSketch = startSketchOn(offsetPlane('YZ', 150))\n |> circle({ center = [0, 100], radius = 50 }, %)\n\nloft([squareSketch, circleSketch])", "// Loft a square and a circle on the `YZ` plane using offset.\nsquareSketch = startSketchOn('YZ')\n |> startProfileAt([-100, 200], %)\n |> line(end = [200, 0])\n |> line(end = [0, -200])\n |> line(end = [-200, 0])\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n\ncircleSketch = startSketchOn(offsetPlane('YZ', offset = 150))\n |> circle({ center = [0, 100], radius = 50 }, %)\n\nloft([squareSketch, circleSketch])",
"// Loft a square and a circle on the `-XZ` plane using offset.\nsquareSketch = startSketchOn('-XZ')\n |> startProfileAt([-100, 200], %)\n |> line(end = [200, 0])\n |> line(end = [0, -200])\n |> line(end = [-200, 0])\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n\ncircleSketch = startSketchOn(offsetPlane('-XZ', -150))\n |> circle({ center = [0, 100], radius = 50 }, %)\n\nloft([squareSketch, circleSketch])", "// Loft a square and a circle on the `-XZ` plane using offset.\nsquareSketch = startSketchOn('-XZ')\n |> startProfileAt([-100, 200], %)\n |> line(end = [200, 0])\n |> line(end = [0, -200])\n |> line(end = [-200, 0])\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n\ncircleSketch = startSketchOn(offsetPlane('-XZ', offset = -150))\n |> circle({ center = [0, 100], radius = 50 }, %)\n\nloft([squareSketch, circleSketch])",
"// A circle on the XY plane\nstartSketchOn(\"XY\")\n |> startProfileAt([0, 0], %)\n |> circle({ radius = 10, center = [0, 0] }, %)\n\n// Triangle on the plane 4 units above\nstartSketchOn(offsetPlane(\"XY\", 4))\n |> startProfileAt([0, 0], %)\n |> line(end = [10, 0])\n |> line(end = [0, 10])\n |> close()" "// A circle on the XY plane\nstartSketchOn(\"XY\")\n |> startProfileAt([0, 0], %)\n |> circle({ radius = 10, center = [0, 0] }, %)\n\n// Triangle on the plane 4 units above\nstartSketchOn(offsetPlane(\"XY\", offset = 4))\n |> startProfileAt([0, 0], %)\n |> line(end = [10, 0])\n |> line(end = [0, 10])\n |> close()"
] ]
}, },
{ {

View File

@ -24,7 +24,7 @@ sketch001 = startSketchOn('XZ')
revolve001 = revolve({ axis = "X" }, sketch001) revolve001 = revolve({ axis = "X" }, sketch001)
triangle() triangle()
|> extrude(length = 30) |> extrude(length = 30)
plane001 = offsetPlane('XY', 10) plane001 = offsetPlane('XY', offset = 10)
sketch002 = startSketchOn(plane001) sketch002 = startSketchOn(plane001)
|> startProfileAt([-20, 0], %) |> startProfileAt([-20, 0], %)
|> line(end = [5, -15]) |> line(end = [5, -15])
@ -54,7 +54,7 @@ sketch002 = startSketchOn(extrude001, rectangleSegmentB001)
center = [-1, 2], center = [-1, 2],
radius = .5 radius = .5
}, %) }, %)
plane001 = offsetPlane('XZ', -5) plane001 = offsetPlane('XZ', offset = -5)
sketch003 = startSketchOn(plane001) sketch003 = startSketchOn(plane001)
|> circle({ center = [0, 0], radius = 5 }, %) |> circle({ center = [0, 0], radius = 5 }, %)
` `
@ -116,7 +116,7 @@ test.describe('Feature Tree pane', () => {
await testViewSource({ await testViewSource({
operationName: 'Offset Plane', operationName: 'Offset Plane',
operationIndex: 0, operationIndex: 0,
expectedActiveLine: "plane001 = offsetPlane('XY', 10)", expectedActiveLine: "plane001 = offsetPlane('XY', offset = 10)",
}) })
await testViewSource({ await testViewSource({
operationName: 'Extrude', operationName: 'Extrude',
@ -342,7 +342,8 @@ test.describe('Feature Tree pane', () => {
toolbar, toolbar,
cmdBar, cmdBar,
}) => { }) => {
const testCode = (value: string) => `p = offsetPlane('XY', ${value})` const testCode = (value: string) =>
`p = offsetPlane('XY', offset = ${value})`
const initialInput = '10' const initialInput = '10'
const initialCode = testCode(initialInput) const initialCode = testCode(initialInput)
const newInput = '5 + 10' const newInput = '5 + 10'

View File

@ -1052,7 +1052,7 @@ openSketch = startSketchOn('XY')
// One dumb hardcoded screen pixel value // One dumb hardcoded screen pixel value
const testPoint = { x: 700, y: 150 } const testPoint = { x: 700, y: 150 }
const [clickOnXzPlane] = scene.makeMouseHelpers(testPoint.x, testPoint.y) const [clickOnXzPlane] = scene.makeMouseHelpers(testPoint.x, testPoint.y)
const expectedOutput = `plane001 = offsetPlane('XZ', 5)` const expectedOutput = `plane001 = offsetPlane('XZ', offset = 5)`
await homePage.goToModelingScene() await homePage.goToModelingScene()
// FIXME: Since there is no KCL code loaded. We need to wait for the scene to load before we continue. // FIXME: Since there is no KCL code loaded. We need to wait for the scene to load before we continue.
@ -1188,7 +1188,7 @@ openSketch = startSketchOn('XY')
}) => { }) => {
const initialCode = `sketch001 = startSketchOn('XZ') const initialCode = `sketch001 = startSketchOn('XZ')
|> circle({ center = [0, 0], radius = 30 }, %) |> circle({ center = [0, 0], radius = 30 }, %)
plane001 = offsetPlane('XZ', 50) plane001 = offsetPlane('XZ', offset = 50)
sketch002 = startSketchOn(plane001) sketch002 = startSketchOn(plane001)
|> circle({ center = [0, 0], radius = 20 }, %) |> circle({ center = [0, 0], radius = 20 }, %)
` `
@ -1274,7 +1274,7 @@ openSketch = startSketchOn('XY')
}) => { }) => {
const initialCode = `sketch001 = startSketchOn('XZ') const initialCode = `sketch001 = startSketchOn('XZ')
|> circle({ center = [0, 0], radius = 30 }, %) |> circle({ center = [0, 0], radius = 30 }, %)
plane001 = offsetPlane('XZ', 50) plane001 = offsetPlane('XZ', offset = 50)
sketch002 = startSketchOn(plane001) sketch002 = startSketchOn(plane001)
|> circle({ center = [0, 0], radius = 20 }, %) |> circle({ center = [0, 0], radius = 20 }, %)
loft001 = loft([sketch001, sketch002]) loft001 = loft([sketch001, sketch002])
@ -1321,7 +1321,7 @@ loft001 = loft([sketch001, sketch002])
await page.waitForTimeout(1000) await page.waitForTimeout(1000)
await clickOnSketch2() await clickOnSketch2()
await expect(page.locator('.cm-activeLine')).toHaveText(` await expect(page.locator('.cm-activeLine')).toHaveText(`
plane001 = offsetPlane('XZ', 50) plane001 = offsetPlane('XZ', offset = 50)
`) `)
await page.keyboard.press('Backspace') await page.keyboard.press('Backspace')
// Check for sketch 1 // Check for sketch 1

View File

@ -1304,7 +1304,7 @@ test.describe(`Sketching with offset planes`, () => {
await context.addInitScript(() => { await context.addInitScript(() => {
localStorage.setItem( localStorage.setItem(
'persistCode', 'persistCode',
`offsetPlane001 = offsetPlane("XY", 10)` `offsetPlane001 = offsetPlane("XY", offset = 10)`
) )
}) })
@ -1318,9 +1318,9 @@ test.describe(`Sketching with offset planes`, () => {
await test.step(`Hovering should highlight code`, async () => { await test.step(`Hovering should highlight code`, async () => {
await planeHover() await planeHover()
await editor.expectState({ await editor.expectState({
activeLines: [`offsetPlane001=offsetPlane("XY",10)`], activeLines: [`offsetPlane001=offsetPlane("XY",offset=10)`],
diagnostics: [], diagnostics: [],
highlightedCode: 'offsetPlane("XY", 10)', highlightedCode: 'offsetPlane("XY", offset = 10)',
}) })
}) })
@ -1331,7 +1331,7 @@ test.describe(`Sketching with offset planes`, () => {
await expect(toolbar.lineBtn).toBeEnabled() await expect(toolbar.lineBtn).toBeEnabled()
await editor.expectEditor.toContain('startSketchOn(offsetPlane001)') await editor.expectEditor.toContain('startSketchOn(offsetPlane001)')
await editor.expectState({ await editor.expectState({
activeLines: [`offsetPlane001=offsetPlane("XY",10)`], activeLines: [`offsetPlane001=offsetPlane("XY",offset=10)`],
diagnostics: [], diagnostics: [],
highlightedCode: '', highlightedCode: '',
}) })

View File

@ -85,7 +85,7 @@
"fmt": "prettier --write ./src *.ts *.json *.js ./e2e ./packages", "fmt": "prettier --write ./src *.ts *.json *.js ./e2e ./packages",
"fmt-check": "prettier --check ./src *.ts *.json *.js ./e2e ./packages", "fmt-check": "prettier --check ./src *.ts *.json *.js ./e2e ./packages",
"fetch:wasm": "./get-latest-wasm-bundle.sh", "fetch:wasm": "./get-latest-wasm-bundle.sh",
"fetch:samples": "echo \"Fetching latest KCL samples...\" && curl -o public/kcl-samples-manifest-fallback.json https://raw.githubusercontent.com/KittyCAD/kcl-samples/achalmers/kw-pattern-transform2/manifest.json", "fetch:samples": "echo \"Fetching latest KCL samples...\" && curl -o public/kcl-samples-manifest-fallback.json https://raw.githubusercontent.com/KittyCAD/kcl-samples/achalmers/offset-plane-kwargs/manifest.json",
"isomorphic-copy-wasm": "(copy src/wasm-lib/pkg/wasm_lib_bg.wasm public || cp src/wasm-lib/pkg/wasm_lib_bg.wasm public)", "isomorphic-copy-wasm": "(copy src/wasm-lib/pkg/wasm_lib_bg.wasm public || cp src/wasm-lib/pkg/wasm_lib_bg.wasm public)",
"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-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": "yarn wasm-prep && cd src/wasm-lib && wasm-pack build --release --target web --out-dir pkg && cargo test -p kcl-lib export_bindings && cd ../.. && yarn isomorphic-copy-wasm && yarn fmt", "build:wasm": "yarn wasm-prep && cd src/wasm-lib && wasm-pack build --release --target web --out-dir pkg && cargo test -p kcl-lib export_bindings && cd ../.. && yarn isomorphic-copy-wasm && yarn fmt",

View File

@ -32,7 +32,7 @@ child_process.spawnSync('git', [
'clone', 'clone',
'--single-branch', '--single-branch',
'--branch', '--branch',
'achalmers/kw-pattern-transform2', 'achalmers/offset-plane-kwargs',
URL_GIT_KCL_SAMPLES, URL_GIT_KCL_SAMPLES,
DIR_KCL_SAMPLES, DIR_KCL_SAMPLES,
]) ])

View File

@ -33,6 +33,7 @@ import {
traverse, traverse,
ARG_INDEX_FIELD, ARG_INDEX_FIELD,
LABELED_ARG_FIELD, LABELED_ARG_FIELD,
UNLABELED_ARG,
} from './queryAst' } from './queryAst'
import { import {
addTagForSketchOnFace, addTagForSketchOnFace,
@ -656,10 +657,11 @@ export function addOffsetPlane({
const newPlane = createVariableDeclaration( const newPlane = createVariableDeclaration(
newPlaneName, newPlaneName,
createCallExpressionStdLib('offsetPlane', [ createCallExpressionStdLibKw(
'offsetPlane',
createLiteral(defaultPlane.toUpperCase()), createLiteral(defaultPlane.toUpperCase()),
offset, [createLabeledArg('offset', offset)]
]) )
) )
const insertAt = const insertAt =
@ -677,8 +679,7 @@ export function addOffsetPlane({
[insertAt, 'index'], [insertAt, 'index'],
['declaration', 'VariableDeclaration'], ['declaration', 'VariableDeclaration'],
['init', 'VariableDeclarator'], ['init', 'VariableDeclarator'],
['arguments', 'CallExpression'], ['unlabeled', UNLABELED_ARG],
[0, 'index'],
] ]
return { return {
modifiedAst, modifiedAst,

View File

@ -582,7 +582,7 @@ sketch002 = startSketchOn(extrude001, $seg01)
it('finds sketch001 and sketch002 pipes to be lofted', async () => { it('finds sketch001 and sketch002 pipes to be lofted', async () => {
const exampleCode = `sketch001 = startSketchOn('XZ') const exampleCode = `sketch001 = startSketchOn('XZ')
|> circle({ center = [0, 0], radius = 1 }, %) |> circle({ center = [0, 0], radius = 1 }, %)
plane001 = offsetPlane('XZ', 2) plane001 = offsetPlane('XZ', offset = 2)
sketch002 = startSketchOn(plane001) sketch002 = startSketchOn(plane001)
|> circle({ center = [0, 0], radius = 3 }, %) |> circle({ center = [0, 0], radius = 3 }, %)
` `

View File

@ -44,6 +44,7 @@ import { codeRefFromRange } from './std/artifactGraph'
import { KclSettingsAnnotation } from 'lib/settings/settingsTypes' import { KclSettingsAnnotation } from 'lib/settings/settingsTypes'
export const LABELED_ARG_FIELD = 'LabeledArg -> Arg' export const LABELED_ARG_FIELD = 'LabeledArg -> Arg'
export const UNLABELED_ARG = 'unlabeled first arg'
export const ARG_INDEX_FIELD = 'arg index' export const ARG_INDEX_FIELD = 'arg index'
/** /**

View File

@ -126,8 +126,7 @@ const prepareToEditOffsetPlane: PrepareToEditCallback = async ({
if ( if (
operation.type !== 'StdLibCall' || operation.type !== 'StdLibCall' ||
!operation.labeledArgs || !operation.labeledArgs ||
!('std_plane' in operation.labeledArgs) || !operation.unlabeledArg ||
!operation.labeledArgs.std_plane ||
!('offset' in operation.labeledArgs) || !('offset' in operation.labeledArgs) ||
!operation.labeledArgs.offset !operation.labeledArgs.offset
) { ) {
@ -135,11 +134,9 @@ const prepareToEditOffsetPlane: PrepareToEditCallback = async ({
} }
// TODO: Implement conversion to arbitrary plane selection // TODO: Implement conversion to arbitrary plane selection
// once the Offset Plane command supports it. // once the Offset Plane command supports it.
const stdPlane = operation.unlabeledArg
const planeName = codeManager.code const planeName = codeManager.code
.slice( .slice(stdPlane.sourceRange[0], stdPlane.sourceRange[1])
operation.labeledArgs.std_plane.sourceRange[0],
operation.labeledArgs.std_plane.sourceRange[1]
)
.replaceAll(`'`, ``) .replaceAll(`'`, ``)
if (!isDefaultPlaneStr(planeName)) { if (!isDefaultPlaneStr(planeName)) {

View File

@ -456,13 +456,6 @@ impl Args {
FromArgs::from_args(self, 0) FromArgs::from_args(self, 0)
} }
pub(crate) fn get_data_and_float<'a, T>(&'a self) -> Result<(T, f64), KclError>
where
T: serde::de::DeserializeOwned + FromKclValue<'a> + Sized,
{
FromArgs::from_args(self, 0)
}
pub(crate) async fn get_adjacent_face_to_tag( pub(crate) async fn get_adjacent_face_to_tag(
&self, &self,
exec_state: &mut ExecState, exec_state: &mut ExecState,

View File

@ -57,7 +57,7 @@ pub async fn loft(exec_state: &mut ExecState, args: Args) -> Result<KclValue, Kc
/// |> line(endAbsolute = [profileStartX(%), profileStartY(%)]) /// |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
/// |> close() /// |> close()
/// ///
/// triangleSketch = startSketchOn(offsetPlane('XY', 75)) /// triangleSketch = startSketchOn(offsetPlane('XY', offset = 75))
/// |> startProfileAt([0, 125], %) /// |> startProfileAt([0, 125], %)
/// |> line(end = [-15, -30]) /// |> line(end = [-15, -30])
/// |> line(end = [30, 0]) /// |> line(end = [30, 0])
@ -77,10 +77,10 @@ pub async fn loft(exec_state: &mut ExecState, args: Args) -> Result<KclValue, Kc
/// |> line(endAbsolute = [profileStartX(%), profileStartY(%)]) /// |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
/// |> close() /// |> close()
/// ///
/// circleSketch0 = startSketchOn(offsetPlane('XY', 75)) /// circleSketch0 = startSketchOn(offsetPlane('XY', offset = 75))
/// |> circle({ center = [0, 100], radius = 50 }, %) /// |> circle({ center = [0, 100], radius = 50 }, %)
/// ///
/// circleSketch1 = startSketchOn(offsetPlane('XY', 150)) /// circleSketch1 = startSketchOn(offsetPlane('XY', offset = 150))
/// |> circle({ center = [0, 100], radius = 20 }, %) /// |> circle({ center = [0, 100], radius = 20 }, %)
/// ///
/// loft([squareSketch, circleSketch0, circleSketch1]) /// loft([squareSketch, circleSketch0, circleSketch1])
@ -96,10 +96,10 @@ pub async fn loft(exec_state: &mut ExecState, args: Args) -> Result<KclValue, Kc
/// |> line(endAbsolute = [profileStartX(%), profileStartY(%)]) /// |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
/// |> close() /// |> close()
/// ///
/// circleSketch0 = startSketchOn(offsetPlane('XY', 75)) /// circleSketch0 = startSketchOn(offsetPlane('XY', offset = 75))
/// |> circle({ center = [0, 100], radius = 50 }, %) /// |> circle({ center = [0, 100], radius = 50 }, %)
/// ///
/// circleSketch1 = startSketchOn(offsetPlane('XY', 150)) /// circleSketch1 = startSketchOn(offsetPlane('XY', offset = 150))
/// |> circle({ center = [0, 100], radius = 20 }, %) /// |> circle({ center = [0, 100], radius = 20 }, %)
/// ///
/// loft([squareSketch, circleSketch0, circleSketch1], /// loft([squareSketch, circleSketch0, circleSketch1],

View File

@ -52,7 +52,9 @@ impl From<StandardPlane> for PlaneData {
/// Offset a plane by a distance along its normal. /// Offset a plane by a distance along its normal.
pub async fn offset_plane(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> { pub async fn offset_plane(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let (std_plane, offset): (StandardPlane, f64) = args.get_data_and_float()?; // let (std_plane, offset): (StandardPlane, f64) = args.get_data_and_float()?;
let std_plane = args.get_unlabeled_kw_arg("stdPlane")?;
let offset = args.get_kw_arg("offset")?;
let plane = inner_offset_plane(std_plane, offset, exec_state).await?; let plane = inner_offset_plane(std_plane, offset, exec_state).await?;
make_offset_plane_in_engine(&plane, exec_state, &args).await?; make_offset_plane_in_engine(&plane, exec_state, &args).await?;
Ok(KclValue::Plane { value: Box::new(plane) }) Ok(KclValue::Plane { value: Box::new(plane) })
@ -73,7 +75,7 @@ pub async fn offset_plane(exec_state: &mut ExecState, args: Args) -> Result<KclV
/// |> line(endAbsolute = [profileStartX(%), profileStartY(%)]) /// |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
/// |> close() /// |> close()
/// ///
/// circleSketch = startSketchOn(offsetPlane('XY', 150)) /// circleSketch = startSketchOn(offsetPlane('XY', offset = 150))
/// |> circle({ center = [0, 100], radius = 50 }, %) /// |> circle({ center = [0, 100], radius = 50 }, %)
/// ///
/// loft([squareSketch, circleSketch]) /// loft([squareSketch, circleSketch])
@ -89,7 +91,7 @@ pub async fn offset_plane(exec_state: &mut ExecState, args: Args) -> Result<KclV
/// |> line(endAbsolute = [profileStartX(%), profileStartY(%)]) /// |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
/// |> close() /// |> close()
/// ///
/// circleSketch = startSketchOn(offsetPlane('XZ', 150)) /// circleSketch = startSketchOn(offsetPlane('XZ', offset = 150))
/// |> circle({ center = [0, 100], radius = 50 }, %) /// |> circle({ center = [0, 100], radius = 50 }, %)
/// ///
/// loft([squareSketch, circleSketch]) /// loft([squareSketch, circleSketch])
@ -105,7 +107,7 @@ pub async fn offset_plane(exec_state: &mut ExecState, args: Args) -> Result<KclV
/// |> line(endAbsolute = [profileStartX(%), profileStartY(%)]) /// |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
/// |> close() /// |> close()
/// ///
/// circleSketch = startSketchOn(offsetPlane('YZ', 150)) /// circleSketch = startSketchOn(offsetPlane('YZ', offset = 150))
/// |> circle({ center = [0, 100], radius = 50 }, %) /// |> circle({ center = [0, 100], radius = 50 }, %)
/// ///
/// loft([squareSketch, circleSketch]) /// loft([squareSketch, circleSketch])
@ -121,7 +123,7 @@ pub async fn offset_plane(exec_state: &mut ExecState, args: Args) -> Result<KclV
/// |> line(endAbsolute = [profileStartX(%), profileStartY(%)]) /// |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
/// |> close() /// |> close()
/// ///
/// circleSketch = startSketchOn(offsetPlane('-XZ', -150)) /// circleSketch = startSketchOn(offsetPlane('-XZ', offset = -150))
/// |> circle({ center = [0, 100], radius = 50 }, %) /// |> circle({ center = [0, 100], radius = 50 }, %)
/// ///
/// loft([squareSketch, circleSketch]) /// loft([squareSketch, circleSketch])
@ -133,7 +135,7 @@ pub async fn offset_plane(exec_state: &mut ExecState, args: Args) -> Result<KclV
/// |> circle({ radius = 10, center = [0, 0] }, %) /// |> circle({ radius = 10, center = [0, 0] }, %)
/// ///
/// // Triangle on the plane 4 units above /// // Triangle on the plane 4 units above
/// startSketchOn(offsetPlane("XY", 4)) /// startSketchOn(offsetPlane("XY", offset = 4))
/// |> startProfileAt([0, 0], %) /// |> startProfileAt([0, 0], %)
/// |> line(end = [10, 0]) /// |> line(end = [10, 0])
/// |> line(end = [0, 10]) /// |> line(end = [0, 10])
@ -143,6 +145,12 @@ pub async fn offset_plane(exec_state: &mut ExecState, args: Args) -> Result<KclV
#[stdlib { #[stdlib {
name = "offsetPlane", name = "offsetPlane",
feature_tree_operation = true, feature_tree_operation = true,
keywords = true,
unlabeled_first = true,
args = {
std_plane = { docs = "Which standard plane (e.g. XY) should this new plane be created from?" },
offset = { docs = "Distance from the standard plane this new plane will be created at." },
}
}] }]
async fn inner_offset_plane( async fn inner_offset_plane(
std_plane: StandardPlane, std_plane: StandardPlane,

View File

@ -286,7 +286,7 @@ snapshot_kind: text
"cmdId": "[uuid]", "cmdId": "[uuid]",
"range": [ "range": [
17, 17,
38, 47,
0 0
], ],
"command": { "command": {
@ -315,7 +315,7 @@ snapshot_kind: text
"cmdId": "[uuid]", "cmdId": "[uuid]",
"range": [ "range": [
17, 17,
38, 47,
0 0
], ],
"command": { "command": {
@ -332,8 +332,8 @@ snapshot_kind: text
{ {
"cmdId": "[uuid]", "cmdId": "[uuid]",
"range": [ "range": [
56, 65,
78, 96,
0 0
], ],
"command": { "command": {
@ -361,8 +361,8 @@ snapshot_kind: text
{ {
"cmdId": "[uuid]", "cmdId": "[uuid]",
"range": [ "range": [
56, 65,
78, 96,
0 0
], ],
"command": { "command": {
@ -379,8 +379,8 @@ snapshot_kind: text
{ {
"cmdId": "[uuid]", "cmdId": "[uuid]",
"range": [ "range": [
96, 114,
117, 144,
0 0
], ],
"command": { "command": {
@ -408,8 +408,8 @@ snapshot_kind: text
{ {
"cmdId": "[uuid]", "cmdId": "[uuid]",
"range": [ "range": [
96, 114,
117, 144,
0 0
], ],
"command": { "command": {
@ -426,8 +426,8 @@ snapshot_kind: text
{ {
"cmdId": "[uuid]", "cmdId": "[uuid]",
"range": [ "range": [
166, 193,
191, 218,
0 0
], ],
"command": { "command": {
@ -446,8 +446,8 @@ snapshot_kind: text
{ {
"cmdId": "[uuid]", "cmdId": "[uuid]",
"range": [ "range": [
166, 193,
191, 218,
0 0
], ],
"command": { "command": {
@ -457,8 +457,8 @@ snapshot_kind: text
{ {
"cmdId": "[uuid]", "cmdId": "[uuid]",
"range": [ "range": [
166, 193,
191, 218,
0 0
], ],
"command": { "command": {
@ -474,8 +474,8 @@ snapshot_kind: text
{ {
"cmdId": "[uuid]", "cmdId": "[uuid]",
"range": [ "range": [
197, 224,
222, 249,
0 0
], ],
"command": { "command": {
@ -495,8 +495,8 @@ snapshot_kind: text
{ {
"cmdId": "[uuid]", "cmdId": "[uuid]",
"range": [ "range": [
166, 193,
191, 218,
0 0
], ],
"command": { "command": {

View File

@ -1,12 +1,12 @@
```mermaid ```mermaid
flowchart LR flowchart LR
subgraph path4 [Path] subgraph path4 [Path]
4["Path<br>[166, 191, 0]"] 4["Path<br>[193, 218, 0]"]
5["Segment<br>[197, 222, 0]"] 5["Segment<br>[224, 249, 0]"]
end end
1["Plane<br>[17, 38, 0]"] 1["Plane<br>[17, 47, 0]"]
2["Plane<br>[56, 78, 0]"] 2["Plane<br>[65, 96, 0]"]
3["Plane<br>[96, 117, 0]"] 3["Plane<br>[114, 144, 0]"]
1 --- 4 1 --- 4
4 --- 5 4 --- 5
``` ```

View File

@ -1,13 +1,14 @@
--- ---
source: kcl/src/simulation_tests.rs source: kcl/src/simulation_tests.rs
description: Result of parsing artifact_graph_example_code_offset_planes.kcl description: Result of parsing artifact_graph_example_code_offset_planes.kcl
snapshot_kind: text
--- ---
{ {
"Ok": { "Ok": {
"body": [ "body": [
{ {
"declaration": { "declaration": {
"end": 38, "end": 47,
"id": { "id": {
"end": 14, "end": 14,
"name": "offsetPlane001", "name": "offsetPlane001",
@ -17,17 +18,15 @@ description: Result of parsing artifact_graph_example_code_offset_planes.kcl
"init": { "init": {
"arguments": [ "arguments": [
{ {
"end": 33, "type": "LabeledArg",
"raw": "\"XY\"", "label": {
"start": 29, "type": "Identifier",
"type": "Literal", "name": "offset"
"type": "Literal",
"value": "XY"
}, },
{ "arg": {
"end": 37, "end": 46,
"raw": "20", "raw": "20",
"start": 35, "start": 44,
"type": "Literal", "type": "Literal",
"type": "Literal", "type": "Literal",
"value": { "value": {
@ -35,6 +34,7 @@ description: Result of parsing artifact_graph_example_code_offset_planes.kcl
"suffix": "None" "suffix": "None"
} }
} }
}
], ],
"callee": { "callee": {
"end": 28, "end": 28,
@ -42,15 +42,23 @@ description: Result of parsing artifact_graph_example_code_offset_planes.kcl
"start": 17, "start": 17,
"type": "Identifier" "type": "Identifier"
}, },
"end": 38, "end": 47,
"start": 17, "start": 17,
"type": "CallExpression", "type": "CallExpressionKw",
"type": "CallExpression" "type": "CallExpressionKw",
"unlabeled": {
"end": 33,
"raw": "\"XY\"",
"start": 29,
"type": "Literal",
"type": "Literal",
"value": "XY"
}
}, },
"start": 0, "start": 0,
"type": "VariableDeclarator" "type": "VariableDeclarator"
}, },
"end": 38, "end": 47,
"kind": "const", "kind": "const",
"start": 0, "start": 0,
"type": "VariableDeclaration", "type": "VariableDeclaration",
@ -58,28 +66,26 @@ description: Result of parsing artifact_graph_example_code_offset_planes.kcl
}, },
{ {
"declaration": { "declaration": {
"end": 78, "end": 96,
"id": { "id": {
"end": 53, "end": 62,
"name": "offsetPlane002", "name": "offsetPlane002",
"start": 39, "start": 48,
"type": "Identifier" "type": "Identifier"
}, },
"init": { "init": {
"arguments": [ "arguments": [
{ {
"end": 72, "type": "LabeledArg",
"raw": "\"XZ\"", "label": {
"start": 68, "type": "Identifier",
"type": "Literal", "name": "offset"
"type": "Literal",
"value": "XZ"
}, },
{ "arg": {
"argument": { "argument": {
"end": 77, "end": 95,
"raw": "50", "raw": "50",
"start": 75, "start": 93,
"type": "Literal", "type": "Literal",
"type": "Literal", "type": "Literal",
"value": { "value": {
@ -87,56 +93,63 @@ description: Result of parsing artifact_graph_example_code_offset_planes.kcl
"suffix": "None" "suffix": "None"
} }
}, },
"end": 77, "end": 95,
"operator": "-", "operator": "-",
"start": 74, "start": 92,
"type": "UnaryExpression", "type": "UnaryExpression",
"type": "UnaryExpression" "type": "UnaryExpression"
} }
}
], ],
"callee": { "callee": {
"end": 67, "end": 76,
"name": "offsetPlane", "name": "offsetPlane",
"start": 56, "start": 65,
"type": "Identifier" "type": "Identifier"
}, },
"end": 78, "end": 96,
"start": 56, "start": 65,
"type": "CallExpression", "type": "CallExpressionKw",
"type": "CallExpression" "type": "CallExpressionKw",
"unlabeled": {
"end": 81,
"raw": "\"XZ\"",
"start": 77,
"type": "Literal",
"type": "Literal",
"value": "XZ"
}
}, },
"start": 39, "start": 48,
"type": "VariableDeclarator" "type": "VariableDeclarator"
}, },
"end": 78, "end": 96,
"kind": "const", "kind": "const",
"start": 39, "start": 48,
"type": "VariableDeclaration", "type": "VariableDeclaration",
"type": "VariableDeclaration" "type": "VariableDeclaration"
}, },
{ {
"declaration": { "declaration": {
"end": 117, "end": 144,
"id": { "id": {
"end": 93, "end": 111,
"name": "offsetPlane003", "name": "offsetPlane003",
"start": 79, "start": 97,
"type": "Identifier" "type": "Identifier"
}, },
"init": { "init": {
"arguments": [ "arguments": [
{ {
"end": 112, "type": "LabeledArg",
"raw": "\"YZ\"", "label": {
"start": 108, "type": "Identifier",
"type": "Literal", "name": "offset"
"type": "Literal",
"value": "YZ"
}, },
{ "arg": {
"end": 116, "end": 143,
"raw": "10", "raw": "10",
"start": 114, "start": 141,
"type": "Literal", "type": "Literal",
"type": "Literal", "type": "Literal",
"value": { "value": {
@ -144,34 +157,43 @@ description: Result of parsing artifact_graph_example_code_offset_planes.kcl
"suffix": "None" "suffix": "None"
} }
} }
}
], ],
"callee": { "callee": {
"end": 107, "end": 125,
"name": "offsetPlane", "name": "offsetPlane",
"start": 96, "start": 114,
"type": "Identifier" "type": "Identifier"
}, },
"end": 117, "end": 144,
"start": 96, "start": 114,
"type": "CallExpression", "type": "CallExpressionKw",
"type": "CallExpression" "type": "CallExpressionKw",
"unlabeled": {
"end": 130,
"raw": "\"YZ\"",
"start": 126,
"type": "Literal",
"type": "Literal",
"value": "YZ"
}
}, },
"start": 79, "start": 97,
"type": "VariableDeclarator" "type": "VariableDeclarator"
}, },
"end": 117, "end": 144,
"kind": "const", "kind": "const",
"start": 79, "start": 97,
"type": "VariableDeclaration", "type": "VariableDeclaration",
"type": "VariableDeclaration" "type": "VariableDeclaration"
}, },
{ {
"declaration": { "declaration": {
"end": 222, "end": 249,
"id": { "id": {
"end": 128, "end": 155,
"name": "sketch002", "name": "sketch002",
"start": 119, "start": 146,
"type": "Identifier" "type": "Identifier"
}, },
"init": { "init": {
@ -179,21 +201,21 @@ description: Result of parsing artifact_graph_example_code_offset_planes.kcl
{ {
"arguments": [ "arguments": [
{ {
"end": 159, "end": 186,
"name": "offsetPlane001", "name": "offsetPlane001",
"start": 145, "start": 172,
"type": "Identifier", "type": "Identifier",
"type": "Identifier" "type": "Identifier"
} }
], ],
"callee": { "callee": {
"end": 144, "end": 171,
"name": "startSketchOn", "name": "startSketchOn",
"start": 131, "start": 158,
"type": "Identifier" "type": "Identifier"
}, },
"end": 160, "end": 187,
"start": 131, "start": 158,
"type": "CallExpression", "type": "CallExpression",
"type": "CallExpression" "type": "CallExpression"
}, },
@ -202,9 +224,9 @@ description: Result of parsing artifact_graph_example_code_offset_planes.kcl
{ {
"elements": [ "elements": [
{ {
"end": 183, "end": 210,
"raw": "0", "raw": "0",
"start": 182, "start": 209,
"type": "Literal", "type": "Literal",
"type": "Literal", "type": "Literal",
"value": { "value": {
@ -213,9 +235,9 @@ description: Result of parsing artifact_graph_example_code_offset_planes.kcl
} }
}, },
{ {
"end": 186, "end": 213,
"raw": "0", "raw": "0",
"start": 185, "start": 212,
"type": "Literal", "type": "Literal",
"type": "Literal", "type": "Literal",
"value": { "value": {
@ -224,26 +246,26 @@ description: Result of parsing artifact_graph_example_code_offset_planes.kcl
} }
} }
], ],
"end": 187, "end": 214,
"start": 181, "start": 208,
"type": "ArrayExpression", "type": "ArrayExpression",
"type": "ArrayExpression" "type": "ArrayExpression"
}, },
{ {
"end": 190, "end": 217,
"start": 189, "start": 216,
"type": "PipeSubstitution", "type": "PipeSubstitution",
"type": "PipeSubstitution" "type": "PipeSubstitution"
} }
], ],
"callee": { "callee": {
"end": 180, "end": 207,
"name": "startProfileAt", "name": "startProfileAt",
"start": 166, "start": 193,
"type": "Identifier" "type": "Identifier"
}, },
"end": 191, "end": 218,
"start": 166, "start": 193,
"type": "CallExpression", "type": "CallExpression",
"type": "CallExpression" "type": "CallExpression"
}, },
@ -258,9 +280,9 @@ description: Result of parsing artifact_graph_example_code_offset_planes.kcl
"arg": { "arg": {
"elements": [ "elements": [
{ {
"end": 213, "end": 240,
"raw": "6.78", "raw": "6.78",
"start": 209, "start": 236,
"type": "Literal", "type": "Literal",
"type": "Literal", "type": "Literal",
"value": { "value": {
@ -269,9 +291,9 @@ description: Result of parsing artifact_graph_example_code_offset_planes.kcl
} }
}, },
{ {
"end": 220, "end": 247,
"raw": "15.01", "raw": "15.01",
"start": 215, "start": 242,
"type": "Literal", "type": "Literal",
"type": "Literal", "type": "Literal",
"value": { "value": {
@ -280,48 +302,48 @@ description: Result of parsing artifact_graph_example_code_offset_planes.kcl
} }
} }
], ],
"end": 221, "end": 248,
"start": 208, "start": 235,
"type": "ArrayExpression", "type": "ArrayExpression",
"type": "ArrayExpression" "type": "ArrayExpression"
} }
} }
], ],
"callee": { "callee": {
"end": 201, "end": 228,
"name": "line", "name": "line",
"start": 197, "start": 224,
"type": "Identifier" "type": "Identifier"
}, },
"end": 222, "end": 249,
"start": 197, "start": 224,
"type": "CallExpressionKw", "type": "CallExpressionKw",
"type": "CallExpressionKw", "type": "CallExpressionKw",
"unlabeled": null "unlabeled": null
} }
], ],
"end": 222, "end": 249,
"start": 131, "start": 158,
"type": "PipeExpression", "type": "PipeExpression",
"type": "PipeExpression" "type": "PipeExpression"
}, },
"start": 119, "start": 146,
"type": "VariableDeclarator" "type": "VariableDeclarator"
}, },
"end": 222, "end": 249,
"kind": "const", "kind": "const",
"start": 119, "start": 146,
"type": "VariableDeclaration", "type": "VariableDeclaration",
"type": "VariableDeclaration" "type": "VariableDeclaration"
} }
], ],
"end": 223, "end": 250,
"nonCodeMeta": { "nonCodeMeta": {
"nonCodeNodes": { "nonCodeNodes": {
"2": [ "2": [
{ {
"end": 119, "end": 146,
"start": 117, "start": 144,
"type": "NonCodeNode", "type": "NonCodeNode",
"value": { "value": {
"type": "newLine" "type": "newLine"

View File

@ -1,6 +1,6 @@
offsetPlane001 = offsetPlane("XY", 20) offsetPlane001 = offsetPlane("XY", offset = 20)
offsetPlane002 = offsetPlane("XZ", -50) offsetPlane002 = offsetPlane("XZ", offset = -50)
offsetPlane003 = offsetPlane("YZ", 10) offsetPlane003 = offsetPlane("YZ", offset = 10)
sketch002 = startSketchOn(offsetPlane001) sketch002 = startSketchOn(offsetPlane001)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)

View File

@ -8,15 +8,8 @@ snapshot_kind: text
"labeledArgs": { "labeledArgs": {
"offset": { "offset": {
"sourceRange": [ "sourceRange": [
35, 44,
37, 46,
0
]
},
"std_plane": {
"sourceRange": [
29,
33,
0 0
] ]
} }
@ -24,78 +17,82 @@ snapshot_kind: text
"name": "offsetPlane", "name": "offsetPlane",
"sourceRange": [ "sourceRange": [
17, 17,
38, 47,
0 0
], ],
"type": "StdLibCall", "type": "StdLibCall",
"unlabeledArg": null "unlabeledArg": {
"sourceRange": [
29,
33,
0
]
}
}, },
{ {
"labeledArgs": { "labeledArgs": {
"offset": { "offset": {
"sourceRange": [ "sourceRange": [
74, 92,
77, 95,
0
]
},
"std_plane": {
"sourceRange": [
68,
72,
0 0
] ]
} }
}, },
"name": "offsetPlane", "name": "offsetPlane",
"sourceRange": [ "sourceRange": [
56, 65,
78, 96,
0 0
], ],
"type": "StdLibCall", "type": "StdLibCall",
"unlabeledArg": null "unlabeledArg": {
"sourceRange": [
77,
81,
0
]
}
}, },
{ {
"labeledArgs": { "labeledArgs": {
"offset": { "offset": {
"sourceRange": [
141,
143,
0
]
}
},
"name": "offsetPlane",
"sourceRange": [ "sourceRange": [
114, 114,
116, 144,
0
]
},
"std_plane": {
"sourceRange": [
108,
112,
0
]
}
},
"name": "offsetPlane",
"sourceRange": [
96,
117,
0 0
], ],
"type": "StdLibCall", "type": "StdLibCall",
"unlabeledArg": null "unlabeledArg": {
"sourceRange": [
126,
130,
0
]
}
}, },
{ {
"labeledArgs": { "labeledArgs": {
"data": { "data": {
"sourceRange": [ "sourceRange": [
145, 172,
159, 186,
0 0
] ]
} }
}, },
"name": "startSketchOn", "name": "startSketchOn",
"sourceRange": [ "sourceRange": [
131, 158,
160, 187,
0 0
], ],
"type": "StdLibCall", "type": "StdLibCall",

View File

@ -1,6 +1,7 @@
--- ---
source: kcl/src/simulation_tests.rs source: kcl/src/simulation_tests.rs
description: Variables in memory after executing artifact_graph_example_code_offset_planes.kcl description: Variables in memory after executing artifact_graph_example_code_offset_planes.kcl
snapshot_kind: text
--- ---
{ {
"HALF_TURN": { "HALF_TURN": {
@ -129,8 +130,8 @@ description: Variables in memory after executing artifact_graph_example_code_off
"__geoMeta": { "__geoMeta": {
"id": "[uuid]", "id": "[uuid]",
"sourceRange": [ "sourceRange": [
197, 224,
222, 249,
0 0
] ]
}, },
@ -189,8 +190,8 @@ description: Variables in memory after executing artifact_graph_example_code_off
"__geoMeta": { "__geoMeta": {
"id": "[uuid]", "id": "[uuid]",
"sourceRange": [ "sourceRange": [
166, 193,
191, 218,
0 0
] ]
} }
@ -203,8 +204,8 @@ description: Variables in memory after executing artifact_graph_example_code_off
"__meta": [ "__meta": [
{ {
"sourceRange": [ "sourceRange": [
166, 193,
191, 218,
0 0
] ]
} }