KCL: User-defined KCL functions in examples etc now use keywords (#6603)
Preparing for the removal of positional functions from the language. The first big step is to change all our KCL code examples, test code, public samples etc to all use keyword functions. Apologies for how large this PR is. Most of it is: - Changing example KCL that defined its own functions, so the functions now use keyword arguments rather than positional arguments. E.g. change `cube([20, 20])` to be `cube(center = [20, 20])`. - Some parts of the code assumed positional code and didn't handle keyword calls, e.g. the linter would only check for positional calls to startSketchOn. Now they should work with either positional or keyword. - Update all the artifacts This does _not_ remove support for positional calls. That will be in a follow-up PR.
This commit is contained in:
@ -72,9 +72,9 @@ fn cube(center) {
|
||||
|> extrude(length = 10)
|
||||
}
|
||||
|
||||
example0 = cube([0, 0])
|
||||
example1 = cube([20, 0])
|
||||
example2 = cube([40, 0])
|
||||
example0 = cube(center = [0, 0])
|
||||
example1 = cube(center = [20, 0])
|
||||
example2 = cube(center = [40, 0])
|
||||
|
||||
appearance(
|
||||
[example0, example1],
|
||||
|
@ -76,7 +76,7 @@ sg = startSketchOn(XY)
|
||||
return sg
|
||||
}
|
||||
|
||||
part001 = cube([0,0], 20)
|
||||
part001 = cube(pos = [0,0], scale = 20)
|
||||
|> close(tag = $line1)
|
||||
|> extrude(length = 20)
|
||||
// We tag the chamfer to reference it later.
|
||||
|
@ -44,8 +44,8 @@ fn cube(center, size) {
|
||||
|> extrude(length = 10)
|
||||
}
|
||||
|
||||
part001 = cube([0, 0], 10)
|
||||
part002 = cube([7, 3], 5)
|
||||
part001 = cube(center = [0, 0], size = 10)
|
||||
part002 = cube(center = [7, 3], size = 5)
|
||||
|> translate(z = 1)
|
||||
|
||||
intersectedPart = intersect([part001, part002])
|
||||
@ -69,8 +69,8 @@ fn cube(center, size) {
|
||||
|> extrude(length = 10)
|
||||
}
|
||||
|
||||
part001 = cube([0, 0], 10)
|
||||
part002 = cube([7, 3], 5)
|
||||
part001 = cube(center = [0, 0], size = 10)
|
||||
part002 = cube(center = [7, 3], size = 5)
|
||||
|> translate(z = 1)
|
||||
|
||||
// This is the equivalent of: intersect([part001, part002])
|
||||
|
@ -32,7 +32,7 @@ map(
|
||||
|
||||
```kcl
|
||||
r = 10 // radius
|
||||
fn drawCircle(id) {
|
||||
fn drawCircle(@id) {
|
||||
return startSketchOn(XY)
|
||||
|> circle(center = [id * 2 * r, 0], radius = r)
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ to other modules.
|
||||
|
||||
```kcl
|
||||
// util.kcl
|
||||
export fn increment(x) {
|
||||
export fn increment(@x) {
|
||||
return x + 1
|
||||
}
|
||||
```
|
||||
@ -37,11 +37,11 @@ Multiple functions can be exported in a file.
|
||||
|
||||
```kcl
|
||||
// util.kcl
|
||||
export fn increment(x) {
|
||||
export fn increment(@x) {
|
||||
return x + 1
|
||||
}
|
||||
|
||||
export fn decrement(x) {
|
||||
export fn decrement(@x) {
|
||||
return x - 1
|
||||
}
|
||||
```
|
||||
@ -81,7 +81,7 @@ fn cube(center) {
|
||||
|> extrude(length = 10)
|
||||
}
|
||||
|
||||
myCube = cube([0, 0])
|
||||
myCube = cube(center = [0, 0])
|
||||
```
|
||||
|
||||
*Pros*
|
||||
|
File diff suppressed because one or more lines are too long
@ -36,7 +36,7 @@ patternTransform2d(
|
||||
|
||||
```kcl
|
||||
// Each instance will be shifted along the X axis.
|
||||
fn transform(id) {
|
||||
fn transform(@id) {
|
||||
return { translate = [4 * id, 0] }
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ fn add(a, b) {
|
||||
// This function adds an array of numbers.
|
||||
// It uses the `reduce` function, to call the `add` function on every
|
||||
// element of the `arr` parameter. The starting value is 0.
|
||||
fn sum(arr) {
|
||||
fn sum(@arr) {
|
||||
return reduce(arr, initial = 0, f = add)
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ assert(
|
||||
|
||||
```kcl
|
||||
// Declare a function that sketches a decagon.
|
||||
fn decagon(radius) {
|
||||
fn decagon(@radius) {
|
||||
// Each side of the decagon is turned this many radians from the previous angle.
|
||||
stepAngle = (1 / 10 * TAU): number(rad)
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -32507,7 +32507,7 @@
|
||||
"examples": [
|
||||
"// Add color to an extruded solid.\nexampleSketch = startSketchOn(XZ)\n |> startProfile(at = [0, 0])\n |> line(endAbsolute = [10, 0])\n |> line(endAbsolute = [0, 10])\n |> line(endAbsolute = [-10, 0])\n |> close()\n\nexample = extrude(exampleSketch, length = 5)\n // There are other options besides 'color', but they're optional.\n |> appearance(color = '#ff0000')",
|
||||
"// Add color to a revolved solid.\nsketch001 = startSketchOn(XY)\n |> circle(center = [15, 0], radius = 5)\n |> revolve(angle = 360, axis = Y)\n |> appearance(color = '#ff0000', metalness = 90, roughness = 90)",
|
||||
"// Add color to different solids.\nfn cube(center) {\n return startSketchOn(XY)\n |> startProfile(at = [center[0] - 10, center[1] - 10])\n |> line(endAbsolute = [center[0] + 10, center[1] - 10])\n |> line(endAbsolute = [center[0] + 10, center[1] + 10])\n |> line(endAbsolute = [center[0] - 10, center[1] + 10])\n |> close()\n |> extrude(length = 10)\n}\n\nexample0 = cube([0, 0])\nexample1 = cube([20, 0])\nexample2 = cube([40, 0])\n\nappearance(\n [example0, example1],\n color = '#ff0000',\n metalness = 50,\n roughness = 50,\n)\nappearance(\n example2,\n color = '#00ff00',\n metalness = 50,\n roughness = 50,\n)",
|
||||
"// Add color to different solids.\nfn cube(center) {\n return startSketchOn(XY)\n |> startProfile(at = [center[0] - 10, center[1] - 10])\n |> line(endAbsolute = [center[0] + 10, center[1] - 10])\n |> line(endAbsolute = [center[0] + 10, center[1] + 10])\n |> line(endAbsolute = [center[0] - 10, center[1] + 10])\n |> close()\n |> extrude(length = 10)\n}\n\nexample0 = cube(center = [0, 0])\nexample1 = cube(center = [20, 0])\nexample2 = cube(center = [40, 0])\n\nappearance(\n [example0, example1],\n color = '#ff0000',\n metalness = 50,\n roughness = 50,\n)\nappearance(\n example2,\n color = '#00ff00',\n metalness = 50,\n roughness = 50,\n)",
|
||||
"// You can set the appearance before or after you shell it will yield the same result.\n// This example shows setting the appearance _after_ the shell.\nfirstSketch = startSketchOn(XY)\n |> startProfile(at = [-12, 12])\n |> line(end = [24, 0])\n |> line(end = [0, -24])\n |> line(end = [-24, 0])\n |> close()\n |> extrude(length = 6)\n\nshell(firstSketch, faces = [END], thickness = 0.25)\n |> appearance(color = '#ff0000', metalness = 90, roughness = 90)",
|
||||
"// You can set the appearance before or after you shell it will yield the same result.\n// This example shows setting the appearance _before_ the shell.\nfirstSketch = startSketchOn(XY)\n |> startProfile(at = [-12, 12])\n |> line(end = [24, 0])\n |> line(end = [0, -24])\n |> line(end = [-24, 0])\n |> close()\n |> extrude(length = 6)\n |> appearance(color = '#ff0000', metalness = 90, roughness = 90)\n\nshell(firstSketch, faces = [END], thickness = 0.25)",
|
||||
"// Setting the appearance of a 3D pattern can be done _before_ or _after_ the pattern.\n// This example shows _before_ the pattern.\nexampleSketch = startSketchOn(XZ)\n |> startProfile(at = [0, 0])\n |> line(end = [0, 2])\n |> line(end = [3, 1])\n |> line(end = [0, -4])\n |> close()\n\nexample = extrude(exampleSketch, length = 1)\n |> appearance(color = '#ff0000', metalness = 90, roughness = 90)\n |> patternLinear3d(axis = [1, 0, 1], instances = 7, distance = 6)",
|
||||
@ -90118,8 +90118,8 @@
|
||||
"unpublished": false,
|
||||
"deprecated": false,
|
||||
"examples": [
|
||||
"// Intersect two cubes using the stdlib functions.\n\n\nfn cube(center, size) {\n return startSketchOn(XY)\n |> startProfile(at = [center[0] - size, center[1] - size])\n |> line(endAbsolute = [center[0] + size, center[1] - size])\n |> line(endAbsolute = [center[0] + size, center[1] + size])\n |> line(endAbsolute = [center[0] - size, center[1] + size])\n |> close()\n |> extrude(length = 10)\n}\n\npart001 = cube([0, 0], 10)\npart002 = cube([7, 3], 5)\n |> translate(z = 1)\n\nintersectedPart = intersect([part001, part002])",
|
||||
"// Intersect two cubes using operators.\n// NOTE: This will not work when using codemods through the UI.\n// Codemods will generate the stdlib function call instead.\n\n\nfn cube(center, size) {\n return startSketchOn(XY)\n |> startProfile(at = [center[0] - size, center[1] - size])\n |> line(endAbsolute = [center[0] + size, center[1] - size])\n |> line(endAbsolute = [center[0] + size, center[1] + size])\n |> line(endAbsolute = [center[0] - size, center[1] + size])\n |> close()\n |> extrude(length = 10)\n}\n\npart001 = cube([0, 0], 10)\npart002 = cube([7, 3], 5)\n |> translate(z = 1)\n\n// This is the equivalent of: intersect([part001, part002])\nintersectedPart = part001 & part002"
|
||||
"// Intersect two cubes using the stdlib functions.\n\n\nfn cube(center, size) {\n return startSketchOn(XY)\n |> startProfile(at = [center[0] - size, center[1] - size])\n |> line(endAbsolute = [center[0] + size, center[1] - size])\n |> line(endAbsolute = [center[0] + size, center[1] + size])\n |> line(endAbsolute = [center[0] - size, center[1] + size])\n |> close()\n |> extrude(length = 10)\n}\n\npart001 = cube(center = [0, 0], size = 10)\npart002 = cube(center = [7, 3], size = 5)\n |> translate(z = 1)\n\nintersectedPart = intersect([part001, part002])",
|
||||
"// Intersect two cubes using operators.\n// NOTE: This will not work when using codemods through the UI.\n// Codemods will generate the stdlib function call instead.\n\n\nfn cube(center, size) {\n return startSketchOn(XY)\n |> startProfile(at = [center[0] - size, center[1] - size])\n |> line(endAbsolute = [center[0] + size, center[1] - size])\n |> line(endAbsolute = [center[0] + size, center[1] + size])\n |> line(endAbsolute = [center[0] - size, center[1] + size])\n |> close()\n |> extrude(length = 10)\n}\n\npart001 = cube(center = [0, 0], size = 10)\npart002 = cube(center = [7, 3], size = 5)\n |> translate(z = 1)\n\n// This is the equivalent of: intersect([part001, part002])\nintersectedPart = part001 & part002"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -133614,7 +133614,7 @@
|
||||
"unpublished": false,
|
||||
"deprecated": false,
|
||||
"examples": [
|
||||
"r = 10 // radius\nfn drawCircle(id) {\n return startSketchOn(XY)\n |> circle(center = [id * 2 * r, 0], radius = r)\n}\n\n// Call `drawCircle`, passing in each element of the array.\n// The outputs from each `drawCircle` form a new array,\n// which is the return value from `map`.\ncircles = map([1..3], f = drawCircle)",
|
||||
"r = 10 // radius\nfn drawCircle(@id) {\n return startSketchOn(XY)\n |> circle(center = [id * 2 * r, 0], radius = r)\n}\n\n// Call `drawCircle`, passing in each element of the array.\n// The outputs from each `drawCircle` form a new array,\n// which is the return value from `map`.\ncircles = map([1..3], f = drawCircle)",
|
||||
"r = 10 // radius\n// Call `map`, using an anonymous function instead of a named one.\ncircles = map(\n [1..3],\n f = fn(id) {\n return startSketchOn(XY)\n |> circle(center = [id * 2 * r, 0], radius = r)\n },\n)"
|
||||
]
|
||||
},
|
||||
@ -185080,12 +185080,12 @@
|
||||
"unpublished": false,
|
||||
"deprecated": false,
|
||||
"examples": [
|
||||
"// Each instance will be shifted along the X axis.\nfn transform(id) {\n return { translate = [4 * id, 0, 0] }\n}\n\n// Sketch 4 cylinders.\nsketch001 = startSketchOn(XZ)\n |> circle(center = [0, 0], radius = 2)\n |> extrude(length = 5)\n |> patternTransform(instances = 4, transform = transform)",
|
||||
"// Each instance will be shifted along the X axis,\n// with a gap between the original (at x = 0) and the first replica\n// (at x = 8). This is because `id` starts at 1.\nfn transform(id) {\n return { translate = [4 * (1 + id), 0, 0] }\n}\n\nsketch001 = startSketchOn(XZ)\n |> circle(center = [0, 0], radius = 2)\n |> extrude(length = 5)\n |> patternTransform(instances = 4, transform = transform)",
|
||||
"fn cube(length, center) {\n l = length / 2\n x = center[0]\n y = center[1]\n p0 = [-l + x, -l + y]\n p1 = [-l + x, l + y]\n p2 = [l + x, l + y]\n p3 = [l + x, -l + y]\n\n return startSketchOn(XY)\n |> startProfile(at = p0)\n |> line(endAbsolute = p1)\n |> line(endAbsolute = p2)\n |> line(endAbsolute = p3)\n |> line(endAbsolute = p0)\n |> close()\n |> extrude(length = length)\n}\n\nwidth = 20\nfn transform(i) {\n return {\n // Move down each time.\n translate = [0, 0, -i * width],\n // Make the cube longer, wider and flatter each time.\n scale = [\n pow(1.1, exp = i),\n pow(1.1, exp = i),\n pow(0.9, exp = i)\n ],\n // Turn by 15 degrees each time.\n rotation = { angle = 15 * i, origin = \"local\" }\n }\n}\n\nmyCubes = cube(width, [100, 0])\n |> patternTransform(instances = 25, transform = transform)",
|
||||
"fn cube(length, center) {\n l = length / 2\n x = center[0]\n y = center[1]\n p0 = [-l + x, -l + y]\n p1 = [-l + x, l + y]\n p2 = [l + x, l + y]\n p3 = [l + x, -l + y]\n\n return startSketchOn(XY)\n |> startProfile(at = p0)\n |> line(endAbsolute = p1)\n |> line(endAbsolute = p2)\n |> line(endAbsolute = p3)\n |> line(endAbsolute = p0)\n |> close()\n |> extrude(length = length)\n}\n\nwidth = 20\nfn transform(i) {\n return {\n translate = [0, 0, -i * width],\n rotation = {\n angle = 90 * i,\n // Rotate around the overall scene's origin.\n origin = \"global\"\n }\n }\n}\nmyCubes = cube(width, [100, 100])\n |> patternTransform(instances = 4, transform = transform)",
|
||||
"// Parameters\nr = 50 // base radius\nh = 10 // layer height\nt = 0.005 // taper factor [0-1)\n// Defines how to modify each layer of the vase.\n// Each replica is shifted up the Z axis, and has a smoothly-varying radius\nfn transform(replicaId) {\n scale = r * abs(1 - (t * replicaId)) * (5 + cos((replicaId / 8): number(rad)))\n return {\n translate = [0, 0, replicaId * 10],\n scale = [scale, scale, 0]\n }\n}\n// Each layer is just a pretty thin cylinder.\nfn layer() {\n return startSketchOn(XY)\n // or some other plane idk\n |> circle(center = [0, 0], radius = 1, tag = $tag1)\n |> extrude(length = h)\n}\n// The vase is 100 layers tall.\n// The 100 layers are replica of each other, with a slight transformation applied to each.\nvase = layer()\n |> patternTransform(instances = 100, transform = transform)",
|
||||
"fn transform(i) {\n // Transform functions can return multiple transforms. They'll be applied in order.\n return [\n { translate = [30 * i, 0, 0] },\n { rotation = { angle = 45 * i } }\n ]\n}\nstartSketchOn(XY)\n |> startProfile(at = [0, 0])\n |> polygon(\n radius = 10,\n numSides = 4,\n center = [0, 0],\n inscribed = false,\n )\n |> extrude(length = 4)\n |> patternTransform(instances = 3, transform = transform)"
|
||||
"// Each instance will be shifted along the X axis.\nfn transform(@id) {\n return { translate = [4 * id, 0, 0] }\n}\n\n// Sketch 4 cylinders.\nsketch001 = startSketchOn(XZ)\n |> circle(center = [0, 0], radius = 2)\n |> extrude(length = 5)\n |> patternTransform(instances = 4, transform = transform)",
|
||||
"// Each instance will be shifted along the X axis,\n// with a gap between the original (at x = 0) and the first replica\n// (at x = 8). This is because `id` starts at 1.\nfn transform(@id) {\n return { translate = [4 * (1 + id), 0, 0] }\n}\n\nsketch001 = startSketchOn(XZ)\n |> circle(center = [0, 0], radius = 2)\n |> extrude(length = 5)\n |> patternTransform(instances = 4, transform = transform)",
|
||||
"fn cube(length, center) {\n l = length / 2\n x = center[0]\n y = center[1]\n p0 = [-l + x, -l + y]\n p1 = [-l + x, l + y]\n p2 = [l + x, l + y]\n p3 = [l + x, -l + y]\n\n return startSketchOn(XY)\n |> startProfile(at = p0)\n |> line(endAbsolute = p1)\n |> line(endAbsolute = p2)\n |> line(endAbsolute = p3)\n |> line(endAbsolute = p0)\n |> close()\n |> extrude(length = length)\n}\n\nwidth = 20\nfn transform(@i) {\n return {\n // Move down each time.\n translate = [0, 0, -i * width],\n // Make the cube longer, wider and flatter each time.\n scale = [\n pow(1.1, exp = i),\n pow(1.1, exp = i),\n pow(0.9, exp = i)\n ],\n // Turn by 15 degrees each time.\n rotation = { angle = 15 * i, origin = \"local\" }\n }\n}\n\nmyCubes = cube(length = width, center = [100, 0])\n |> patternTransform(instances = 25, transform = transform)",
|
||||
"fn cube(length, center) {\n l = length / 2\n x = center[0]\n y = center[1]\n p0 = [-l + x, -l + y]\n p1 = [-l + x, l + y]\n p2 = [l + x, l + y]\n p3 = [l + x, -l + y]\n\n return startSketchOn(XY)\n |> startProfile(at = p0)\n |> line(endAbsolute = p1)\n |> line(endAbsolute = p2)\n |> line(endAbsolute = p3)\n |> line(endAbsolute = p0)\n |> close()\n |> extrude(length = length)\n}\n\nwidth = 20\nfn transform(@i) {\n return {\n translate = [0, 0, -i * width],\n rotation = {\n angle = 90 * i,\n // Rotate around the overall scene's origin.\n origin = \"global\"\n }\n }\n}\nmyCubes = cube(length = width, center = [100, 100])\n |> patternTransform(instances = 4, transform = transform)",
|
||||
"// Parameters\nr = 50 // base radius\nh = 10 // layer height\nt = 0.005 // taper factor [0-1)\n// Defines how to modify each layer of the vase.\n// Each replica is shifted up the Z axis, and has a smoothly-varying radius\nfn transform(@replicaId) {\n scale = r * abs(1 - (t * replicaId)) * (5 + cos((replicaId / 8): number(rad)))\n return {\n translate = [0, 0, replicaId * 10],\n scale = [scale, scale, 0]\n }\n}\n// Each layer is just a pretty thin cylinder.\nfn layer() {\n return startSketchOn(XY)\n // or some other plane idk\n |> circle(center = [0, 0], radius = 1, tag = $tag1)\n |> extrude(length = h)\n}\n// The vase is 100 layers tall.\n// The 100 layers are replica of each other, with a slight transformation applied to each.\nvase = layer()\n |> patternTransform(instances = 100, transform = transform)",
|
||||
"fn transform(@i) {\n // Transform functions can return multiple transforms. They'll be applied in order.\n return [\n { translate = [30 * i, 0, 0] },\n { rotation = { angle = 45 * i } }\n ]\n}\nstartSketchOn(XY)\n |> startProfile(at = [0, 0])\n |> polygon(\n radius = 10,\n numSides = 4,\n center = [0, 0],\n inscribed = false,\n )\n |> extrude(length = 4)\n |> patternTransform(instances = 3, transform = transform)"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -193126,7 +193126,7 @@
|
||||
"unpublished": false,
|
||||
"deprecated": false,
|
||||
"examples": [
|
||||
"// Each instance will be shifted along the X axis.\nfn transform(id) {\n return { translate = [4 * id, 0] }\n}\n\n// Sketch 4 circles.\nsketch001 = startSketchOn(XZ)\n |> circle(center = [0, 0], radius = 2)\n |> patternTransform2d(instances = 4, transform = transform)"
|
||||
"// Each instance will be shifted along the X axis.\nfn transform(@id) {\n return { translate = [4 * id, 0] }\n}\n\n// Sketch 4 circles.\nsketch001 = startSketchOn(XZ)\n |> circle(center = [0, 0], radius = 2)\n |> patternTransform2d(instances = 4, transform = transform)"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -232205,9 +232205,9 @@
|
||||
"unpublished": false,
|
||||
"deprecated": false,
|
||||
"examples": [
|
||||
"// This function adds two numbers.\nfn add(a, b) {\n return a + b\n}\n\n// This function adds an array of numbers.\n// It uses the `reduce` function, to call the `add` function on every\n// element of the `arr` parameter. The starting value is 0.\nfn sum(arr) {\n return reduce(arr, initial = 0, f = add)\n}\n\n/* The above is basically like this pseudo-code:\nfn sum(arr):\n sumSoFar = 0\n for i in arr:\n sumSoFar = add(sumSoFar, i)\n return sumSoFar */\n\n// We use `assert` to check that our `sum` function gives the\n// expected result. It's good to check your work!\nassert(\n sum([1, 2, 3]),\n isEqualTo = 6,\n tolerance = 0.1,\n error = \"1 + 2 + 3 summed is 6\",\n)",
|
||||
"// This function adds two numbers.\nfn add(a, b) {\n return a + b\n}\n\n// This function adds an array of numbers.\n// It uses the `reduce` function, to call the `add` function on every\n// element of the `arr` parameter. The starting value is 0.\nfn sum(@arr) {\n return reduce(arr, initial = 0, f = add)\n}\n\n/* The above is basically like this pseudo-code:\nfn sum(arr):\n sumSoFar = 0\n for i in arr:\n sumSoFar = add(sumSoFar, i)\n return sumSoFar */\n\n// We use `assert` to check that our `sum` function gives the\n// expected result. It's good to check your work!\nassert(\n sum([1, 2, 3]),\n isEqualTo = 6,\n tolerance = 0.1,\n error = \"1 + 2 + 3 summed is 6\",\n)",
|
||||
"// This example works just like the previous example above, but it uses\n// an anonymous `add` function as its parameter, instead of declaring a\n// named function outside.\narr = [1, 2, 3]\nsum = reduce(\n arr,\n initial = 0,\n f = fn(i, result_so_far) {\n return i + result_so_far\n },\n)\n\n// We use `assert` to check that our `sum` function gives the\n// expected result. It's good to check your work!\nassert(\n sum,\n isEqualTo = 6,\n tolerance = 0.1,\n error = \"1 + 2 + 3 summed is 6\",\n)",
|
||||
"// Declare a function that sketches a decagon.\nfn decagon(radius) {\n // Each side of the decagon is turned this many radians from the previous angle.\n stepAngle = (1 / 10 * TAU): number(rad)\n\n // Start the decagon sketch at this point.\n startOfDecagonSketch = startSketchOn(XY)\n |> startProfile(at = [cos(0) * radius, sin(0) * radius])\n\n // Use a `reduce` to draw the remaining decagon sides.\n // For each number in the array 1..10, run the given function,\n // which takes a partially-sketched decagon and adds one more edge to it.\n fullDecagon = reduce(\n [1..10],\n initial = startOfDecagonSketch,\n f = fn(i, partialDecagon) {\n // Draw one edge of the decagon.\n x = cos(stepAngle * i) * radius\n y = sin(stepAngle * i) * radius\n return line(partialDecagon, end = [x, y])\n },\n )\n\n return fullDecagon\n}\n\n/* The `decagon` above is basically like this pseudo-code:\nfn decagon(radius):\n stepAngle = ((1/10) * TAU): number(rad)\n plane = startSketchOn(XY)\n startOfDecagonSketch = startProfile(plane, at = [(cos(0)*radius), (sin(0) * radius)])\n\n // Here's the reduce part.\n partialDecagon = startOfDecagonSketch\n for i in [1..10]:\n x = cos(stepAngle * i) * radius\n y = sin(stepAngle * i) * radius\n partialDecagon = line(partialDecagon, end = [x, y])\n fullDecagon = partialDecagon // it's now full\n return fullDecagon */\n\n// Use the `decagon` function declared above, to sketch a decagon with radius 5.\ndecagon(5.0)\n |> close()"
|
||||
"// Declare a function that sketches a decagon.\nfn decagon(@radius) {\n // Each side of the decagon is turned this many radians from the previous angle.\n stepAngle = (1 / 10 * TAU): number(rad)\n\n // Start the decagon sketch at this point.\n startOfDecagonSketch = startSketchOn(XY)\n |> startProfile(at = [cos(0) * radius, sin(0) * radius])\n\n // Use a `reduce` to draw the remaining decagon sides.\n // For each number in the array 1..10, run the given function,\n // which takes a partially-sketched decagon and adds one more edge to it.\n fullDecagon = reduce(\n [1..10],\n initial = startOfDecagonSketch,\n f = fn(i, partialDecagon) {\n // Draw one edge of the decagon.\n x = cos(stepAngle * i) * radius\n y = sin(stepAngle * i) * radius\n return line(partialDecagon, end = [x, y])\n },\n )\n\n return fullDecagon\n}\n\n/* The `decagon` above is basically like this pseudo-code:\nfn decagon(radius):\n stepAngle = ((1/10) * TAU): number(rad)\n plane = startSketchOn(XY)\n startOfDecagonSketch = startProfile(plane, at = [(cos(0)*radius), (sin(0) * radius)])\n\n // Here's the reduce part.\n partialDecagon = startOfDecagonSketch\n for i in [1..10]:\n x = cos(stepAngle * i) * radius\n y = sin(stepAngle * i) * radius\n partialDecagon = line(partialDecagon, end = [x, y])\n fullDecagon = partialDecagon // it's now full\n return fullDecagon */\n\n// Use the `decagon` function declared above, to sketch a decagon with radius 5.\ndecagon(5.0)\n |> close()"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -255105,7 +255105,7 @@
|
||||
"unpublished": false,
|
||||
"deprecated": false,
|
||||
"examples": [
|
||||
"w = 15\ncube = startSketchOn(XY)\n |> startProfile(at = [0, 0])\n |> line(end = [w, 0], tag = $line1)\n |> line(end = [0, w], tag = $line2)\n |> line(end = [-w, 0], tag = $line3)\n |> line(end = [0, -w], tag = $line4)\n |> close()\n |> extrude(length = 5)\n\nfn cylinder(radius, tag) {\n return startSketchOn(XY)\n |> startProfile(at = [0, 0])\n |> circle(radius = radius, center = segEnd(tag))\n |> extrude(length = radius)\n}\n\ncylinder(1, line1)\ncylinder(2, line2)\ncylinder(3, line3)\ncylinder(4, line4)"
|
||||
"w = 15\ncube = startSketchOn(XY)\n |> startProfile(at = [0, 0])\n |> line(end = [w, 0], tag = $line1)\n |> line(end = [0, w], tag = $line2)\n |> line(end = [-w, 0], tag = $line3)\n |> line(end = [0, -w], tag = $line4)\n |> close()\n |> extrude(length = 5)\n\nfn cylinder(radius, tag) {\n return startSketchOn(XY)\n |> startProfile(at = [0, 0])\n |> circle(radius = radius, center = segEnd(tag))\n |> extrude(length = radius)\n}\n\ncylinder(radius = 1, tag = line1)\ncylinder(radius = 2, tag = line2)\ncylinder(radius = 3, tag = line3)\ncylinder(radius = 4, tag = line4)"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -255307,7 +255307,7 @@
|
||||
"unpublished": false,
|
||||
"deprecated": false,
|
||||
"examples": [
|
||||
"w = 15\ncube = startSketchOn(XY)\n |> startProfile(at = [0, 0])\n |> line(end = [w, 0], tag = $line1)\n |> line(end = [0, w], tag = $line2)\n |> line(end = [-w, 0], tag = $line3)\n |> line(end = [0, -w], tag = $line4)\n |> close()\n |> extrude(length = 5)\n\nfn cylinder(radius, tag) {\n return startSketchOn(XY)\n |> startProfile(at = [0, 0])\n |> circle(radius = radius, center = segStart(tag))\n |> extrude(length = radius)\n}\n\ncylinder(1, line1)\ncylinder(2, line2)\ncylinder(3, line3)\ncylinder(4, line4)"
|
||||
"w = 15\ncube = startSketchOn(XY)\n |> startProfile(at = [0, 0])\n |> line(end = [w, 0], tag = $line1)\n |> line(end = [0, w], tag = $line2)\n |> line(end = [-w, 0], tag = $line3)\n |> line(end = [0, -w], tag = $line4)\n |> close()\n |> extrude(length = 5)\n\nfn cylinder(radius, tag) {\n return startSketchOn(XY)\n |> startProfile(at = [0, 0])\n |> circle(radius = radius, center = segStart(tag))\n |> extrude(length = radius)\n}\n\ncylinder(radius = 1, tag = line1)\ncylinder(radius = 2, tag = line2)\ncylinder(radius = 3, tag = line3)\ncylinder(radius = 4, tag = line4)"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -273775,8 +273775,8 @@
|
||||
"unpublished": false,
|
||||
"deprecated": false,
|
||||
"examples": [
|
||||
"// Subtract a cylinder from a cube using the stdlib functions.\n\n\nfn cube(center, size) {\n return startSketchOn(XY)\n |> startProfile(at = [center[0] - size, center[1] - size])\n |> line(endAbsolute = [center[0] + size, center[1] - size])\n |> line(endAbsolute = [center[0] + size, center[1] + size])\n |> line(endAbsolute = [center[0] - size, center[1] + size])\n |> close()\n |> extrude(length = 10)\n}\n\npart001 = cube([0, 0], 10)\npart002 = cube([7, 3], 5)\n |> translate(z = 1)\n\nsubtractedPart = subtract([part001], tools = [part002])",
|
||||
"// Subtract a cylinder from a cube using operators.\n// NOTE: This will not work when using codemods through the UI.\n// Codemods will generate the stdlib function call instead.\n\n\nfn cube(center, size) {\n return startSketchOn(XY)\n |> startProfile(at = [center[0] - size, center[1] - size])\n |> line(endAbsolute = [center[0] + size, center[1] - size])\n |> line(endAbsolute = [center[0] + size, center[1] + size])\n |> line(endAbsolute = [center[0] - size, center[1] + size])\n |> close()\n |> extrude(length = 10)\n}\n\npart001 = cube([0, 0], 10)\npart002 = cube([7, 3], 5)\n |> translate(z = 1)\n\n// This is the equivalent of: subtract([part001], tools=[part002])\nsubtractedPart = part001 - part002"
|
||||
"// Subtract a cylinder from a cube using the stdlib functions.\n\n\nfn cube(center, size) {\n return startSketchOn(XY)\n |> startProfile(at = [center[0] - size, center[1] - size])\n |> line(endAbsolute = [center[0] + size, center[1] - size])\n |> line(endAbsolute = [center[0] + size, center[1] + size])\n |> line(endAbsolute = [center[0] - size, center[1] + size])\n |> close()\n |> extrude(length = 10)\n}\n\npart001 = cube(center = [0, 0], size = 10)\npart002 = cube(center = [7, 3], size = 5)\n |> translate(z = 1)\n\nsubtractedPart = subtract([part001], tools = [part002])",
|
||||
"// Subtract a cylinder from a cube using operators.\n// NOTE: This will not work when using codemods through the UI.\n// Codemods will generate the stdlib function call instead.\n\n\nfn cube(center, size) {\n return startSketchOn(XY)\n |> startProfile(at = [center[0] - size, center[1] - size])\n |> line(endAbsolute = [center[0] + size, center[1] - size])\n |> line(endAbsolute = [center[0] + size, center[1] + size])\n |> line(endAbsolute = [center[0] - size, center[1] + size])\n |> close()\n |> extrude(length = 10)\n}\n\npart001 = cube(center = [0, 0], size = 10)\npart002 = cube(center = [7, 3], size = 5)\n |> translate(z = 1)\n\n// This is the equivalent of: subtract([part001], tools=[part002])\nsubtractedPart = part001 - part002"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -311484,7 +311484,7 @@
|
||||
"// Move a pipe.\n\n// Create a path for the sweep.\nsweepPath = startSketchOn(XZ)\n |> startProfile(at = [0.05, 0.05])\n |> line(end = [0, 7])\n |> tangentialArc(angle = 90, radius = 5)\n |> line(end = [-3, 0])\n |> tangentialArc(angle = -90, radius = 5)\n |> line(end = [0, 7])\n\n// Create a hole for the pipe.\npipeHole = startSketchOn(XY)\n |> circle(center = [0, 0], radius = 1.5)\n\nsweepSketch = startSketchOn(XY)\n |> circle(center = [0, 0], radius = 2)\n |> subtract2d(tool = pipeHole)\n |> sweep(path = sweepPath)\n |> translate(x = 1.0, y = 1.0, z = 2.5)",
|
||||
"// Move an imported model.\n\n\nimport \"tests/inputs/cube.sldprt\" as cube\n\n// Circle so you actually see the move.\nstartSketchOn(XY)\n |> circle(center = [-10, -10], radius = 10)\n |> extrude(length = 10)\n\ncube\n |> translate(x = 10.0, y = 10.0, z = 2.5)",
|
||||
"// Sweep two sketches along the same path.\n\n\nsketch001 = startSketchOn(XY)\nrectangleSketch = startProfile(sketch001, at = [-200, 23.86])\n |> angledLine(angle = 0, length = 73.47, tag = $rectangleSegmentA001)\n |> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 50.61)\n |> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001))\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n\ncircleSketch = circle(sketch001, center = [200, -30.29], radius = 32.63)\n\nsketch002 = startSketchOn(YZ)\nsweepPath = startProfile(sketch002, at = [0, 0])\n |> yLine(length = 231.81)\n |> tangentialArc(radius = 80, angle = -90)\n |> xLine(length = 384.93)\n\nparts = sweep([rectangleSketch, circleSketch], path = sweepPath)\n\n// Move the sweeps.\ntranslate(\n parts,\n x = 1.0,\n y = 1.0,\n z = 2.5,\n)",
|
||||
"// Move a sketch.\n\n\nfn square(length) {\n l = length / 2\n p0 = [-l, -l]\n p1 = [-l, l]\n p2 = [l, l]\n p3 = [l, -l]\n\n return startSketchOn(XY)\n |> startProfile(at = p0)\n |> line(endAbsolute = p1)\n |> line(endAbsolute = p2)\n |> line(endAbsolute = p3)\n |> close()\n}\n\nsquare(10)\n |> translate(x = 5, y = 5)\n |> extrude(length = 10)",
|
||||
"// Move a sketch.\n\n\nfn square(@length) {\n l = length / 2\n p0 = [-l, -l]\n p1 = [-l, l]\n p2 = [l, l]\n p3 = [l, -l]\n\n return startSketchOn(XY)\n |> startProfile(at = p0)\n |> line(endAbsolute = p1)\n |> line(endAbsolute = p2)\n |> line(endAbsolute = p3)\n |> close()\n}\n\nsquare(10)\n |> translate(x = 5, y = 5)\n |> extrude(length = 10)",
|
||||
"// Translate and rotate a sketch to create a loft.\nsketch001 = startSketchOn(XY)\n\nfn square() {\n return startProfile(sketch001, at = [-10, 10])\n |> xLine(length = 20)\n |> yLine(length = -20)\n |> xLine(length = -20)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n}\n\nprofile001 = square()\n\nprofile002 = square()\n |> translate(z = 20)\n |> rotate(axis = [0, 0, 1.0], angle = 45)\n\nloft([profile001, profile002])"
|
||||
]
|
||||
},
|
||||
@ -316320,9 +316320,9 @@
|
||||
"unpublished": false,
|
||||
"deprecated": false,
|
||||
"examples": [
|
||||
"// Union two cubes using the stdlib functions.\n\n\nfn cube(center, size) {\n return startSketchOn(XY)\n |> startProfile(at = [center[0] - size, center[1] - size])\n |> line(endAbsolute = [center[0] + size, center[1] - size])\n |> line(endAbsolute = [center[0] + size, center[1] + size])\n |> line(endAbsolute = [center[0] - size, center[1] + size])\n |> close()\n |> extrude(length = 10)\n}\n\npart001 = cube([0, 0], 10)\npart002 = cube([7, 3], 5)\n |> translate(z = 1)\n\nunionedPart = union([part001, part002])",
|
||||
"// Union two cubes using operators.\n// NOTE: This will not work when using codemods through the UI.\n// Codemods will generate the stdlib function call instead.\n\n\nfn cube(center, size) {\n return startSketchOn(XY)\n |> startProfile(at = [center[0] - size, center[1] - size])\n |> line(endAbsolute = [center[0] + size, center[1] - size])\n |> line(endAbsolute = [center[0] + size, center[1] + size])\n |> line(endAbsolute = [center[0] - size, center[1] + size])\n |> close()\n |> extrude(length = 10)\n}\n\npart001 = cube([0, 0], 10)\npart002 = cube([7, 3], 5)\n |> translate(z = 1)\n\n// This is the equivalent of: union([part001, part002])\nunionedPart = part001 + part002",
|
||||
"// Union two cubes using the more programmer-friendly operator.\n// NOTE: This will not work when using codemods through the UI.\n// Codemods will generate the stdlib function call instead.\n\n\nfn cube(center, size) {\n return startSketchOn(XY)\n |> startProfile(at = [center[0] - size, center[1] - size])\n |> line(endAbsolute = [center[0] + size, center[1] - size])\n |> line(endAbsolute = [center[0] + size, center[1] + size])\n |> line(endAbsolute = [center[0] - size, center[1] + size])\n |> close()\n |> extrude(length = 10)\n}\n\npart001 = cube([0, 0], 10)\npart002 = cube([7, 3], 5)\n |> translate(z = 1)\n\n // This is the equivalent of: union([part001, part002])\n // Programmers will understand `|` as a union operation, but mechanical engineers\n// will understand `+`, we made both work.\nunionedPart = part001 | part002"
|
||||
"// Union two cubes using the stdlib functions.\n\n\nfn cube(center, size) {\n return startSketchOn(XY)\n |> startProfile(at = [center[0] - size, center[1] - size])\n |> line(endAbsolute = [center[0] + size, center[1] - size])\n |> line(endAbsolute = [center[0] + size, center[1] + size])\n |> line(endAbsolute = [center[0] - size, center[1] + size])\n |> close()\n |> extrude(length = 10)\n}\n\npart001 = cube(center = [0, 0], size = 10)\npart002 = cube(center = [7, 3], size = 5)\n |> translate(z = 1)\n\nunionedPart = union([part001, part002])",
|
||||
"// Union two cubes using operators.\n// NOTE: This will not work when using codemods through the UI.\n// Codemods will generate the stdlib function call instead.\n\n\nfn cube(center, size) {\n return startSketchOn(XY)\n |> startProfile(at = [center[0] - size, center[1] - size])\n |> line(endAbsolute = [center[0] + size, center[1] - size])\n |> line(endAbsolute = [center[0] + size, center[1] + size])\n |> line(endAbsolute = [center[0] - size, center[1] + size])\n |> close()\n |> extrude(length = 10)\n}\n\npart001 = cube(center = [0, 0], size = 10)\npart002 = cube(center = [7, 3], size = 5)\n |> translate(z = 1)\n\n// This is the equivalent of: union([part001, part002])\nunionedPart = part001 + part002",
|
||||
"// Union two cubes using the more programmer-friendly operator.\n// NOTE: This will not work when using codemods through the UI.\n// Codemods will generate the stdlib function call instead.\n\n\nfn cube(center, size) {\n return startSketchOn(XY)\n |> startProfile(at = [center[0] - size, center[1] - size])\n |> line(endAbsolute = [center[0] + size, center[1] - size])\n |> line(endAbsolute = [center[0] + size, center[1] + size])\n |> line(endAbsolute = [center[0] - size, center[1] + size])\n |> close()\n |> extrude(length = 10)\n}\n\npart001 = cube(center = [0, 0], size = 10)\npart002 = cube(center = [7, 3], size = 5)\n |> translate(z = 1)\n\n // This is the equivalent of: union([part001, part002])\n // Programmers will understand `|` as a union operation, but mechanical engineers\n// will understand `+`, we made both work.\nunionedPart = part001 | part002"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -46,8 +46,8 @@ fn cube(center, size) {
|
||||
|> extrude(length = 10)
|
||||
}
|
||||
|
||||
part001 = cube([0, 0], 10)
|
||||
part002 = cube([7, 3], 5)
|
||||
part001 = cube(center = [0, 0], size = 10)
|
||||
part002 = cube(center = [7, 3], size = 5)
|
||||
|> translate(z = 1)
|
||||
|
||||
subtractedPart = subtract([part001], tools = [part002])
|
||||
@ -71,8 +71,8 @@ fn cube(center, size) {
|
||||
|> extrude(length = 10)
|
||||
}
|
||||
|
||||
part001 = cube([0, 0], 10)
|
||||
part002 = cube([7, 3], 5)
|
||||
part001 = cube(center = [0, 0], size = 10)
|
||||
part002 = cube(center = [7, 3], size = 5)
|
||||
|> translate(z = 1)
|
||||
|
||||
// This is the equivalent of: subtract([part001], tools=[part002])
|
||||
|
@ -117,7 +117,7 @@ translate(
|
||||
// Move a sketch.
|
||||
|
||||
|
||||
fn square(length) {
|
||||
fn square(@length) {
|
||||
l = length / 2
|
||||
p0 = [-l, -l]
|
||||
p1 = [-l, l]
|
||||
|
@ -249,8 +249,8 @@ fn rect(origin) {
|
||||
|> close()
|
||||
}
|
||||
|
||||
rect([0, 0])
|
||||
rect([20, 0])
|
||||
rect(origin = [0, 0])
|
||||
rect(origin = [20, 0])
|
||||
```
|
||||
|
||||
Those tags would only be available in the `rect` function and not globally.
|
||||
@ -279,8 +279,8 @@ fn rect(origin) {
|
||||
|> close()
|
||||
}
|
||||
|
||||
rect([0, 0])
|
||||
myRect = rect([20, 0])
|
||||
rect(origin = [0, 0])
|
||||
myRect = rect(origin = [20, 0])
|
||||
|
||||
myRect
|
||||
|> extrude(length = 10)
|
||||
|
@ -62,8 +62,8 @@ fn rect(origin) {
|
||||
|> close()
|
||||
}
|
||||
|
||||
rect([0, 0])
|
||||
rect([20, 0])
|
||||
rect(origin = [0, 0])
|
||||
rect(origin = [20, 0])
|
||||
```
|
||||
|
||||
Those tags would only be available in the `rect` function and not globally.
|
||||
@ -90,8 +90,8 @@ fn rect(origin) {
|
||||
|> close()
|
||||
}
|
||||
|
||||
rect([0, 0])
|
||||
myRect = rect([20, 0])
|
||||
rect(origin = [0, 0])
|
||||
myRect = rect(origin = [20, 0])
|
||||
|
||||
myRect
|
||||
|> extrude(length = 10)
|
||||
|
@ -44,8 +44,8 @@ fn cube(center, size) {
|
||||
|> extrude(length = 10)
|
||||
}
|
||||
|
||||
part001 = cube([0, 0], 10)
|
||||
part002 = cube([7, 3], 5)
|
||||
part001 = cube(center = [0, 0], size = 10)
|
||||
part002 = cube(center = [7, 3], size = 5)
|
||||
|> translate(z = 1)
|
||||
|
||||
unionedPart = union([part001, part002])
|
||||
@ -69,8 +69,8 @@ fn cube(center, size) {
|
||||
|> extrude(length = 10)
|
||||
}
|
||||
|
||||
part001 = cube([0, 0], 10)
|
||||
part002 = cube([7, 3], 5)
|
||||
part001 = cube(center = [0, 0], size = 10)
|
||||
part002 = cube(center = [7, 3], size = 5)
|
||||
|> translate(z = 1)
|
||||
|
||||
// This is the equivalent of: union([part001, part002])
|
||||
@ -95,8 +95,8 @@ fn cube(center, size) {
|
||||
|> extrude(length = 10)
|
||||
}
|
||||
|
||||
part001 = cube([0, 0], 10)
|
||||
part002 = cube([7, 3], 5)
|
||||
part001 = cube(center = [0, 0], size = 10)
|
||||
part002 = cube(center = [7, 3], size = 5)
|
||||
|> translate(z = 1)
|
||||
|
||||
// This is the equivalent of: union([part001, part002])
|
||||
|
@ -139,4 +139,4 @@ fn rail8020(originStart, railHeight, railLength) {
|
||||
}
|
||||
|
||||
// Generate one adjustable rail of 80/20
|
||||
rail8020([0, 0], 1.5, 48)
|
||||
rail8020(originStart = [0, 0], railHeight = 1.5, railLength = 48)
|
||||
|
@ -72,14 +72,14 @@ fn fanBlade(offsetHeight, startAngle: number(deg)) {
|
||||
}
|
||||
|
||||
// Loft the fan blade cross sections into a single blade, then pattern them about the fan center
|
||||
loft([
|
||||
fanBlade(4.5, 50),
|
||||
fanBlade((fanHeight - 2 - 4) / 2, 30),
|
||||
fanBlade(fanHeight - 2, 0)
|
||||
])
|
||||
crossSections = [
|
||||
fanBlade(offsetHeight = 4.5, startAngle = 50),
|
||||
fanBlade(offsetHeight = (fanHeight - 2 - 4) / 2, startAngle = 30),
|
||||
fanBlade(offsetHeight = fanHeight - 2, startAngle = 0)
|
||||
]
|
||||
loft(crossSections)
|
||||
|> appearance(color = "#f3e2d8")
|
||||
|> patternCircular3d(
|
||||
%,
|
||||
instances = 9,
|
||||
axis = [0, 0, 1],
|
||||
center = [0, 0, 0],
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
export dividerThickness = 4
|
||||
|
||||
fn dividerSketch(plane) {
|
||||
fn dividerSketch(@plane) {
|
||||
sketch000 = startSketchOn(plane)
|
||||
|> startProfile(at = [-16.82, 21.2])
|
||||
|> line(end = [-0.13, -1.27])
|
||||
@ -33,7 +33,7 @@ fn dividerSketch(plane) {
|
||||
return sketch000
|
||||
}
|
||||
|
||||
export fn divider(plane) {
|
||||
export fn divider(@plane) {
|
||||
right = dividerSketch(plane)
|
||||
|> extrude(length = dividerThickness / 2)
|
||||
left = dividerSketch(plane)
|
||||
@ -43,7 +43,7 @@ export fn divider(plane) {
|
||||
return 0
|
||||
}
|
||||
|
||||
fn connectorSketch(plane, start) {
|
||||
fn connectorSketch(@plane, start) {
|
||||
sketch001 = startSketchOn(plane)
|
||||
|> startProfile(at = start)
|
||||
|> polygon(
|
||||
@ -55,15 +55,15 @@ fn connectorSketch(plane, start) {
|
||||
return sketch001
|
||||
}
|
||||
|
||||
export fn connector(plane, length) {
|
||||
connectorSketch(plane, [-12, 8])
|
||||
export fn connector(@plane, length) {
|
||||
connectorSketch(plane, start = [-12, 8])
|
||||
|> extrude(length = length)
|
||||
connectorSketch(plane, [16, 8])
|
||||
connectorSketch(plane, start = [16, 8])
|
||||
|> extrude(length = length)
|
||||
return 0
|
||||
}
|
||||
|
||||
fn seatSlatSketch(plane) {
|
||||
fn seatSlatSketch(@plane) {
|
||||
sketch003 = startSketchOn(plane)
|
||||
|> startProfile(at = [-7, 19])
|
||||
|> line(end = [-10, 0.5])
|
||||
@ -77,13 +77,13 @@ fn seatSlatSketch(plane) {
|
||||
return sketch003
|
||||
}
|
||||
|
||||
export fn seatSlats(plane, length) {
|
||||
export fn seatSlats(@plane, length) {
|
||||
seatSlatSketch(plane)
|
||||
|> extrude(length = length)
|
||||
return 0
|
||||
}
|
||||
|
||||
fn backSlatsSketch(plane) {
|
||||
fn backSlatsSketch(@plane) {
|
||||
sketch004 = startSketchOn(plane)
|
||||
|> startProfile(at = [22, 38.5])
|
||||
|> angledLine(angle = 173, length = 2)
|
||||
@ -97,13 +97,13 @@ fn backSlatsSketch(plane) {
|
||||
return sketch004
|
||||
}
|
||||
|
||||
export fn backSlats(plane, length) {
|
||||
export fn backSlats(@plane, length) {
|
||||
b = backSlatsSketch(plane)
|
||||
|> extrude(length = length)
|
||||
return b
|
||||
}
|
||||
|
||||
fn armRestPath(plane) {
|
||||
fn armRestPath(@plane) {
|
||||
sketch005 = startSketchOn(plane)
|
||||
|> startProfile(at = [20, 33])
|
||||
|> xLine(length = -20)
|
||||
@ -111,7 +111,7 @@ fn armRestPath(plane) {
|
||||
return sketch005
|
||||
}
|
||||
|
||||
fn armRestProfile(plane, offset) {
|
||||
fn armRestProfile(@plane, offset) {
|
||||
sketch006 = startSketchOn(plane)
|
||||
|> startProfile(at = [offset, 32.4])
|
||||
|> xLine(length = 1.3)
|
||||
@ -124,9 +124,9 @@ fn armRestProfile(plane, offset) {
|
||||
return sketch006
|
||||
}
|
||||
|
||||
export fn armRest(plane, offset) {
|
||||
export fn armRest(@plane, offset) {
|
||||
path = armRestPath( offsetPlane(plane, offset = offset))
|
||||
profile = armRestProfile( offsetPlane(-XZ, offset = 20), -offset)
|
||||
profile = armRestProfile( offsetPlane(-XZ, offset = 20), offset = -offset)
|
||||
sweep(profile, path = path)
|
||||
return 0
|
||||
}
|
||||
|
@ -21,14 +21,14 @@ divider(offsetPlane(YZ, offset = benchLength / 2))
|
||||
divider(offsetPlane(YZ, offset = -benchLength / 2))
|
||||
|
||||
// Create the connectors to join the dividers
|
||||
connector(offsetPlane(YZ, offset = -benchLength / 2), benchLength)
|
||||
connector(offsetPlane(YZ, offset = -benchLength / 2), length = benchLength)
|
||||
|
||||
// Create the seat slats
|
||||
seatSlats(offsetPlane(YZ, offset = -benchLength / 2 - (dividerThickness / 2)), benchLength + dividerThickness)
|
||||
seatSlats(offsetPlane(YZ, offset = -benchLength / 2 - (dividerThickness / 2)), length = benchLength + dividerThickness)
|
||||
|
||||
// Create the back slats
|
||||
backSlats(offsetPlane(YZ, offset = -benchLength / 2 - (dividerThickness / 2)), benchLength + dividerThickness)
|
||||
backSlats(offsetPlane(YZ, offset = -benchLength / 2 - (dividerThickness / 2)), length = benchLength + dividerThickness)
|
||||
|
||||
// Create the arm rests
|
||||
armRest(YZ, benchLength / 2)
|
||||
armRest(YZ, -benchLength / 2)
|
||||
armRest(YZ, offset = benchLength / 2)
|
||||
armRest(YZ, offset = -benchLength / 2)
|
||||
|
@ -121,8 +121,8 @@ fn spoke(spokeGap, spokeAngle, spokeThickness) {
|
||||
return spokePattern
|
||||
}
|
||||
|
||||
spoke(spokeGap, spokeAngle, spokeThickness)
|
||||
spoke(-spokeGap, -spokeAngle, -spokeThickness)
|
||||
spoke(spokeGap = spokeGap, spokeAngle = spokeAngle, spokeThickness = spokeThickness)
|
||||
spoke(spokeGap = -spokeGap, spokeAngle = -spokeAngle, spokeThickness = -spokeThickness)
|
||||
|
||||
// Define and revolve wheel exterior
|
||||
startSketchOn(XY)
|
||||
|
@ -31,4 +31,4 @@ fn lug(plane, length, diameter) {
|
||||
return lugSketch
|
||||
}
|
||||
|
||||
lugNut = lug(customPlane, lugLength, lugDiameter)
|
||||
lugNut = lug(plane = customPlane, length = lugLength, diameter = lugDiameter)
|
||||
|
@ -33,9 +33,9 @@ fn sketchRectangle(profile, color) {
|
||||
}
|
||||
|
||||
// Sketch each side of the cube
|
||||
sketchRectangle(bluePlane, '#0000FF')
|
||||
sketchRectangle(yellowPlane, '#FFFF00')
|
||||
sketchRectangle(greenPlane, '#00FF00')
|
||||
sketchRectangle(redPlane, '#FF0000')
|
||||
sketchRectangle(tealPlane, '#00FFFF')
|
||||
sketchRectangle(purplePlane, '#FF00FF')
|
||||
sketchRectangle(profile = bluePlane, color = '#0000FF')
|
||||
sketchRectangle(profile = yellowPlane, color = '#FFFF00')
|
||||
sketchRectangle(profile = greenPlane, color = '#00FF00')
|
||||
sketchRectangle(profile = redPlane, color = '#FF0000')
|
||||
sketchRectangle(profile = tealPlane, color = '#00FFFF')
|
||||
sketchRectangle(profile = purplePlane, color = '#FF00FF')
|
||||
|
@ -7,7 +7,7 @@
|
||||
// Create a function for the cycloidal gear
|
||||
fn cycloidalGear(gearPitch, gearHeight, holeDiameter, helixAngle: number(deg)) {
|
||||
// Create a function to draw the gear profile as a sketch. Rotate each profile about the gear's axis by an helix angle proportional to the total gear height
|
||||
fn gearSketch(gHeight) {
|
||||
fn gearSketch(@gHeight) {
|
||||
helixAngleP = helixAngle * gHeight / gearHeight
|
||||
gearProfile = startSketchOn(offsetPlane(XY, offset = gHeight))
|
||||
|> startProfile(at = [
|
||||
@ -36,4 +36,9 @@ fn cycloidalGear(gearPitch, gearHeight, holeDiameter, helixAngle: number(deg)) {
|
||||
}
|
||||
|
||||
// Call the cycloidal gear function
|
||||
cycloidalGear(.3, 1.5, 0.297, -80)
|
||||
cycloidalGear(
|
||||
gearPitch = .3,
|
||||
gearHeight = 1.5,
|
||||
holeDiameter = 0.297,
|
||||
helixAngle = -80,
|
||||
)
|
||||
|
@ -8,7 +8,7 @@
|
||||
dihedral = 116.565
|
||||
|
||||
// Create a face template function that makes a large thin cube
|
||||
fn createFaceTemplate(dither) {
|
||||
fn createFaceTemplate(@dither) {
|
||||
baseSketch = startSketchOn(XY)
|
||||
|> startProfile(at = [-1000 - dither, -1000 - dither])
|
||||
|> line(endAbsolute = [1000 + dither, -1000 - dither])
|
||||
@ -62,7 +62,7 @@ dodecFaces = map(
|
||||
},
|
||||
)
|
||||
|
||||
fn calculateArrayLength(arr) {
|
||||
fn calculateArrayLength(@arr) {
|
||||
return reduce(
|
||||
arr,
|
||||
initial = 0,
|
||||
@ -72,7 +72,7 @@ fn calculateArrayLength(arr) {
|
||||
)
|
||||
}
|
||||
|
||||
fn createIntersection(solids) {
|
||||
fn createIntersection(@solids) {
|
||||
fn reduceIntersect(previous, current) {
|
||||
return intersect([previous, current])
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ extrude001 = extrude(sketch001, length = height)
|
||||
|> shell(faces = [END], thickness = wallThickness)
|
||||
|
||||
// Define a function to create the internal structure to secure a fastener at each corner
|
||||
fn function001(originStart) {
|
||||
fn function001(@originStart) {
|
||||
// Create a plane to sketch on shell interior
|
||||
plane001 = {
|
||||
origin = [0.0, 0.0, wallThickness],
|
||||
|
@ -42,10 +42,34 @@ fn primaryTube(n, angle001, length001, length002, length003) {
|
||||
}
|
||||
|
||||
// Draw a primary tube for each cylinder with specified lengths and angles
|
||||
primaryTube(0, 0, 3, 6, 5)
|
||||
primaryTube(1, 1, 3, 6, 5)
|
||||
primaryTube(2, 24.3, 5, 5, 3)
|
||||
primaryTube(3, 25.2, 5, 5, 3)
|
||||
primaryTube(
|
||||
n = 0,
|
||||
angle001 = 0,
|
||||
length001 = 3,
|
||||
length002 = 6,
|
||||
length003 = 5,
|
||||
)
|
||||
primaryTube(
|
||||
n = 1,
|
||||
angle001 = 1,
|
||||
length001 = 3,
|
||||
length002 = 6,
|
||||
length003 = 5,
|
||||
)
|
||||
primaryTube(
|
||||
n = 2,
|
||||
angle001 = 24.3,
|
||||
length001 = 5,
|
||||
length002 = 5,
|
||||
length003 = 3,
|
||||
)
|
||||
primaryTube(
|
||||
n = 3,
|
||||
angle001 = 25.2,
|
||||
length001 = 5,
|
||||
length002 = 5,
|
||||
length003 = 3,
|
||||
)
|
||||
|
||||
// Create the mounting flange for the header
|
||||
flangeSketch = startSketchOn(XY)
|
||||
|
@ -15,17 +15,6 @@ tabLength = 25
|
||||
tabWidth = 12
|
||||
tabThk = 4
|
||||
|
||||
// Define a rectangular shape func
|
||||
fn rectShape(pos, w, l) {
|
||||
rr = startSketchOn(XY)
|
||||
|> startProfile(at = [pos[0] - (w / 2), pos[1] - (l / 2)])
|
||||
|> line(endAbsolute = [pos[0] + w / 2, pos[1] - (l / 2)], tag = $edge01)
|
||||
|> line(endAbsolute = [pos[0] + w / 2, pos[1] + l / 2], tag = $edge02)
|
||||
|> line(endAbsolute = [pos[0] - (w / 2), pos[1] + l / 2], tag = $edge03)
|
||||
|> close(tag = $edge04)
|
||||
return rr
|
||||
}
|
||||
|
||||
// Define the bracket plane
|
||||
bracketPlane = {
|
||||
origin = { x = 0, y = length / 2 + thk, z = 0 },
|
||||
@ -50,7 +39,7 @@ fn bracketSketch(w, d, t) {
|
||||
}
|
||||
|
||||
// Build the body of the bracket
|
||||
bs = bracketSketch(width, depth, thk)
|
||||
bs = bracketSketch(w = width, d = depth, t = thk)
|
||||
bracketBody = bs
|
||||
|> extrude(length = length + 2 * thk)
|
||||
|> fillet(
|
||||
|
@ -55,13 +55,28 @@ flipperProfile = startProfile(flipperSketch, at = [-flipperLength, -32.0])
|
||||
|> close()
|
||||
|
||||
// Create a profile of the middle
|
||||
slotProfile000 = slot(flipperSketch, [-25, 0], [-55, 0], flipperSlotWidth)
|
||||
slotProfile000 = slot(
|
||||
sketch1 = flipperSketch,
|
||||
start = [-25, 0],
|
||||
end = [-55, 0],
|
||||
width = flipperSlotWidth,
|
||||
)
|
||||
|
||||
// Create a profile of the top slot
|
||||
slotProfile001 = slot(flipperSketch, [-25, 18], [-55, 19], flipperSlotWidth)
|
||||
slotProfile001 = slot(
|
||||
sketch1 = flipperSketch,
|
||||
start = [-25, 18],
|
||||
end = [-55, 19],
|
||||
width = flipperSlotWidth,
|
||||
)
|
||||
|
||||
// Create a profile of the bottom slot
|
||||
slotProfile002 = slot(flipperSketch, [-25, -18], [-55, -19], flipperSlotWidth)
|
||||
slotProfile002 = slot(
|
||||
sketch1 = flipperSketch,
|
||||
start = [-25, -18],
|
||||
end = [-55, -19],
|
||||
width = flipperSlotWidth,
|
||||
)
|
||||
|
||||
// Create a profile with slots for the spatula
|
||||
spatulaProfile = flipperProfile
|
||||
@ -138,7 +153,12 @@ grip = extrude(gripProfile, length = -gripLength)
|
||||
holeSketch = startSketchOn(grip, face = gripEdgeTop)
|
||||
|
||||
// Create a profile for the grip hole
|
||||
gripHoleProfile = slot(holeSketch, [0, 200], [0, 210], gripSlotWidth)
|
||||
gripHoleProfile = slot(
|
||||
sketch1 = holeSketch,
|
||||
start = [0, 200],
|
||||
end = [0, 210],
|
||||
width = gripSlotWidth,
|
||||
)
|
||||
|
||||
// Cut a hole in the grip
|
||||
extrude(gripHoleProfile, length = -gripWidth - 20)
|
||||
|
@ -22,7 +22,7 @@ countBinLength = 3
|
||||
height = firstStep + secondStep + thirdStep
|
||||
|
||||
// Define a function which builds the profile of the baseplate bin
|
||||
fn face(plane) {
|
||||
fn face(@plane) {
|
||||
faceSketch = startSketchOn(plane)
|
||||
|> startProfile(at = [0, 0])
|
||||
|> yLine(length = height)
|
||||
@ -84,7 +84,7 @@ basePlateCorners = patternLinear3d(
|
||||
|> patternLinear3d(axis = [0.0, 1.0, 0.0], instances = countBinLength, distance = binLength)
|
||||
|
||||
// Create the center cutout for the magnet profile
|
||||
fn magnetCenterCutout(plane) {
|
||||
fn magnetCenterCutout(@plane) {
|
||||
magnetSketch = startSketchOn(plane)
|
||||
|> startProfile(at = [
|
||||
firstStep + thirdStep,
|
||||
@ -111,7 +111,7 @@ fn magnetCenterCutout(plane) {
|
||||
}
|
||||
|
||||
// Create the outside profile of the magnets
|
||||
fn magnetBase(plane) {
|
||||
fn magnetBase(@plane) {
|
||||
magnetBaseSketch = startSketchOn(plane)
|
||||
|> startProfile(at = [0, 0])
|
||||
|> xLine(length = binLength, tag = $line001)
|
||||
|
@ -19,7 +19,7 @@ countBinLength = 3
|
||||
height = firstStep + secondStep + thirdStep
|
||||
|
||||
// Define a function which builds the profile of the baseplate bin
|
||||
fn face(plane) {
|
||||
fn face(@plane) {
|
||||
faceSketch = startSketchOn(plane)
|
||||
|> startProfile(at = [0, 0])
|
||||
|> yLine(length = height)
|
||||
|
@ -34,7 +34,7 @@ height = firstStep + secondStep + thirdStep
|
||||
lipHeight = lipStep1 + lipStep2 + lipStep3 + lipStep4 + lipStep5
|
||||
|
||||
// Define a function which builds the profile of the baseplate bin
|
||||
fn face(plane) {
|
||||
fn face(@plane) {
|
||||
faceSketch = startSketchOn(plane)
|
||||
|> startProfile(at = [binBaseLength + binTol, 0])
|
||||
|> yLine(length = height)
|
||||
@ -174,7 +174,7 @@ binTop = startSketchOn(offsetPlane(XY, offset = height))
|
||||
|> shell(faces = [END], thickness = binThk)
|
||||
|
||||
// Define a function which builds the profile of the baseplate bin
|
||||
fn lipFace(plane) {
|
||||
fn lipFace(@plane) {
|
||||
faceSketch = startSketchOn(plane)
|
||||
|> startProfile(at = [0, 0])
|
||||
// |> yLine(length = lipHeight, tag = $line100)
|
||||
|
@ -27,7 +27,7 @@ countBinHeight = 2
|
||||
height = firstStep + secondStep + thirdStep
|
||||
|
||||
// Define a function which builds the profile of the baseplate bin
|
||||
fn face(plane) {
|
||||
fn face(@plane) {
|
||||
faceSketch = startSketchOn(plane)
|
||||
|> startProfile(at = [binBaseLength + binTol, 0])
|
||||
|> yLine(length = height)
|
||||
|
@ -25,4 +25,4 @@ fn hexNut(start, thk, innerDia) {
|
||||
}
|
||||
|
||||
// Create a hex nut
|
||||
hexNut([0, 0], thickness, diameter)
|
||||
hexNut(start = [0, 0], thk = thickness, innerDia = diameter)
|
||||
|
@ -88,37 +88,163 @@ fn keyFn(originStart, keyWidth, keyHeight, repeats, color) {
|
||||
}
|
||||
|
||||
// Build the first row of keys
|
||||
keyFn([0.3, row1], 1.1, keyHeight, 0, highlightColor2)
|
||||
keyFn([1.5, row1], 0.8, keyHeight, 2, highlightColor1)
|
||||
keyFn([spacing * 7 + 3.5, row1], 5.2, keyHeight, 0, highlightColor2)
|
||||
keyFn([spacing * 8 + 8.7, row1], 0.8, keyHeight, 0, highlightColor1)
|
||||
keyFn([spacing * 8 + 9.6, row1], 0.8, keyHeight, 0, highlightColor1)
|
||||
keyFn([spacing * 10 + 10.3, row1], 1.1, keyHeight, 0, highlightColor1)
|
||||
keyFn([spacing * 12 + 10.3 + 1, row1], 0.8, keyHeight, 0, highlightColor2)
|
||||
keyFn(
|
||||
originStart = [0.3, row1],
|
||||
keyWidth = 1.1,
|
||||
keyHeight = keyHeight,
|
||||
repeats = 0,
|
||||
color = highlightColor2,
|
||||
)
|
||||
keyFn(
|
||||
originStart = [1.5, row1],
|
||||
keyWidth = 0.8,
|
||||
keyHeight = keyHeight,
|
||||
repeats = 2,
|
||||
color = highlightColor1,
|
||||
)
|
||||
keyFn(
|
||||
originStart = [spacing * 7 + 3.5, row1],
|
||||
keyWidth = 5.2,
|
||||
keyHeight = keyHeight,
|
||||
repeats = 0,
|
||||
color = highlightColor2,
|
||||
)
|
||||
keyFn(
|
||||
originStart = [spacing * 8 + 8.7, row1],
|
||||
keyWidth = 0.8,
|
||||
keyHeight = keyHeight,
|
||||
repeats = 0,
|
||||
color = highlightColor1,
|
||||
)
|
||||
keyFn(
|
||||
originStart = [spacing * 8 + 9.6, row1],
|
||||
keyWidth = 0.8,
|
||||
keyHeight = keyHeight,
|
||||
repeats = 0,
|
||||
color = highlightColor1,
|
||||
)
|
||||
keyFn(
|
||||
originStart = [spacing * 10 + 10.3, row1],
|
||||
keyWidth = 1.1,
|
||||
keyHeight = keyHeight,
|
||||
repeats = 0,
|
||||
color = highlightColor1,
|
||||
)
|
||||
keyFn(
|
||||
originStart = [spacing * 12 + 10.3 + 1, row1],
|
||||
keyWidth = 0.8,
|
||||
keyHeight = keyHeight,
|
||||
repeats = 0,
|
||||
color = highlightColor2,
|
||||
)
|
||||
|
||||
// Build the second row of keys
|
||||
keyFn([spacing * 3, row2], 1.7, keyHeight, 0, highlightColor2)
|
||||
keyFn([spacing * 4 + 1.7, row2], 0.8, keyHeight, 9, highlightColor1)
|
||||
keyFn([spacing * 14 + 1.7 + 0.8 * 10, row2], 2.2, keyHeight, 0, highlightColor2)
|
||||
keyFn(
|
||||
originStart = [spacing * 3, row2],
|
||||
keyWidth = 1.7,
|
||||
keyHeight = keyHeight,
|
||||
repeats = 0,
|
||||
color = highlightColor2,
|
||||
)
|
||||
keyFn(
|
||||
originStart = [spacing * 4 + 1.7, row2],
|
||||
keyWidth = 0.8,
|
||||
keyHeight = keyHeight,
|
||||
repeats = 9,
|
||||
color = highlightColor1,
|
||||
)
|
||||
keyFn(
|
||||
originStart = [spacing * 14 + 1.7 + 0.8 * 10, row2],
|
||||
keyWidth = 2.2,
|
||||
keyHeight = keyHeight,
|
||||
repeats = 0,
|
||||
color = highlightColor2,
|
||||
)
|
||||
|
||||
// Build the third row of keys
|
||||
keyFn([spacing * 3, row3], 1.1 + .1, keyHeight, 0, highlightColor1)
|
||||
keyFn([spacing * 4 + 1.1 + .1, row3], 0.8, keyHeight, 10, highlightColor1)
|
||||
keyFn([spacing * 3 + 11.1 + .1, row3], 1.4 + .4, keyHeight, 0, highlightColor2)
|
||||
keyFn(
|
||||
originStart = [spacing * 3, row3],
|
||||
keyWidth = 1.1 + .1,
|
||||
keyHeight = keyHeight,
|
||||
repeats = 0,
|
||||
color = highlightColor1,
|
||||
)
|
||||
keyFn(
|
||||
originStart = [spacing * 4 + 1.1 + .1, row3],
|
||||
keyWidth = 0.8,
|
||||
keyHeight = keyHeight,
|
||||
repeats = 10,
|
||||
color = highlightColor1,
|
||||
)
|
||||
keyFn(
|
||||
originStart = [spacing * 3 + 11.1 + .1, row3],
|
||||
keyWidth = 1.4 + .4,
|
||||
keyHeight = keyHeight,
|
||||
repeats = 0,
|
||||
color = highlightColor2,
|
||||
)
|
||||
|
||||
// Build the fourth row of keys
|
||||
keyFn([spacing * 3, row4], 0.9, keyHeight, 0, highlightColor1)
|
||||
keyFn([spacing * 4 + 0.9, row4], 0.8, keyHeight, 11, highlightColor1)
|
||||
keyFn([spacing * 3 + 11.8, row4], 1.2, keyHeight, 0, highlightColor1)
|
||||
keyFn(
|
||||
originStart = [spacing * 3, row4],
|
||||
keyWidth = 0.9,
|
||||
keyHeight = keyHeight,
|
||||
repeats = 0,
|
||||
color = highlightColor1,
|
||||
)
|
||||
keyFn(
|
||||
originStart = [spacing * 4 + 0.9, row4],
|
||||
keyWidth = 0.8,
|
||||
keyHeight = keyHeight,
|
||||
repeats = 11,
|
||||
color = highlightColor1,
|
||||
)
|
||||
keyFn(
|
||||
originStart = [spacing * 3 + 11.8, row4],
|
||||
keyWidth = 1.2,
|
||||
keyHeight = keyHeight,
|
||||
repeats = 0,
|
||||
color = highlightColor1,
|
||||
)
|
||||
|
||||
// Build the fifth row of keys
|
||||
keyFn([spacing * 3, row5], 0.8, keyHeight, 12, highlightColor1)
|
||||
keyFn([spacing * 3 + 11.7, row5], 1.3, keyHeight, 0, highlightColor2)
|
||||
keyFn(
|
||||
originStart = [spacing * 3, row5],
|
||||
keyWidth = 0.8,
|
||||
keyHeight = keyHeight,
|
||||
repeats = 12,
|
||||
color = highlightColor1,
|
||||
)
|
||||
keyFn(
|
||||
originStart = [spacing * 3 + 11.7, row5],
|
||||
keyWidth = 1.3,
|
||||
keyHeight = keyHeight,
|
||||
repeats = 0,
|
||||
color = highlightColor2,
|
||||
)
|
||||
|
||||
// Build the sixth row of keys
|
||||
keyFn([spacing * 3, row6], 1.1, keyHeight * .6, 0, highlightColor2)
|
||||
keyFn([spacing * 4 + 1.1, row6], 0.8, keyHeight * .6, 11, highlightColor1)
|
||||
keyFn([spacing * 3 + 12, row6], 1, keyHeight * .6, 0, highlightColor2)
|
||||
keyFn(
|
||||
originStart = [spacing * 3, row6],
|
||||
keyWidth = 1.1,
|
||||
keyHeight = keyHeight * .6,
|
||||
repeats = 0,
|
||||
color = highlightColor2,
|
||||
)
|
||||
keyFn(
|
||||
originStart = [spacing * 4 + 1.1, row6],
|
||||
keyWidth = 0.8,
|
||||
keyHeight = keyHeight * .6,
|
||||
repeats = 11,
|
||||
color = highlightColor1,
|
||||
)
|
||||
keyFn(
|
||||
originStart = [spacing * 3 + 12, row6],
|
||||
keyWidth = 1,
|
||||
keyHeight = keyHeight * .6,
|
||||
repeats = 0,
|
||||
color = highlightColor2,
|
||||
)
|
||||
|
||||
// Create a plane to sketch ZOO brand letters on
|
||||
plane002 = {
|
||||
@ -185,6 +311,6 @@ fn o(origin, scale, depth) {
|
||||
}
|
||||
|
||||
// Place the Z logo on the Z key. Place the O logo on the O and P keys
|
||||
z([2.3, 1.3], .4, 0.03)
|
||||
o([8.71, row4 + .08], 0.4, 0.03)
|
||||
o([8.71 + 0.9, row4 + .08], 0.4, 0.03)
|
||||
z(origin = [2.3, 1.3], scale = .4, depth = 0.03)
|
||||
o(origin = [8.71, row4 + .08], scale = 0.4, depth = 0.03)
|
||||
o(origin = [8.71 + 0.9, row4 + .08], scale = 0.4, depth = 0.03)
|
||||
|
@ -37,7 +37,15 @@ kitHeadElevation = kitBodyElevation + kitBodyHeight - kitHeadOffset - kitHeadHei
|
||||
|
||||
kitHeadWidth = kitBodyWidth - (kitHeadOffset * 2)
|
||||
kitHeadDepth = 3
|
||||
kitHead = pixelBox(kitBody, END, -kitHeadWidth / 2, kitHeadElevation, kitHeadWidth, kitHeadHeight, kitHeadDepth)
|
||||
kitHead = pixelBox(
|
||||
kitExtrude = kitBody,
|
||||
extrudeTag = END,
|
||||
positionY = -kitHeadWidth / 2,
|
||||
positionZ = kitHeadElevation,
|
||||
width = kitHeadWidth,
|
||||
height = kitHeadHeight,
|
||||
depth = kitHeadDepth,
|
||||
)
|
||||
kitFaceElevation = kitHeadElevation + 2
|
||||
|
||||
// 3. Kitty Face
|
||||
@ -67,17 +75,49 @@ kitFace = startSketchOn(kitHead, face = END)
|
||||
|
||||
// 3.1.1 Kitty Left Eye
|
||||
kitEyeDepth = 0.5
|
||||
kitEyeHeihgt = kitFaceElevation + 7
|
||||
kitEyeHeight = kitFaceElevation + 7
|
||||
kitEyeOffset = 7
|
||||
|
||||
// 3.1.2 Kitty Right Eye
|
||||
kitLeftEye1 = pixelBox(kitFace, START, -kitEyeOffset, kitEyeHeihgt, 1, 1, kitEyeDepth)
|
||||
kitLeftEye1 = pixelBox(
|
||||
kitExtrude = kitFace,
|
||||
extrudeTag = START,
|
||||
positionY = -kitEyeOffset,
|
||||
positionZ = kitEyeHeight,
|
||||
width = 1,
|
||||
height = 1,
|
||||
depth = kitEyeDepth,
|
||||
)
|
||||
|
||||
// 3.2 Kitty Nose
|
||||
kitLeftEye2 = pixelBox(kitFace, START, -kitEyeOffset + 1, kitEyeHeihgt + 1, 3, 1, kitEyeDepth)
|
||||
kitLeftEye3 = pixelBox(kitFace, START, -kitEyeOffset + 4, kitEyeHeihgt, 1, 1, kitEyeDepth)
|
||||
kitRightEye = pixelBox(kitFace, START, kitEyeOffset - 3, kitEyeHeihgt - 1, 2, 4, kitEyeDepth)
|
||||
kitNoseElevation = kitEyeHeihgt - 5
|
||||
kitLeftEye2 = pixelBox(
|
||||
kitExtrude = kitFace,
|
||||
extrudeTag = START,
|
||||
positionY = -kitEyeOffset + 1,
|
||||
positionZ = kitEyeHeight + 1,
|
||||
width = 3,
|
||||
height = 1,
|
||||
depth = kitEyeDepth,
|
||||
)
|
||||
kitLeftEye3 = pixelBox(
|
||||
kitExtrude = kitFace,
|
||||
extrudeTag = START,
|
||||
positionY = -kitEyeOffset + 4,
|
||||
positionZ = kitEyeHeight,
|
||||
width = 1,
|
||||
height = 1,
|
||||
depth = kitEyeDepth,
|
||||
)
|
||||
kitRightEye = pixelBox(
|
||||
kitExtrude = kitFace,
|
||||
extrudeTag = START,
|
||||
positionY = kitEyeOffset - 3,
|
||||
positionZ = kitEyeHeight - 1,
|
||||
width = 2,
|
||||
height = 4,
|
||||
depth = kitEyeDepth,
|
||||
)
|
||||
kitNoseElevation = kitEyeHeight - 5
|
||||
kitNose = startSketchOn(kitFace, face = START)
|
||||
|> startProfile(at = [-2, kitNoseElevation]) // H V
|
||||
|> line(end = [0, 1]) // lower-left up
|
||||
@ -97,13 +137,45 @@ kitNose = startSketchOn(kitFace, face = START)
|
||||
|
||||
// 3.3 Kitty Mouth
|
||||
kitMouthOffset = 4
|
||||
kitMouthHeight = kitEyeHeihgt - 3
|
||||
kitMouthUpLeft = pixelBox(kitFace, START, -kitMouthOffset, kitMouthHeight, 1, 1, kitEyeDepth)
|
||||
kitMouthHeight = kitEyeHeight - 3
|
||||
kitMouthUpLeft = pixelBox(
|
||||
kitExtrude = kitFace,
|
||||
extrudeTag = START,
|
||||
positionY = -kitMouthOffset,
|
||||
positionZ = kitMouthHeight,
|
||||
width = 1,
|
||||
height = 1,
|
||||
depth = kitEyeDepth,
|
||||
)
|
||||
|
||||
// 4. Kitty Belly
|
||||
kitMouthDownLeft = pixelBox(kitFace, START, -kitMouthOffset + 1, kitMouthHeight - 1, 1, 1, kitEyeDepth)
|
||||
kitMouthUpRight = pixelBox(kitFace, START, kitMouthOffset, kitMouthHeight, 1, 1, kitEyeDepth)
|
||||
kitMouthDownRight = pixelBox(kitFace, START, kitMouthOffset - 1, kitMouthHeight - 1, 1, 1, kitEyeDepth)
|
||||
kitMouthDownLeft = pixelBox(
|
||||
kitExtrude = kitFace,
|
||||
extrudeTag = START,
|
||||
positionY = -kitMouthOffset + 1,
|
||||
positionZ = kitMouthHeight - 1,
|
||||
width = 1,
|
||||
height = 1,
|
||||
depth = kitEyeDepth,
|
||||
)
|
||||
kitMouthUpRight = pixelBox(
|
||||
kitExtrude = kitFace,
|
||||
extrudeTag = START,
|
||||
positionY = kitMouthOffset,
|
||||
positionZ = kitMouthHeight,
|
||||
width = 1,
|
||||
height = 1,
|
||||
depth = kitEyeDepth,
|
||||
)
|
||||
kitMouthDownRight = pixelBox(
|
||||
kitExtrude = kitFace,
|
||||
extrudeTag = START,
|
||||
positionY = kitMouthOffset - 1,
|
||||
positionZ = kitMouthHeight - 1,
|
||||
width = 1,
|
||||
height = 1,
|
||||
depth = kitEyeDepth,
|
||||
)
|
||||
kitBellyElevation = kitBodyElevation + 1
|
||||
|
||||
kitBellyHeight = kitHeadElevation - kitBellyElevation - 1
|
||||
@ -111,7 +183,15 @@ kitBellyHeight = kitHeadElevation - kitBellyElevation - 1
|
||||
// 4.1 Kitty VHS
|
||||
kitBellyWidth = kitHeadWidth
|
||||
kitBellyDepth = kitHeadDepth
|
||||
kitBelly = pixelBox(kitBody, END, -kitBellyWidth / 2, kitBellyElevation, kitBellyWidth, kitBellyHeight, kitBellyDepth)
|
||||
kitBelly = pixelBox(
|
||||
kitExtrude = kitBody,
|
||||
extrudeTag = END,
|
||||
positionY = -kitBellyWidth / 2,
|
||||
positionZ = kitBellyElevation,
|
||||
width = kitBellyWidth,
|
||||
height = kitBellyHeight,
|
||||
depth = kitBellyDepth,
|
||||
)
|
||||
kitVHSelevation = kitBellyElevation + 1
|
||||
|
||||
kitVHSheight = 2
|
||||
@ -119,7 +199,15 @@ kitVHSheight = 2
|
||||
// 4.2 Kitty Floppy
|
||||
kitVHSwidth = 8
|
||||
kitVHSdepth = 1
|
||||
kitVHS = pixelBox(kitBelly, END, -kitVHSwidth / 2, kitVHSelevation, kitVHSwidth, kitVHSheight, kitVHSdepth)
|
||||
kitVHS = pixelBox(
|
||||
kitExtrude = kitBelly,
|
||||
extrudeTag = END,
|
||||
positionY = -kitVHSwidth / 2,
|
||||
positionZ = kitVHSelevation,
|
||||
width = kitVHSwidth,
|
||||
height = kitVHSheight,
|
||||
depth = kitVHSdepth,
|
||||
)
|
||||
kitFloppyElevation = kitBellyElevation + 1
|
||||
kitFloppyHeight = 1
|
||||
|
||||
@ -128,9 +216,33 @@ kitFloppyOffset = kitBellyWidth / 2 - 1
|
||||
kitFloppyDepth = 2
|
||||
|
||||
// 4.3 Kitty Belly Button
|
||||
kitFloppy1 = pixelBox(kitBelly, END, -kitFloppyOffset, kitFloppyElevation, kitFloppyWidth, kitFloppyHeight, -kitFloppyDepth)
|
||||
kitFloppy2 = pixelBox(kitBelly, END, -kitFloppyOffset, kitFloppyElevation + 2, kitFloppyWidth, kitFloppyHeight, -kitFloppyDepth)
|
||||
kitFloppy3 = pixelBox(kitBelly, END, kitFloppyOffset, kitFloppyElevation, -kitFloppyWidth, kitFloppyHeight, -kitFloppyDepth)
|
||||
kitFloppy1 = pixelBox(
|
||||
kitExtrude = kitBelly,
|
||||
extrudeTag = END,
|
||||
positionY = -kitFloppyOffset,
|
||||
positionZ = kitFloppyElevation,
|
||||
width = kitFloppyWidth,
|
||||
height = kitFloppyHeight,
|
||||
depth = -kitFloppyDepth,
|
||||
)
|
||||
kitFloppy2 = pixelBox(
|
||||
kitExtrude = kitBelly,
|
||||
extrudeTag = END,
|
||||
positionY = -kitFloppyOffset,
|
||||
positionZ = kitFloppyElevation + 2,
|
||||
width = kitFloppyWidth,
|
||||
height = kitFloppyHeight,
|
||||
depth = -kitFloppyDepth,
|
||||
)
|
||||
kitFloppy3 = pixelBox(
|
||||
kitExtrude = kitBelly,
|
||||
extrudeTag = END,
|
||||
positionY = kitFloppyOffset,
|
||||
positionZ = kitFloppyElevation,
|
||||
width = -kitFloppyWidth,
|
||||
height = kitFloppyHeight,
|
||||
depth = -kitFloppyDepth,
|
||||
)
|
||||
kitBellyButtonOffset = kitHeadWidth / 2 - 3
|
||||
kitBellyButtonElevation = kitHeadElevation - 1
|
||||
|
||||
@ -139,18 +251,50 @@ kitBellyButtonWidth = 2
|
||||
// 4.4 Kitty Buttons
|
||||
kitBellyButtonHeight = 1
|
||||
kitBellyButtonDepth = kitHeadDepth + 1
|
||||
kitBellyButton = pixelBox(kitBody, END, -kitBellyButtonOffset, kitBellyButtonElevation, kitBellyButtonWidth, kitBellyButtonHeight, kitBellyButtonDepth)
|
||||
kitBellyButton = pixelBox(
|
||||
kitExtrude = kitBody,
|
||||
extrudeTag = END,
|
||||
positionY = -kitBellyButtonOffset,
|
||||
positionZ = kitBellyButtonElevation,
|
||||
width = kitBellyButtonWidth,
|
||||
height = kitBellyButtonHeight,
|
||||
depth = kitBellyButtonDepth,
|
||||
)
|
||||
|
||||
kitButtonWidth = 1
|
||||
kitButtonHeight = 2
|
||||
kitButtonDepth = kitFloppyDepth
|
||||
kitButtonElevation = kitFloppyElevation + 2
|
||||
|
||||
kitButton1 = pixelBox(kitBelly, END, kitFloppyOffset, kitFloppyElevation + 2, -kitButtonWidth, kitButtonHeight, -kitButtonDepth)
|
||||
kitButton1 = pixelBox(
|
||||
kitExtrude = kitBelly,
|
||||
extrudeTag = END,
|
||||
positionY = kitFloppyOffset,
|
||||
positionZ = kitFloppyElevation + 2,
|
||||
width = -kitButtonWidth,
|
||||
height = kitButtonHeight,
|
||||
depth = -kitButtonDepth,
|
||||
)
|
||||
|
||||
// 5. Kitty Legs
|
||||
kitButton2 = pixelBox(kitBelly, END, kitFloppyOffset - kitButtonWidth - 1, kitFloppyElevation + 2, -kitButtonWidth, kitButtonHeight, -kitButtonDepth)
|
||||
kitButton3 = pixelBox(kitBelly, END, kitFloppyOffset - (2 * (kitButtonWidth + 1)), kitFloppyElevation + 2, -kitButtonWidth, kitButtonHeight, -kitButtonDepth)
|
||||
kitButton2 = pixelBox(
|
||||
kitExtrude = kitBelly,
|
||||
extrudeTag = END,
|
||||
positionY = kitFloppyOffset - kitButtonWidth - 1,
|
||||
positionZ = kitFloppyElevation + 2,
|
||||
width = -kitButtonWidth,
|
||||
height = kitButtonHeight,
|
||||
depth = -kitButtonDepth,
|
||||
)
|
||||
kitButton3 = pixelBox(
|
||||
kitExtrude = kitBelly,
|
||||
extrudeTag = END,
|
||||
positionY = kitFloppyOffset - (2 * (kitButtonWidth + 1)),
|
||||
positionZ = kitFloppyElevation + 2,
|
||||
width = -kitButtonWidth,
|
||||
height = kitButtonHeight,
|
||||
depth = -kitButtonDepth,
|
||||
)
|
||||
|
||||
kitShoeWidth = 7
|
||||
kitShoeLength = 10
|
||||
@ -175,14 +319,22 @@ fn kitLeg(offsetFront, offsetSide) {
|
||||
kitPantsFrontWidth = kitPantsWidth
|
||||
kitPantsHeight = kitBodyElevation - kitShoeHeight
|
||||
|
||||
kitPants = pixelBox(kitShoe, END, kitPantsOffsetSide, kitPantsOffsetFront, kitPantsFrontWidth, kitPantsWidth, kitPantsHeight)
|
||||
kitPants = pixelBox(
|
||||
kitExtrude = kitShoe,
|
||||
extrudeTag = END,
|
||||
positionY = kitPantsOffsetSide,
|
||||
positionZ = kitPantsOffsetFront,
|
||||
width = kitPantsFrontWidth,
|
||||
height = kitPantsWidth,
|
||||
depth = kitPantsHeight,
|
||||
)
|
||||
|
||||
return kitShoe
|
||||
}
|
||||
kitLegOffset = 3
|
||||
|
||||
kitRightLeg = kitLeg(0, kitLegOffset)
|
||||
kitLeftLeg = kitLeg(0, -kitLegOffset - kitShoeWidth)
|
||||
kitRightLeg = kitLeg(offsetFront = 0, offsetSide = kitLegOffset)
|
||||
kitLeftLeg = kitLeg(offsetFront = 0, offsetSide = -kitLegOffset - kitShoeWidth)
|
||||
|
||||
// 6. Kitty Ears
|
||||
kitEarWidth = 8
|
||||
@ -192,24 +344,56 @@ kitEarHeight = 2
|
||||
fn kitEar(earOffsetFront, earOffsetSide) {
|
||||
kitNewEarOffsetFront = kitBodyDepth - earOffsetFront
|
||||
kitNewEarOffsetSide = -(kitBodyWidth / 2 - earOffsetSide)
|
||||
baseVolume = pixelBox(kitBody, seg01, kitNewEarOffsetSide, kitNewEarOffsetFront, kitEarWidth, -kitEarDepth, kitEarHeight)
|
||||
baseVolume = pixelBox(
|
||||
kitExtrude = kitBody,
|
||||
extrudeTag = seg01,
|
||||
positionY = kitNewEarOffsetSide,
|
||||
positionZ = kitNewEarOffsetFront,
|
||||
width = kitEarWidth,
|
||||
height = -kitEarDepth,
|
||||
depth = kitEarHeight,
|
||||
)
|
||||
|
||||
secondOffset = 1
|
||||
secondLevel = pixelBox(baseVolume, END, kitNewEarOffsetSide + secondOffset, kitNewEarOffsetFront - 0.01, kitEarWidth - (secondOffset * 2), -kitEarDepth + secondOffset * 2, kitEarHeight)
|
||||
secondLevel = pixelBox(
|
||||
kitExtrude = baseVolume,
|
||||
extrudeTag = END,
|
||||
positionY = kitNewEarOffsetSide + secondOffset,
|
||||
positionZ = kitNewEarOffsetFront - 0.01,
|
||||
width = kitEarWidth - (secondOffset * 2),
|
||||
height = -kitEarDepth + secondOffset * 2,
|
||||
depth = kitEarHeight,
|
||||
)
|
||||
|
||||
thirdOffset = 2
|
||||
thirdLevel = pixelBox(secondLevel, END, kitNewEarOffsetSide + thirdOffset, kitNewEarOffsetFront - 0.02, kitEarWidth - (thirdOffset * 2), -kitEarDepth + thirdOffset * 2, kitEarHeight)
|
||||
thirdLevel = pixelBox(
|
||||
kitExtrude = secondLevel,
|
||||
extrudeTag = END,
|
||||
positionY = kitNewEarOffsetSide + thirdOffset,
|
||||
positionZ = kitNewEarOffsetFront - 0.02,
|
||||
width = kitEarWidth - (thirdOffset * 2),
|
||||
height = -kitEarDepth + thirdOffset * 2,
|
||||
depth = kitEarHeight,
|
||||
)
|
||||
|
||||
fourthOffset = 3
|
||||
fourthLevel = pixelBox(thirdLevel, END, kitNewEarOffsetSide + fourthOffset, kitNewEarOffsetFront - 0.03, kitEarWidth - (fourthOffset * 2), -kitEarDepth + fourthOffset * 2, kitEarHeight)
|
||||
fourthLevel = pixelBox(
|
||||
kitExtrude = thirdLevel,
|
||||
extrudeTag = END,
|
||||
positionY = kitNewEarOffsetSide + fourthOffset,
|
||||
positionZ = kitNewEarOffsetFront - 0.03,
|
||||
width = kitEarWidth - (fourthOffset * 2),
|
||||
height = -kitEarDepth + fourthOffset * 2,
|
||||
depth = kitEarHeight,
|
||||
)
|
||||
|
||||
return baseVolume
|
||||
}
|
||||
kitEarOffsetFront = 4
|
||||
kitEarOffsetSide = 1
|
||||
|
||||
kitRightEar = kitEar(kitEarOffsetFront, kitEarOffsetSide)
|
||||
kitLeftEar = kitEar(kitEarOffsetFront, kitBodyWidth - kitEarWidth - kitEarOffsetSide)
|
||||
kitRightEar = kitEar(earOffsetFront = kitEarOffsetFront, earOffsetSide = kitEarOffsetSide)
|
||||
kitLeftEar = kitEar(earOffsetFront = kitEarOffsetFront, earOffsetSide = kitBodyWidth - kitEarWidth - kitEarOffsetSide)
|
||||
|
||||
// 7. Kitty Side
|
||||
// 7.1 Grill
|
||||
@ -228,19 +412,75 @@ grillColumnE = grillColumnA - 4
|
||||
grillHoleSize = 1
|
||||
grillHoleDepth = -2
|
||||
|
||||
grillHoleAB = pixelBox(kitBody, seg02, grillRowA, grillColumnB, grillHoleSize, grillHoleSize, grillHoleDepth)
|
||||
grillHoleAB = pixelBox(
|
||||
kitExtrude = kitBody,
|
||||
extrudeTag = seg02,
|
||||
positionY = grillRowA,
|
||||
positionZ = grillColumnB,
|
||||
width = grillHoleSize,
|
||||
height = grillHoleSize,
|
||||
depth = grillHoleDepth,
|
||||
)
|
||||
|
||||
grillHoleAD = pixelBox(kitBody, seg02, grillRowA, grillColumnD, grillHoleSize, grillHoleSize, grillHoleDepth)
|
||||
grillHoleAD = pixelBox(
|
||||
kitExtrude = kitBody,
|
||||
extrudeTag = seg02,
|
||||
positionY = grillRowA,
|
||||
positionZ = grillColumnD,
|
||||
width = grillHoleSize,
|
||||
height = grillHoleSize,
|
||||
depth = grillHoleDepth,
|
||||
)
|
||||
|
||||
grillHoleBA = pixelBox(kitBody, seg02, grillRowB, grillColumnA, grillHoleSize, grillHoleSize, grillHoleDepth)
|
||||
grillHoleBA = pixelBox(
|
||||
kitExtrude = kitBody,
|
||||
extrudeTag = seg02,
|
||||
positionY = grillRowB,
|
||||
positionZ = grillColumnA,
|
||||
width = grillHoleSize,
|
||||
height = grillHoleSize,
|
||||
depth = grillHoleDepth,
|
||||
)
|
||||
|
||||
grillHoleBC = pixelBox(kitBody, seg02, grillRowB, grillColumnC, grillHoleSize, grillHoleSize, grillHoleDepth)
|
||||
grillHoleBC = pixelBox(
|
||||
kitExtrude = kitBody,
|
||||
extrudeTag = seg02,
|
||||
positionY = grillRowB,
|
||||
positionZ = grillColumnC,
|
||||
width = grillHoleSize,
|
||||
height = grillHoleSize,
|
||||
depth = grillHoleDepth,
|
||||
)
|
||||
|
||||
grillHoleBE = pixelBox(kitBody, seg02, grillRowB, grillColumnE, grillHoleSize, grillHoleSize, grillHoleDepth)
|
||||
grillHoleBE = pixelBox(
|
||||
kitExtrude = kitBody,
|
||||
extrudeTag = seg02,
|
||||
positionY = grillRowB,
|
||||
positionZ = grillColumnE,
|
||||
width = grillHoleSize,
|
||||
height = grillHoleSize,
|
||||
depth = grillHoleDepth,
|
||||
)
|
||||
|
||||
grillHoleCB = pixelBox(kitBody, seg02, grillRowC, grillColumnB, grillHoleSize, grillHoleSize, grillHoleDepth)
|
||||
grillHoleCB = pixelBox(
|
||||
kitExtrude = kitBody,
|
||||
extrudeTag = seg02,
|
||||
positionY = grillRowC,
|
||||
positionZ = grillColumnB,
|
||||
width = grillHoleSize,
|
||||
height = grillHoleSize,
|
||||
depth = grillHoleDepth,
|
||||
)
|
||||
|
||||
grillHoleCD = pixelBox(kitBody, seg02, grillRowC, grillColumnD, grillHoleSize, grillHoleSize, grillHoleDepth)
|
||||
grillHoleCD = pixelBox(
|
||||
kitExtrude = kitBody,
|
||||
extrudeTag = seg02,
|
||||
positionY = grillRowC,
|
||||
positionZ = grillColumnD,
|
||||
width = grillHoleSize,
|
||||
height = grillHoleSize,
|
||||
depth = grillHoleDepth,
|
||||
)
|
||||
|
||||
// 7.2 Kitty Vent
|
||||
kitVentElevation = kitBodyElevation + 1
|
||||
@ -249,8 +489,32 @@ kitVentHoleWidth = 1
|
||||
kitVentHoleHeight = 4
|
||||
kitVentHoleDepth = grillHoleDepth
|
||||
|
||||
kitVentA = pixelBox(kitBody, seg02, kitVentElevation, kitVentOffset, kitVentHoleHeight, kitVentHoleWidth, kitVentHoleDepth)
|
||||
kitVentA = pixelBox(
|
||||
kitExtrude = kitBody,
|
||||
extrudeTag = seg02,
|
||||
positionY = kitVentElevation,
|
||||
positionZ = kitVentOffset,
|
||||
width = kitVentHoleHeight,
|
||||
height = kitVentHoleWidth,
|
||||
depth = kitVentHoleDepth,
|
||||
)
|
||||
|
||||
kitVentB = pixelBox(kitBody, seg02, kitVentElevation, kitVentOffset + 2, kitVentHoleHeight, kitVentHoleWidth, kitVentHoleDepth)
|
||||
kitVentB = pixelBox(
|
||||
kitExtrude = kitBody,
|
||||
extrudeTag = seg02,
|
||||
positionY = kitVentElevation,
|
||||
positionZ = kitVentOffset + 2,
|
||||
width = kitVentHoleHeight,
|
||||
height = kitVentHoleWidth,
|
||||
depth = kitVentHoleDepth,
|
||||
)
|
||||
|
||||
kitVentC = pixelBox(kitBody, seg02, kitVentElevation, kitVentOffset + 4, kitVentHoleHeight, kitVentHoleWidth, kitVentHoleDepth)
|
||||
kitVentC = pixelBox(
|
||||
kitExtrude = kitBody,
|
||||
extrudeTag = seg02,
|
||||
positionY = kitVentElevation,
|
||||
positionZ = kitVentOffset + 4,
|
||||
width = kitVentHoleHeight,
|
||||
height = kitVentHoleWidth,
|
||||
depth = kitVentHoleDepth,
|
||||
)
|
||||
|
@ -29,15 +29,15 @@ fn hingeFn(x, y, z) {
|
||||
return hingeBody
|
||||
}
|
||||
|
||||
hingePartA1 = hingeFn(0, 0, 0)
|
||||
hingePartA2 = hingeFn(0, 0, hingeHeight + hingeGap)
|
||||
hingePartA3 = hingeFn(0, 0, hingeHeight * 2 + hingeGap * 2)
|
||||
hingePartA1 = hingeFn(x = 0, y = 0, z = 0)
|
||||
hingePartA2 = hingeFn(x = 0, y = 0, z = hingeHeight + hingeGap)
|
||||
hingePartA3 = hingeFn(x = 0, y = 0, z = hingeHeight * 2 + hingeGap * 2)
|
||||
|
||||
hingePartB2 = hingeFn(armLength, 0, hingeHeight + hingeGap)
|
||||
hingePartB3 = hingeFn(armLength, 0, hingeHeight * 2 + hingeGap * 2)
|
||||
hingePartB2 = hingeFn(x = armLength, y = 0, z = hingeHeight + hingeGap)
|
||||
hingePartB3 = hingeFn(x = armLength, y = 0, z = hingeHeight * 2 + hingeGap * 2)
|
||||
|
||||
hingePartC2 = hingeFn(armLength, -armLength, hingeHeight * 2 + hingeGap * 2)
|
||||
hingePartC3 = hingeFn(armLength, -armLength, hingeHeight * 3 + hingeGap * 3)
|
||||
hingePartC2 = hingeFn(x = armLength, y = -armLength, z = hingeHeight * 2 + hingeGap * 2)
|
||||
hingePartC3 = hingeFn(x = armLength, y = -armLength, z = hingeHeight * 3 + hingeGap * 3)
|
||||
|
||||
// Add a function to create the arm
|
||||
fn armFn(plane, offset, altitude) {
|
||||
@ -47,8 +47,8 @@ fn armFn(plane, offset, altitude) {
|
||||
return armBody
|
||||
}
|
||||
|
||||
armPartA = armFn(YZ, 0, hingeHeight * 1.5 + hingeGap)
|
||||
armPartB = armFn(XZ, armLength, hingeHeight * 2.5 + hingeGap * 2)
|
||||
armPartA = armFn(plane = YZ, offset = 0, altitude = hingeHeight * 1.5 + hingeGap)
|
||||
armPartB = armFn(plane = XZ, offset = armLength, altitude = hingeHeight * 2.5 + hingeGap * 2)
|
||||
|
||||
// Add a function to create the mirror
|
||||
fn mirrorFn(plane, offsetX, offsetY, altitude, radius, tiefe, gestellR, gestellD) {
|
||||
@ -72,4 +72,13 @@ fn mirrorFn(plane, offsetX, offsetY, altitude, radius, tiefe, gestellR, gestellD
|
||||
return armBody
|
||||
}
|
||||
|
||||
mirror = mirrorFn(XZ, armLength, armLength, hingeHeight * 4 + hingeGap * 3 + mirrorRadius + archToMirrorGap + archThickness, mirrorRadius, mirrorThickness, archRadius, archThickness)
|
||||
mirror = mirrorFn(
|
||||
plane = XZ,
|
||||
offsetX = armLength,
|
||||
offsetY = armLength,
|
||||
altitude = hingeHeight * 4 + hingeGap * 3 + mirrorRadius + archToMirrorGap + archThickness,
|
||||
radius = mirrorRadius,
|
||||
tiefe = mirrorThickness,
|
||||
gestellR = archRadius,
|
||||
gestellD = archThickness,
|
||||
)
|
||||
|
@ -27,7 +27,7 @@ holeRadius = .25
|
||||
holeIndex = .75
|
||||
|
||||
// Create the mounting plate extrusion, holes, and fillets
|
||||
rs = rectShape([0, 0], plateWidth, plateLength)
|
||||
rs = rectShape(pos = [0, 0], w = plateWidth, l = plateLength)
|
||||
part = rs
|
||||
|> subtract2d(tool = circle(
|
||||
center = [
|
||||
|
@ -62,10 +62,10 @@ case = startSketchOn(XZ)
|
||||
|> subtract2d(tool = squareHolePatternSketch)
|
||||
|
||||
// Create the Zoo logo
|
||||
|> subtract2d(tool = zLogo(startSketchOn(XZ), [-.30, -1.825], .20))
|
||||
|> subtract2d(tool = oLogo(startSketchOn(XZ), [-.075, -1.825], .20))
|
||||
|> subtract2d(tool = oLogo2(startSketchOn(XZ), [-.075, -1.825], .20))
|
||||
|> subtract2d(tool = oLogo(startSketchOn(XZ), [.175, -1.825], .20))
|
||||
|> subtract2d(tool = oLogo2(startSketchOn(XZ), [.175, -1.825], .20))
|
||||
|> subtract2d(tool = zLogo(surface = startSketchOn(XZ), origin = [-.30, -1.825], scale = .20))
|
||||
|> subtract2d(tool = oLogo(surface = startSketchOn(XZ), origin = [-.075, -1.825], scale = .20))
|
||||
|> subtract2d(tool = oLogo2(surface = startSketchOn(XZ), origin = [-.075, -1.825], scale = .20))
|
||||
|> subtract2d(tool = oLogo(surface = startSketchOn(XZ), origin = [.175, -1.825], scale = .20))
|
||||
|> subtract2d(tool = oLogo2(surface = startSketchOn(XZ), origin = [.175, -1.825], scale = .20))
|
||||
extrude(case, length = -0.0625)
|
||||
|> appearance(color = '#D0FF01', metalness = 0, roughness = 50)
|
||||
|
@ -17,4 +17,4 @@ fn cube(length, center) {
|
||||
|> extrude(length = length)
|
||||
}
|
||||
|
||||
myCube = cube(40, [0,0])
|
||||
myCube = cube(length=40, center=[0,0])
|
||||
|
@ -48,7 +48,7 @@ fn bracketSketch(w, d, t) {
|
||||
}
|
||||
|
||||
// build the body of the bracket
|
||||
bs = bracketSketch(width, depth, thk)
|
||||
bs = bracketSketch(w = width, d = depth, t = thk)
|
||||
bracketBody = bs
|
||||
|> fillet(
|
||||
radius = radius,
|
||||
|
@ -40,9 +40,9 @@ miniHdmiHole = startSketchOn(XY)
|
||||
|
||||
case = startSketchOn(XY)
|
||||
|> startProfile(at = [0, 0])
|
||||
|> line(endAbsolute = [caseWidth, 0], $edge1)
|
||||
|> line(endAbsolute = [caseWidth, caseLength], $edge2)
|
||||
|> line(endAbsolute = [0, caseLength], $edge3)
|
||||
|> line(endAbsolute = [caseWidth, 0], tag = $edge1)
|
||||
|> line(endAbsolute = [caseWidth, caseLength], tag = $edge2)
|
||||
|> line(endAbsolute = [0, caseLength], tag = $edge3)
|
||||
|> close(tag = $edge4)
|
||||
|> extrude(length = caseHeight)
|
||||
|> fillet(
|
||||
@ -65,15 +65,15 @@ fn m25Screw(x, y, height) {
|
||||
return screw
|
||||
}
|
||||
|
||||
m25Screw(border + rpizWidth / 2 - (widthBetweenScrews / 2), 0 + border + rpizLength / 2 - (lengthBetweenScrews / 2), screwHeight)
|
||||
m25Screw(x = border + rpizWidth / 2 - (widthBetweenScrews / 2), y = 0 + border + rpizLength / 2 - (lengthBetweenScrews / 2), height = screwHeight)
|
||||
|
||||
m25Screw(border + rpizWidth / 2 - (widthBetweenScrews / 2), 0 + border + rpizLength / 2 + lengthBetweenScrews / 2, screwHeight)
|
||||
m25Screw(x = border + rpizWidth / 2 - (widthBetweenScrews / 2), y = 0 + border + rpizLength / 2 + lengthBetweenScrews / 2, height = screwHeight)
|
||||
|
||||
m25Screw(border + rpizWidth / 2 + widthBetweenScrews / 2, 0 + border + rpizLength / 2 + lengthBetweenScrews / 2, screwHeight)
|
||||
m25Screw(x = border + rpizWidth / 2 + widthBetweenScrews / 2, y = 0 + border + rpizLength / 2 + lengthBetweenScrews / 2, height = screwHeight)
|
||||
|
||||
m25Screw(border + rpizWidth / 2 + widthBetweenScrews / 2, 0 + border + rpizLength / 2 - (lengthBetweenScrews / 2), screwHeight)
|
||||
m25Screw(x = border + rpizWidth / 2 + widthBetweenScrews / 2, y = 0 + border + rpizLength / 2 - (lengthBetweenScrews / 2), height = screwHeight)
|
||||
|
||||
shell(
|
||||
faces = ['end'],
|
||||
faces = [END],
|
||||
thickness = caseThickness
|
||||
)
|
||||
|
@ -48,7 +48,7 @@ fn bracketSketch(w, d, t) {
|
||||
}
|
||||
|
||||
// build the body of the bracket
|
||||
bs = bracketSketch(width, depth, thk)
|
||||
bs = bracketSketch(w = width, d = depth, t = thk)
|
||||
bracketBody = bs
|
||||
|> extrude(length = length + 2 * thk)
|
||||
|> fillet(
|
||||
|
@ -10,4 +10,4 @@ fn box(h, l, w) {
|
||||
return myBox
|
||||
}
|
||||
|
||||
fnBox = box(3, 6, 10)
|
||||
fnBox = box(h = 3, l = 6, w = 10)
|
||||
|
@ -10,4 +10,4 @@ fn box(p, h, l, w) {
|
||||
return myBox
|
||||
}
|
||||
|
||||
thing = box([0,0], 3, 6, 10)
|
||||
thing = box(p = [0,0], h = 3, l = 6, w = 10)
|
||||
|
@ -48,7 +48,7 @@ fn bracketSketch(w, d, t) {
|
||||
}
|
||||
|
||||
// build the body of the bracket
|
||||
bs = bracketSketch(width, depth, thk)
|
||||
bs = bracketSketch(w = width, d = depth, t = thk)
|
||||
bracketBody = bs
|
||||
|> extrude(length = length + 2 * thk)
|
||||
|> fillet(
|
||||
|
@ -3,14 +3,14 @@
|
||||
|
||||
// Comparators
|
||||
|
||||
fn cond(bools) {
|
||||
fn cond(@bools) {
|
||||
return fn(a, b) {
|
||||
x = min([max([-1, a-b]), 1]) + 1
|
||||
return bools[x]
|
||||
}
|
||||
}
|
||||
|
||||
fn Not(b) { return if b { false } else { true } }
|
||||
fn Not(@b) { return if b { false } else { true } }
|
||||
fn And(a, b) { return if a { if b { true } else { false } } else { false }}
|
||||
fn Or(a, b) { return if a { true } else { if b { true } else { false }}}
|
||||
|
||||
@ -18,14 +18,14 @@ Eq = cond([false, true, false])
|
||||
Lt = cond([true, false, false])
|
||||
Gt = cond([false, false, true])
|
||||
|
||||
fn Lte(a, b) { return Not(Gt(a, b)) }
|
||||
fn Gte(a, b) { return Not(Lt(a, b)) }
|
||||
fn Lte(a, b) { return Not(Gt(a = a, b = b)) }
|
||||
fn Gte(a, b) { return Not(Lt(a = a, b = b)) }
|
||||
|
||||
// L-system
|
||||
// Note: it was most concise to encode productions directly in axioms.
|
||||
// Change them as you need.
|
||||
|
||||
fn setSketch(state, q) {
|
||||
fn setSketch(@state, q) {
|
||||
return {
|
||||
depthMax = state.depthMax,
|
||||
depth = state.depth + 1,
|
||||
@ -37,7 +37,7 @@ fn setSketch(state, q) {
|
||||
}
|
||||
}
|
||||
|
||||
fn setDepth(state, q) {
|
||||
fn setDepth(@state, q) {
|
||||
return {
|
||||
depthMax = state.depthMax,
|
||||
depth = q,
|
||||
@ -49,7 +49,7 @@ fn setDepth(state, q) {
|
||||
}
|
||||
}
|
||||
|
||||
fn setAngle(state, q) {
|
||||
fn setAngle(@state, q) {
|
||||
return {
|
||||
depthMax = state.depthMax,
|
||||
depth = state.depth,
|
||||
@ -61,7 +61,7 @@ fn setAngle(state, q) {
|
||||
}
|
||||
}
|
||||
|
||||
fn setLength(state, q) {
|
||||
fn setLength(@state, q) {
|
||||
return {
|
||||
depthMax = state.depthMax,
|
||||
depth = state.depth,
|
||||
@ -73,31 +73,31 @@ fn setLength(state, q) {
|
||||
}
|
||||
}
|
||||
|
||||
fn Gt2(state) { return setLength(state, state.currentLength * state.factor) }
|
||||
fn Lt2(state) { return setLength(state, state.currentLength / state.factor) }
|
||||
fn Add(state) { return setAngle(state, rem(state.currentAngle - state.angle, divisor = 360)) }
|
||||
fn Sub(state) { return setAngle(state, rem(state.currentAngle + state.angle, divisor = 360)) }
|
||||
fn Gt2(@state) { return setLength(state, q = state.currentLength * state.factor) }
|
||||
fn Lt2(@state) { return setLength(state, q = state.currentLength / state.factor) }
|
||||
fn Add(@state) { return setAngle(state, q = rem(state.currentAngle - state.angle, divisor = 360)) }
|
||||
fn Sub(@state) { return setAngle(state, q = rem(state.currentAngle + state.angle, divisor = 360)) }
|
||||
|
||||
// Only necessary to get around recursion limitations...
|
||||
fn F(state, F) {
|
||||
return if Lt(state.depth, state.depthMax) {
|
||||
stateNext = state |> setDepth(%, state.depth + 1)
|
||||
fn F(@state, F) {
|
||||
return if Lt(a = state.depth, b = state.depthMax) {
|
||||
stateNext = state |> setDepth(%, q = state.depth + 1)
|
||||
|
||||
// Produce
|
||||
// Note:if you need [ and ], just save state to a variable.
|
||||
stateNext
|
||||
|> F(%, F) |> Sub(%) |> F(%, F)
|
||||
|> F(%, F = F) |> Sub(%) |> F(%, F = F)
|
||||
|> Add(%) |> Add(%)
|
||||
|> F(%, F) |> Sub(%) |> F(%, F)
|
||||
|> setDepth(%, stateNext.depth - 1)
|
||||
|> F(%, F = F) |> Sub(%) |> F(%, F = F)
|
||||
|> setDepth(%, q = stateNext.depth - 1)
|
||||
|
||||
} else {
|
||||
// Pass onto the next instruction
|
||||
state |> setSketch(%, angledLine(state.q, angle = state.currentAngle, length = state.currentLength))
|
||||
state |> setSketch(%, q = angledLine(state.q, angle = state.currentAngle, length = state.currentLength))
|
||||
}
|
||||
}
|
||||
|
||||
fn LSystem(args, axioms) {
|
||||
fn LSystem(@args, axioms) {
|
||||
myThing = startSketchOn(XY)
|
||||
|> startProfile(at = [0, 0])
|
||||
return axioms({
|
||||
@ -115,7 +115,8 @@ LSystem({
|
||||
iterations = 1,
|
||||
factor = 1.36,
|
||||
angle = 60,
|
||||
}, fn(q) {
|
||||
result = q |> F(%, F) |> Add(%) |> Add(%) |> F(%, F) |> Add(%) |> Add(%) |> F(%, F)
|
||||
}, axioms = fn(@q) {
|
||||
result = q |> F(%, F = F) |> Add(%) |> Add(%) |> F(%, F = F) |> Add(%) |> Add(%) |> F(%, F = F)
|
||||
return result.q
|
||||
})
|
||||
|
||||
|
@ -9,8 +9,8 @@ fn square(pos, scale) {
|
||||
return sg
|
||||
}
|
||||
|
||||
sq = square([0,0], 10)
|
||||
cb = square([3,3], 4)
|
||||
sq = square(pos = [0,0], scale = 10)
|
||||
cb = square(pos = [3,3], scale = 4)
|
||||
|> extrude(length = 10)
|
||||
|
||||
// pt1 = sq.paths[0]
|
||||
|
@ -13,7 +13,7 @@ fn box(sk1, sk2, scale) {
|
||||
return boxSketch
|
||||
}
|
||||
|
||||
box(0, 0, 5)
|
||||
box(10, 23, 8)
|
||||
thing = box(-12, -15, 10)
|
||||
box(-20, -5, 10)
|
||||
box(sk1 = 0, sk2 = 0, scale = 5)
|
||||
box(sk1 = 10, sk2 = 23, scale = 8)
|
||||
thing = box(sk1 = -12, sk2 = -15, scale = 10)
|
||||
box(sk1 = -20, sk2 = -5, scale = 10)
|
||||
|
@ -1,3 +1,3 @@
|
||||
export fn identity(x) {
|
||||
export fn identity(@x) {
|
||||
return x
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
export fn increment(x) {
|
||||
export fn increment(@x) {
|
||||
return x + 1
|
||||
}
|
||||
|
||||
export fn decrement(x) {
|
||||
export fn decrement(@x) {
|
||||
return x - 1
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Make sure pipe value doesn't leak into the function call.
|
||||
fn f(ignored) {
|
||||
fn f(@ignored) {
|
||||
return %
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ h = 10 // layer height
|
||||
t = 0.005 // taper factor [0-1)
|
||||
// Defines how to modify each layer of the vase.
|
||||
// Each replica is shifted up the Z axis, and has a smoothly-varying radius
|
||||
fn transform(replicaId) {
|
||||
fn transform(@replicaId) {
|
||||
scale = r * abs(1 - (t * replicaId)) * (5 + cos((replicaId / 8): number(rad)))
|
||||
return {
|
||||
translate = [0, 0, replicaId * 10],
|
||||
|
@ -10,7 +10,7 @@ p = startSketchOn(XY)
|
||||
|> angledLine(angle = 300, length = triangleLen, tag = $c)
|
||||
|> extrude(length = triangleHeight)
|
||||
|
||||
fn circl(x, face) {
|
||||
fn circl(@x, face) {
|
||||
return startSketchOn(p, face = face)
|
||||
|> startProfile(at = [x + radius, triangleHeight/2])
|
||||
|> arc(
|
||||
@ -22,7 +22,7 @@ return startSketchOn(p, face = face)
|
||||
|> close()
|
||||
}
|
||||
|
||||
c1 = circl(-200,c)
|
||||
c1 = circl(-200, face = c)
|
||||
plumbus1 =
|
||||
c1
|
||||
|> extrude(length = plumbusLen)
|
||||
@ -30,7 +30,7 @@ plumbus1 =
|
||||
radius = 5,
|
||||
tags = [c1.tags.arc_tag, getOppositeEdge(c1.tags.arc_tag)]
|
||||
)
|
||||
c2 = circl(200, a)
|
||||
c2 = circl(200, face = a)
|
||||
plumbus0 =
|
||||
c2
|
||||
|> extrude(length = plumbusLen)
|
||||
|
@ -17,7 +17,7 @@ fn cube(length, center) {
|
||||
|> extrude(length = length)
|
||||
}
|
||||
|
||||
fn double(x) { return x * 2}
|
||||
fn double(@x) { return x * 2}
|
||||
fn width() { return 200 }
|
||||
|
||||
myCube = cube(200 |> double(%), [0,0])
|
||||
myCube = cube(length = 200 |> double(), center = [0,0])
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
ANSWER = 41803
|
||||
|
||||
fn t(s) {
|
||||
fn t(@s) {
|
||||
return (ANSWER * s + 12345) % 214748
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
fn rect(origin) {
|
||||
fn rect(@origin) {
|
||||
return startSketchOn(XZ)
|
||||
|> startProfile(at = origin)
|
||||
|> angledLine(
|
||||
|
@ -9,7 +9,7 @@ serverDepth = 31
|
||||
width = 21.53
|
||||
|
||||
// simple caster model at each corner
|
||||
fn caster(originStart) {
|
||||
fn caster(@originStart) {
|
||||
plane001c = {
|
||||
origin = [
|
||||
-(3.543 - 2.756) / 2 + originStart[0],
|
||||
@ -1330,7 +1330,7 @@ extrude012rl = extrude(sketch012rl, length = -thickness)
|
||||
|
||||
// GENERATE SERVER MODELS
|
||||
// Define planes so the server can be moved
|
||||
fn streamServer(serverPos) {
|
||||
fn streamServer(@serverPos) {
|
||||
planeXYs = {
|
||||
origin = [0, 0 + 2, 4.114 + 1 + serverPos * 1.75],
|
||||
xAxis = [1.0, 0.0, 0.0],
|
||||
|
@ -7,7 +7,7 @@ serverDepth = 31
|
||||
width = 21.53
|
||||
|
||||
// simple caster model at each corner
|
||||
fn caster(originStart) {
|
||||
fn caster(@originStart) {
|
||||
plane001c = {
|
||||
origin = [
|
||||
-(3.543 - 2.756) / 2 + originStart[0],
|
||||
@ -967,7 +967,7 @@ sketch012rl = startSketchOn(extrude001rl, face = 'START')
|
||||
extrude012rl = extrude(sketch012rl, length = -thickness)
|
||||
|
||||
// Define planes so the server can be moved
|
||||
fn streamServer(serverPos) {
|
||||
fn streamServer(@serverPos) {
|
||||
planeXYs = {
|
||||
origin = [0, 0 + 2, 4.114 + 1 + serverPos * 1.75],
|
||||
xAxis = [1.0, 0.0, 0.0],
|
||||
|
@ -7,10 +7,10 @@ fn cube(pos, scale) {
|
||||
|
||||
return sg
|
||||
}
|
||||
part001 = cube([0,0], 20)
|
||||
part001 = cube(pos = [0,0], scale = 20)
|
||||
|> close()
|
||||
|> extrude(length = 20)
|
||||
|
||||
part002 = startSketchOn(part001, face = "end")
|
||||
|> circle(center: [0, 0], radius: 5, tag =$myCircle)
|
||||
|> circle(center = [0, 0], radius = 5, tag = $myCircle)
|
||||
|> extrude(length = 5)
|
||||
|
@ -7,7 +7,7 @@ fn cube(pos, scale) {
|
||||
|
||||
return sg
|
||||
}
|
||||
part001 = cube([0,0], 20)
|
||||
part001 = cube(pos = [0,0], scale = 20)
|
||||
|> close()
|
||||
|> extrude(length = 20)
|
||||
|
||||
|
@ -7,7 +7,7 @@ fn cube(pos, scale) {
|
||||
|
||||
return sg
|
||||
}
|
||||
part001 = cube([0,0], 20)
|
||||
part001 = cube(pos = [0,0], scale = 20)
|
||||
|> close()
|
||||
|> extrude(length = 20)
|
||||
|
||||
|
@ -7,7 +7,7 @@ fn cube(pos, scale) {
|
||||
|
||||
return sg
|
||||
}
|
||||
part001 = cube([0,0], 20)
|
||||
part001 = cube(pos = [0,0], scale = 20)
|
||||
|> close()
|
||||
|> extrude(length = 20)
|
||||
|
||||
|
@ -197,11 +197,11 @@ fn box(sk1, sk2, scale, plane) {
|
||||
return boxsketch
|
||||
}
|
||||
|
||||
box(0, 0, 5, XY)
|
||||
box(10, 23, 8, XZ)
|
||||
box(30, 43, 18, -XY)
|
||||
thing = box(-12, -15, 10, YZ)
|
||||
box(-20, -5, 10, XY)"#;
|
||||
box(sk1 = 0, sk2 = 0, scale = 5, plane = XY)
|
||||
box(sk1 = 10, sk2 = 23, scale = 8, plane = XZ)
|
||||
box(sk1 = 30, sk2 = 43, scale = 18, plane = -XY)
|
||||
thing = box(sk1 = -12, sk2 = -15, scale = 10, plane = YZ)
|
||||
box(sk1 = -20, sk2 = -5, scale = 10, plane = XY)"#;
|
||||
|
||||
let result = execute_and_snapshot(code, None).await.unwrap();
|
||||
assert_out("different_planes_same_drawing", &result);
|
||||
@ -295,7 +295,7 @@ async fn optional_params() {
|
||||
return sg
|
||||
}
|
||||
|
||||
thing = other_circle([2, 2], 20)
|
||||
thing = other_circle(pos = [2, 2], radius = 20)
|
||||
"#;
|
||||
let result = execute_and_snapshot(code, None).await.unwrap();
|
||||
assert_out("optional_params", &result);
|
||||
@ -303,7 +303,7 @@ thing = other_circle([2, 2], 20)
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn kcl_test_rounded_with_holes() {
|
||||
let code = r#"fn tarc(to, sktch, tag?) {
|
||||
let code = r#"fn tarc(@to, sktch, tag?) {
|
||||
return tangentialArc(sktch, endAbsolute = to, tag = tag)
|
||||
}
|
||||
|
||||
@ -311,13 +311,13 @@ fn roundedRectangle(pos, w, l, cornerRadius) {
|
||||
rr = startSketchOn(XY)
|
||||
|> startProfile(at = [pos[0] - w/2, 0])
|
||||
|> line(endAbsolute = [pos[0] - w/2, pos[1] - l/2 + cornerRadius])
|
||||
|> tarc([pos[0] - w/2 + cornerRadius, pos[1] - l/2], %, $arc0)
|
||||
|> tarc([pos[0] - w/2 + cornerRadius, pos[1] - l/2], sktch=%, tag=$arc0)
|
||||
|> line(endAbsolute = [pos[0] + w/2 - cornerRadius, pos[1] - l/2])
|
||||
|> tarc([pos[0] + w/2, pos[1] - l/2 + cornerRadius], %)
|
||||
|> tarc([pos[0] + w/2, pos[1] - l/2 + cornerRadius], sktch=%)
|
||||
|> line(endAbsolute = [pos[0] + w/2, pos[1] + l/2 - cornerRadius])
|
||||
|> tarc([pos[0] + w/2 - cornerRadius, pos[1] + l/2], %, $arc2)
|
||||
|> tarc([pos[0] + w/2 - cornerRadius, pos[1] + l/2], sktch=%, tag=$arc2)
|
||||
|> line(endAbsolute = [pos[0] - w/2 + cornerRadius, pos[1] + l/2])
|
||||
|> tarc([pos[0] - w/2, pos[1] + l/2 - cornerRadius], %)
|
||||
|> tarc([pos[0] - w/2, pos[1] + l/2 - cornerRadius], sktch=%)
|
||||
|> close()
|
||||
return rr
|
||||
}
|
||||
@ -325,11 +325,11 @@ fn roundedRectangle(pos, w, l, cornerRadius) {
|
||||
holeRadius = 1
|
||||
holeIndex = 6
|
||||
|
||||
part = roundedRectangle([0, 0], 20, 20, 4)
|
||||
|> subtract2d(tool = circle(center = [-holeIndex, holeIndex], radius= holeRadius))
|
||||
|> subtract2d(tool = circle(center = [holeIndex, holeIndex], radius= holeRadius))
|
||||
|> subtract2d(tool = circle(center = [-holeIndex, -holeIndex], radius= holeRadius))
|
||||
|> subtract2d(tool = circle(center = [holeIndex, -holeIndex], radius= holeRadius))
|
||||
part = roundedRectangle(pos=[0, 0], w=20, l=20, cornerRadius=4)
|
||||
|> subtract2d(tool = circle(center = [-holeIndex, holeIndex], radius = holeRadius))
|
||||
|> subtract2d(tool = circle(center = [holeIndex, holeIndex], radius = holeRadius))
|
||||
|> subtract2d(tool = circle(center = [-holeIndex, -holeIndex], radius = holeRadius))
|
||||
|> subtract2d(tool = circle(center = [holeIndex, -holeIndex], radius = holeRadius))
|
||||
|> extrude(length = 2)
|
||||
"#;
|
||||
|
||||
@ -581,7 +581,7 @@ async fn kcl_test_cube_mm() {
|
||||
return sg
|
||||
}
|
||||
|
||||
myCube = cube([0,0], 10)
|
||||
myCube = cube(pos = [0,0], scale = 10)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, None).await.unwrap();
|
||||
@ -603,7 +603,7 @@ fn cube(pos, scale) {
|
||||
return sg
|
||||
}
|
||||
|
||||
myCube = cube([0,0], 10)
|
||||
myCube = cube(pos = [0,0], scale = 10)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, None).await.unwrap();
|
||||
@ -625,7 +625,7 @@ fn cube(pos, scale) {
|
||||
return sg
|
||||
}
|
||||
|
||||
myCube = cube([0,0], 10)
|
||||
myCube = cube(pos = [0,0], scale = 10)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, None).await.unwrap();
|
||||
@ -647,7 +647,7 @@ fn cube(pos, scale) {
|
||||
return sg
|
||||
}
|
||||
|
||||
myCube = cube([0,0], 10)
|
||||
myCube = cube(pos = [0,0], scale = 10)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, None).await.unwrap();
|
||||
@ -669,7 +669,7 @@ fn cube(pos, scale) {
|
||||
return sg
|
||||
}
|
||||
|
||||
myCube = cube([0,0], 10)
|
||||
myCube = cube(pos = [0,0], scale = 10)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, None).await.unwrap();
|
||||
@ -691,7 +691,7 @@ fn cube(pos, scale) {
|
||||
return sg
|
||||
}
|
||||
|
||||
myCube = cube([0,0], 10)
|
||||
myCube = cube(pos = [0,0], scale = 10)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, None).await.unwrap();
|
||||
@ -709,7 +709,7 @@ async fn kcl_test_error_sketch_on_arc_face() {
|
||||
|
||||
return sg
|
||||
}
|
||||
part001 = cube([0, 0], 20)
|
||||
part001 = cube(pos = [0, 0], scale = 20)
|
||||
|> close()
|
||||
|> extrude(length = 20)
|
||||
|
||||
@ -745,7 +745,7 @@ async fn kcl_test_sketch_on_face_of_face() {
|
||||
|
||||
return sg
|
||||
}
|
||||
part001 = cube([0,0], 20)
|
||||
part001 = cube(pos = [0,0], scale = 20)
|
||||
|> close()
|
||||
|> extrude(length = 20)
|
||||
|
||||
@ -805,7 +805,7 @@ async fn kcl_test_sketch_on_face_circle() {
|
||||
|
||||
return sg
|
||||
}
|
||||
part001 = cube([0,0], 20)
|
||||
part001 = cube(pos = [0,0], scale = 20)
|
||||
|> close()
|
||||
|> extrude(length = 20)
|
||||
|
||||
@ -1151,7 +1151,7 @@ async fn kcl_test_plumbus_fillets() {
|
||||
return sg
|
||||
}
|
||||
|
||||
fn pentagon(len) {
|
||||
fn pentagon(@len) {
|
||||
sg = startSketchOn(XY)
|
||||
|> startProfile(at = [-len / 2, -len / 2])
|
||||
|> angledLine(angle = 0, length = len, tag = $a)
|
||||
@ -1181,7 +1181,7 @@ fn pentagon(len) {
|
||||
p = pentagon(32)
|
||||
|> extrude(length = 10)
|
||||
|
||||
circle0 = make_circle(p, p.sketch.tags.a, [0, 0], 2.5)
|
||||
circle0 = make_circle(ext=p, face=p.sketch.tags.a, pos=[0, 0], radius=2.5)
|
||||
plumbus0 = circle0
|
||||
|> extrude(length = 10)
|
||||
|> fillet(
|
||||
@ -1189,7 +1189,7 @@ plumbus0 = circle0
|
||||
tags = [circle0.tags.arc1, getOppositeEdge(circle0.tags.arc1)]
|
||||
)
|
||||
|
||||
circle1 = make_circle(p, p.sketch.tags.b, [0, 0], 2.5)
|
||||
circle1 = make_circle(ext=p, face=p.sketch.tags.b, pos=[0, 0], radius=2.5)
|
||||
plumbus1 = circle1
|
||||
|> extrude(length = 10)
|
||||
|> fillet(
|
||||
@ -1231,7 +1231,7 @@ async fn kcl_test_member_expression_in_params() {
|
||||
return screw
|
||||
}
|
||||
|
||||
capScrew([0, 0.5, 0], 50, 37.5, 50, 25)
|
||||
capScrew(originStart = [0, 0.5, 0], length=50, dia=37.5, capDia=50, capHeadLength=25)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, None).await.unwrap();
|
||||
@ -1327,13 +1327,13 @@ fn squareHole(l, w) {
|
||||
|
||||
extrusion = startSketchOn(XY)
|
||||
|> circle(center = [0, 0], radius= dia/2 )
|
||||
|> subtract2d(tool = squareHole(length, width, height))
|
||||
|> subtract2d(tool = squareHole(l = length, w = width, h = height))
|
||||
|> extrude(length = height)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, None).await;
|
||||
assert!(result.is_err());
|
||||
let expected_msg = "semantic: Expected 2 arguments, got 3";
|
||||
let expected_msg = "semantic: `h` is not an argument of `squareHole`";
|
||||
let err = result.unwrap_err().as_kcl_error().unwrap().get_message();
|
||||
assert_eq!(err, expected_msg);
|
||||
}
|
||||
@ -1531,7 +1531,7 @@ async fn kcl_test_linear_pattern3d_filleted_sketch() {
|
||||
|
||||
return sg
|
||||
}
|
||||
part001 = cube([0,0], 20)
|
||||
part001 = cube(pos = [0,0], scale = 20)
|
||||
|> close(tag = $line1)
|
||||
|> extrude(length = 20)
|
||||
|> fillet(
|
||||
@ -1562,7 +1562,7 @@ async fn kcl_test_circular_pattern3d_filleted_sketch() {
|
||||
|
||||
return sg
|
||||
}
|
||||
part001 = cube([0,0], 20)
|
||||
part001 = cube(pos = [0,0], scale = 20)
|
||||
|> close(tag = $line1)
|
||||
|> extrude(length = 20)
|
||||
|> fillet(
|
||||
@ -1589,7 +1589,7 @@ async fn kcl_test_circular_pattern3d_chamfered_sketch() {
|
||||
|
||||
return sg
|
||||
}
|
||||
part001 = cube([0,0], 20)
|
||||
part001 = cube(pos = [0,0], scale = 20)
|
||||
|> close(tag = $line1)
|
||||
|> extrude(length = 20)
|
||||
|> chamfer(
|
||||
@ -1615,7 +1615,7 @@ async fn kcl_test_tag_chamfer_with_more_than_one_edge_should_fail() {
|
||||
|
||||
return sg
|
||||
}
|
||||
part001 = cube([0,0], 20)
|
||||
part001 = cube(pos = [0,0], scale = 20)
|
||||
|> close(tag = $line1)
|
||||
|> extrude(length = 20)
|
||||
|> chamfer(
|
||||
@ -1640,7 +1640,7 @@ part001 = cube([0,0], 20)
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn kcl_test_duplicate_tags_should_error() {
|
||||
let code = r#"fn triangle(len) {
|
||||
let code = r#"fn triangle(@len) {
|
||||
return startSketchOn(XY)
|
||||
|> startProfile(at = [-len / 2, -len / 2])
|
||||
|> angledLine(angle = 0, length = len , tag = $a)
|
||||
@ -1926,7 +1926,7 @@ example = extrude(exampleSketch, length = 10)
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn kcl_test_error_inside_fn_also_has_source_range_of_call_site() {
|
||||
let code = r#"fn someFunction(something) {
|
||||
let code = r#"fn someFunction(@something) {
|
||||
startSketchOn(something)
|
||||
}
|
||||
|
||||
@ -1937,14 +1937,14 @@ someFunction('INVALID')
|
||||
assert!(result.is_err());
|
||||
assert_eq!(
|
||||
result.err().unwrap().to_string(),
|
||||
r#"semantic: KclErrorDetails { source_ranges: [SourceRange([45, 54, 0]), SourceRange([59, 82, 0])], message: "This function expected the input argument to be Solid or Plane but it's actually of type string (text)" }"#
|
||||
r#"semantic: KclErrorDetails { source_ranges: [SourceRange([46, 55, 0]), SourceRange([60, 83, 0])], message: "This function expected the input argument to be Solid or Plane but it's actually of type string (text)" }"#
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn kcl_test_error_inside_fn_also_has_source_range_of_call_site_recursive() {
|
||||
let code = r#"fn someFunction(something) {
|
||||
fn someNestedFunction(something2) {
|
||||
let code = r#"fn someFunction(@something) {
|
||||
fn someNestedFunction(@something2) {
|
||||
startSketchOn(something2)
|
||||
}
|
||||
|
||||
@ -1958,7 +1958,7 @@ someFunction('INVALID')
|
||||
assert!(result.is_err());
|
||||
assert_eq!(
|
||||
result.err().unwrap().to_string(),
|
||||
r#"semantic: KclErrorDetails { source_ranges: [SourceRange([91, 101, 0]), SourceRange([114, 143, 0]), SourceRange([147, 170, 0])], message: "This function expected the input argument to be Solid or Plane but it's actually of type string (text)" }"#
|
||||
r#"semantic: KclErrorDetails { source_ranges: [SourceRange([93, 103, 0]), SourceRange([116, 145, 0]), SourceRange([149, 172, 0])], message: "This function expected the input argument to be Solid or Plane but it's actually of type string (text)" }"#
|
||||
);
|
||||
}
|
||||
|
||||
@ -2038,6 +2038,17 @@ async fn kcl_test_ensure_nothing_left_in_batch_multi_file() {
|
||||
|
||||
ctx.close().await;
|
||||
}
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn kcl_test_default_param_for_unlabeled() {
|
||||
let code = r#"fn myExtrude(@sk, len) {
|
||||
return extrude(sk, length = len)
|
||||
}
|
||||
|
||||
sketch001 = startSketchOn(XY)
|
||||
|> circle(center = [0, 0], radius = 93.75)
|
||||
|> myExtrude(len = 40)"#;
|
||||
let _ = execute_and_snapshot(code, None).await.unwrap();
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn kcl_test_better_type_names() {
|
||||
|
@ -2187,7 +2187,15 @@ fn assign_args_to_params_kw(
|
||||
.mut_stack()
|
||||
.add(param.identifier.name.clone(), arg_val, (¶m.identifier).into())?;
|
||||
} else {
|
||||
let Some(unlabeled) = args.unlabeled.take() else {
|
||||
// TODO: Get the actual source range.
|
||||
// Part of https://github.com/KittyCAD/modeling-app/issues/6613
|
||||
let pipe_value_source_range = Default::default();
|
||||
let default_unlabeled = exec_state
|
||||
.mod_local
|
||||
.pipe_value
|
||||
.clone()
|
||||
.map(|val| Arg::new(val, pipe_value_source_range));
|
||||
let Some(unlabeled) = args.unlabeled.take().or(default_unlabeled) else {
|
||||
let param_name = ¶m.identifier.name;
|
||||
return Err(if args.labeled.contains_key(param_name) {
|
||||
KclError::Semantic(KclErrorDetails {
|
||||
|
@ -1298,16 +1298,16 @@ mod tests {
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn test_execute_fn_definitions() {
|
||||
let ast = r#"fn def(x) {
|
||||
let ast = r#"fn def(@x) {
|
||||
return x
|
||||
}
|
||||
fn ghi(x) {
|
||||
fn ghi(@x) {
|
||||
return x
|
||||
}
|
||||
fn jkl(x) {
|
||||
fn jkl(@x) {
|
||||
return x
|
||||
}
|
||||
fn hmm(x) {
|
||||
fn hmm(@x) {
|
||||
return x
|
||||
}
|
||||
|
||||
@ -1408,7 +1408,7 @@ firstExtrude = startSketchOn(XY)
|
||||
l = 8
|
||||
h = 10
|
||||
|
||||
fn thing(x) {
|
||||
fn thing(@x) {
|
||||
return -x
|
||||
}
|
||||
|
||||
@ -1429,7 +1429,7 @@ firstExtrude = startSketchOn(XY)
|
||||
l = 8
|
||||
h = 10
|
||||
|
||||
fn thing(x) {
|
||||
fn thing(@x) {
|
||||
return [0, -x]
|
||||
}
|
||||
|
||||
@ -1450,11 +1450,11 @@ firstExtrude = startSketchOn(XY)
|
||||
l = 8
|
||||
h = 10
|
||||
|
||||
fn other_thing(y) {
|
||||
fn other_thing(@y) {
|
||||
return -y
|
||||
}
|
||||
|
||||
fn thing(x) {
|
||||
fn thing(@x) {
|
||||
return other_thing(x)
|
||||
}
|
||||
|
||||
@ -1483,14 +1483,14 @@ firstExtrude = startSketchOn(XY)
|
||||
return myBox
|
||||
}
|
||||
|
||||
fnBox = box(3, 6, 10)"#;
|
||||
fnBox = box(h = 3, l = 6, w = 10)"#;
|
||||
|
||||
parse_execute(ast).await.unwrap();
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn test_get_member_of_object_with_function_period() {
|
||||
let ast = r#"fn box(obj) {
|
||||
let ast = r#"fn box(@obj) {
|
||||
myBox = startSketchOn(XY)
|
||||
|> startProfile(at = obj.start)
|
||||
|> line(end = [0, obj.l])
|
||||
@ -1577,7 +1577,7 @@ for var in [[3, 6, 10, [0,0]], [1.5, 3, 5, [-10,-10]]] {
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn test_get_member_of_array_with_function() {
|
||||
let ast = r#"fn box(arr) {
|
||||
let ast = r#"fn box(@arr) {
|
||||
myBox =startSketchOn(XY)
|
||||
|> startProfile(at = arr[0])
|
||||
|> line(end = [0, arr[1]])
|
||||
@ -1623,7 +1623,7 @@ answer = returnX()"#;
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn type_aliases() {
|
||||
let text = r#"type MyTy = [number; 2]
|
||||
fn foo(x: MyTy) {
|
||||
fn foo(@x: MyTy) {
|
||||
return x[0]
|
||||
}
|
||||
|
||||
@ -1783,7 +1783,7 @@ fn check(x) {
|
||||
assertIs(!x, error = "expected argument to be false")
|
||||
return true
|
||||
}
|
||||
check(false)
|
||||
check(x = false)
|
||||
"#;
|
||||
let result = parse_execute(ast).await.unwrap();
|
||||
assert_eq!(
|
||||
@ -1961,7 +1961,7 @@ bracket = startSketchOn(XY)
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn test_execute_function_no_return() {
|
||||
let ast = r#"fn test(origin) {
|
||||
let ast = r#"fn test(@origin) {
|
||||
origin
|
||||
}
|
||||
|
||||
@ -2154,7 +2154,7 @@ w = f() + f()
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn read_tag_version() {
|
||||
let ast = r#"fn bar(t) {
|
||||
let ast = r#"fn bar(@t) {
|
||||
return startSketchOn(XY)
|
||||
|> startProfile(at = [0,0])
|
||||
|> angledLine(
|
||||
|
@ -5,7 +5,10 @@ use crate::{
|
||||
errors::Suggestion,
|
||||
execution::{types::UnitLen, PlaneInfo, Point3d},
|
||||
lint::rule::{def_finding, Discovered, Finding},
|
||||
parsing::ast::types::{BinaryPart, Expr, LiteralValue, Node as AstNode, ObjectExpression, Program, UnaryOperator},
|
||||
parsing::ast::types::{
|
||||
BinaryPart, CallExpression, CallExpressionKw, Expr, LiteralValue, Node as AstNode, ObjectExpression, Program,
|
||||
UnaryOperator,
|
||||
},
|
||||
walk::Node,
|
||||
SourceRange,
|
||||
};
|
||||
@ -124,10 +127,16 @@ fn get_offset(info: &PlaneInfo) -> Option<f64> {
|
||||
}
|
||||
|
||||
pub fn start_sketch_on_check_specific_plane(node: Node) -> Result<Option<(SourceRange, PlaneName, f64)>> {
|
||||
let Node::CallExpression(call) = node else {
|
||||
return Ok(None);
|
||||
};
|
||||
match node {
|
||||
Node::CallExpression(node) => start_sketch_on_check_specific_plane_pos(node),
|
||||
Node::CallExpressionKw(node) => start_sketch_on_check_specific_plane_kw(node),
|
||||
_ => Ok(None),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn start_sketch_on_check_specific_plane_pos(
|
||||
call: &AstNode<CallExpression>,
|
||||
) -> Result<Option<(SourceRange, PlaneName, f64)>> {
|
||||
if call.inner.callee.inner.name.name != "startSketchOn" {
|
||||
return Ok(None);
|
||||
}
|
||||
@ -147,7 +156,34 @@ pub fn start_sketch_on_check_specific_plane(node: Node) -> Result<Option<(Source
|
||||
let Expr::ObjectExpression(arg) = &call.arguments[0] else {
|
||||
return Ok(None);
|
||||
};
|
||||
common(arg, call_source_range)
|
||||
}
|
||||
|
||||
pub fn start_sketch_on_check_specific_plane_kw(
|
||||
call: &AstNode<CallExpressionKw>,
|
||||
) -> Result<Option<(SourceRange, PlaneName, f64)>> {
|
||||
if call.inner.callee.inner.name.name != "startSketchOn" {
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
let Some(ref unlabeled) = call.inner.unlabeled else {
|
||||
// we only look for single-argument object patterns, if there's more
|
||||
// than that we don't have a plane decl
|
||||
return Ok(None);
|
||||
};
|
||||
|
||||
let call_source_range = SourceRange::new(unlabeled.start(), unlabeled.end(), unlabeled.module_id());
|
||||
|
||||
let Expr::ObjectExpression(arg) = &unlabeled else {
|
||||
return Ok(None);
|
||||
};
|
||||
common(arg, call_source_range)
|
||||
}
|
||||
|
||||
pub fn common(
|
||||
arg: &AstNode<ObjectExpression>,
|
||||
call_source_range: SourceRange,
|
||||
) -> Result<Option<(SourceRange, PlaneName, f64)>> {
|
||||
let mut origin: Option<Point3d> = None;
|
||||
let mut x_vec: Option<Point3d> = None;
|
||||
let mut y_vec: Option<Point3d> = None;
|
||||
|
@ -533,6 +533,23 @@ impl Backend {
|
||||
return Ok(false);
|
||||
}
|
||||
}
|
||||
crate::walk::Node::CallExpressionKw(call_expr) => {
|
||||
let sr: SourceRange = (&call_expr.callee).into();
|
||||
if sr.contains(source_range.start()) {
|
||||
let mut ti = token_index.lock().map_err(|_| anyhow::anyhow!("mutex"))?;
|
||||
*ti = match self.get_semantic_token_type_index(&SemanticTokenType::FUNCTION) {
|
||||
Some(index) => index,
|
||||
None => token_type_index,
|
||||
};
|
||||
|
||||
if self.stdlib_completions.contains_key(&call_expr.callee.name.name) {
|
||||
// This is a stdlib function.
|
||||
return get_modifier(vec![SemanticTokenModifier::DEFAULT_LIBRARY]);
|
||||
}
|
||||
|
||||
return Ok(false);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
Ok(true)
|
||||
|
@ -895,7 +895,7 @@ async fn test_kcl_lsp_on_hover() {
|
||||
foo = 42
|
||||
foo
|
||||
|
||||
fn bar(x: string): string {
|
||||
fn bar(@x: string): string {
|
||||
return x
|
||||
}
|
||||
|
||||
@ -971,7 +971,7 @@ startSketchOn(XY)
|
||||
|
||||
match hover.unwrap().contents {
|
||||
tower_lsp::lsp_types::HoverContents::Markup(tower_lsp::lsp_types::MarkupContent { value, .. }) => {
|
||||
assert!(value.contains("bar(x: string): string"));
|
||||
assert!(value.contains("bar(@x: string): string"));
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
@ -2027,7 +2027,7 @@ insideRevolve = startSketchOn(XZ)
|
||||
|> line(end = [0, -thickness])
|
||||
|> line(end = [-overHangLength, 0])
|
||||
|> close()
|
||||
|> revolve({ axis = Y }, %)
|
||||
|> revolve(axis = Y)
|
||||
|
||||
// Sketch and revolve one of the balls and duplicate it using a circular pattern. (This is currently a workaround, we have a bug with rotating on a sketch that touches the rotation axis)
|
||||
sphere = startSketchOn(XZ)
|
||||
@ -2035,7 +2035,7 @@ sphere = startSketchOn(XZ)
|
||||
|> line(end = [sphereDia - 0.1, 0])
|
||||
|> arc(angle_start = 0, angle_end = -180, radius = sphereDia / 2 - 0.05)
|
||||
|> close()
|
||||
|> revolve({ axis = X }, %)
|
||||
|> revolve(axis = X)
|
||||
|> patternCircular3d(
|
||||
axis = [0, 0, 1],
|
||||
center = [0, 0, 0],
|
||||
@ -2056,7 +2056,7 @@ outsideRevolve = startSketchOn(XZ)
|
||||
|> line(end = [0, thickness])
|
||||
|> line(end = [overHangLength - thickness, 0])
|
||||
|> close()
|
||||
|> revolve({ axis = Y }, %)"#
|
||||
|> revolve(axis = Y)"#
|
||||
.to_string(),
|
||||
},
|
||||
})
|
||||
@ -2090,7 +2090,7 @@ outsideRevolve = startSketchOn(XZ)
|
||||
start: tower_lsp::lsp_types::Position { line: 0, character: 0 },
|
||||
end: tower_lsp::lsp_types::Position {
|
||||
line: 50,
|
||||
character: 29
|
||||
character: 22
|
||||
}
|
||||
}
|
||||
);
|
||||
@ -2117,7 +2117,7 @@ insideRevolve = startSketchOn(XZ)
|
||||
|> line(end = [0, -thickness])
|
||||
|> line(end = [-overHangLength, 0])
|
||||
|> close()
|
||||
|> revolve({ axis = Y }, %)
|
||||
|> revolve(axis = Y)
|
||||
|
||||
// Sketch and revolve one of the balls and duplicate it using a circular pattern. (This is currently a workaround, we have a bug with rotating on a sketch that touches the rotation axis)
|
||||
sphere = startSketchOn(XZ)
|
||||
@ -2128,7 +2128,7 @@ sphere = startSketchOn(XZ)
|
||||
|> line(end = [sphereDia - 0.1, 0])
|
||||
|> arc(angle_start = 0, angle_end = -180, radius = sphereDia / 2 - 0.05)
|
||||
|> close()
|
||||
|> revolve({ axis = X }, %)
|
||||
|> revolve(axis = X)
|
||||
|> patternCircular3d(
|
||||
axis = [0, 0, 1],
|
||||
center = [0, 0, 0],
|
||||
@ -2152,7 +2152,7 @@ outsideRevolve = startSketchOn(XZ)
|
||||
|> line(end = [0, thickness])
|
||||
|> line(end = [overHangLength - thickness, 0])
|
||||
|> close()
|
||||
|> revolve({ axis = Y }, %)"#
|
||||
|> revolve(axis = Y)"#
|
||||
);
|
||||
}
|
||||
|
||||
@ -3891,7 +3891,7 @@ async fn test_kcl_lsp_on_hover_untitled_file_scheme() {
|
||||
foo = 42
|
||||
foo
|
||||
|
||||
fn bar(x: string): string {
|
||||
fn bar(@x: string): string {
|
||||
return x
|
||||
}
|
||||
|
||||
@ -3967,7 +3967,7 @@ startSketchOn(XY)
|
||||
|
||||
match hover.unwrap().contents {
|
||||
tower_lsp::lsp_types::HoverContents::Markup(tower_lsp::lsp_types::MarkupContent { value, .. }) => {
|
||||
assert!(value.contains("bar(x: string): string"));
|
||||
assert!(value.contains("bar(@x: string): string"));
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
@ -529,13 +529,13 @@ mod test {
|
||||
async fn test_parse_digest() {
|
||||
let prog1_string = r#"startSketchOn(XY)
|
||||
|> startProfile(at = [0, 0])
|
||||
|> line([5, 5], %)
|
||||
|> line([5, 5])
|
||||
"#;
|
||||
let prog1_digest = crate::parsing::top_level_parse(prog1_string).unwrap().compute_digest();
|
||||
|
||||
let prog2_string = r#"startSketchOn(XY)
|
||||
|> startProfile(at = [0, 2])
|
||||
|> line([5, 5], %)
|
||||
|> line([5, 5])
|
||||
"#;
|
||||
let prog2_digest = crate::parsing::top_level_parse(prog2_string).unwrap().compute_digest();
|
||||
|
||||
@ -543,7 +543,7 @@ mod test {
|
||||
|
||||
let prog3_string = r#"startSketchOn(XY)
|
||||
|> startProfile(at = [0, 0])
|
||||
|> line([5, 5], %)
|
||||
|> line([5, 5])
|
||||
"#;
|
||||
let prog3_digest = crate::parsing::top_level_parse(prog3_string).unwrap().compute_digest();
|
||||
|
||||
|
@ -3739,11 +3739,11 @@ mod tests {
|
||||
fn test_get_lsp_folding_ranges() {
|
||||
let code = r#"part001 = startSketchOn(XY)
|
||||
|> startProfile(at = [0.0000000000, 5.0000000000])
|
||||
|> line([0.4900857016, -0.0240763666], %)
|
||||
|> line([0.4900857016, -0.0240763666])
|
||||
|
||||
startSketchOn(XY)
|
||||
|> startProfile(at = [0.0000000000, 5.0000000000])
|
||||
|> line([0.4900857016, -0.0240763666], %)
|
||||
|> line([0.4900857016, -0.0240763666])
|
||||
|
||||
part002 = "part002"
|
||||
things = [part001, 0.0]
|
||||
@ -3751,7 +3751,7 @@ blah = 1
|
||||
foo = false
|
||||
baz = {a = 1, b = "thing"}
|
||||
|
||||
fn ghi(x) {
|
||||
fn ghi(@x) {
|
||||
return x
|
||||
}
|
||||
|
||||
@ -3761,24 +3761,24 @@ ghi("things")
|
||||
let folding_ranges = program.get_lsp_folding_ranges();
|
||||
assert_eq!(folding_ranges.len(), 3);
|
||||
assert_eq!(folding_ranges[0].start_line, 27);
|
||||
assert_eq!(folding_ranges[0].end_line, 126);
|
||||
assert_eq!(folding_ranges[0].end_line, 123);
|
||||
assert_eq!(
|
||||
folding_ranges[0].collapsed_text,
|
||||
Some("part001 = startSketchOn(XY)".to_string())
|
||||
);
|
||||
assert_eq!(folding_ranges[1].start_line, 145);
|
||||
assert_eq!(folding_ranges[1].end_line, 244);
|
||||
assert_eq!(folding_ranges[1].start_line, 142);
|
||||
assert_eq!(folding_ranges[1].end_line, 238);
|
||||
assert_eq!(folding_ranges[1].collapsed_text, Some("startSketchOn(XY)".to_string()));
|
||||
assert_eq!(folding_ranges[2].start_line, 350);
|
||||
assert_eq!(folding_ranges[2].end_line, 363);
|
||||
assert_eq!(folding_ranges[2].collapsed_text, Some("fn ghi(x) {".to_string()));
|
||||
assert_eq!(folding_ranges[2].start_line, 345);
|
||||
assert_eq!(folding_ranges[2].end_line, 358);
|
||||
assert_eq!(folding_ranges[2].collapsed_text, Some("fn ghi(@x) {".to_string()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_lsp_symbols() {
|
||||
let code = r#"part001 = startSketchOn(XY)
|
||||
|> startProfile(at = [0.0000000000, 5.0000000000])
|
||||
|> line([0.4900857016, -0.0240763666], %)
|
||||
|> line([0.4900857016, -0.0240763666])
|
||||
|
||||
part002 = "part002"
|
||||
things = [part001, 0.0]
|
||||
@ -3804,12 +3804,12 @@ h = 30
|
||||
|
||||
cylinder = startSketchOn(-XZ)
|
||||
|> startProfile(at = [50, 0])
|
||||
|> arc({
|
||||
|> arc(
|
||||
angle_end = 360,
|
||||
angle_start = 0,
|
||||
radius = r
|
||||
}, %)
|
||||
|> extrude(h, %)
|
||||
)
|
||||
|> extrude(h)
|
||||
"#;
|
||||
let program = crate::parsing::top_level_parse(some_program_string).unwrap();
|
||||
|
||||
@ -3825,12 +3825,12 @@ h = 30
|
||||
cylinder = startSketchOn(-XZ)
|
||||
|> startProfile(at = [50, 0])
|
||||
// comment
|
||||
|> arc({
|
||||
|> arc(
|
||||
angle_end= 360,
|
||||
angle_start= 0,
|
||||
radius= r
|
||||
}, %)
|
||||
|> extrude(h, %)
|
||||
)
|
||||
|> extrude(h)
|
||||
"#;
|
||||
let program = crate::parsing::top_level_parse(some_program_string).unwrap();
|
||||
|
||||
@ -4105,7 +4105,7 @@ cylinder = startSketchOn(-XZ)
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn test_parse_object_bool() {
|
||||
let some_program_string = r#"some_func({thing: true, other_thing: false})"#;
|
||||
let some_program_string = r#"some_func({thing = true, other_thing = false})"#;
|
||||
let program = crate::parsing::top_level_parse(some_program_string).unwrap();
|
||||
|
||||
// We want to get the bool and verify it is a bool.
|
||||
@ -4123,15 +4123,23 @@ cylinder = startSketchOn(-XZ)
|
||||
panic!("expected a function!");
|
||||
};
|
||||
|
||||
let Expr::CallExpression(ce) = expression else {
|
||||
panic!("expected a function!");
|
||||
};
|
||||
let oe = match expression {
|
||||
Expr::CallExpressionKw(ce) => {
|
||||
assert!(ce.unlabeled.is_some());
|
||||
|
||||
assert!(!ce.arguments.is_empty());
|
||||
|
||||
let Expr::ObjectExpression(oe) = ce.arguments.first().unwrap() else {
|
||||
let Expr::ObjectExpression(oe) = ce.unlabeled.as_ref().unwrap() else {
|
||||
panic!("expected a object!");
|
||||
};
|
||||
oe
|
||||
}
|
||||
Expr::CallExpression(ce) => {
|
||||
let Expr::ObjectExpression(ref oe) = (ce.arguments).first().unwrap() else {
|
||||
panic!("expected an object!");
|
||||
};
|
||||
oe
|
||||
}
|
||||
other => panic!("expected a Call or CallKw, found {other:?}"),
|
||||
};
|
||||
|
||||
assert_eq!(oe.properties.len(), 2);
|
||||
|
||||
|
@ -14,7 +14,7 @@ use winnow::{
|
||||
};
|
||||
|
||||
use super::{
|
||||
ast::types::{AscribedExpression, ImportPath, LabelledExpression},
|
||||
ast::types::{AscribedExpression, CallExpression, ImportPath, LabelledExpression},
|
||||
token::{NumericSuffix, RESERVED_WORDS},
|
||||
DeprecationKind,
|
||||
};
|
||||
@ -24,13 +24,12 @@ use crate::{
|
||||
parsing::{
|
||||
ast::types::{
|
||||
Annotation, ArrayExpression, ArrayRangeExpression, BinaryExpression, BinaryOperator, BinaryPart, BodyItem,
|
||||
BoxNode, CallExpression, CallExpressionKw, CommentStyle, DefaultParamVal, ElseIf, Expr,
|
||||
ExpressionStatement, FunctionExpression, Identifier, IfExpression, ImportItem, ImportSelector,
|
||||
ImportStatement, ItemVisibility, LabeledArg, Literal, LiteralIdentifier, LiteralValue, MemberExpression,
|
||||
MemberObject, Name, Node, NodeList, NonCodeMeta, NonCodeNode, NonCodeValue, ObjectExpression,
|
||||
ObjectProperty, Parameter, PipeExpression, PipeSubstitution, PrimitiveType, Program, ReturnStatement,
|
||||
Shebang, TagDeclarator, Type, TypeDeclaration, UnaryExpression, UnaryOperator, VariableDeclaration,
|
||||
VariableDeclarator, VariableKind,
|
||||
BoxNode, CallExpressionKw, CommentStyle, DefaultParamVal, ElseIf, Expr, ExpressionStatement,
|
||||
FunctionExpression, Identifier, IfExpression, ImportItem, ImportSelector, ImportStatement, ItemVisibility,
|
||||
LabeledArg, Literal, LiteralIdentifier, LiteralValue, MemberExpression, MemberObject, Name, Node, NodeList,
|
||||
NonCodeMeta, NonCodeNode, NonCodeValue, ObjectExpression, ObjectProperty, Parameter, PipeExpression,
|
||||
PipeSubstitution, PrimitiveType, Program, ReturnStatement, Shebang, TagDeclarator, Type, TypeDeclaration,
|
||||
UnaryExpression, UnaryOperator, VariableDeclaration, VariableDeclarator, VariableKind,
|
||||
},
|
||||
math::BinaryExpressionToken,
|
||||
token::{Token, TokenSlice, TokenType},
|
||||
@ -3047,6 +3046,46 @@ fn fn_call_kw(i: &mut TokenSlice) -> PResult<Node<CallExpressionKw>> {
|
||||
let _ = open_paren.parse_next(i)?;
|
||||
ignore_whitespace(i);
|
||||
|
||||
// Special case: no args
|
||||
let early_close = peek(close_paren).parse_next(i);
|
||||
if early_close.is_ok() {
|
||||
let cl = close_paren.parse_next(i)?;
|
||||
let result = Node::new_node(
|
||||
fn_name.start,
|
||||
cl.end,
|
||||
fn_name.module_id,
|
||||
CallExpressionKw {
|
||||
callee: fn_name,
|
||||
unlabeled: Default::default(),
|
||||
arguments: Default::default(),
|
||||
digest: None,
|
||||
non_code_meta: Default::default(),
|
||||
},
|
||||
);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
// Special case: one arg (unlabeled)
|
||||
let early_close = peek((expression, opt(whitespace), close_paren)).parse_next(i);
|
||||
if early_close.is_ok() {
|
||||
let first_expression = expression.parse_next(i)?;
|
||||
ignore_whitespace(i);
|
||||
let end = close_paren.parse_next(i)?.end;
|
||||
let result = Node::new_node(
|
||||
fn_name.start,
|
||||
end,
|
||||
fn_name.module_id,
|
||||
CallExpressionKw {
|
||||
callee: fn_name,
|
||||
unlabeled: Some(first_expression),
|
||||
arguments: Default::default(),
|
||||
digest: None,
|
||||
non_code_meta: Default::default(),
|
||||
},
|
||||
);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
enum ArgPlace {
|
||||
NonCode(Node<NonCodeNode>),
|
||||
@ -3834,7 +3873,7 @@ mySk1 = startSketchOn(XY)
|
||||
#[test]
|
||||
fn pipes_on_pipes_minimal() {
|
||||
let test_program = r#"startSketchOn(XY)
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> startProfile(at = [0, 0])
|
||||
|> line(endAbsolute = [0, -0]) // MoveRelative
|
||||
|
||||
"#;
|
||||
@ -4105,7 +4144,7 @@ mySk1 = startSketchOn(XY)
|
||||
fn test_parse_half_pipe_small() {
|
||||
assert_err_contains(
|
||||
"secondExtrude = startSketchOn(XY)
|
||||
|> startProfileAt([0,0], %)
|
||||
|> startProfile(at = [0,0])
|
||||
|",
|
||||
"Unexpected token: |",
|
||||
);
|
||||
@ -4169,7 +4208,7 @@ height = [obj["a"] -1, 0]"#;
|
||||
|
||||
#[test]
|
||||
fn test_anon_fn() {
|
||||
crate::parsing::top_level_parse("foo(42, fn(x) { return x + 1 })").unwrap();
|
||||
crate::parsing::top_level_parse("foo(num=42, closure=fn(x) { return x + 1 })").unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -4198,15 +4237,15 @@ height = [obj["a"] -1, 0]"#;
|
||||
let code = "height = 10
|
||||
|
||||
firstExtrude = startSketchOn(XY)
|
||||
|> startProfileAt([0,0], %)
|
||||
|> line([0, 8], %)
|
||||
|> line([20, 0], %)
|
||||
|> line([0, -8], %)
|
||||
|> startProfile(at = [0,0])
|
||||
|> line(at = [0, 8])
|
||||
|> line(at = [20, 0])
|
||||
|> line(at = [0, -8])
|
||||
|> close()
|
||||
|> extrude(length=2)
|
||||
|
||||
secondExtrude = startSketchOn(XY)
|
||||
|> startProfileAt([0,0], %)
|
||||
|> startProfile(at = [0,0])
|
||||
|";
|
||||
assert_err_contains(code, "Unexpected token: |");
|
||||
}
|
||||
@ -4477,7 +4516,7 @@ e
|
||||
///
|
||||
/// ```
|
||||
/// exampleSketch = startSketchOn(XZ)
|
||||
/// |> startProfileAt([0, 0], %)
|
||||
/// |> startProfile(at = [0, 0])
|
||||
/// |> angledLine(
|
||||
/// angle = 30,
|
||||
/// length = 3 / cos(toRadians(30)),
|
||||
@ -4517,7 +4556,7 @@ export fn cos(num: number(rad)): number(_) {}"#;
|
||||
|
||||
#[test]
|
||||
fn error_underscore() {
|
||||
let (_, errs) = assert_no_fatal("_foo(_blah, _)");
|
||||
let (_, errs) = assert_no_fatal("_foo(a=_blah, b=_)");
|
||||
assert_eq!(errs.len(), 3, "found: {errs:#?}");
|
||||
}
|
||||
|
||||
@ -4629,11 +4668,11 @@ thing(false)
|
||||
#[test]
|
||||
fn random_words_fail() {
|
||||
let test_program = r#"part001 = startSketchOn(-XZ)
|
||||
|> startProfileAt([8.53, 11.8], %)
|
||||
|> startProfile(at = [8.53, 11.8])
|
||||
asdasd asdasd
|
||||
|> line([11.12, -14.82], %)
|
||||
|> line([-13.27, -6.98], %)
|
||||
|> line([-5.09, 12.33], %)
|
||||
|> line(at = [11.12, -14.82])
|
||||
|> line(at = [-13.27, -6.98])
|
||||
|> line(at = [-5.09, 12.33])
|
||||
asdasd
|
||||
"#;
|
||||
let _ = crate::parsing::top_level_parse(test_program).unwrap_errs();
|
||||
@ -4643,16 +4682,16 @@ thing(false)
|
||||
fn test_member_expression_sketch() {
|
||||
let some_program_string = r#"fn cube(pos, scale) {
|
||||
sg = startSketchOn(XY)
|
||||
|> startProfileAt(pos, %)
|
||||
|> line([0, scale], %)
|
||||
|> line([scale, 0], %)
|
||||
|> line([0, -scale], %)
|
||||
|> startProfile(pos)
|
||||
|> line(at = [0, scale])
|
||||
|> line(at = [scale, 0])
|
||||
|> line(at = [0, -scale])
|
||||
|
||||
return sg
|
||||
}
|
||||
|
||||
b1 = cube([0,0], 10)
|
||||
b2 = cube([3,3], 4)
|
||||
b1 = cube(pos=[0,0], scale=10)
|
||||
b2 = cube(pos=[3,3], scale=4)
|
||||
|
||||
pt1 = b1[0]
|
||||
pt2 = b2[0]
|
||||
@ -4671,16 +4710,16 @@ let other_thing = 2 * cos(3)"#;
|
||||
fn test_negative_arguments() {
|
||||
let some_program_string = r#"fn box(p, h, l, w) {
|
||||
myBox = startSketchOn(XY)
|
||||
|> startProfileAt(p, %)
|
||||
|> line([0, l], %)
|
||||
|> line([w, 0], %)
|
||||
|> line([0, -l], %)
|
||||
|> startProfile(p)
|
||||
|> line(at = [0, l])
|
||||
|> line(at = [w, 0])
|
||||
|> line(at = [0, -l])
|
||||
|> close()
|
||||
|> extrude(length=h)
|
||||
|
||||
return myBox
|
||||
}
|
||||
let myBox = box([0,0], -3, -16, -10)
|
||||
let myBox = box(p=[0,0], h=-3, l=-16, w=-10)
|
||||
"#;
|
||||
crate::parsing::top_level_parse(some_program_string).unwrap();
|
||||
}
|
||||
@ -4697,20 +4736,20 @@ let myBox = box([0,0], -3, -16, -10)
|
||||
#[test]
|
||||
fn test_parse_tag_named_std_lib() {
|
||||
let some_program_string = r#"startSketchOn(XY)
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> line([5, 5], %, $xLine)
|
||||
|> startProfile(at = [0, 0])
|
||||
|> line(%, end = [5, 5], tag = $xLine)
|
||||
"#;
|
||||
assert_err(
|
||||
some_program_string,
|
||||
"Cannot assign a tag to a reserved keyword: xLine",
|
||||
[74, 80],
|
||||
[86, 92],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_empty_tag_brace() {
|
||||
let some_program_string = r#"startSketchOn(XY)
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> startProfile(at = [0, 0])
|
||||
|> line(%, $)
|
||||
"#;
|
||||
assert_err(some_program_string, "Tag names must not be empty", [67, 68]);
|
||||
@ -4718,7 +4757,7 @@ let myBox = box([0,0], -3, -16, -10)
|
||||
#[test]
|
||||
fn test_parse_empty_tag_whitespace() {
|
||||
let some_program_string = r#"startSketchOn(XY)
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> startProfile(at = [0, 0])
|
||||
|> line(%, $ ,01)
|
||||
"#;
|
||||
assert_err(some_program_string, "Tag names must not be empty", [67, 68]);
|
||||
@ -4727,7 +4766,7 @@ let myBox = box([0,0], -3, -16, -10)
|
||||
#[test]
|
||||
fn test_parse_empty_tag_comma() {
|
||||
let some_program_string = r#"startSketchOn(XY)
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> startProfile(at = [0, 0])
|
||||
|> line(%, $,)
|
||||
"#;
|
||||
assert_err(some_program_string, "Tag names must not be empty", [67, 68]);
|
||||
@ -4736,7 +4775,7 @@ let myBox = box([0,0], -3, -16, -10)
|
||||
fn test_parse_tag_starting_with_digit() {
|
||||
let some_program_string = r#"
|
||||
startSketchOn(XY)
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> startProfile(at = [0, 0])
|
||||
|> line(%, $01)"#;
|
||||
assert_err(
|
||||
some_program_string,
|
||||
@ -4748,14 +4787,14 @@ let myBox = box([0,0], -3, -16, -10)
|
||||
fn test_parse_tag_including_digit() {
|
||||
let some_program_string = r#"
|
||||
startSketchOn(XY)
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> line(%, $var01)"#;
|
||||
|> startProfile(at = [0, 0])
|
||||
|> line(%, tag = $var01)"#;
|
||||
assert_no_err(some_program_string);
|
||||
}
|
||||
#[test]
|
||||
fn test_parse_tag_starting_with_bang() {
|
||||
let some_program_string = r#"startSketchOn(XY)
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> startProfile(at = [0, 0])
|
||||
|> line(%, $!var,01)
|
||||
"#;
|
||||
assert_err(some_program_string, "Tag names must not start with a bang", [67, 68]);
|
||||
@ -4763,7 +4802,7 @@ let myBox = box([0,0], -3, -16, -10)
|
||||
#[test]
|
||||
fn test_parse_tag_starting_with_dollar() {
|
||||
let some_program_string = r#"startSketchOn(XY)
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> startProfile(at = [0, 0])
|
||||
|> line(%, $$,01)
|
||||
"#;
|
||||
assert_err(some_program_string, "Tag names must not start with a dollar", [67, 68]);
|
||||
@ -4771,7 +4810,7 @@ let myBox = box([0,0], -3, -16, -10)
|
||||
#[test]
|
||||
fn test_parse_tag_starting_with_fn() {
|
||||
let some_program_string = r#"startSketchOn(XY)
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> startProfile(at = [0, 0])
|
||||
|> line(%, $fn,01)
|
||||
"#;
|
||||
assert_err(some_program_string, "Tag names must not start with a keyword", [67, 69]);
|
||||
@ -4779,7 +4818,7 @@ let myBox = box([0,0], -3, -16, -10)
|
||||
#[test]
|
||||
fn test_parse_tag_starting_with_a_comment() {
|
||||
let some_program_string = r#"startSketchOn(XY)
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> startProfile(at = [0, 0])
|
||||
|> line(%, $//
|
||||
,01)
|
||||
"#;
|
||||
@ -4794,8 +4833,8 @@ let myBox = box([0,0], -3, -16, -10)
|
||||
fn test_parse_tag_with_reserved_in_middle_works() {
|
||||
let some_program_string = r#"
|
||||
startSketchOn(XY)
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> line([5, 5], %, $sketching)
|
||||
|> startProfile(at = [0, 0])
|
||||
|> line(end = [5, 5], tag = $sketching)
|
||||
"#;
|
||||
assert_no_err(some_program_string);
|
||||
}
|
||||
@ -4803,21 +4842,21 @@ let myBox = box([0,0], -3, -16, -10)
|
||||
#[test]
|
||||
fn test_parse_array_missing_closing_bracket() {
|
||||
let some_program_string = r#"
|
||||
sketch001 = startSketchOn(XZ) |> startProfileAt([90.45, 119.09, %)"#;
|
||||
sketch001 = startSketchOn(XZ) |> startProfile(at = [90.45, 119.09)"#;
|
||||
assert_err(
|
||||
some_program_string,
|
||||
"Encountered an unexpected character(s) before finding a closing bracket(`]`) for the array",
|
||||
[49, 65],
|
||||
[52, 60],
|
||||
);
|
||||
}
|
||||
#[test]
|
||||
fn test_parse_array_missing_comma() {
|
||||
let some_program_string = r#"
|
||||
sketch001 = startSketchOn(XZ) |> startProfileAt([90.45 119.09], %)"#;
|
||||
sketch001 = startSketchOn(XZ) |> startProfile(at = [90.45 119.09])"#;
|
||||
assert_err(
|
||||
some_program_string,
|
||||
"Unexpected character encountered. You might be missing a comma in between elements.",
|
||||
[50, 63],
|
||||
[53, 66],
|
||||
);
|
||||
}
|
||||
#[test]
|
||||
@ -4825,21 +4864,21 @@ sketch001 = startSketchOn(XZ) |> startProfileAt([90.45 119.09], %)"#;
|
||||
// since there is an early exit if encountering a reserved word, the error should be about
|
||||
// that and not the missing comma
|
||||
let some_program_string = r#"
|
||||
sketch001 = startSketchOn(XZ) |> startProfileAt([90.45 $struct], %)"#;
|
||||
sketch001 = startSketchOn(XZ) |> startProfile(at = [90.45 $struct])"#;
|
||||
assert_err(
|
||||
some_program_string,
|
||||
"Encountered an unexpected character(s) before finding a closing bracket(`]`) for the array",
|
||||
[49, 50],
|
||||
[52, 53],
|
||||
);
|
||||
}
|
||||
#[test]
|
||||
fn test_parse_array_random_brace() {
|
||||
let some_program_string = r#"
|
||||
sketch001 = startSketchOn(XZ) |> startProfileAt([}], %)"#;
|
||||
sketch001 = startSketchOn(XZ) |> startProfile(at = [}])"#;
|
||||
assert_err(
|
||||
some_program_string,
|
||||
"Encountered an unexpected character(s) before finding a closing bracket(`]`) for the array",
|
||||
[49, 50],
|
||||
[52, 53],
|
||||
);
|
||||
}
|
||||
|
||||
@ -5075,17 +5114,17 @@ mod snapshot_tests {
|
||||
snapshot_test!(
|
||||
a,
|
||||
r#"boxSketch = startSketchOn(XY)
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> line([0, 10], %)
|
||||
|> tangentialArc([-5, 5], %)
|
||||
|> line([5, -15], %)
|
||||
|> startProfileAt(at = [0, 0])
|
||||
|> line(at = [0, 10])
|
||||
|> tangentialArc(end = [-5, 5])
|
||||
|> line(at = [5, -15])
|
||||
|> extrude(length=10)
|
||||
"#
|
||||
);
|
||||
snapshot_test!(b, "myVar = min(5 , -legLen(5, 4))"); // Space before comma
|
||||
snapshot_test!(b, "myVar = min(x=5 , y=-legLen(5, z=4))"); // Space before comma
|
||||
|
||||
snapshot_test!(c, "myVar = min(-legLen(5, 4), 5)");
|
||||
snapshot_test!(d, "myVar = 5 + 6 |> myFunc(45, %)");
|
||||
snapshot_test!(c, "myVar = min(x=-legLen(a=5, b=4), y=5)");
|
||||
snapshot_test!(d, "myVar = 5 + 6 |> myFunc(45)");
|
||||
snapshot_test!(e, "x = 1 * (3 - 4)");
|
||||
snapshot_test!(f, r#"x = 1 // this is an inline comment"#);
|
||||
snapshot_test!(
|
||||
@ -5141,11 +5180,11 @@ mod snapshot_tests {
|
||||
snapshot_test!(v, r#"pt1 = b1[0]"#);
|
||||
snapshot_test!(w, r#"pt1 = b1['zero']"#);
|
||||
snapshot_test!(x, r#"pt1 = b1.zero"#);
|
||||
snapshot_test!(y, r#"sg = startSketchOn(XY) |> startProfileAt(pos, %)"#);
|
||||
snapshot_test!(y, r#"sg = startSketchOn(XY) |> startProfile(pos)"#);
|
||||
snapshot_test!(
|
||||
z,
|
||||
"sg = startSketchOn(XY)
|
||||
|> startProfileAt(pos) |> line([0, -scale], %)"
|
||||
|> startProfile(pos) |> line([0, -scale])"
|
||||
);
|
||||
snapshot_test!(aa, r#"sg = -scale"#);
|
||||
snapshot_test!(ab, "line(endAbsolute = [0, -1])");
|
||||
@ -5168,7 +5207,7 @@ mod snapshot_tests {
|
||||
snapshot_test!(
|
||||
af,
|
||||
r#"mySketch = startSketchOn(XY)
|
||||
|> startProfileAt([0,0], %)
|
||||
|> startProfile(at = [0,0])
|
||||
|> line(endAbsolute = [0, 1], tag = $myPath)
|
||||
|> line(endAbsolute = [1, 1])
|
||||
|> line(endAbsolute = [1, 0], tag = $rightPath)
|
||||
@ -5176,21 +5215,21 @@ mod snapshot_tests {
|
||||
);
|
||||
snapshot_test!(
|
||||
ag,
|
||||
"mySketch = startSketchOn(XY) |> startProfileAt([0,0], %) |> line(endAbsolute = [1, 1]) |> close()"
|
||||
"mySketch = startSketchOn(XY) |> startProfile(at = [0,0]) |> line(endAbsolute = [1, 1]) |> close()"
|
||||
);
|
||||
snapshot_test!(ah, "myBox = startSketchOn(XY) |> startProfileAt(p, %)");
|
||||
snapshot_test!(ai, r#"myBox = f(1) |> g(2, %)"#);
|
||||
snapshot_test!(ah, "myBox = startSketchOn(XY) |> startProfile(at = p)");
|
||||
snapshot_test!(ai, r#"myBox = f(1) |> g(2)"#);
|
||||
snapshot_test!(
|
||||
aj,
|
||||
r#"myBox = startSketchOn(XY) |> startProfileAt(p, %) |> line(end = [0, l])"#
|
||||
r#"myBox = startSketchOn(XY) |> startProfile(at = p) |> line(end = [0, l])"#
|
||||
);
|
||||
snapshot_test!(ak, "line(endAbsolute = [0, 1])");
|
||||
snapshot_test!(ap, "mySketch = startSketchOn(XY) |> startProfileAt([0,0], %)");
|
||||
snapshot_test!(aq, "log(5, \"hello\", aIdentifier)");
|
||||
snapshot_test!(ap, "mySketch = startSketchOn(XY) |> startProfile(at = [0,0])");
|
||||
snapshot_test!(aq, "log(number = 5, msg = \"hello\", id=aIdentifier)");
|
||||
snapshot_test!(ar, r#"5 + "a""#);
|
||||
snapshot_test!(at, "line([0, l], %)");
|
||||
snapshot_test!(at, "line([0, l])");
|
||||
snapshot_test!(au, include_str!("../../e2e/executor/inputs/cylinder.kcl"));
|
||||
snapshot_test!(av, "fn f(angle?) { return default(angle, 360) }");
|
||||
snapshot_test!(av, "fn f(angle?) { return default(maybe=angle, otherwise=360) }");
|
||||
snapshot_test!(
|
||||
aw,
|
||||
"numbers = [
|
||||
|
@ -8,7 +8,7 @@ expression: actual
|
||||
"commentStart": 0,
|
||||
"declaration": {
|
||||
"commentStart": 0,
|
||||
"end": 170,
|
||||
"end": 179,
|
||||
"id": {
|
||||
"commentStart": 0,
|
||||
"end": 9,
|
||||
@ -61,13 +61,22 @@ expression: actual
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 52,
|
||||
"end": 54,
|
||||
"name": "at",
|
||||
"start": 52,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 57,
|
||||
"elements": [
|
||||
{
|
||||
"commentStart": 53,
|
||||
"end": 54,
|
||||
"commentStart": 58,
|
||||
"end": 59,
|
||||
"raw": "0",
|
||||
"start": 53,
|
||||
"start": 58,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
@ -76,10 +85,10 @@ expression: actual
|
||||
}
|
||||
},
|
||||
{
|
||||
"commentStart": 56,
|
||||
"end": 57,
|
||||
"commentStart": 61,
|
||||
"end": 62,
|
||||
"raw": "0",
|
||||
"start": 56,
|
||||
"start": 61,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
@ -88,17 +97,11 @@ expression: actual
|
||||
}
|
||||
}
|
||||
],
|
||||
"end": 58,
|
||||
"start": 52,
|
||||
"end": 63,
|
||||
"start": 57,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
},
|
||||
{
|
||||
"commentStart": 60,
|
||||
"end": 61,
|
||||
"start": 60,
|
||||
"type": "PipeSubstitution",
|
||||
"type": "PipeSubstitution"
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
@ -117,21 +120,31 @@ expression: actual
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 37,
|
||||
"end": 62,
|
||||
"end": 64,
|
||||
"start": 37,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"commentStart": 75,
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 77,
|
||||
"end": 79,
|
||||
"name": "at",
|
||||
"start": 77,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 82,
|
||||
"elements": [
|
||||
{
|
||||
"commentStart": 76,
|
||||
"end": 77,
|
||||
"commentStart": 83,
|
||||
"end": 84,
|
||||
"raw": "0",
|
||||
"start": 76,
|
||||
"start": 83,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
@ -140,10 +153,10 @@ expression: actual
|
||||
}
|
||||
},
|
||||
{
|
||||
"commentStart": 79,
|
||||
"end": 81,
|
||||
"commentStart": 86,
|
||||
"end": 88,
|
||||
"raw": "10",
|
||||
"start": 79,
|
||||
"start": 86,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
@ -152,51 +165,55 @@ expression: actual
|
||||
}
|
||||
}
|
||||
],
|
||||
"end": 82,
|
||||
"start": 75,
|
||||
"end": 89,
|
||||
"start": 82,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
},
|
||||
{
|
||||
"commentStart": 84,
|
||||
"end": 85,
|
||||
"start": 84,
|
||||
"type": "PipeSubstitution",
|
||||
"type": "PipeSubstitution"
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 70,
|
||||
"end": 74,
|
||||
"commentStart": 72,
|
||||
"end": 76,
|
||||
"name": {
|
||||
"commentStart": 70,
|
||||
"end": 74,
|
||||
"commentStart": 72,
|
||||
"end": 76,
|
||||
"name": "line",
|
||||
"start": 70,
|
||||
"start": 72,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 70,
|
||||
"start": 72,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 70,
|
||||
"end": 86,
|
||||
"start": 70,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
"commentStart": 72,
|
||||
"end": 90,
|
||||
"start": 72,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"commentStart": 108,
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 112,
|
||||
"end": 115,
|
||||
"name": "end",
|
||||
"start": 112,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 118,
|
||||
"elements": [
|
||||
{
|
||||
"argument": {
|
||||
"commentStart": 110,
|
||||
"end": 111,
|
||||
"commentStart": 120,
|
||||
"end": 121,
|
||||
"raw": "5",
|
||||
"start": 110,
|
||||
"start": 120,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
@ -204,18 +221,18 @@ expression: actual
|
||||
"suffix": "None"
|
||||
}
|
||||
},
|
||||
"commentStart": 109,
|
||||
"end": 111,
|
||||
"commentStart": 119,
|
||||
"end": 121,
|
||||
"operator": "-",
|
||||
"start": 109,
|
||||
"start": 119,
|
||||
"type": "UnaryExpression",
|
||||
"type": "UnaryExpression"
|
||||
},
|
||||
{
|
||||
"commentStart": 113,
|
||||
"end": 114,
|
||||
"commentStart": 123,
|
||||
"end": 124,
|
||||
"raw": "5",
|
||||
"start": 113,
|
||||
"start": 123,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
@ -224,50 +241,54 @@ expression: actual
|
||||
}
|
||||
}
|
||||
],
|
||||
"end": 115,
|
||||
"start": 108,
|
||||
"end": 125,
|
||||
"start": 118,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
},
|
||||
{
|
||||
"commentStart": 117,
|
||||
"end": 118,
|
||||
"start": 117,
|
||||
"type": "PipeSubstitution",
|
||||
"type": "PipeSubstitution"
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 94,
|
||||
"end": 107,
|
||||
"commentStart": 98,
|
||||
"end": 111,
|
||||
"name": {
|
||||
"commentStart": 94,
|
||||
"end": 107,
|
||||
"commentStart": 98,
|
||||
"end": 111,
|
||||
"name": "tangentialArc",
|
||||
"start": 94,
|
||||
"start": 98,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 94,
|
||||
"start": 98,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 94,
|
||||
"end": 119,
|
||||
"start": 94,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
"commentStart": 98,
|
||||
"end": 126,
|
||||
"start": 98,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"commentStart": 132,
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 139,
|
||||
"end": 141,
|
||||
"name": "at",
|
||||
"start": 139,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 144,
|
||||
"elements": [
|
||||
{
|
||||
"commentStart": 133,
|
||||
"end": 134,
|
||||
"commentStart": 145,
|
||||
"end": 146,
|
||||
"raw": "5",
|
||||
"start": 133,
|
||||
"start": 145,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
@ -277,10 +298,10 @@ expression: actual
|
||||
},
|
||||
{
|
||||
"argument": {
|
||||
"commentStart": 137,
|
||||
"end": 139,
|
||||
"commentStart": 149,
|
||||
"end": 151,
|
||||
"raw": "15",
|
||||
"start": 137,
|
||||
"start": 149,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
@ -288,64 +309,59 @@ expression: actual
|
||||
"suffix": "None"
|
||||
}
|
||||
},
|
||||
"commentStart": 136,
|
||||
"end": 139,
|
||||
"commentStart": 148,
|
||||
"end": 151,
|
||||
"operator": "-",
|
||||
"start": 136,
|
||||
"start": 148,
|
||||
"type": "UnaryExpression",
|
||||
"type": "UnaryExpression"
|
||||
}
|
||||
],
|
||||
"end": 140,
|
||||
"start": 132,
|
||||
"end": 152,
|
||||
"start": 144,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
},
|
||||
{
|
||||
"commentStart": 142,
|
||||
"end": 143,
|
||||
"start": 142,
|
||||
"type": "PipeSubstitution",
|
||||
"type": "PipeSubstitution"
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 127,
|
||||
"end": 131,
|
||||
"commentStart": 134,
|
||||
"end": 138,
|
||||
"name": {
|
||||
"commentStart": 127,
|
||||
"end": 131,
|
||||
"commentStart": 134,
|
||||
"end": 138,
|
||||
"name": "line",
|
||||
"start": 127,
|
||||
"start": 134,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 127,
|
||||
"start": 134,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 127,
|
||||
"end": 144,
|
||||
"start": 127,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
"commentStart": 134,
|
||||
"end": 153,
|
||||
"start": 134,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 160,
|
||||
"end": 166,
|
||||
"commentStart": 169,
|
||||
"end": 175,
|
||||
"name": "length",
|
||||
"start": 160,
|
||||
"start": 169,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 167,
|
||||
"end": 169,
|
||||
"commentStart": 176,
|
||||
"end": 178,
|
||||
"raw": "10",
|
||||
"start": 167,
|
||||
"start": 176,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
@ -357,29 +373,29 @@ expression: actual
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 152,
|
||||
"end": 159,
|
||||
"commentStart": 161,
|
||||
"end": 168,
|
||||
"name": {
|
||||
"commentStart": 152,
|
||||
"end": 159,
|
||||
"commentStart": 161,
|
||||
"end": 168,
|
||||
"name": "extrude",
|
||||
"start": 152,
|
||||
"start": 161,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 152,
|
||||
"start": 161,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 152,
|
||||
"end": 170,
|
||||
"start": 152,
|
||||
"commentStart": 161,
|
||||
"end": 179,
|
||||
"start": 161,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
}
|
||||
],
|
||||
"commentStart": 12,
|
||||
"end": 170,
|
||||
"end": 179,
|
||||
"start": 12,
|
||||
"type": "PipeExpression",
|
||||
"type": "PipeExpression"
|
||||
@ -387,7 +403,7 @@ expression: actual
|
||||
"start": 0,
|
||||
"type": "VariableDeclarator"
|
||||
},
|
||||
"end": 170,
|
||||
"end": 179,
|
||||
"kind": "const",
|
||||
"start": 0,
|
||||
"type": "VariableDeclaration",
|
||||
@ -395,6 +411,6 @@ expression: actual
|
||||
}
|
||||
],
|
||||
"commentStart": 0,
|
||||
"end": 171,
|
||||
"end": 180,
|
||||
"start": 0
|
||||
}
|
||||
|
@ -61,13 +61,22 @@ expression: actual
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"commentStart": 55,
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 53,
|
||||
"end": 55,
|
||||
"name": "at",
|
||||
"start": 53,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 58,
|
||||
"elements": [
|
||||
{
|
||||
"commentStart": 56,
|
||||
"end": 57,
|
||||
"commentStart": 59,
|
||||
"end": 60,
|
||||
"raw": "0",
|
||||
"start": 56,
|
||||
"start": 59,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
@ -76,10 +85,10 @@ expression: actual
|
||||
}
|
||||
},
|
||||
{
|
||||
"commentStart": 58,
|
||||
"end": 59,
|
||||
"commentStart": 61,
|
||||
"end": 62,
|
||||
"raw": "0",
|
||||
"start": 58,
|
||||
"start": 61,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
@ -88,27 +97,21 @@ expression: actual
|
||||
}
|
||||
}
|
||||
],
|
||||
"end": 60,
|
||||
"start": 55,
|
||||
"end": 63,
|
||||
"start": 58,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
},
|
||||
{
|
||||
"commentStart": 62,
|
||||
"end": 63,
|
||||
"start": 62,
|
||||
"type": "PipeSubstitution",
|
||||
"type": "PipeSubstitution"
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 40,
|
||||
"end": 54,
|
||||
"end": 52,
|
||||
"name": {
|
||||
"commentStart": 40,
|
||||
"end": 54,
|
||||
"name": "startProfileAt",
|
||||
"end": 52,
|
||||
"name": "startProfile",
|
||||
"start": 40,
|
||||
"type": "Identifier"
|
||||
},
|
||||
@ -119,8 +122,9 @@ expression: actual
|
||||
"commentStart": 40,
|
||||
"end": 64,
|
||||
"start": 40,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
|
@ -61,13 +61,22 @@ expression: actual
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"commentStart": 47,
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 45,
|
||||
"end": 47,
|
||||
"name": "at",
|
||||
"start": 45,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 50,
|
||||
"elements": [
|
||||
{
|
||||
"commentStart": 48,
|
||||
"end": 49,
|
||||
"commentStart": 51,
|
||||
"end": 52,
|
||||
"raw": "0",
|
||||
"start": 48,
|
||||
"start": 51,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
@ -76,10 +85,10 @@ expression: actual
|
||||
}
|
||||
},
|
||||
{
|
||||
"commentStart": 50,
|
||||
"end": 51,
|
||||
"commentStart": 53,
|
||||
"end": 54,
|
||||
"raw": "0",
|
||||
"start": 50,
|
||||
"start": 53,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
@ -88,27 +97,21 @@ expression: actual
|
||||
}
|
||||
}
|
||||
],
|
||||
"end": 52,
|
||||
"start": 47,
|
||||
"end": 55,
|
||||
"start": 50,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
},
|
||||
{
|
||||
"commentStart": 54,
|
||||
"end": 55,
|
||||
"start": 54,
|
||||
"type": "PipeSubstitution",
|
||||
"type": "PipeSubstitution"
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 32,
|
||||
"end": 46,
|
||||
"end": 44,
|
||||
"name": {
|
||||
"commentStart": 32,
|
||||
"end": 46,
|
||||
"name": "startProfileAt",
|
||||
"end": 44,
|
||||
"name": "startProfile",
|
||||
"start": 32,
|
||||
"type": "Identifier"
|
||||
},
|
||||
@ -119,8 +122,9 @@ expression: actual
|
||||
"commentStart": 32,
|
||||
"end": 56,
|
||||
"start": 32,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
|
@ -61,37 +61,40 @@ expression: actual
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 42,
|
||||
"end": 44,
|
||||
"name": "at",
|
||||
"start": 42,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"abs_path": false,
|
||||
"commentStart": 44,
|
||||
"end": 45,
|
||||
"commentStart": 47,
|
||||
"end": 48,
|
||||
"name": {
|
||||
"commentStart": 44,
|
||||
"end": 45,
|
||||
"commentStart": 47,
|
||||
"end": 48,
|
||||
"name": "p",
|
||||
"start": 44,
|
||||
"start": 47,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 44,
|
||||
"start": 47,
|
||||
"type": "Name",
|
||||
"type": "Name"
|
||||
},
|
||||
{
|
||||
"commentStart": 47,
|
||||
"end": 48,
|
||||
"start": 47,
|
||||
"type": "PipeSubstitution",
|
||||
"type": "PipeSubstitution"
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 29,
|
||||
"end": 43,
|
||||
"end": 41,
|
||||
"name": {
|
||||
"commentStart": 29,
|
||||
"end": 43,
|
||||
"name": "startProfileAt",
|
||||
"end": 41,
|
||||
"name": "startProfile",
|
||||
"start": 29,
|
||||
"type": "Identifier"
|
||||
},
|
||||
@ -102,8 +105,9 @@ expression: actual
|
||||
"commentStart": 29,
|
||||
"end": 49,
|
||||
"start": 29,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
}
|
||||
],
|
||||
"commentStart": 8,
|
||||
|
@ -8,7 +8,7 @@ expression: actual
|
||||
"commentStart": 0,
|
||||
"declaration": {
|
||||
"commentStart": 0,
|
||||
"end": 23,
|
||||
"end": 20,
|
||||
"id": {
|
||||
"commentStart": 0,
|
||||
"end": 5,
|
||||
@ -67,13 +67,6 @@ expression: actual
|
||||
"value": 2.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
},
|
||||
{
|
||||
"commentStart": 21,
|
||||
"end": 22,
|
||||
"start": 21,
|
||||
"type": "PipeSubstitution",
|
||||
"type": "PipeSubstitution"
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
@ -92,14 +85,14 @@ expression: actual
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 16,
|
||||
"end": 23,
|
||||
"end": 20,
|
||||
"start": 16,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
}
|
||||
],
|
||||
"commentStart": 8,
|
||||
"end": 23,
|
||||
"end": 20,
|
||||
"start": 8,
|
||||
"type": "PipeExpression",
|
||||
"type": "PipeExpression"
|
||||
@ -107,7 +100,7 @@ expression: actual
|
||||
"start": 0,
|
||||
"type": "VariableDeclarator"
|
||||
},
|
||||
"end": 23,
|
||||
"end": 20,
|
||||
"kind": "const",
|
||||
"start": 0,
|
||||
"type": "VariableDeclaration",
|
||||
@ -115,6 +108,6 @@ expression: actual
|
||||
}
|
||||
],
|
||||
"commentStart": 0,
|
||||
"end": 23,
|
||||
"end": 20,
|
||||
"start": 0
|
||||
}
|
||||
|
@ -61,37 +61,40 @@ expression: actual
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 42,
|
||||
"end": 44,
|
||||
"name": "at",
|
||||
"start": 42,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"abs_path": false,
|
||||
"commentStart": 44,
|
||||
"end": 45,
|
||||
"commentStart": 47,
|
||||
"end": 48,
|
||||
"name": {
|
||||
"commentStart": 44,
|
||||
"end": 45,
|
||||
"commentStart": 47,
|
||||
"end": 48,
|
||||
"name": "p",
|
||||
"start": 44,
|
||||
"start": 47,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 44,
|
||||
"start": 47,
|
||||
"type": "Name",
|
||||
"type": "Name"
|
||||
},
|
||||
{
|
||||
"commentStart": 47,
|
||||
"end": 48,
|
||||
"start": 47,
|
||||
"type": "PipeSubstitution",
|
||||
"type": "PipeSubstitution"
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 29,
|
||||
"end": 43,
|
||||
"end": 41,
|
||||
"name": {
|
||||
"commentStart": 29,
|
||||
"end": 43,
|
||||
"name": "startProfileAt",
|
||||
"end": 41,
|
||||
"name": "startProfile",
|
||||
"start": 29,
|
||||
"type": "Identifier"
|
||||
},
|
||||
@ -102,8 +105,9 @@ expression: actual
|
||||
"commentStart": 29,
|
||||
"end": 49,
|
||||
"start": 29,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
|
@ -61,13 +61,22 @@ expression: actual
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"commentStart": 47,
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 45,
|
||||
"end": 47,
|
||||
"name": "at",
|
||||
"start": 45,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 50,
|
||||
"elements": [
|
||||
{
|
||||
"commentStart": 48,
|
||||
"end": 49,
|
||||
"commentStart": 51,
|
||||
"end": 52,
|
||||
"raw": "0",
|
||||
"start": 48,
|
||||
"start": 51,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
@ -76,10 +85,10 @@ expression: actual
|
||||
}
|
||||
},
|
||||
{
|
||||
"commentStart": 50,
|
||||
"end": 51,
|
||||
"commentStart": 53,
|
||||
"end": 54,
|
||||
"raw": "0",
|
||||
"start": 50,
|
||||
"start": 53,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
@ -88,27 +97,21 @@ expression: actual
|
||||
}
|
||||
}
|
||||
],
|
||||
"end": 52,
|
||||
"start": 47,
|
||||
"end": 55,
|
||||
"start": 50,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
},
|
||||
{
|
||||
"commentStart": 54,
|
||||
"end": 55,
|
||||
"start": 54,
|
||||
"type": "PipeSubstitution",
|
||||
"type": "PipeSubstitution"
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 32,
|
||||
"end": 46,
|
||||
"end": 44,
|
||||
"name": {
|
||||
"commentStart": 32,
|
||||
"end": 46,
|
||||
"name": "startProfileAt",
|
||||
"end": 44,
|
||||
"name": "startProfile",
|
||||
"start": 32,
|
||||
"type": "Identifier"
|
||||
},
|
||||
@ -119,8 +122,9 @@ expression: actual
|
||||
"commentStart": 32,
|
||||
"end": 56,
|
||||
"start": 32,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
}
|
||||
],
|
||||
"commentStart": 11,
|
||||
|
@ -6,46 +6,76 @@ expression: actual
|
||||
"body": [
|
||||
{
|
||||
"commentStart": 0,
|
||||
"end": 28,
|
||||
"end": 46,
|
||||
"expression": {
|
||||
"arguments": [
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 4,
|
||||
"end": 5,
|
||||
"raw": "5",
|
||||
"end": 10,
|
||||
"name": "number",
|
||||
"start": 4,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 13,
|
||||
"end": 14,
|
||||
"raw": "5",
|
||||
"start": 13,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 5.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"commentStart": 7,
|
||||
"end": 14,
|
||||
"raw": "\"hello\"",
|
||||
"start": 7,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": "hello"
|
||||
},
|
||||
{
|
||||
"abs_path": false,
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 16,
|
||||
"end": 27,
|
||||
"name": {
|
||||
"commentStart": 16,
|
||||
"end": 27,
|
||||
"name": "aIdentifier",
|
||||
"end": 19,
|
||||
"name": "msg",
|
||||
"start": 16,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 22,
|
||||
"end": 29,
|
||||
"raw": "\"hello\"",
|
||||
"start": 22,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": "hello"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 31,
|
||||
"end": 33,
|
||||
"name": "id",
|
||||
"start": 31,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"abs_path": false,
|
||||
"commentStart": 34,
|
||||
"end": 45,
|
||||
"name": {
|
||||
"commentStart": 34,
|
||||
"end": 45,
|
||||
"name": "aIdentifier",
|
||||
"start": 34,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 16,
|
||||
"start": 34,
|
||||
"type": "Name",
|
||||
"type": "Name"
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
@ -63,10 +93,11 @@ expression: actual
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 28,
|
||||
"end": 46,
|
||||
"start": 0,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
},
|
||||
"start": 0,
|
||||
"type": "ExpressionStatement",
|
||||
@ -74,6 +105,6 @@ expression: actual
|
||||
}
|
||||
],
|
||||
"commentStart": 0,
|
||||
"end": 28,
|
||||
"end": 46,
|
||||
"start": 0
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ expression: actual
|
||||
"body": [
|
||||
{
|
||||
"commentStart": 0,
|
||||
"end": 15,
|
||||
"end": 12,
|
||||
"expression": {
|
||||
"arguments": [
|
||||
{
|
||||
@ -45,13 +45,6 @@ expression: actual
|
||||
"start": 5,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
},
|
||||
{
|
||||
"commentStart": 13,
|
||||
"end": 14,
|
||||
"start": 13,
|
||||
"type": "PipeSubstitution",
|
||||
"type": "PipeSubstitution"
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
@ -70,7 +63,7 @@ expression: actual
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 15,
|
||||
"end": 12,
|
||||
"start": 0,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
@ -81,6 +74,6 @@ expression: actual
|
||||
}
|
||||
],
|
||||
"commentStart": 0,
|
||||
"end": 15,
|
||||
"end": 12,
|
||||
"start": 0
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ expression: actual
|
||||
"commentStart": 0,
|
||||
"declaration": {
|
||||
"commentStart": 3,
|
||||
"end": 43,
|
||||
"end": 59,
|
||||
"id": {
|
||||
"commentStart": 3,
|
||||
"end": 4,
|
||||
@ -23,26 +23,45 @@ expression: actual
|
||||
"argument": {
|
||||
"arguments": [
|
||||
{
|
||||
"abs_path": false,
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 30,
|
||||
"end": 35,
|
||||
"name": {
|
||||
"commentStart": 30,
|
||||
"end": 35,
|
||||
"name": "angle",
|
||||
"name": "maybe",
|
||||
"start": 30,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"abs_path": false,
|
||||
"commentStart": 36,
|
||||
"end": 41,
|
||||
"name": {
|
||||
"commentStart": 36,
|
||||
"end": 41,
|
||||
"name": "angle",
|
||||
"start": 36,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 30,
|
||||
"start": 36,
|
||||
"type": "Name",
|
||||
"type": "Name"
|
||||
}
|
||||
},
|
||||
{
|
||||
"commentStart": 37,
|
||||
"end": 40,
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 43,
|
||||
"end": 52,
|
||||
"name": "otherwise",
|
||||
"start": 43,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 53,
|
||||
"end": 56,
|
||||
"raw": "360",
|
||||
"start": 37,
|
||||
"start": 53,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
@ -50,6 +69,7 @@ expression: actual
|
||||
"suffix": "None"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
@ -67,24 +87,25 @@ expression: actual
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 22,
|
||||
"end": 41,
|
||||
"end": 57,
|
||||
"start": 22,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
},
|
||||
"commentStart": 15,
|
||||
"end": 41,
|
||||
"end": 57,
|
||||
"start": 15,
|
||||
"type": "ReturnStatement",
|
||||
"type": "ReturnStatement"
|
||||
}
|
||||
],
|
||||
"commentStart": 13,
|
||||
"end": 43,
|
||||
"end": 59,
|
||||
"start": 13
|
||||
},
|
||||
"commentStart": 4,
|
||||
"end": 43,
|
||||
"end": 59,
|
||||
"params": [
|
||||
{
|
||||
"type": "Parameter",
|
||||
@ -109,7 +130,7 @@ expression: actual
|
||||
"start": 3,
|
||||
"type": "VariableDeclarator"
|
||||
},
|
||||
"end": 43,
|
||||
"end": 59,
|
||||
"kind": "fn",
|
||||
"start": 0,
|
||||
"type": "VariableDeclaration",
|
||||
@ -117,6 +138,6 @@ expression: actual
|
||||
}
|
||||
],
|
||||
"commentStart": 0,
|
||||
"end": 43,
|
||||
"end": 59,
|
||||
"start": 0
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ expression: actual
|
||||
"commentStart": 0,
|
||||
"declaration": {
|
||||
"commentStart": 0,
|
||||
"end": 30,
|
||||
"end": 36,
|
||||
"id": {
|
||||
"commentStart": 0,
|
||||
"end": 5,
|
||||
@ -19,37 +19,53 @@ expression: actual
|
||||
"init": {
|
||||
"arguments": [
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 12,
|
||||
"end": 13,
|
||||
"raw": "5",
|
||||
"name": "x",
|
||||
"start": 12,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 14,
|
||||
"end": 15,
|
||||
"raw": "5",
|
||||
"start": 14,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 5.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 18,
|
||||
"end": 19,
|
||||
"name": "y",
|
||||
"start": 18,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"argument": {
|
||||
"arguments": [
|
||||
{
|
||||
"commentStart": 24,
|
||||
"end": 25,
|
||||
"raw": "5",
|
||||
"start": 24,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 5.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 31,
|
||||
"end": 32,
|
||||
"name": "z",
|
||||
"start": 31,
|
||||
"type": "Identifier"
|
||||
},
|
||||
{
|
||||
"commentStart": 27,
|
||||
"end": 28,
|
||||
"arg": {
|
||||
"commentStart": 33,
|
||||
"end": 34,
|
||||
"raw": "4",
|
||||
"start": 27,
|
||||
"start": 33,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
@ -57,35 +73,49 @@ expression: actual
|
||||
"suffix": "None"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 17,
|
||||
"end": 23,
|
||||
"commentStart": 21,
|
||||
"end": 27,
|
||||
"name": {
|
||||
"commentStart": 17,
|
||||
"end": 23,
|
||||
"commentStart": 21,
|
||||
"end": 27,
|
||||
"name": "legLen",
|
||||
"start": 17,
|
||||
"start": 21,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 17,
|
||||
"start": 21,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 17,
|
||||
"commentStart": 21,
|
||||
"end": 35,
|
||||
"start": 21,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": {
|
||||
"commentStart": 28,
|
||||
"end": 29,
|
||||
"start": 17,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
"raw": "5",
|
||||
"start": 28,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 5.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
}
|
||||
},
|
||||
"commentStart": 16,
|
||||
"end": 29,
|
||||
"commentStart": 20,
|
||||
"end": 35,
|
||||
"operator": "-",
|
||||
"start": 16,
|
||||
"start": 20,
|
||||
"type": "UnaryExpression",
|
||||
"type": "UnaryExpression"
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
@ -103,15 +133,16 @@ expression: actual
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 8,
|
||||
"end": 30,
|
||||
"end": 36,
|
||||
"start": 8,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
},
|
||||
"start": 0,
|
||||
"type": "VariableDeclarator"
|
||||
},
|
||||
"end": 30,
|
||||
"end": 36,
|
||||
"kind": "const",
|
||||
"start": 0,
|
||||
"type": "VariableDeclaration",
|
||||
@ -119,6 +150,6 @@ expression: actual
|
||||
}
|
||||
],
|
||||
"commentStart": 0,
|
||||
"end": 30,
|
||||
"end": 36,
|
||||
"start": 0
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ expression: actual
|
||||
"commentStart": 0,
|
||||
"declaration": {
|
||||
"commentStart": 0,
|
||||
"end": 29,
|
||||
"end": 37,
|
||||
"id": {
|
||||
"commentStart": 0,
|
||||
"end": 5,
|
||||
@ -19,25 +19,53 @@ expression: actual
|
||||
"init": {
|
||||
"arguments": [
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 12,
|
||||
"end": 13,
|
||||
"name": "x",
|
||||
"start": 12,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"argument": {
|
||||
"arguments": [
|
||||
{
|
||||
"commentStart": 20,
|
||||
"end": 21,
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 22,
|
||||
"end": 23,
|
||||
"name": "a",
|
||||
"start": 22,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 24,
|
||||
"end": 25,
|
||||
"raw": "5",
|
||||
"start": 20,
|
||||
"start": 24,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 5.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"commentStart": 23,
|
||||
"end": 24,
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 27,
|
||||
"end": 28,
|
||||
"name": "b",
|
||||
"start": 27,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 29,
|
||||
"end": 30,
|
||||
"raw": "4",
|
||||
"start": 23,
|
||||
"start": 29,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
@ -45,40 +73,52 @@ expression: actual
|
||||
"suffix": "None"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 13,
|
||||
"end": 19,
|
||||
"commentStart": 15,
|
||||
"end": 21,
|
||||
"name": {
|
||||
"commentStart": 13,
|
||||
"end": 19,
|
||||
"commentStart": 15,
|
||||
"end": 21,
|
||||
"name": "legLen",
|
||||
"start": 13,
|
||||
"start": 15,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 13,
|
||||
"start": 15,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 13,
|
||||
"end": 25,
|
||||
"start": 13,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
"commentStart": 15,
|
||||
"end": 31,
|
||||
"start": 15,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
},
|
||||
"commentStart": 12,
|
||||
"end": 25,
|
||||
"commentStart": 14,
|
||||
"end": 31,
|
||||
"operator": "-",
|
||||
"start": 12,
|
||||
"start": 14,
|
||||
"type": "UnaryExpression",
|
||||
"type": "UnaryExpression"
|
||||
}
|
||||
},
|
||||
{
|
||||
"commentStart": 27,
|
||||
"end": 28,
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 33,
|
||||
"end": 34,
|
||||
"name": "y",
|
||||
"start": 33,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 35,
|
||||
"end": 36,
|
||||
"raw": "5",
|
||||
"start": 27,
|
||||
"start": 35,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
@ -86,6 +126,7 @@ expression: actual
|
||||
"suffix": "None"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
@ -103,15 +144,16 @@ expression: actual
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 8,
|
||||
"end": 29,
|
||||
"end": 37,
|
||||
"start": 8,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
},
|
||||
"start": 0,
|
||||
"type": "VariableDeclarator"
|
||||
},
|
||||
"end": 29,
|
||||
"end": 37,
|
||||
"kind": "const",
|
||||
"start": 0,
|
||||
"type": "VariableDeclaration",
|
||||
@ -119,6 +161,6 @@ expression: actual
|
||||
}
|
||||
],
|
||||
"commentStart": 0,
|
||||
"end": 29,
|
||||
"end": 37,
|
||||
"start": 0
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ expression: actual
|
||||
"commentStart": 0,
|
||||
"declaration": {
|
||||
"commentStart": 0,
|
||||
"end": 30,
|
||||
"end": 27,
|
||||
"id": {
|
||||
"commentStart": 0,
|
||||
"end": 5,
|
||||
@ -63,13 +63,6 @@ expression: actual
|
||||
"value": 45.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
},
|
||||
{
|
||||
"commentStart": 28,
|
||||
"end": 29,
|
||||
"start": 28,
|
||||
"type": "PipeSubstitution",
|
||||
"type": "PipeSubstitution"
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
@ -88,14 +81,14 @@ expression: actual
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 17,
|
||||
"end": 30,
|
||||
"end": 27,
|
||||
"start": 17,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
}
|
||||
],
|
||||
"commentStart": 8,
|
||||
"end": 30,
|
||||
"end": 27,
|
||||
"start": 8,
|
||||
"type": "PipeExpression",
|
||||
"type": "PipeExpression"
|
||||
@ -103,7 +96,7 @@ expression: actual
|
||||
"start": 0,
|
||||
"type": "VariableDeclarator"
|
||||
},
|
||||
"end": 30,
|
||||
"end": 27,
|
||||
"kind": "const",
|
||||
"start": 0,
|
||||
"type": "VariableDeclaration",
|
||||
@ -111,6 +104,6 @@ expression: actual
|
||||
}
|
||||
],
|
||||
"commentStart": 0,
|
||||
"end": 30,
|
||||
"end": 27,
|
||||
"start": 0
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ expression: actual
|
||||
"commentStart": 0,
|
||||
"declaration": {
|
||||
"commentStart": 0,
|
||||
"end": 48,
|
||||
"end": 43,
|
||||
"id": {
|
||||
"commentStart": 0,
|
||||
"end": 2,
|
||||
@ -62,36 +62,29 @@ expression: actual
|
||||
"arguments": [
|
||||
{
|
||||
"abs_path": false,
|
||||
"commentStart": 41,
|
||||
"end": 44,
|
||||
"commentStart": 39,
|
||||
"end": 42,
|
||||
"name": {
|
||||
"commentStart": 41,
|
||||
"end": 44,
|
||||
"commentStart": 39,
|
||||
"end": 42,
|
||||
"name": "pos",
|
||||
"start": 41,
|
||||
"start": 39,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 41,
|
||||
"start": 39,
|
||||
"type": "Name",
|
||||
"type": "Name"
|
||||
},
|
||||
{
|
||||
"commentStart": 46,
|
||||
"end": 47,
|
||||
"start": 46,
|
||||
"type": "PipeSubstitution",
|
||||
"type": "PipeSubstitution"
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 26,
|
||||
"end": 40,
|
||||
"end": 38,
|
||||
"name": {
|
||||
"commentStart": 26,
|
||||
"end": 40,
|
||||
"name": "startProfileAt",
|
||||
"end": 38,
|
||||
"name": "startProfile",
|
||||
"start": 26,
|
||||
"type": "Identifier"
|
||||
},
|
||||
@ -100,14 +93,14 @@ expression: actual
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 26,
|
||||
"end": 48,
|
||||
"end": 43,
|
||||
"start": 26,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
}
|
||||
],
|
||||
"commentStart": 5,
|
||||
"end": 48,
|
||||
"end": 43,
|
||||
"start": 5,
|
||||
"type": "PipeExpression",
|
||||
"type": "PipeExpression"
|
||||
@ -115,7 +108,7 @@ expression: actual
|
||||
"start": 0,
|
||||
"type": "VariableDeclarator"
|
||||
},
|
||||
"end": 48,
|
||||
"end": 43,
|
||||
"kind": "const",
|
||||
"start": 0,
|
||||
"type": "VariableDeclaration",
|
||||
@ -123,6 +116,6 @@ expression: actual
|
||||
}
|
||||
],
|
||||
"commentStart": 0,
|
||||
"end": 48,
|
||||
"end": 43,
|
||||
"start": 0
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ expression: actual
|
||||
"commentStart": 0,
|
||||
"declaration": {
|
||||
"commentStart": 0,
|
||||
"end": 73,
|
||||
"end": 68,
|
||||
"id": {
|
||||
"commentStart": 0,
|
||||
"end": 2,
|
||||
@ -62,17 +62,17 @@ expression: actual
|
||||
"arguments": [
|
||||
{
|
||||
"abs_path": false,
|
||||
"commentStart": 45,
|
||||
"end": 48,
|
||||
"commentStart": 43,
|
||||
"end": 46,
|
||||
"name": {
|
||||
"commentStart": 45,
|
||||
"end": 48,
|
||||
"commentStart": 43,
|
||||
"end": 46,
|
||||
"name": "pos",
|
||||
"start": 45,
|
||||
"start": 43,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 45,
|
||||
"start": 43,
|
||||
"type": "Name",
|
||||
"type": "Name"
|
||||
}
|
||||
@ -80,11 +80,11 @@ expression: actual
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 30,
|
||||
"end": 44,
|
||||
"end": 42,
|
||||
"name": {
|
||||
"commentStart": 30,
|
||||
"end": 44,
|
||||
"name": "startProfileAt",
|
||||
"end": 42,
|
||||
"name": "startProfile",
|
||||
"start": 30,
|
||||
"type": "Identifier"
|
||||
},
|
||||
@ -93,7 +93,7 @@ expression: actual
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 30,
|
||||
"end": 49,
|
||||
"end": 47,
|
||||
"start": 30,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
@ -101,13 +101,13 @@ expression: actual
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"commentStart": 58,
|
||||
"commentStart": 56,
|
||||
"elements": [
|
||||
{
|
||||
"commentStart": 59,
|
||||
"end": 60,
|
||||
"commentStart": 57,
|
||||
"end": 58,
|
||||
"raw": "0",
|
||||
"start": 59,
|
||||
"start": 57,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
@ -118,65 +118,58 @@ expression: actual
|
||||
{
|
||||
"argument": {
|
||||
"abs_path": false,
|
||||
"commentStart": 63,
|
||||
"end": 68,
|
||||
"commentStart": 61,
|
||||
"end": 66,
|
||||
"name": {
|
||||
"commentStart": 63,
|
||||
"end": 68,
|
||||
"commentStart": 61,
|
||||
"end": 66,
|
||||
"name": "scale",
|
||||
"start": 63,
|
||||
"start": 61,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 63,
|
||||
"start": 61,
|
||||
"type": "Name",
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 62,
|
||||
"end": 68,
|
||||
"commentStart": 60,
|
||||
"end": 66,
|
||||
"operator": "-",
|
||||
"start": 62,
|
||||
"start": 60,
|
||||
"type": "UnaryExpression",
|
||||
"type": "UnaryExpression"
|
||||
}
|
||||
],
|
||||
"end": 69,
|
||||
"start": 58,
|
||||
"end": 67,
|
||||
"start": 56,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
},
|
||||
{
|
||||
"commentStart": 71,
|
||||
"end": 72,
|
||||
"start": 71,
|
||||
"type": "PipeSubstitution",
|
||||
"type": "PipeSubstitution"
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 53,
|
||||
"end": 57,
|
||||
"commentStart": 51,
|
||||
"end": 55,
|
||||
"name": {
|
||||
"commentStart": 53,
|
||||
"end": 57,
|
||||
"commentStart": 51,
|
||||
"end": 55,
|
||||
"name": "line",
|
||||
"start": 53,
|
||||
"start": 51,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 53,
|
||||
"start": 51,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 53,
|
||||
"end": 73,
|
||||
"start": 53,
|
||||
"commentStart": 51,
|
||||
"end": 68,
|
||||
"start": 51,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
}
|
||||
],
|
||||
"commentStart": 5,
|
||||
"end": 73,
|
||||
"end": 68,
|
||||
"start": 5,
|
||||
"type": "PipeExpression",
|
||||
"type": "PipeExpression"
|
||||
@ -184,7 +177,7 @@ expression: actual
|
||||
"start": 0,
|
||||
"type": "VariableDeclarator"
|
||||
},
|
||||
"end": 73,
|
||||
"end": 68,
|
||||
"kind": "const",
|
||||
"start": 0,
|
||||
"type": "VariableDeclaration",
|
||||
@ -192,6 +185,6 @@ expression: actual
|
||||
}
|
||||
],
|
||||
"commentStart": 0,
|
||||
"end": 73,
|
||||
"end": 68,
|
||||
"start": 0
|
||||
}
|
||||
|
@ -282,6 +282,7 @@ fn assert_common_snapshots(
|
||||
insta::assert_json_snapshot!("ops", operations, {
|
||||
"[].unlabeledArg.*.value.**[].from[]" => rounded_redaction(4),
|
||||
"[].unlabeledArg.*.value.**[].to[]" => rounded_redaction(4),
|
||||
"[].*.unlabeledArg.value.value" => rounded_redaction(4),
|
||||
"[].labeledArgs.*.value.**[].from[]" => rounded_redaction(4),
|
||||
"[].labeledArgs.*.value.**[].to[]" => rounded_redaction(4),
|
||||
".**.sourceRange" => Vec::new(),
|
||||
|
@ -51,6 +51,7 @@ async fn unparse_test(test: &Test) {
|
||||
.map(|file| {
|
||||
tokio::spawn(async move {
|
||||
let contents = tokio::fs::read_to_string(&file).await.unwrap();
|
||||
eprintln!("{}", file.display());
|
||||
let program = crate::Program::parse_no_errs(&contents).unwrap();
|
||||
let recast = program.recast_with_options(&Default::default());
|
||||
|
||||
|
@ -91,9 +91,9 @@ pub async fn appearance(exec_state: &mut ExecState, args: Args) -> Result<KclVal
|
||||
/// |> extrude(length = 10)
|
||||
/// }
|
||||
///
|
||||
/// example0 = cube([0, 0])
|
||||
/// example1 = cube([20, 0])
|
||||
/// example2 = cube([40, 0])
|
||||
/// example0 = cube(center = [0, 0])
|
||||
/// example1 = cube(center = [20, 0])
|
||||
/// example2 = cube(center = [40, 0])
|
||||
///
|
||||
/// appearance([example0, example1], color='#ff0000', metalness=50, roughness=50)
|
||||
/// appearance(example2, color='#00ff00', metalness=50, roughness=50)
|
||||
|
@ -26,7 +26,7 @@ pub async fn map(exec_state: &mut ExecState, args: Args) -> Result<KclValue, Kcl
|
||||
/// `[f(a), f(b), f(c)]`
|
||||
/// ```no_run
|
||||
/// r = 10 // radius
|
||||
/// fn drawCircle(id) {
|
||||
/// fn drawCircle(@id) {
|
||||
/// return startSketchOn(XY)
|
||||
/// |> circle( center= [id * 2 * r, 0], radius= r)
|
||||
/// }
|
||||
@ -110,7 +110,7 @@ pub async fn reduce(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
|
||||
/// // This function adds an array of numbers.
|
||||
/// // It uses the `reduce` function, to call the `add` function on every
|
||||
/// // element of the `arr` parameter. The starting value is 0.
|
||||
/// fn sum(arr) { return reduce(arr, initial = 0, f = add) }
|
||||
/// fn sum(@arr) { return reduce(arr, initial = 0, f = add) }
|
||||
///
|
||||
/// /*
|
||||
/// The above is basically like this pseudo-code:
|
||||
@ -138,7 +138,7 @@ pub async fn reduce(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
|
||||
/// ```
|
||||
/// ```no_run
|
||||
/// // Declare a function that sketches a decagon.
|
||||
/// fn decagon(radius) {
|
||||
/// fn decagon(@radius) {
|
||||
/// // Each side of the decagon is turned this many radians from the previous angle.
|
||||
/// stepAngle = ((1/10) * TAU): number(rad)
|
||||
///
|
||||
|
@ -49,8 +49,8 @@ pub async fn union(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
/// |> extrude(length = 10)
|
||||
/// }
|
||||
///
|
||||
/// part001 = cube([0, 0], 10)
|
||||
/// part002 = cube([7, 3], 5)
|
||||
/// part001 = cube(center = [0, 0], size = 10)
|
||||
/// part002 = cube(center = [7, 3], size = 5)
|
||||
/// |> translate(z = 1)
|
||||
///
|
||||
/// unionedPart = union([part001, part002])
|
||||
@ -71,8 +71,8 @@ pub async fn union(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
/// |> extrude(length = 10)
|
||||
/// }
|
||||
///
|
||||
/// part001 = cube([0, 0], 10)
|
||||
/// part002 = cube([7, 3], 5)
|
||||
/// part001 = cube(center = [0, 0], size = 10)
|
||||
/// part002 = cube(center = [7, 3], size = 5)
|
||||
/// |> translate(z = 1)
|
||||
///
|
||||
/// // This is the equivalent of: union([part001, part002])
|
||||
@ -94,8 +94,8 @@ pub async fn union(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
/// |> extrude(length = 10)
|
||||
/// }
|
||||
///
|
||||
/// part001 = cube([0, 0], 10)
|
||||
/// part002 = cube([7, 3], 5)
|
||||
/// part001 = cube(center = [0, 0], size = 10)
|
||||
/// part002 = cube(center = [7, 3], size = 5)
|
||||
/// |> translate(z = 1)
|
||||
///
|
||||
/// // This is the equivalent of: union([part001, part002])
|
||||
@ -199,8 +199,8 @@ pub async fn intersect(exec_state: &mut ExecState, args: Args) -> Result<KclValu
|
||||
/// |> extrude(length = 10)
|
||||
/// }
|
||||
///
|
||||
/// part001 = cube([0, 0], 10)
|
||||
/// part002 = cube([7, 3], 5)
|
||||
/// part001 = cube(center = [0, 0], size = 10)
|
||||
/// part002 = cube(center = [7, 3], size = 5)
|
||||
/// |> translate(z = 1)
|
||||
///
|
||||
/// intersectedPart = intersect([part001, part002])
|
||||
@ -221,8 +221,8 @@ pub async fn intersect(exec_state: &mut ExecState, args: Args) -> Result<KclValu
|
||||
/// |> extrude(length = 10)
|
||||
/// }
|
||||
///
|
||||
/// part001 = cube([0, 0], 10)
|
||||
/// part002 = cube([7, 3], 5)
|
||||
/// part001 = cube(center = [0, 0], size = 10)
|
||||
/// part002 = cube(center = [7, 3], size = 5)
|
||||
/// |> translate(z = 1)
|
||||
///
|
||||
/// // This is the equivalent of: intersect([part001, part002])
|
||||
@ -332,8 +332,8 @@ pub async fn subtract(exec_state: &mut ExecState, args: Args) -> Result<KclValue
|
||||
/// |> extrude(length = 10)
|
||||
/// }
|
||||
///
|
||||
/// part001 = cube([0, 0], 10)
|
||||
/// part002 = cube([7, 3], 5)
|
||||
/// part001 = cube(center = [0, 0], size = 10)
|
||||
/// part002 = cube(center = [7, 3], size = 5)
|
||||
/// |> translate(z = 1)
|
||||
///
|
||||
/// subtractedPart = subtract([part001], tools=[part002])
|
||||
@ -354,8 +354,8 @@ pub async fn subtract(exec_state: &mut ExecState, args: Args) -> Result<KclValue
|
||||
/// |> extrude(length = 10)
|
||||
/// }
|
||||
///
|
||||
/// part001 = cube([0, 0], 10)
|
||||
/// part002 = cube([7, 3], 5)
|
||||
/// part001 = cube(center = [0, 0], size = 10)
|
||||
/// part002 = cube(center = [7, 3], size = 5)
|
||||
/// |> translate(z = 1)
|
||||
///
|
||||
/// // This is the equivalent of: subtract([part001], tools=[part002])
|
||||
|
@ -96,7 +96,7 @@ pub async fn pattern_transform_2d(exec_state: &mut ExecState, args: Args) -> Res
|
||||
///
|
||||
/// ```no_run
|
||||
/// // Each instance will be shifted along the X axis.
|
||||
/// fn transform(id) {
|
||||
/// fn transform(@id) {
|
||||
/// return { translate = [4 * id, 0, 0] }
|
||||
/// }
|
||||
///
|
||||
@ -110,7 +110,7 @@ pub async fn pattern_transform_2d(exec_state: &mut ExecState, args: Args) -> Res
|
||||
/// // Each instance will be shifted along the X axis,
|
||||
/// // with a gap between the original (at x = 0) and the first replica
|
||||
/// // (at x = 8). This is because `id` starts at 1.
|
||||
/// fn transform(id) {
|
||||
/// fn transform(@id) {
|
||||
/// return { translate = [4 * (1+id), 0, 0] }
|
||||
/// }
|
||||
///
|
||||
@ -140,7 +140,7 @@ pub async fn pattern_transform_2d(exec_state: &mut ExecState, args: Args) -> Res
|
||||
/// }
|
||||
///
|
||||
/// width = 20
|
||||
/// fn transform(i) {
|
||||
/// fn transform(@i) {
|
||||
/// return {
|
||||
/// // Move down each time.
|
||||
/// translate = [0, 0, -i * width],
|
||||
@ -155,7 +155,7 @@ pub async fn pattern_transform_2d(exec_state: &mut ExecState, args: Args) -> Res
|
||||
/// }
|
||||
///
|
||||
/// myCubes =
|
||||
/// cube(width, [100,0])
|
||||
/// cube(length = width, center = [100,0])
|
||||
/// |> patternTransform(instances = 25, transform = transform)
|
||||
/// ```
|
||||
///
|
||||
@ -180,7 +180,7 @@ pub async fn pattern_transform_2d(exec_state: &mut ExecState, args: Args) -> Res
|
||||
/// }
|
||||
///
|
||||
/// width = 20
|
||||
/// fn transform(i) {
|
||||
/// fn transform(@i) {
|
||||
/// return {
|
||||
/// translate = [0, 0, -i * width],
|
||||
/// rotation = {
|
||||
@ -191,7 +191,7 @@ pub async fn pattern_transform_2d(exec_state: &mut ExecState, args: Args) -> Res
|
||||
/// }
|
||||
/// }
|
||||
/// myCubes =
|
||||
/// cube(width, [100,100])
|
||||
/// cube(length = width, center = [100,100])
|
||||
/// |> patternTransform(instances = 4, transform = transform)
|
||||
/// ```
|
||||
/// ```no_run
|
||||
@ -201,7 +201,7 @@ pub async fn pattern_transform_2d(exec_state: &mut ExecState, args: Args) -> Res
|
||||
/// t = 0.005 // taper factor [0-1)
|
||||
/// // Defines how to modify each layer of the vase.
|
||||
/// // Each replica is shifted up the Z axis, and has a smoothly-varying radius
|
||||
/// fn transform(replicaId) {
|
||||
/// fn transform(@replicaId) {
|
||||
/// scale = r * abs(1 - (t * replicaId)) * (5 + cos((replicaId / 8): number(rad)))
|
||||
/// return {
|
||||
/// translate = [0, 0, replicaId * 10],
|
||||
@ -219,7 +219,7 @@ pub async fn pattern_transform_2d(exec_state: &mut ExecState, args: Args) -> Res
|
||||
/// vase = layer() |> patternTransform(instances = 100, transform = transform)
|
||||
/// ```
|
||||
/// ```
|
||||
/// fn transform(i) {
|
||||
/// fn transform(@i) {
|
||||
/// // Transform functions can return multiple transforms. They'll be applied in order.
|
||||
/// return [
|
||||
/// { translate = [30 * i, 0, 0] },
|
||||
@ -282,7 +282,7 @@ async fn inner_pattern_transform<'a>(
|
||||
/// Just like patternTransform, but works on 2D sketches not 3D solids.
|
||||
/// ```no_run
|
||||
/// // Each instance will be shifted along the X axis.
|
||||
/// fn transform(id) {
|
||||
/// fn transform(@id) {
|
||||
/// return { translate = [4 * id, 0] }
|
||||
/// }
|
||||
///
|
||||
|
@ -42,10 +42,10 @@ pub async fn segment_end(exec_state: &mut ExecState, args: Args) -> Result<KclVa
|
||||
/// |> extrude(length = radius)
|
||||
/// }
|
||||
///
|
||||
/// cylinder(1, line1)
|
||||
/// cylinder(2, line2)
|
||||
/// cylinder(3, line3)
|
||||
/// cylinder(4, line4)
|
||||
/// cylinder(radius = 1, tag = line1)
|
||||
/// cylinder(radius = 2, tag = line2)
|
||||
/// cylinder(radius = 3, tag = line3)
|
||||
/// cylinder(radius = 4, tag = line4)
|
||||
/// ```
|
||||
#[stdlib {
|
||||
name = "segEnd",
|
||||
@ -178,10 +178,10 @@ pub async fn segment_start(exec_state: &mut ExecState, args: Args) -> Result<Kcl
|
||||
/// |> extrude(length = radius)
|
||||
/// }
|
||||
///
|
||||
/// cylinder(1, line1)
|
||||
/// cylinder(2, line2)
|
||||
/// cylinder(3, line3)
|
||||
/// cylinder(4, line4)
|
||||
/// cylinder(radius = 1, tag = line1)
|
||||
/// cylinder(radius = 2, tag = line2)
|
||||
/// cylinder(radius = 3, tag = line3)
|
||||
/// cylinder(radius = 4, tag = line4)
|
||||
/// ```
|
||||
#[stdlib {
|
||||
name = "segStart",
|
||||
|
@ -326,7 +326,7 @@ pub async fn translate(exec_state: &mut ExecState, args: Args) -> Result<KclValu
|
||||
/// ```no_run
|
||||
/// // Move a sketch.
|
||||
///
|
||||
/// fn square(length){
|
||||
/// fn square(@length){
|
||||
/// l = length / 2
|
||||
/// p0 = [-l, -l]
|
||||
/// p1 = [-l, l]
|
||||
|
@ -1125,27 +1125,27 @@ d = 1
|
||||
|
||||
fn rect(x, y, w, h) {
|
||||
startSketchOn(XY)
|
||||
|> startProfileAt([x, y], %)
|
||||
|> startProfile(at = [x, y])
|
||||
|> xLine(length = w)
|
||||
|> yLine(length = h)
|
||||
|> xLine(length = -w)
|
||||
|> close()
|
||||
|> extrude(d, %)
|
||||
|> extrude(d)
|
||||
}
|
||||
|
||||
fn quad(x1, y1, x2, y2, x3, y3, x4, y4) {
|
||||
startSketchOn(XY)
|
||||
|> startProfileAt([x1, y1], %)
|
||||
|> startProfile(at = [x1, y1])
|
||||
|> line(endAbsolute = [x2, y2])
|
||||
|> line(endAbsolute = [x3, y3])
|
||||
|> line(endAbsolute = [x4, y4])
|
||||
|> close()
|
||||
|> extrude(d, %)
|
||||
|> extrude(d)
|
||||
}
|
||||
|
||||
fn crosshair(x, y) {
|
||||
startSketchOn(XY)
|
||||
|> startProfileAt([x, y], %)
|
||||
|> startProfile(at = [x, y])
|
||||
|> yLine(length = 1)
|
||||
|> yLine(length = -2)
|
||||
|> yLine(length = 1)
|
||||
@ -1159,11 +1159,30 @@ fn z(z_x, z_y) {
|
||||
z_corner = s * 2
|
||||
z_w = z_end_w + 2 * z_corner
|
||||
z_h = z_w * 1.08130081300813
|
||||
rect(z_x, z_y, z_end_w, -z_end_h)
|
||||
rect(z_x + z_w, z_y, -z_corner, -z_corner)
|
||||
rect(z_x + z_w, z_y - z_h, -z_end_w, z_end_h)
|
||||
rect(z_x, z_y - z_h, z_corner, z_corner)
|
||||
quad(z_x, z_y - z_h + z_corner, z_x + z_w - z_corner, z_y, z_x + z_w, z_y - z_corner, z_x + z_corner, z_y - z_h)
|
||||
rect(
|
||||
z_x,
|
||||
a = z_y,
|
||||
b = z_end_w,
|
||||
c = -z_end_h,
|
||||
)
|
||||
rect(
|
||||
z_x + z_w,
|
||||
a = z_y,
|
||||
b = -z_corner,
|
||||
c = -z_corner,
|
||||
)
|
||||
rect(
|
||||
z_x + z_w,
|
||||
a = z_y - z_h,
|
||||
b = -z_end_w,
|
||||
c = z_end_h,
|
||||
)
|
||||
rect(
|
||||
z_x,
|
||||
a = z_y - z_h,
|
||||
b = z_corner,
|
||||
c = z_corner,
|
||||
)
|
||||
}
|
||||
|
||||
fn o(c_x, c_y) {
|
||||
@ -1175,61 +1194,45 @@ fn o(c_x, c_y) {
|
||||
a = 7
|
||||
|
||||
// Start point for the top sketch
|
||||
o_x1 = c_x + o_r * cos((45 + a) / 360 * tau())
|
||||
o_y1 = c_y + o_r * sin((45 + a) / 360 * tau())
|
||||
o_x1 = c_x + o_r * cos((45 + a) / 360 * TAU)
|
||||
o_y1 = c_y + o_r * sin((45 + a) / 360 * TAU)
|
||||
|
||||
// Start point for the bottom sketch
|
||||
o_x2 = c_x + o_r * cos((225 + a) / 360 * tau())
|
||||
o_y2 = c_y + o_r * sin((225 + a) / 360 * tau())
|
||||
o_x2 = c_x + o_r * cos((225 + a) / 360 * TAU)
|
||||
o_y2 = c_y + o_r * sin((225 + a) / 360 * TAU)
|
||||
|
||||
// End point for the bottom startSketch
|
||||
o_x3 = c_x + o_r * cos((45 - a) / 360 * tau())
|
||||
o_y3 = c_y + o_r * sin((45 - a) / 360 * tau())
|
||||
o_x3 = c_x + o_r * cos((45 - a) / 360 * TAU)
|
||||
o_y3 = c_y + o_r * sin((45 - a) / 360 * TAU)
|
||||
|
||||
// Where is the center?
|
||||
// crosshair(c_x, c_y)
|
||||
|
||||
|
||||
startSketchOn(XY)
|
||||
|> startProfileAt([o_x1, o_y1], %)
|
||||
|> arc({
|
||||
radius = o_r,
|
||||
angle_start = 45 + a,
|
||||
angle_end = 225 - a
|
||||
}, %)
|
||||
|> startProfile(at = [o_x1, o_y1])
|
||||
|> arc(radius = o_r, angle_start = 45 + a, angle_end = 225 - a)
|
||||
|> angledLine(angle = 45, length = o_r - i_r)
|
||||
|> arc({
|
||||
radius = i_r,
|
||||
angle_start = 225 - a,
|
||||
angle_end = 45 + a
|
||||
}, %)
|
||||
|> arc(radius = i_r, angle_start = 225 - a, angle_end = 45 + a)
|
||||
|> close()
|
||||
|> extrude(d, %)
|
||||
|> extrude(d)
|
||||
|
||||
startSketchOn(XY)
|
||||
|> startProfileAt([o_x2, o_y2], %)
|
||||
|> arc({
|
||||
radius = o_r,
|
||||
angle_start = 225 + a,
|
||||
angle_end = 360 + 45 - a
|
||||
}, %)
|
||||
|> startProfile(at = [o_x2, o_y2])
|
||||
|> arc(radius = o_r, angle_start = 225 + a, angle_end = 360 + 45 - a)
|
||||
|> angledLine(angle = 225, length = o_r - i_r)
|
||||
|> arc({
|
||||
radius = i_r,
|
||||
angle_start = 45 - a,
|
||||
angle_end = 225 + a - 360
|
||||
}, %)
|
||||
|> arc(radius = i_r, angle_start = 45 - a, angle_end = 225 + a - 360)
|
||||
|> close()
|
||||
|> extrude(d, %)
|
||||
|> extrude(d)
|
||||
}
|
||||
|
||||
fn zoo(x0, y0) {
|
||||
z(x0, y0)
|
||||
o(x0 + s * 20, y0 - (s * 6.7))
|
||||
o(x0 + s * 35, y0 - (s * 6.7))
|
||||
z(x = x0, y = y0)
|
||||
o(x = x0 + s * 20, y = y0 - (s * 6.7))
|
||||
o(x = x0 + s * 35, y = y0 - (s * 6.7))
|
||||
}
|
||||
|
||||
zoo(zoo_x, zoo_y)
|
||||
zoo(x = zoo_x, y = zoo_y)
|
||||
"#;
|
||||
let program = crate::parsing::top_level_parse(some_program_string).unwrap();
|
||||
|
||||
@ -1250,32 +1253,32 @@ overHangLength = .4
|
||||
|
||||
// Sketch and revolve the inside bearing piece
|
||||
insideRevolve = startSketchOn(XZ)
|
||||
|> startProfileAt([insideDia / 2, 0], %)
|
||||
|> line([0, thickness + sphereDia / 2], %)
|
||||
|> line([overHangLength, 0], %)
|
||||
|> line([0, -thickness], %)
|
||||
|> line([-overHangLength + thickness, 0], %)
|
||||
|> line([0, -sphereDia], %)
|
||||
|> line([overHangLength - thickness, 0], %)
|
||||
|> line([0, -thickness], %)
|
||||
|> line([-overHangLength, 0], %)
|
||||
|> startProfile(at = [insideDia / 2, 0])
|
||||
|> line(end = [0, thickness + sphereDia / 2])
|
||||
|> line(end = [overHangLength, 0])
|
||||
|> line(end = [0, -thickness])
|
||||
|> line(end = [-overHangLength + thickness, 0])
|
||||
|> line(end = [0, -sphereDia])
|
||||
|> line(end = [overHangLength - thickness, 0])
|
||||
|> line(end = [0, -thickness])
|
||||
|> line(end = [-overHangLength, 0])
|
||||
|> close()
|
||||
|> revolve({ axis = Y }, %)
|
||||
|> revolve(axis = Y)
|
||||
|
||||
// Sketch and revolve one of the balls and duplicate it using a circular pattern. (This is currently a workaround, we have a bug with rotating on a sketch that touches the rotation axis)
|
||||
sphere = startSketchOn(XZ)
|
||||
|> startProfileAt([
|
||||
|> startProfile(at = [
|
||||
0.05 + insideDia / 2 + thickness,
|
||||
0 - 0.05
|
||||
], %)
|
||||
|> line([sphereDia - 0.1, 0], %)
|
||||
|> arc({
|
||||
])
|
||||
|> line(end = [sphereDia - 0.1, 0])
|
||||
|> arc(
|
||||
angle_start = 0,
|
||||
angle_end = -180,
|
||||
radius = sphereDia / 2 - 0.05
|
||||
}, %)
|
||||
)
|
||||
|> close()
|
||||
|> revolve({ axis = X }, %)
|
||||
|> revolve(axis = X)
|
||||
|> patternCircular3d(
|
||||
axis = [0, 0, 1],
|
||||
center = [0, 0, 0],
|
||||
@ -1286,20 +1289,21 @@ sphere = startSketchOn(XZ)
|
||||
|
||||
// Sketch and revolve the outside bearing
|
||||
outsideRevolve = startSketchOn(XZ)
|
||||
|> startProfileAt([
|
||||
|> startProfile(at = [
|
||||
insideDia / 2 + thickness + sphereDia,
|
||||
0
|
||||
], %)
|
||||
|> line([0, sphereDia / 2], %)
|
||||
|> line([-overHangLength + thickness, 0], %)
|
||||
|> line([0, thickness], %)
|
||||
|> line([overHangLength, 0], %)
|
||||
|> line([0, -2 * thickness - sphereDia], %)
|
||||
|> line([-overHangLength, 0], %)
|
||||
|> line([0, thickness], %)
|
||||
|> line([overHangLength - thickness, 0], %)
|
||||
]
|
||||
)
|
||||
|> line(end = [0, sphereDia / 2])
|
||||
|> line(end = [-overHangLength + thickness, 0])
|
||||
|> line(end = [0, thickness])
|
||||
|> line(end = [overHangLength, 0])
|
||||
|> line(end = [0, -2 * thickness - sphereDia])
|
||||
|> line(end = [-overHangLength, 0])
|
||||
|> line(end = [0, thickness])
|
||||
|> line(end = [overHangLength - thickness, 0])
|
||||
|> close()
|
||||
|> revolve({ axis = Y }, %)"#;
|
||||
|> revolve(axis = Y)"#;
|
||||
let program = crate::parsing::top_level_parse(some_program_string).unwrap();
|
||||
|
||||
let recasted = program.recast(&Default::default(), 0);
|
||||
@ -1316,32 +1320,28 @@ overHangLength = .4
|
||||
|
||||
// Sketch and revolve the inside bearing piece
|
||||
insideRevolve = startSketchOn(XZ)
|
||||
|> startProfileAt([insideDia / 2, 0], %)
|
||||
|> line([0, thickness + sphereDia / 2], %)
|
||||
|> line([overHangLength, 0], %)
|
||||
|> line([0, -thickness], %)
|
||||
|> line([-overHangLength + thickness, 0], %)
|
||||
|> line([0, -sphereDia], %)
|
||||
|> line([overHangLength - thickness, 0], %)
|
||||
|> line([0, -thickness], %)
|
||||
|> line([-overHangLength, 0], %)
|
||||
|> startProfile(at = [insideDia / 2, 0])
|
||||
|> line(end = [0, thickness + sphereDia / 2])
|
||||
|> line(end = [overHangLength, 0])
|
||||
|> line(end = [0, -thickness])
|
||||
|> line(end = [-overHangLength + thickness, 0])
|
||||
|> line(end = [0, -sphereDia])
|
||||
|> line(end = [overHangLength - thickness, 0])
|
||||
|> line(end = [0, -thickness])
|
||||
|> line(end = [-overHangLength, 0])
|
||||
|> close()
|
||||
|> revolve({ axis = Y }, %)
|
||||
|> revolve(axis = Y)
|
||||
|
||||
// Sketch and revolve one of the balls and duplicate it using a circular pattern. (This is currently a workaround, we have a bug with rotating on a sketch that touches the rotation axis)
|
||||
sphere = startSketchOn(XZ)
|
||||
|> startProfileAt([
|
||||
|> startProfile(at = [
|
||||
0.05 + insideDia / 2 + thickness,
|
||||
0 - 0.05
|
||||
], %)
|
||||
|> line([sphereDia - 0.1, 0], %)
|
||||
|> arc({
|
||||
angle_start = 0,
|
||||
angle_end = -180,
|
||||
radius = sphereDia / 2 - 0.05
|
||||
}, %)
|
||||
])
|
||||
|> line(end = [sphereDia - 0.1, 0])
|
||||
|> arc(angle_start = 0, angle_end = -180, radius = sphereDia / 2 - 0.05)
|
||||
|> close()
|
||||
|> revolve({ axis = X }, %)
|
||||
|> revolve(axis = X)
|
||||
|> patternCircular3d(
|
||||
axis = [0, 0, 1],
|
||||
center = [0, 0, 0],
|
||||
@ -1352,20 +1352,20 @@ sphere = startSketchOn(XZ)
|
||||
|
||||
// Sketch and revolve the outside bearing
|
||||
outsideRevolve = startSketchOn(XZ)
|
||||
|> startProfileAt([
|
||||
|> startProfile(at = [
|
||||
insideDia / 2 + thickness + sphereDia,
|
||||
0
|
||||
], %)
|
||||
|> line([0, sphereDia / 2], %)
|
||||
|> line([-overHangLength + thickness, 0], %)
|
||||
|> line([0, thickness], %)
|
||||
|> line([overHangLength, 0], %)
|
||||
|> line([0, -2 * thickness - sphereDia], %)
|
||||
|> line([-overHangLength, 0], %)
|
||||
|> line([0, thickness], %)
|
||||
|> line([overHangLength - thickness, 0], %)
|
||||
])
|
||||
|> line(end = [0, sphereDia / 2])
|
||||
|> line(end = [-overHangLength + thickness, 0])
|
||||
|> line(end = [0, thickness])
|
||||
|> line(end = [overHangLength, 0])
|
||||
|> line(end = [0, -2 * thickness - sphereDia])
|
||||
|> line(end = [-overHangLength, 0])
|
||||
|> line(end = [0, thickness])
|
||||
|> line(end = [overHangLength - thickness, 0])
|
||||
|> close()
|
||||
|> revolve({ axis = Y }, %)
|
||||
|> revolve(axis = Y)
|
||||
"#
|
||||
);
|
||||
}
|
||||
@ -1458,7 +1458,7 @@ f = [1, 2, 3]: [number; 1+]
|
||||
let some_program_string = r#"bing = { yo = 55 }
|
||||
myNestedVar = [
|
||||
{
|
||||
prop: line([bing.yo, 21], sketch001)
|
||||
prop: line(a = [bing.yo, 21], b = sketch001)
|
||||
}
|
||||
]
|
||||
"#;
|
||||
@ -1470,7 +1470,7 @@ myNestedVar = [
|
||||
r#"bing = { yo = 55 }
|
||||
myNestedVar = [
|
||||
{
|
||||
prop = line([bing.yo, 21], sketch001)
|
||||
prop = line(a = [bing.yo, 21], b = sketch001)
|
||||
}
|
||||
]
|
||||
"#
|
||||
@ -1502,10 +1502,10 @@ myNestedVar = [
|
||||
fn test_recast_shebang() {
|
||||
let some_program_string = r#"#!/usr/local/env zoo kcl
|
||||
part001 = startSketchOn(XY)
|
||||
|> startProfileAt([-10, -10], %)
|
||||
|> line([20, 0], %)
|
||||
|> line([0, 20], %)
|
||||
|> line([-20, 0], %)
|
||||
|> startProfile(at = [-10, -10])
|
||||
|> line(end = [20, 0])
|
||||
|> line(end = [0, 20])
|
||||
|> line(end = [-20, 0])
|
||||
|> close()
|
||||
"#;
|
||||
|
||||
@ -1517,10 +1517,10 @@ part001 = startSketchOn(XY)
|
||||
r#"#!/usr/local/env zoo kcl
|
||||
|
||||
part001 = startSketchOn(XY)
|
||||
|> startProfileAt([-10, -10], %)
|
||||
|> line([20, 0], %)
|
||||
|> line([0, 20], %)
|
||||
|> line([-20, 0], %)
|
||||
|> startProfile(at = [-10, -10])
|
||||
|> line(end = [20, 0])
|
||||
|> line(end = [0, 20])
|
||||
|> line(end = [-20, 0])
|
||||
|> close()
|
||||
"#
|
||||
);
|
||||
@ -1533,10 +1533,10 @@ part001 = startSketchOn(XY)
|
||||
|
||||
|
||||
part001 = startSketchOn(XY)
|
||||
|> startProfileAt([-10, -10], %)
|
||||
|> line([20, 0], %)
|
||||
|> line([0, 20], %)
|
||||
|> line([-20, 0], %)
|
||||
|> startProfile(at = [-10, -10])
|
||||
|> line(end = [20, 0])
|
||||
|> line(end = [0, 20])
|
||||
|> line(end = [-20, 0])
|
||||
|> close()
|
||||
"#;
|
||||
|
||||
@ -1548,10 +1548,10 @@ part001 = startSketchOn(XY)
|
||||
r#"#!/usr/local/env zoo kcl
|
||||
|
||||
part001 = startSketchOn(XY)
|
||||
|> startProfileAt([-10, -10], %)
|
||||
|> line([20, 0], %)
|
||||
|> line([0, 20], %)
|
||||
|> line([-20, 0], %)
|
||||
|> startProfile(at = [-10, -10])
|
||||
|> line(end = [20, 0])
|
||||
|> line(end = [0, 20])
|
||||
|> line(end = [-20, 0])
|
||||
|> close()
|
||||
"#
|
||||
);
|
||||
@ -1563,10 +1563,10 @@ part001 = startSketchOn(XY)
|
||||
|
||||
// Yo yo my comments.
|
||||
part001 = startSketchOn(XY)
|
||||
|> startProfileAt([-10, -10], %)
|
||||
|> line([20, 0], %)
|
||||
|> line([0, 20], %)
|
||||
|> line([-20, 0], %)
|
||||
|> startProfile(at = [-10, -10])
|
||||
|> line(end = [20, 0])
|
||||
|> line(end = [0, 20])
|
||||
|> line(end = [-20, 0])
|
||||
|> close()
|
||||
"#;
|
||||
|
||||
@ -1579,10 +1579,10 @@ part001 = startSketchOn(XY)
|
||||
|
||||
// Yo yo my comments.
|
||||
part001 = startSketchOn(XY)
|
||||
|> startProfileAt([-10, -10], %)
|
||||
|> line([20, 0], %)
|
||||
|> line([0, 20], %)
|
||||
|> line([-20, 0], %)
|
||||
|> startProfile(at = [-10, -10])
|
||||
|> line(end = [20, 0])
|
||||
|> line(end = [0, 20])
|
||||
|> line(end = [-20, 0])
|
||||
|> close()
|
||||
"#
|
||||
);
|
||||
@ -1613,7 +1613,7 @@ hole_diam = 5
|
||||
// define a rectangular shape func
|
||||
fn rectShape(pos, w, l) {
|
||||
rr = startSketchOn(XY)
|
||||
|> startProfileAt([pos[0] - (w / 2), pos[1] - (l / 2)], %)
|
||||
|> startProfile(at = [pos[0] - (w / 2), pos[1] - (l / 2)])
|
||||
|> line(endAbsolute = [pos[0] + w / 2, pos[1] - (l / 2)], tag = $edge1)
|
||||
|> line(endAbsolute = [pos[0] + w / 2, pos[1] + l / 2], tag = $edge2)
|
||||
|> line(endAbsolute = [pos[0] - (w / 2), pos[1] + l / 2], tag = $edge3)
|
||||
@ -1622,8 +1622,8 @@ fn rectShape(pos, w, l) {
|
||||
}
|
||||
// build the body of the focusrite scarlett solo gen 4
|
||||
// only used for visualization
|
||||
scarlett_body = rectShape([0, 0], width, length)
|
||||
|> extrude(depth, %)
|
||||
scarlett_body = rectShape(pos = [0, 0], w = width, l = length)
|
||||
|> extrude(depth)
|
||||
|> fillet(
|
||||
radius = radius,
|
||||
tags = [
|
||||
@ -1636,14 +1636,14 @@ scarlett_body = rectShape([0, 0], width, length)
|
||||
// build the bracket sketch around the body
|
||||
fn bracketSketch(w, d, t) {
|
||||
s = startSketchOn({
|
||||
plane: {
|
||||
plane = {
|
||||
origin = { x = 0, y = length / 2 + thk, z = 0 },
|
||||
x_axis = { x = 1, y = 0, z = 0 },
|
||||
y_axis = { x = 0, y = 0, z = 1 },
|
||||
z_axis = { x = 0, y = 1, z = 0 }
|
||||
}
|
||||
})
|
||||
|> startProfileAt([-w / 2 - t, d + t], %)
|
||||
|> startProfile(at = [-w / 2 - t, d + t])
|
||||
|> line(endAbsolute = [-w / 2 - t, -t], tag = $edge1)
|
||||
|> line(endAbsolute = [w / 2 + t, -t], tag = $edge2)
|
||||
|> line(endAbsolute = [w / 2 + t, d + t], tag = $edge3)
|
||||
@ -1655,8 +1655,8 @@ fn bracketSketch(w, d, t) {
|
||||
return s
|
||||
}
|
||||
// build the body of the bracket
|
||||
bracket_body = bracketSketch(width, depth, thk)
|
||||
|> extrude(length + 10, %)
|
||||
bracket_body = bracketSketch(w = width, d = depth, t = thk)
|
||||
|> extrude(length + 10)
|
||||
|> fillet(
|
||||
radius = radius,
|
||||
tags = [
|
||||
@ -1668,26 +1668,26 @@ bracket_body = bracketSketch(width, depth, thk)
|
||||
)
|
||||
// build the tabs of the mounting bracket (right side)
|
||||
tabs_r = startSketchOn({
|
||||
plane: {
|
||||
plane = {
|
||||
origin = { x = 0, y = 0, z = depth + thk },
|
||||
x_axis = { x = 1, y = 0, z = 0 },
|
||||
y_axis = { x = 0, y = 1, z = 0 },
|
||||
z_axis = { x = 0, y = 0, z = 1 }
|
||||
}
|
||||
})
|
||||
|> startProfileAt([width / 2 + thk, length / 2 + thk], %)
|
||||
|> line([10, -5], %)
|
||||
|> line([0, -10], %)
|
||||
|> line([-10, -5], %)
|
||||
|> startProfile(at = [width / 2 + thk, length / 2 + thk])
|
||||
|> line(end = [10, -5])
|
||||
|> line(end = [0, -10])
|
||||
|> line(end = [-10, -5])
|
||||
|> close()
|
||||
|> hole(circle(
|
||||
|> subtract2d(tool = circle(
|
||||
center = [
|
||||
width / 2 + thk + hole_diam,
|
||||
length / 2 - hole_diam
|
||||
],
|
||||
radius = hole_diam / 2
|
||||
), %)
|
||||
|> extrude(-thk, %)
|
||||
))
|
||||
|> extrude(-thk)
|
||||
|> patternLinear3d(
|
||||
axis = [0, -1, 0],
|
||||
repetitions = 1,
|
||||
@ -1695,26 +1695,26 @@ tabs_r = startSketchOn({
|
||||
)
|
||||
// build the tabs of the mounting bracket (left side)
|
||||
tabs_l = startSketchOn({
|
||||
plane: {
|
||||
plane = {
|
||||
origin = { x = 0, y = 0, z = depth + thk },
|
||||
x_axis = { x = 1, y = 0, z = 0 },
|
||||
y_axis = { x = 0, y = 1, z = 0 },
|
||||
z_axis = { x = 0, y = 0, z = 1 }
|
||||
}
|
||||
})
|
||||
|> startProfileAt([-width / 2 - thk, length / 2 + thk], %)
|
||||
|> line([-10, -5], %)
|
||||
|> line([0, -10], %)
|
||||
|> line([10, -5], %)
|
||||
|> startProfile(at = [-width / 2 - thk, length / 2 + thk])
|
||||
|> line(end = [-10, -5])
|
||||
|> line(end = [0, -10])
|
||||
|> line(end = [10, -5])
|
||||
|> close()
|
||||
|> hole(circle(
|
||||
|> subtract2d(tool = circle(
|
||||
center = [
|
||||
-width / 2 - thk - hole_diam,
|
||||
length / 2 - hole_diam
|
||||
],
|
||||
radius = hole_diam / 2
|
||||
), %)
|
||||
|> extrude(-thk, %)
|
||||
))
|
||||
|> extrude(-thk)
|
||||
|> patternLinear3d(axis = [0, -1, 0], repetitions = 1, distance = length - 10ft)
|
||||
"#;
|
||||
let program = crate::parsing::top_level_parse(some_program_string).unwrap();
|
||||
@ -1735,7 +1735,7 @@ hole_diam = 5
|
||||
// define a rectangular shape func
|
||||
fn rectShape(pos, w, l) {
|
||||
rr = startSketchOn(XY)
|
||||
|> startProfileAt([pos[0] - (w / 2), pos[1] - (l / 2)], %)
|
||||
|> startProfile(at = [pos[0] - (w / 2), pos[1] - (l / 2)])
|
||||
|> line(endAbsolute = [pos[0] + w / 2, pos[1] - (l / 2)], tag = $edge1)
|
||||
|> line(endAbsolute = [pos[0] + w / 2, pos[1] + l / 2], tag = $edge2)
|
||||
|> line(endAbsolute = [pos[0] - (w / 2), pos[1] + l / 2], tag = $edge3)
|
||||
@ -1744,8 +1744,8 @@ fn rectShape(pos, w, l) {
|
||||
}
|
||||
// build the body of the focusrite scarlett solo gen 4
|
||||
// only used for visualization
|
||||
scarlett_body = rectShape([0, 0], width, length)
|
||||
|> extrude(depth, %)
|
||||
scarlett_body = rectShape(pos = [0, 0], w = width, l = length)
|
||||
|> extrude(depth)
|
||||
|> fillet(
|
||||
radius = radius,
|
||||
tags = [
|
||||
@ -1765,7 +1765,7 @@ fn bracketSketch(w, d, t) {
|
||||
z_axis = { x = 0, y = 1, z = 0 }
|
||||
}
|
||||
})
|
||||
|> startProfileAt([-w / 2 - t, d + t], %)
|
||||
|> startProfile(at = [-w / 2 - t, d + t])
|
||||
|> line(endAbsolute = [-w / 2 - t, -t], tag = $edge1)
|
||||
|> line(endAbsolute = [w / 2 + t, -t], tag = $edge2)
|
||||
|> line(endAbsolute = [w / 2 + t, d + t], tag = $edge3)
|
||||
@ -1777,8 +1777,8 @@ fn bracketSketch(w, d, t) {
|
||||
return s
|
||||
}
|
||||
// build the body of the bracket
|
||||
bracket_body = bracketSketch(width, depth, thk)
|
||||
|> extrude(length + 10, %)
|
||||
bracket_body = bracketSketch(w = width, d = depth, t = thk)
|
||||
|> extrude(length + 10)
|
||||
|> fillet(
|
||||
radius = radius,
|
||||
tags = [
|
||||
@ -1797,19 +1797,19 @@ tabs_r = startSketchOn({
|
||||
z_axis = { x = 0, y = 0, z = 1 }
|
||||
}
|
||||
})
|
||||
|> startProfileAt([width / 2 + thk, length / 2 + thk], %)
|
||||
|> line([10, -5], %)
|
||||
|> line([0, -10], %)
|
||||
|> line([-10, -5], %)
|
||||
|> startProfile(at = [width / 2 + thk, length / 2 + thk])
|
||||
|> line(end = [10, -5])
|
||||
|> line(end = [0, -10])
|
||||
|> line(end = [-10, -5])
|
||||
|> close()
|
||||
|> hole(circle(
|
||||
|> subtract2d(tool = circle(
|
||||
center = [
|
||||
width / 2 + thk + hole_diam,
|
||||
length / 2 - hole_diam
|
||||
],
|
||||
radius = hole_diam / 2,
|
||||
), %)
|
||||
|> extrude(-thk, %)
|
||||
))
|
||||
|> extrude(-thk)
|
||||
|> patternLinear3d(axis = [0, -1, 0], repetitions = 1, distance = length - 10)
|
||||
// build the tabs of the mounting bracket (left side)
|
||||
tabs_l = startSketchOn({
|
||||
@ -1820,19 +1820,19 @@ tabs_l = startSketchOn({
|
||||
z_axis = { x = 0, y = 0, z = 1 }
|
||||
}
|
||||
})
|
||||
|> startProfileAt([-width / 2 - thk, length / 2 + thk], %)
|
||||
|> line([-10, -5], %)
|
||||
|> line([0, -10], %)
|
||||
|> line([10, -5], %)
|
||||
|> startProfile(at = [-width / 2 - thk, length / 2 + thk])
|
||||
|> line(end = [-10, -5])
|
||||
|> line(end = [0, -10])
|
||||
|> line(end = [10, -5])
|
||||
|> close()
|
||||
|> hole(circle(
|
||||
|> subtract2d(tool = circle(
|
||||
center = [
|
||||
-width / 2 - thk - hole_diam,
|
||||
length / 2 - hole_diam
|
||||
],
|
||||
radius = hole_diam / 2,
|
||||
), %)
|
||||
|> extrude(-thk, %)
|
||||
))
|
||||
|> extrude(-thk)
|
||||
|> patternLinear3d(axis = [0, -1, 0], repetitions = 1, distance = length - 10ft)
|
||||
"#
|
||||
);
|
||||
@ -1842,12 +1842,12 @@ tabs_l = startSketchOn({
|
||||
fn test_recast_nested_var_declaration_in_fn_body() {
|
||||
let some_program_string = r#"fn cube(pos, scale) {
|
||||
sg = startSketchOn(XY)
|
||||
|> startProfileAt(pos, %)
|
||||
|> line([0, scale], %)
|
||||
|> line([scale, 0], %)
|
||||
|> line([0, -scale], %)
|
||||
|> startProfile(at = pos)
|
||||
|> line(end = [0, scale])
|
||||
|> line(end = [scale, 0])
|
||||
|> line(end = [0, -scale])
|
||||
|> close()
|
||||
|> extrude(scale, %)
|
||||
|> extrude(scale)
|
||||
}"#;
|
||||
let program = crate::parsing::top_level_parse(some_program_string).unwrap();
|
||||
|
||||
@ -1856,12 +1856,12 @@ tabs_l = startSketchOn({
|
||||
recasted,
|
||||
r#"fn cube(pos, scale) {
|
||||
sg = startSketchOn(XY)
|
||||
|> startProfileAt(pos, %)
|
||||
|> line([0, scale], %)
|
||||
|> line([scale, 0], %)
|
||||
|> line([0, -scale], %)
|
||||
|> startProfile(at = pos)
|
||||
|> line(end = [0, scale])
|
||||
|> line(end = [scale, 0])
|
||||
|> line(end = [0, -scale])
|
||||
|> close()
|
||||
|> extrude(scale, %)
|
||||
|> extrude(scale)
|
||||
}
|
||||
"#
|
||||
);
|
||||
@ -1873,15 +1873,15 @@ tabs_l = startSketchOn({
|
||||
x = dfsfs + dfsfsd as y
|
||||
|
||||
sg = startSketchOn(XY)
|
||||
|> startProfileAt(pos, %) as foo
|
||||
|> line([0, scale], %)
|
||||
|> line([scale, 0], %) as bar
|
||||
|> line([0 as baz, -scale] as qux, %)
|
||||
|> startProfile(at = pos) as foo
|
||||
|> line([0, scale])
|
||||
|> line([scale, 0]) as bar
|
||||
|> line([0 as baz, -scale] as qux)
|
||||
|> close()
|
||||
|> extrude(scale, %)
|
||||
|> extrude(length = scale)
|
||||
}
|
||||
|
||||
cube(0, 0) as cub
|
||||
cube(pos = 0, scale = 0) as cub
|
||||
"#;
|
||||
let program = crate::parsing::top_level_parse(some_program_string).unwrap();
|
||||
|
||||
@ -1892,18 +1892,18 @@ cube(0, 0) as cub
|
||||
#[test]
|
||||
fn test_recast_with_bad_indentation() {
|
||||
let some_program_string = r#"part001 = startSketchOn(XY)
|
||||
|> startProfileAt([0.0, 5.0], %)
|
||||
|> line([0.4900857016, -0.0240763666], %)
|
||||
|> line([0.6804562304, 0.9087880491], %)"#;
|
||||
|> startProfile(at = [0.0, 5.0])
|
||||
|> line(end = [0.4900857016, -0.0240763666])
|
||||
|> line(end = [0.6804562304, 0.9087880491])"#;
|
||||
let program = crate::parsing::top_level_parse(some_program_string).unwrap();
|
||||
|
||||
let recasted = program.recast(&Default::default(), 0);
|
||||
assert_eq!(
|
||||
recasted,
|
||||
r#"part001 = startSketchOn(XY)
|
||||
|> startProfileAt([0.0, 5.0], %)
|
||||
|> line([0.4900857016, -0.0240763666], %)
|
||||
|> line([0.6804562304, 0.9087880491], %)
|
||||
|> startProfile(at = [0.0, 5.0])
|
||||
|> line(end = [0.4900857016, -0.0240763666])
|
||||
|> line(end = [0.6804562304, 0.9087880491])
|
||||
"#
|
||||
);
|
||||
}
|
||||
@ -1911,38 +1911,38 @@ cube(0, 0) as cub
|
||||
#[test]
|
||||
fn test_recast_with_bad_indentation_and_inline_comment() {
|
||||
let some_program_string = r#"part001 = startSketchOn(XY)
|
||||
|> startProfileAt([0.0, 5.0], %)
|
||||
|> line([0.4900857016, -0.0240763666], %) // hello world
|
||||
|> line([0.6804562304, 0.9087880491], %)"#;
|
||||
|> startProfile(at = [0.0, 5.0])
|
||||
|> line(end = [0.4900857016, -0.0240763666]) // hello world
|
||||
|> line(end = [0.6804562304, 0.9087880491])"#;
|
||||
let program = crate::parsing::top_level_parse(some_program_string).unwrap();
|
||||
|
||||
let recasted = program.recast(&Default::default(), 0);
|
||||
assert_eq!(
|
||||
recasted,
|
||||
r#"part001 = startSketchOn(XY)
|
||||
|> startProfileAt([0.0, 5.0], %)
|
||||
|> line([0.4900857016, -0.0240763666], %) // hello world
|
||||
|> line([0.6804562304, 0.9087880491], %)
|
||||
|> startProfile(at = [0.0, 5.0])
|
||||
|> line(end = [0.4900857016, -0.0240763666]) // hello world
|
||||
|> line(end = [0.6804562304, 0.9087880491])
|
||||
"#
|
||||
);
|
||||
}
|
||||
#[test]
|
||||
fn test_recast_with_bad_indentation_and_line_comment() {
|
||||
let some_program_string = r#"part001 = startSketchOn(XY)
|
||||
|> startProfileAt([0.0, 5.0], %)
|
||||
|> line([0.4900857016, -0.0240763666], %)
|
||||
|> startProfile(at = [0.0, 5.0])
|
||||
|> line(end = [0.4900857016, -0.0240763666])
|
||||
// hello world
|
||||
|> line([0.6804562304, 0.9087880491], %)"#;
|
||||
|> line(end = [0.6804562304, 0.9087880491])"#;
|
||||
let program = crate::parsing::top_level_parse(some_program_string).unwrap();
|
||||
|
||||
let recasted = program.recast(&Default::default(), 0);
|
||||
assert_eq!(
|
||||
recasted,
|
||||
r#"part001 = startSketchOn(XY)
|
||||
|> startProfileAt([0.0, 5.0], %)
|
||||
|> line([0.4900857016, -0.0240763666], %)
|
||||
|> startProfile(at = [0.0, 5.0])
|
||||
|> line(end = [0.4900857016, -0.0240763666])
|
||||
// hello world
|
||||
|> line([0.6804562304, 0.9087880491], %)
|
||||
|> line(end = [0.6804562304, 0.9087880491])
|
||||
"#
|
||||
);
|
||||
}
|
||||
@ -2085,7 +2085,7 @@ thing = 'foo'
|
||||
/* comment at start */
|
||||
|
||||
mySk1 = startSketchOn(XY)
|
||||
|> startProfileAt([0, 0], %)"#;
|
||||
|> startProfile(at = [0, 0])"#;
|
||||
let program = crate::parsing::top_level_parse(test_program).unwrap();
|
||||
|
||||
let recasted = program.recast(&Default::default(), 0);
|
||||
@ -2094,7 +2094,7 @@ mySk1 = startSketchOn(XY)
|
||||
r#"/* comment at start */
|
||||
|
||||
mySk1 = startSketchOn(XY)
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> startProfile(at = [0, 0])
|
||||
"#
|
||||
);
|
||||
}
|
||||
@ -2103,7 +2103,7 @@ mySk1 = startSketchOn(XY)
|
||||
fn test_recast_lots_of_comments() {
|
||||
let some_program_string = r#"// comment at start
|
||||
mySk1 = startSketchOn(XY)
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> startProfile(at = [0, 0])
|
||||
|> line(endAbsolute = [1, 1])
|
||||
// comment here
|
||||
|> line(endAbsolute = [0, 1], tag = $myTag)
|
||||
@ -2112,10 +2112,10 @@ mySk1 = startSketchOn(XY)
|
||||
here
|
||||
*/
|
||||
// a comment between pipe expression statements
|
||||
|> rx(90, %)
|
||||
|> rx(90)
|
||||
// and another with just white space between others below
|
||||
|> ry(45, %)
|
||||
|> rx(45, %)
|
||||
|> ry(45)
|
||||
|> rx(45)
|
||||
// one more for good measure"#;
|
||||
let program = crate::parsing::top_level_parse(some_program_string).unwrap();
|
||||
|
||||
@ -2124,7 +2124,7 @@ mySk1 = startSketchOn(XY)
|
||||
recasted,
|
||||
r#"// comment at start
|
||||
mySk1 = startSketchOn(XY)
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> startProfile(at = [0, 0])
|
||||
|> line(endAbsolute = [1, 1])
|
||||
// comment here
|
||||
|> line(endAbsolute = [0, 1], tag = $myTag)
|
||||
@ -2132,10 +2132,10 @@ mySk1 = startSketchOn(XY)
|
||||
/* and
|
||||
here */
|
||||
// a comment between pipe expression statements
|
||||
|> rx(90, %)
|
||||
|> rx(90)
|
||||
// and another with just white space between others below
|
||||
|> ry(45, %)
|
||||
|> rx(45, %)
|
||||
|> ry(45)
|
||||
|> rx(45)
|
||||
// one more for good measure
|
||||
"#
|
||||
);
|
||||
@ -2223,10 +2223,10 @@ myVar3 = 6
|
||||
myAng = 40
|
||||
myAng2 = 134
|
||||
part001 = startSketchOn(XY)
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> line([1, 3.82], %, $seg01) // ln-should-get-tag
|
||||
|> angledLine(angle = -foo(seg01, myVar, %), length = myVar) // ln-lineTo-xAbsolute should use angleToMatchLengthX helper
|
||||
|> angledLine(angle = -bar(seg01, myVar, %), length = myVar) // ln-lineTo-yAbsolute should use angleToMatchLengthY helper"#;
|
||||
|> startProfile(at = [0, 0])
|
||||
|> line(end = [1, 3.82], tag = $seg01) // ln-should-get-tag
|
||||
|> angledLine(angle = -foo(x = seg01, y = myVar, z = %), length = myVar) // ln-lineTo-xAbsolute should use angleToMatchLengthX helper
|
||||
|> angledLine(angle = -bar(x = seg01, y = myVar, z = %), length = myVar) // ln-lineTo-yAbsolute should use angleToMatchLengthY helper"#;
|
||||
let program = crate::parsing::top_level_parse(some_program_string).unwrap();
|
||||
|
||||
let recasted = program.recast(&Default::default(), 0);
|
||||
@ -2241,10 +2241,10 @@ myVar3 = 6
|
||||
myAng = 40
|
||||
myAng2 = 134
|
||||
part001 = startSketchOn(XY)
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> line([1, 3.82], %, $seg01) // ln-should-get-tag
|
||||
|> angledLine(angle = -foo(seg01, myVar, %), length = myVar) // ln-lineTo-xAbsolute should use angleToMatchLengthX helper
|
||||
|> angledLine(angle = -bar(seg01, myVar, %), length = myVar) // ln-lineTo-yAbsolute should use angleToMatchLengthY helper
|
||||
|> startProfile(at = [0, 0])
|
||||
|> line(end = [1, 3.82], tag = $seg01) // ln-should-get-tag
|
||||
|> angledLine(angle = -foo(x = seg01, y = myVar, z = %), length = myVar) // ln-lineTo-xAbsolute should use angleToMatchLengthX helper
|
||||
|> angledLine(angle = -bar(x = seg01, y = myVar, z = %), length = myVar) // ln-lineTo-yAbsolute should use angleToMatchLengthY helper
|
||||
"#;
|
||||
let program = crate::parsing::top_level_parse(some_program_string).unwrap();
|
||||
|
||||
@ -2262,8 +2262,8 @@ part001 = startSketchOn(XY)
|
||||
#[test]
|
||||
fn test_recast_after_rename_std() {
|
||||
let some_program_string = r#"part001 = startSketchOn(XY)
|
||||
|> startProfileAt([0.0000000000, 5.0000000000], %)
|
||||
|> line([0.4900857016, -0.0240763666], %)
|
||||
|> startProfile(at = [0.0000000000, 5.0000000000])
|
||||
|> line(end = [0.4900857016, -0.0240763666])
|
||||
|
||||
part002 = "part002"
|
||||
things = [part001, 0.0]
|
||||
@ -2282,8 +2282,8 @@ fn ghi(part001) {
|
||||
assert_eq!(
|
||||
recasted,
|
||||
r#"mySuperCoolPart = startSketchOn(XY)
|
||||
|> startProfileAt([0.0, 5.0], %)
|
||||
|> line([0.4900857016, -0.0240763666], %)
|
||||
|> startProfile(at = [0.0, 5.0])
|
||||
|> line(end = [0.4900857016, -0.0240763666])
|
||||
|
||||
part002 = "part002"
|
||||
things = [mySuperCoolPart, 0.0]
|
||||
@ -2319,24 +2319,24 @@ fn ghi(part001) {
|
||||
#[test]
|
||||
fn test_recast_trailing_comma() {
|
||||
let some_program_string = r#"startSketchOn(XY)
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> startProfile(at = [0, 0])
|
||||
|> arc({
|
||||
radius = 1,
|
||||
angle_start = 0,
|
||||
angle_end = 180,
|
||||
}, %)"#;
|
||||
})"#;
|
||||
let program = crate::parsing::top_level_parse(some_program_string).unwrap();
|
||||
|
||||
let recasted = program.recast(&Default::default(), 0);
|
||||
assert_eq!(
|
||||
recasted,
|
||||
r#"startSketchOn(XY)
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> startProfile(at = [0, 0])
|
||||
|> arc({
|
||||
radius = 1,
|
||||
angle_start = 0,
|
||||
angle_end = 180
|
||||
}, %)
|
||||
})
|
||||
"#
|
||||
);
|
||||
}
|
||||
@ -2348,12 +2348,12 @@ l = 8
|
||||
h = 10
|
||||
|
||||
firstExtrude = startSketchOn(XY)
|
||||
|> startProfileAt([0,0], %)
|
||||
|> line([0, l], %)
|
||||
|> line([w, 0], %)
|
||||
|> line([0, -l], %)
|
||||
|> startProfile(at = [0,0])
|
||||
|> line(end = [0, l])
|
||||
|> line(end = [w, 0])
|
||||
|> line(end = [0, -l])
|
||||
|> close()
|
||||
|> extrude(h, %)
|
||||
|> extrude(h)
|
||||
"#;
|
||||
let program = crate::parsing::top_level_parse(some_program_string).unwrap();
|
||||
|
||||
@ -2365,12 +2365,12 @@ l = 8
|
||||
h = 10
|
||||
|
||||
firstExtrude = startSketchOn(XY)
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> line([0, l], %)
|
||||
|> line([w, 0], %)
|
||||
|> line([0, -l], %)
|
||||
|> startProfile(at = [0, 0])
|
||||
|> line(end = [0, l])
|
||||
|> line(end = [w, 0])
|
||||
|> line(end = [0, -l])
|
||||
|> close()
|
||||
|> extrude(h, %)
|
||||
|> extrude(h)
|
||||
"#
|
||||
);
|
||||
}
|
||||
@ -2385,12 +2385,12 @@ h = 10
|
||||
// It has multiple lines
|
||||
// And it's really long
|
||||
firstExtrude = startSketchOn(XY)
|
||||
|> startProfileAt([0,0], %)
|
||||
|> line([0, l], %)
|
||||
|> line([w, 0], %)
|
||||
|> line([0, -l], %)
|
||||
|> startProfile(at = [0,0])
|
||||
|> line(end = [0, l])
|
||||
|> line(end = [w, 0])
|
||||
|> line(end = [0, -l])
|
||||
|> close()
|
||||
|> extrude(h, %)
|
||||
|> extrude(h)
|
||||
"#;
|
||||
let program = crate::parsing::top_level_parse(some_program_string).unwrap();
|
||||
|
||||
@ -2405,12 +2405,12 @@ h = 10
|
||||
// It has multiple lines
|
||||
// And it's really long
|
||||
firstExtrude = startSketchOn(XY)
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> line([0, l], %)
|
||||
|> line([w, 0], %)
|
||||
|> line([0, -l], %)
|
||||
|> startProfile(at = [0, 0])
|
||||
|> line(end = [0, l])
|
||||
|> line(end = [w, 0])
|
||||
|> line(end = [0, -l])
|
||||
|> close()
|
||||
|> extrude(h, %)
|
||||
|> extrude(h)
|
||||
"#
|
||||
);
|
||||
}
|
||||
@ -2430,11 +2430,11 @@ firstExtrude = startSketchOn(XY)
|
||||
thickness = 0.5
|
||||
|
||||
startSketchOn(XY)
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> line([0, -(wallMountL - thickness)], %)
|
||||
|> line([0, -(5 - thickness)], %)
|
||||
|> line([0, -(5 - 1)], %)
|
||||
|> line([0, -(-5 - 1)], %)"#;
|
||||
|> startProfile(at = [0, 0])
|
||||
|> line(end = [0, -(wallMountL - thickness)])
|
||||
|> line(end = [0, -(5 - thickness)])
|
||||
|> line(end = [0, -(5 - 1)])
|
||||
|> line(end = [0, -(-5 - 1)])"#;
|
||||
let program = crate::parsing::top_level_parse(some_program_string).unwrap();
|
||||
|
||||
let recasted = program.recast(&Default::default(), 0);
|
||||
@ -2560,9 +2560,13 @@ sketch002 = startSketchOn({
|
||||
|
||||
#[test]
|
||||
fn unparse_fn_unnamed() {
|
||||
let input = r#"squares_out = reduce(arr, 0: number, fn(i, squares) {
|
||||
let input = r#"squares_out = reduce(
|
||||
arr,
|
||||
n = 0: number,
|
||||
f = fn(i, squares) {
|
||||
return 1
|
||||
})
|
||||
},
|
||||
)
|
||||
"#;
|
||||
let ast = crate::parsing::top_level_parse(input).unwrap();
|
||||
let actual = ast.recast(&FormatOptions::new(), 0);
|
||||
|
@ -117,7 +117,7 @@ export fn fillet(
|
||||
/// return sg
|
||||
/// }
|
||||
///
|
||||
/// part001 = cube([0,0], 20)
|
||||
/// part001 = cube(pos = [0,0], scale = 20)
|
||||
/// |> close(tag = $line1)
|
||||
/// |> extrude(length = 20)
|
||||
/// // We tag the chamfer to reference it later.
|
||||
|
@ -88,8 +88,8 @@ export type string
|
||||
/// |> close()
|
||||
/// }
|
||||
///
|
||||
/// rect([0, 0])
|
||||
/// rect([20, 0])
|
||||
/// rect(origin = [0, 0])
|
||||
/// rect(origin = [20, 0])
|
||||
/// ```
|
||||
///
|
||||
/// Those tags would only be available in the `rect` function and not globally.
|
||||
@ -116,8 +116,8 @@ export type string
|
||||
/// |> close()
|
||||
/// }
|
||||
///
|
||||
/// rect([0, 0])
|
||||
/// myRect = rect([20, 0])
|
||||
/// rect(origin = [0, 0])
|
||||
/// myRect = rect(origin = [20, 0])
|
||||
///
|
||||
/// myRect
|
||||
/// |> extrude(length = 10)
|
||||
|
@ -79,7 +79,8 @@ description: Result of parsing add_lots.kcl
|
||||
"name": "i",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
}
|
||||
},
|
||||
"labeled": false
|
||||
}
|
||||
],
|
||||
"start": 0,
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user