Kwargs: map and reduce (#6480)

Migrate array's `map`, `reduce` and `push` functions to use keyword arguments.
This commit is contained in:
Adam Chalmers
2025-04-25 19:09:03 -05:00
committed by GitHub
parent 5a4f8bd522
commit 50f8131d83
35 changed files with 3852 additions and 3498 deletions

File diff suppressed because one or more lines are too long

View File

@ -11,7 +11,7 @@ Returns a new array with the element appended.
```js
push(
array: [KclValue],
elem: KclValue,
item: KclValue,
): KclValue
```
@ -20,8 +20,8 @@ push(
| Name | Type | Description | Required |
|----------|------|-------------|----------|
| `array` | [`[KclValue]`](/docs/kcl/types/KclValue) | | Yes |
| `elem` | [`KclValue`](/docs/kcl/types/KclValue) | Any KCL value. | Yes |
| `array` | [`[KclValue]`](/docs/kcl/types/KclValue) | The array which you're adding a new item to. | Yes |
| `item` | [`KclValue`](/docs/kcl/types/KclValue) | The new item to add to the array | Yes |
### Returns
@ -32,7 +32,7 @@ push(
```js
arr = [1, 2, 3]
new_arr = push(arr, 4)
new_arr = push(arr, item = 4)
assert(
new_arr[3],
isEqualTo = 4,

View File

@ -11,8 +11,8 @@ Take a starting value. Then, for each element of an array, calculate the next va
```js
reduce(
array: [KclValue],
start: KclValue,
reduceFn: FunctionSource,
initial: KclValue,
f: FunctionSource,
): KclValue
```
@ -21,9 +21,9 @@ reduce(
| Name | Type | Description | Required |
|----------|------|-------------|----------|
| `array` | [`[KclValue]`](/docs/kcl/types/KclValue) | | Yes |
| `start` | [`KclValue`](/docs/kcl/types/KclValue) | Any KCL value. | Yes |
| `reduceFn` | `FunctionSource` | | Yes |
| `array` | [`[KclValue]`](/docs/kcl/types/KclValue) | Each element of this array gets run through the function `f`, combined with the previous output from `f`, and then used for the next run. | Yes |
| `initial` | [`KclValue`](/docs/kcl/types/KclValue) | The first time `f` is run, it will be called with the first item of `array` and this initial starting value. | Yes |
| `f` | `FunctionSource` | Run once per item in the input `array`. This function takes an item from the array, and the previous output from `f` (or `initial` on the very first run). The final time `f` is run, its output is returned as the final output from `reduce`. | Yes |
### Returns
@ -42,7 +42,7 @@ fn add(a, b) {
// 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, 0, add)
return reduce(arr, initial = 0, f = add)
}
/* The above is basically like this pseudo-code:
@ -69,9 +69,13 @@ assert(
// an anonymous `add` function as its parameter, instead of declaring a
// named function outside.
arr = [1, 2, 3]
sum = reduce(arr, 0, fn(i, result_so_far) {
sum = reduce(
arr,
initial = 0,
f = fn(i, result_so_far) {
return i + result_so_far
})
},
)
// We use `assert` to check that our `sum` function gives the
// expected result. It's good to check your work!
@ -98,12 +102,16 @@ fn decagon(radius) {
// Use a `reduce` to draw the remaining decagon sides.
// For each number in the array 1..10, run the given function,
// which takes a partially-sketched decagon and adds one more edge to it.
fullDecagon = reduce([1..10], startOfDecagonSketch, fn(i, partialDecagon) {
fullDecagon = reduce(
[1..10],
initial = startOfDecagonSketch,
f = fn(i, partialDecagon) {
// Draw one edge of the decagon.
x = cos(stepAngle * i) * radius
y = sin(stepAngle * i) * radius
return line(partialDecagon, end = [x, y])
})
},
)
return fullDecagon
}

View File

@ -154984,7 +154984,7 @@
"summary": "Apply a function to every element of a list.",
"description": "Given a list like `[a, b, c]`, and a function like `f`, returns `[f(a), f(b), f(c)]`",
"tags": [],
"keywordArguments": false,
"keywordArguments": true,
"args": [
{
"name": "array",
@ -157466,10 +157466,11 @@
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
"description": "Input array. The output array is this input array, but every element has had the function `f` run on it.",
"labelRequired": false
},
{
"name": "mapFn",
"name": "f",
"type": "FunctionSource",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
@ -159945,6 +159946,7 @@
},
"required": true,
"includeInSnippet": true,
"description": "A function. The output array is just the input array, but `f` has been run on every item.",
"labelRequired": true
}
],
@ -162433,8 +162435,8 @@
"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], drawCircle)",
"r = 10 // radius\n// Call `map`, using an anonymous function instead of a named one.\ncircles = map([1..3], fn(id) {\n return startSketchOn(XY)\n |> circle(center = [id * 2 * r, 0], radius = r)\n})"
"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)"
]
},
{
@ -242281,7 +242283,7 @@
"summary": "Append an element to the end of an array.",
"description": "Returns a new array with the element appended.",
"tags": [],
"keywordArguments": false,
"keywordArguments": true,
"args": [
{
"name": "array",
@ -244763,10 +244765,11 @@
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
"description": "The array which you're adding a new item to.",
"labelRequired": false
},
{
"name": "elem",
"name": "item",
"type": "KclValue",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
@ -247625,6 +247628,7 @@
},
"required": true,
"includeInSnippet": true,
"description": "The new item to add to the array",
"labelRequired": true
}
],
@ -250493,7 +250497,7 @@
"unpublished": false,
"deprecated": false,
"examples": [
"arr = [1, 2, 3]\nnew_arr = push(arr, 4)\nassert(\n new_arr[3],\n isEqualTo = 4,\n tolerance = 0.1,\n error = \"4 was added to the end of the array\",\n)"
"arr = [1, 2, 3]\nnew_arr = push(arr, item = 4)\nassert(\n new_arr[3],\n isEqualTo = 4,\n tolerance = 0.1,\n error = \"4 was added to the end of the array\",\n)"
]
},
{
@ -250501,7 +250505,7 @@
"summary": "Take a starting value. Then, for each element of an array, calculate the next value, using the previous value and the element.",
"description": "",
"tags": [],
"keywordArguments": false,
"keywordArguments": true,
"args": [
{
"name": "array",
@ -252983,10 +252987,11 @@
},
"required": true,
"includeInSnippet": true,
"labelRequired": true
"description": "Each element of this array gets run through the function `f`, combined with the previous output from `f`, and then used for the next run.",
"labelRequired": false
},
{
"name": "start",
"name": "initial",
"type": "KclValue",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
@ -255845,10 +255850,11 @@
},
"required": true,
"includeInSnippet": true,
"description": "The first time `f` is run, it will be called with the first item of `array` and this initial starting value.",
"labelRequired": true
},
{
"name": "reduceFn",
"name": "f",
"type": "FunctionSource",
"schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
@ -258324,6 +258330,7 @@
},
"required": true,
"includeInSnippet": true,
"description": "Run once per item in the input `array`. This function takes an item from the array, and the previous output from `f` (or `initial` on the very first run). The final time `f` is run, its output is returned as the final output from `reduce`.",
"labelRequired": true
}
],
@ -261192,9 +261199,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, 0, 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(arr, 0, fn(i, result_so_far) {\n return i + result_so_far\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\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([1..10], startOfDecagonSketch, 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 return fullDecagon\n}\n\n/* The `decagon` above is basically like this pseudo-code:\nfn decagon(radius):\n stepAngle = (1/10) * TAU\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()"
"// 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\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\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()"
]
},
{

View File

@ -49,7 +49,9 @@ faceRotations = [
]
// Create faces by mapping over the rotations array
dodecFaces = map(faceRotations, fn(rotation) {
dodecFaces = map(
faceRotations,
f = fn(rotation) {
return createFaceTemplate(rotation[3])
|> rotate(
pitch = rotation[0],
@ -57,12 +59,17 @@ dodecFaces = map(faceRotations, fn(rotation) {
yaw = rotation[2],
global = true,
)
})
},
)
fn calculateArrayLength(arr) {
return reduce(arr, 0, fn(item, accumulator) {
return reduce(
arr,
initial = 0,
f = fn(item, accumulator) {
return accumulator + 1
})
},
)
}
fn createIntersection(solids) {
@ -72,7 +79,7 @@ fn createIntersection(solids) {
lastIndex = calculateArrayLength(solids) - 1
lastSolid = solids[lastIndex]
remainingSolids = pop(solids)
return reduce(remainingSolids, lastSolid, reduceIntersect)
return reduce(remainingSolids, initial = lastSolid, f = reduceIntersect)
}
// Apply intersection to all faces

View File

@ -17,28 +17,43 @@ gearHeight = 3
// Interpolate points along the involute curve
cmo = 101
rs = map([0..cmo], fn(i) {
rs = map(
[0..cmo],
f = fn(i) {
return baseDiameter / 2 + i / cmo * (tipDiameter - baseDiameter) / 2
})
},
)
// Calculate operating pressure angle
angles = map(rs, fn(r) {
angles = map(
rs,
f = fn(r) {
return toDegrees( acos(baseDiameter / 2 / r))
})
},
)
// Calculate the involute function
invas = map(angles, fn(a) {
invas = map(
angles,
f = fn(a) {
return tan(toRadians(a)) - toRadians(a)
})
},
)
// Map the involute curve
xs = map([0..cmo], fn(i) {
xs = map(
[0..cmo],
f = fn(i) {
return rs[i] * cos(invas[i]: number(rad))
})
},
)
ys = map([0..cmo], fn(i) {
ys = map(
[0..cmo],
f = fn(i) {
return rs[i] * sin(invas[i]: number(rad))
})
},
)
// Extrude the gear body
body = startSketchOn(XY)
@ -62,9 +77,9 @@ fn rightInvolute(i, sg) {
// Draw gear teeth
start = startSketchOn(XY)
|> startProfile(at = [xs[101], ys[101]])
teeth = reduce([0..100], start, leftInvolute)
teeth = reduce([0..100], initial = start, f = leftInvolute)
|> arc(angleStart = 0, angleEnd = toothAngle, radius = baseDiameter / 2)
|> reduce([1..101], %, rightInvolute)
|> reduce([1..101], initial = %, f = rightInvolute)
|> close()
|> extrude(length = gearHeight)
|> patternCircular3d(

View File

@ -1,3 +1,3 @@
arr = [1, 2, 3]
pushedArr = push(arr, 4)
pushedArr = push(arr, item = 4)
fail = arr[3]

View File

@ -760,25 +760,6 @@ pub trait FromKclValue<'a>: Sized {
fn from_kcl_val(arg: &'a KclValue) -> Option<Self>;
}
impl<'a> FromArgs<'a> for Vec<KclValue> {
fn from_args(args: &'a Args, i: usize) -> Result<Self, KclError> {
let Some(arg) = args.args.get(i) else {
return Err(KclError::Semantic(KclErrorDetails {
message: format!("Expected an argument at index {i}"),
source_ranges: vec![args.source_range],
}));
};
let KclValue::MixedArray { value: array, meta: _ } = &arg.value else {
let message = format!("Expected an array but found {}", arg.value.human_friendly_type());
return Err(KclError::Type(KclErrorDetails {
source_ranges: arg.source_ranges(),
message,
}));
};
Ok(array.to_owned())
}
}
impl<'a, T> FromArgs<'a> for T
where
T: FromKclValue<'a> + Sized,
@ -896,6 +877,12 @@ impl<'a> FromKclValue<'a> for Vec<TagIdentifier> {
}
}
impl<'a> FromKclValue<'a> for Vec<KclValue> {
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
arg.as_array().map(|v| v.to_vec())
}
}
impl<'a> FromKclValue<'a> for KclValue {
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
Some(arg.clone())

View File

@ -1,9 +1,6 @@
use kcl_derive_docs::stdlib;
use super::{
args::{Arg, FromArgs},
Args,
};
use super::{args::Arg, Args};
use crate::{
errors::{KclError, KclErrorDetails},
execution::{
@ -16,7 +13,8 @@ use crate::{
/// Apply a function to each element of an array.
pub async fn map(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let (array, f): (Vec<KclValue>, &FunctionSource) = FromArgs::from_args(&args, 0)?;
let array: Vec<KclValue> = args.get_unlabeled_kw_arg("array")?;
let f: &FunctionSource = args.get_kw_arg("f")?;
let meta = vec![args.source_range.into()];
let new_array = inner_map(array, f, exec_state, &args).await?;
Ok(KclValue::MixedArray { value: new_array, meta })
@ -38,7 +36,7 @@ pub async fn map(exec_state: &mut ExecState, args: Args) -> Result<KclValue, Kcl
/// // which is the return value from `map`.
/// circles = map(
/// [1..3],
/// drawCircle
/// f = drawCircle
/// )
/// ```
/// ```no_run
@ -46,7 +44,7 @@ pub async fn map(exec_state: &mut ExecState, args: Args) -> Result<KclValue, Kcl
/// // Call `map`, using an anonymous function instead of a named one.
/// circles = map(
/// [1..3],
/// fn(id) {
/// f = fn(id) {
/// return startSketchOn("XY")
/// |> circle( center= [id * 2 * r, 0], radius= r)
/// }
@ -54,16 +52,22 @@ pub async fn map(exec_state: &mut ExecState, args: Args) -> Result<KclValue, Kcl
/// ```
#[stdlib {
name = "map",
keywords = true,
unlabeled_first = true,
args = {
array = { docs = "Input array. The output array is this input array, but every element has had the function `f` run on it." },
f = { docs = "A function. The output array is just the input array, but `f` has been run on every item." },
}
}]
async fn inner_map<'a>(
array: Vec<KclValue>,
map_fn: &'a FunctionSource,
f: &'a FunctionSource,
exec_state: &mut ExecState,
args: &'a Args,
) -> Result<Vec<KclValue>, KclError> {
let mut new_array = Vec::with_capacity(array.len());
for elem in array {
let new_elem = call_map_closure(elem, map_fn, args.source_range, exec_state, &args.ctx).await?;
let new_elem = call_map_closure(elem, f, args.source_range, exec_state, &args.ctx).await?;
new_array.push(new_elem);
}
Ok(new_array)
@ -91,8 +95,10 @@ async fn call_map_closure(
/// For each item in an array, update a value.
pub async fn reduce(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let (array, start, f): (Vec<KclValue>, KclValue, &FunctionSource) = FromArgs::from_args(&args, 0)?;
inner_reduce(array, start, f, exec_state, &args).await
let array: Vec<KclValue> = args.get_unlabeled_kw_arg("array")?;
let f: &FunctionSource = args.get_kw_arg("f")?;
let initial: KclValue = args.get_kw_arg("initial")?;
inner_reduce(array, initial, f, exec_state, &args).await
}
/// Take a starting value. Then, for each element of an array, calculate the next value,
@ -104,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, 0, add) }
/// fn sum(arr) { return reduce(arr, initial = 0, f = add) }
///
/// /*
/// The above is basically like this pseudo-code:
@ -124,7 +130,7 @@ pub async fn reduce(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
/// // an anonymous `add` function as its parameter, instead of declaring a
/// // named function outside.
/// arr = [1, 2, 3]
/// sum = reduce(arr, 0, (i, result_so_far) => { return i + result_so_far })
/// sum = reduce(arr, initial = 0, f = fn (i, result_so_far) { return i + result_so_far })
///
/// // We use `assert` to check that our `sum` function gives the
/// // expected result. It's good to check your work!
@ -143,7 +149,7 @@ pub async fn reduce(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
/// // Use a `reduce` to draw the remaining decagon sides.
/// // For each number in the array 1..10, run the given function,
/// // which takes a partially-sketched decagon and adds one more edge to it.
/// fullDecagon = reduce([1..10], startOfDecagonSketch, fn(i, partialDecagon) {
/// fullDecagon = reduce([1..10], initial = startOfDecagonSketch, f = fn(i, partialDecagon) {
/// // Draw one edge of the decagon.
/// x = cos(stepAngle * i) * radius
/// y = sin(stepAngle * i) * radius
@ -176,17 +182,24 @@ pub async fn reduce(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
/// ```
#[stdlib {
name = "reduce",
keywords = true,
unlabeled_first = true,
args = {
array = { docs = "Each element of this array gets run through the function `f`, combined with the previous output from `f`, and then used for the next run." },
initial = { docs = "The first time `f` is run, it will be called with the first item of `array` and this initial starting value."},
f = { docs = "Run once per item in the input `array`. This function takes an item from the array, and the previous output from `f` (or `initial` on the very first run). The final time `f` is run, its output is returned as the final output from `reduce`." },
}
}]
async fn inner_reduce<'a>(
array: Vec<KclValue>,
start: KclValue,
reduce_fn: &'a FunctionSource,
initial: KclValue,
f: &'a FunctionSource,
exec_state: &mut ExecState,
args: &'a Args,
) -> Result<KclValue, KclError> {
let mut reduced = start;
let mut reduced = initial;
for elem in array {
reduced = call_reduce_closure(elem, reduced, reduce_fn, args.source_range, exec_state, &args.ctx).await?;
reduced = call_reduce_closure(elem, reduced, f, args.source_range, exec_state, &args.ctx).await?;
}
Ok(reduced)
@ -223,15 +236,20 @@ async fn call_reduce_closure(
///
/// ```no_run
/// arr = [1, 2, 3]
/// new_arr = push(arr, 4)
/// new_arr = push(arr, item = 4)
/// assert(new_arr[3], isEqualTo = 4, tolerance = 0.1, error = "4 was added to the end of the array")
/// ```
#[stdlib {
name = "push",
keywords = true,
unlabeled_first = true,
args = {
array = { docs = "The array which you're adding a new item to." },
item = { docs = "The new item to add to the array" },
}
}]
async fn inner_push(mut array: Vec<KclValue>, elem: KclValue, args: &Args) -> Result<KclValue, KclError> {
// Unwrap the KclValues to JValues for manipulation
array.push(elem);
async fn inner_push(mut array: Vec<KclValue>, item: KclValue, args: &Args) -> Result<KclValue, KclError> {
array.push(item);
Ok(KclValue::MixedArray {
value: array,
meta: vec![args.source_range.into()],
@ -240,7 +258,8 @@ async fn inner_push(mut array: Vec<KclValue>, elem: KclValue, args: &Args) -> Re
pub async fn push(_exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
// Extract the array and the element from the arguments
let (val, elem): (KclValue, KclValue) = FromArgs::from_args(&args, 0)?;
let val: KclValue = args.get_unlabeled_kw_arg("array")?;
let item = args.get_kw_arg("item")?;
let meta = vec![args.source_range];
let KclValue::MixedArray { value: array, meta: _ } = val else {
@ -250,7 +269,7 @@ pub async fn push(_exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
message: format!("You can't push to a value of type {actual_type}, only an array"),
}));
};
inner_push(array, elem, &args).await
inner_push(array, item, &args).await
}
/// Remove the last element from an array.

View File

@ -2,9 +2,10 @@
source: kcl-lib/src/simulation_tests.rs
description: Error from executing argument_error.kcl
---
KCL Type error
KCL Semantic error
× type: Expected an array but found Function
× semantic: This function expected the input argument to be of type
│ Vec<KclValue> but it's actually of type Function
╭─[5:5]
4 │
5 │ map(f, [0, 1])

View File

@ -86,22 +86,15 @@ description: Result of parsing array_elem_push.kcl
"init": {
"arguments": [
{
"abs_path": false,
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "arr",
"name": "item",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
{
"arg": {
"commentStart": 0,
"end": 0,
"raw": "4",
@ -113,6 +106,7 @@ description: Result of parsing array_elem_push.kcl
"suffix": "None"
}
}
}
],
"callee": {
"abs_path": false,
@ -132,8 +126,24 @@ description: Result of parsing array_elem_push.kcl
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "arr",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
}
},
"start": 0,
"type": "VariableDeclarator"
@ -159,22 +169,15 @@ description: Result of parsing array_elem_push.kcl
"init": {
"arguments": [
{
"abs_path": false,
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "new_arr1",
"name": "item",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
{
"arg": {
"commentStart": 0,
"end": 0,
"raw": "5",
@ -186,6 +189,7 @@ description: Result of parsing array_elem_push.kcl
"suffix": "None"
}
}
}
],
"callee": {
"abs_path": false,
@ -205,8 +209,24 @@ description: Result of parsing array_elem_push.kcl
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "new_arr1",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
}
},
"start": 0,
"type": "VariableDeclarator"

View File

@ -1,6 +1,6 @@
arr = [1, 2, 3]
new_arr1 = push(arr, 4)
new_arr2 = push(new_arr1, 5)
new_arr1 = push(arr, item = 4)
new_arr2 = push(new_arr1, item = 5)
assert(new_arr1[0], isEqualTo = 1, error = "element 0 should not have changed")
assert(new_arr1[1], isEqualTo = 2, error = "element 1 should not have changed")
assert(new_arr1[2], isEqualTo = 3, error = "element 2 should not have changed")

View File

@ -3,8 +3,8 @@ source: kcl-lib/src/simulation_tests.rs
description: Result of unparsing array_elem_push.kcl
---
arr = [1, 2, 3]
new_arr1 = push(arr, 4)
new_arr2 = push(new_arr1, 5)
new_arr1 = push(arr, item = 4)
new_arr2 = push(new_arr1, item = 5)
assert(new_arr1[0], isEqualTo = 1, error = "element 0 should not have changed")
assert(new_arr1[1], isEqualTo = 2, error = "element 1 should not have changed")
assert(new_arr1[2], isEqualTo = 3, error = "element 2 should not have changed")

View File

@ -86,22 +86,15 @@ description: Result of parsing array_elem_push_fail.kcl
"init": {
"arguments": [
{
"abs_path": false,
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "arr",
"name": "item",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
{
"arg": {
"commentStart": 0,
"end": 0,
"raw": "4",
@ -113,6 +106,7 @@ description: Result of parsing array_elem_push_fail.kcl
"suffix": "None"
}
}
}
],
"callee": {
"abs_path": false,
@ -132,8 +126,24 @@ description: Result of parsing array_elem_push_fail.kcl
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "arr",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
}
},
"start": 0,
"type": "VariableDeclarator"

View File

@ -6,7 +6,7 @@ KCL UndefinedValue error
× undefined value: The array doesn't have any item at index 3
╭─[3:8]
2 │ pushedArr = push(arr, 4)
2 │ pushedArr = push(arr, item = 4)
3 │ fail = arr[3]
· ───┬──
· ╰── tests/array_elem_push_fail/input.kcl

View File

@ -1,3 +1,3 @@
arr = [1, 2, 3]
pushedArr = push(arr, 4)
pushedArr = push(arr, item = 4)
fail = arr[3]

View File

@ -3,5 +3,5 @@ source: kcl-lib/src/simulation_tests.rs
description: Result of unparsing array_elem_push_fail.kcl
---
arr = [1, 2, 3]
pushedArr = push(arr, 4)
pushedArr = push(arr, item = 4)
fail = arr[3]

View File

@ -181,13 +181,15 @@ description: Result of parsing double_map_fn.kcl
{
"arguments": [
{
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": "f",
"start": 0,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
"type": "Identifier"
},
{
"arg": {
"abs_path": false,
"commentStart": 0,
"end": 0,
@ -203,6 +205,7 @@ description: Result of parsing double_map_fn.kcl
"type": "Name",
"type": "Name"
}
}
],
"callee": {
"abs_path": false,
@ -222,19 +225,22 @@ description: Result of parsing double_map_fn.kcl
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": null
},
{
"arguments": [
{
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": "f",
"start": 0,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
"type": "Identifier"
},
{
"arg": {
"abs_path": false,
"commentStart": 0,
"end": 0,
@ -250,6 +256,7 @@ description: Result of parsing double_map_fn.kcl
"type": "Name",
"type": "Name"
}
}
],
"callee": {
"abs_path": false,
@ -269,8 +276,9 @@ description: Result of parsing double_map_fn.kcl
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": null
}
],
"commentStart": 0,

View File

@ -4,5 +4,5 @@ fn increment(i) {
xs = [0..2]
ys = xs
|> map(%, increment)
|> map(%, increment)
|> map(f = increment)
|> map(f = increment)

View File

@ -8,5 +8,5 @@ fn increment(i) {
xs = [0..2]
ys = xs
|> map(%, increment)
|> map(%, increment)
|> map(f = increment)
|> map(f = increment)

View File

@ -1,239 +1,239 @@
```mermaid
flowchart LR
subgraph path3 [Path]
3["Path<br>[1061, 1111, 0]"]
4["Segment<br>[1061, 1111, 0]"]
3["Path<br>[1081, 1131, 0]"]
4["Segment<br>[1081, 1131, 0]"]
5[Solid2d]
end
subgraph path13 [Path]
13["Path<br>[1588, 1625, 0]"]
14["Segment<br>[1276, 1314, 0]"]
15["Segment<br>[1276, 1314, 0]"]
16["Segment<br>[1276, 1314, 0]"]
17["Segment<br>[1276, 1314, 0]"]
18["Segment<br>[1276, 1314, 0]"]
19["Segment<br>[1276, 1314, 0]"]
20["Segment<br>[1276, 1314, 0]"]
21["Segment<br>[1276, 1314, 0]"]
22["Segment<br>[1276, 1314, 0]"]
23["Segment<br>[1276, 1314, 0]"]
24["Segment<br>[1276, 1314, 0]"]
25["Segment<br>[1276, 1314, 0]"]
26["Segment<br>[1276, 1314, 0]"]
27["Segment<br>[1276, 1314, 0]"]
28["Segment<br>[1276, 1314, 0]"]
29["Segment<br>[1276, 1314, 0]"]
30["Segment<br>[1276, 1314, 0]"]
31["Segment<br>[1276, 1314, 0]"]
32["Segment<br>[1276, 1314, 0]"]
33["Segment<br>[1276, 1314, 0]"]
34["Segment<br>[1276, 1314, 0]"]
35["Segment<br>[1276, 1314, 0]"]
36["Segment<br>[1276, 1314, 0]"]
37["Segment<br>[1276, 1314, 0]"]
38["Segment<br>[1276, 1314, 0]"]
39["Segment<br>[1276, 1314, 0]"]
40["Segment<br>[1276, 1314, 0]"]
41["Segment<br>[1276, 1314, 0]"]
42["Segment<br>[1276, 1314, 0]"]
43["Segment<br>[1276, 1314, 0]"]
44["Segment<br>[1276, 1314, 0]"]
45["Segment<br>[1276, 1314, 0]"]
46["Segment<br>[1276, 1314, 0]"]
47["Segment<br>[1276, 1314, 0]"]
48["Segment<br>[1276, 1314, 0]"]
49["Segment<br>[1276, 1314, 0]"]
50["Segment<br>[1276, 1314, 0]"]
51["Segment<br>[1276, 1314, 0]"]
52["Segment<br>[1276, 1314, 0]"]
53["Segment<br>[1276, 1314, 0]"]
54["Segment<br>[1276, 1314, 0]"]
55["Segment<br>[1276, 1314, 0]"]
56["Segment<br>[1276, 1314, 0]"]
57["Segment<br>[1276, 1314, 0]"]
58["Segment<br>[1276, 1314, 0]"]
59["Segment<br>[1276, 1314, 0]"]
60["Segment<br>[1276, 1314, 0]"]
61["Segment<br>[1276, 1314, 0]"]
62["Segment<br>[1276, 1314, 0]"]
63["Segment<br>[1276, 1314, 0]"]
64["Segment<br>[1276, 1314, 0]"]
65["Segment<br>[1276, 1314, 0]"]
66["Segment<br>[1276, 1314, 0]"]
67["Segment<br>[1276, 1314, 0]"]
68["Segment<br>[1276, 1314, 0]"]
69["Segment<br>[1276, 1314, 0]"]
70["Segment<br>[1276, 1314, 0]"]
71["Segment<br>[1276, 1314, 0]"]
72["Segment<br>[1276, 1314, 0]"]
73["Segment<br>[1276, 1314, 0]"]
74["Segment<br>[1276, 1314, 0]"]
75["Segment<br>[1276, 1314, 0]"]
76["Segment<br>[1276, 1314, 0]"]
77["Segment<br>[1276, 1314, 0]"]
78["Segment<br>[1276, 1314, 0]"]
79["Segment<br>[1276, 1314, 0]"]
80["Segment<br>[1276, 1314, 0]"]
81["Segment<br>[1276, 1314, 0]"]
82["Segment<br>[1276, 1314, 0]"]
83["Segment<br>[1276, 1314, 0]"]
84["Segment<br>[1276, 1314, 0]"]
85["Segment<br>[1276, 1314, 0]"]
86["Segment<br>[1276, 1314, 0]"]
87["Segment<br>[1276, 1314, 0]"]
88["Segment<br>[1276, 1314, 0]"]
89["Segment<br>[1276, 1314, 0]"]
90["Segment<br>[1276, 1314, 0]"]
91["Segment<br>[1276, 1314, 0]"]
92["Segment<br>[1276, 1314, 0]"]
93["Segment<br>[1276, 1314, 0]"]
94["Segment<br>[1276, 1314, 0]"]
95["Segment<br>[1276, 1314, 0]"]
96["Segment<br>[1276, 1314, 0]"]
97["Segment<br>[1276, 1314, 0]"]
98["Segment<br>[1276, 1314, 0]"]
99["Segment<br>[1276, 1314, 0]"]
100["Segment<br>[1276, 1314, 0]"]
101["Segment<br>[1276, 1314, 0]"]
102["Segment<br>[1276, 1314, 0]"]
103["Segment<br>[1276, 1314, 0]"]
104["Segment<br>[1276, 1314, 0]"]
105["Segment<br>[1276, 1314, 0]"]
106["Segment<br>[1276, 1314, 0]"]
107["Segment<br>[1276, 1314, 0]"]
108["Segment<br>[1276, 1314, 0]"]
109["Segment<br>[1276, 1314, 0]"]
110["Segment<br>[1276, 1314, 0]"]
111["Segment<br>[1276, 1314, 0]"]
112["Segment<br>[1276, 1314, 0]"]
113["Segment<br>[1276, 1314, 0]"]
114["Segment<br>[1276, 1314, 0]"]
115["Segment<br>[1677, 1775, 0]"]
116["Segment<br>[1504, 1534, 0]"]
117["Segment<br>[1504, 1534, 0]"]
118["Segment<br>[1504, 1534, 0]"]
119["Segment<br>[1504, 1534, 0]"]
120["Segment<br>[1504, 1534, 0]"]
121["Segment<br>[1504, 1534, 0]"]
122["Segment<br>[1504, 1534, 0]"]
123["Segment<br>[1504, 1534, 0]"]
124["Segment<br>[1504, 1534, 0]"]
125["Segment<br>[1504, 1534, 0]"]
126["Segment<br>[1504, 1534, 0]"]
127["Segment<br>[1504, 1534, 0]"]
128["Segment<br>[1504, 1534, 0]"]
129["Segment<br>[1504, 1534, 0]"]
130["Segment<br>[1504, 1534, 0]"]
131["Segment<br>[1504, 1534, 0]"]
132["Segment<br>[1504, 1534, 0]"]
133["Segment<br>[1504, 1534, 0]"]
134["Segment<br>[1504, 1534, 0]"]
135["Segment<br>[1504, 1534, 0]"]
136["Segment<br>[1504, 1534, 0]"]
137["Segment<br>[1504, 1534, 0]"]
138["Segment<br>[1504, 1534, 0]"]
139["Segment<br>[1504, 1534, 0]"]
140["Segment<br>[1504, 1534, 0]"]
141["Segment<br>[1504, 1534, 0]"]
142["Segment<br>[1504, 1534, 0]"]
143["Segment<br>[1504, 1534, 0]"]
144["Segment<br>[1504, 1534, 0]"]
145["Segment<br>[1504, 1534, 0]"]
146["Segment<br>[1504, 1534, 0]"]
147["Segment<br>[1504, 1534, 0]"]
148["Segment<br>[1504, 1534, 0]"]
149["Segment<br>[1504, 1534, 0]"]
150["Segment<br>[1504, 1534, 0]"]
151["Segment<br>[1504, 1534, 0]"]
152["Segment<br>[1504, 1534, 0]"]
153["Segment<br>[1504, 1534, 0]"]
154["Segment<br>[1504, 1534, 0]"]
155["Segment<br>[1504, 1534, 0]"]
156["Segment<br>[1504, 1534, 0]"]
157["Segment<br>[1504, 1534, 0]"]
158["Segment<br>[1504, 1534, 0]"]
159["Segment<br>[1504, 1534, 0]"]
160["Segment<br>[1504, 1534, 0]"]
161["Segment<br>[1504, 1534, 0]"]
162["Segment<br>[1504, 1534, 0]"]
163["Segment<br>[1504, 1534, 0]"]
164["Segment<br>[1504, 1534, 0]"]
165["Segment<br>[1504, 1534, 0]"]
166["Segment<br>[1504, 1534, 0]"]
167["Segment<br>[1504, 1534, 0]"]
168["Segment<br>[1504, 1534, 0]"]
169["Segment<br>[1504, 1534, 0]"]
170["Segment<br>[1504, 1534, 0]"]
171["Segment<br>[1504, 1534, 0]"]
172["Segment<br>[1504, 1534, 0]"]
173["Segment<br>[1504, 1534, 0]"]
174["Segment<br>[1504, 1534, 0]"]
175["Segment<br>[1504, 1534, 0]"]
176["Segment<br>[1504, 1534, 0]"]
177["Segment<br>[1504, 1534, 0]"]
178["Segment<br>[1504, 1534, 0]"]
179["Segment<br>[1504, 1534, 0]"]
180["Segment<br>[1504, 1534, 0]"]
181["Segment<br>[1504, 1534, 0]"]
182["Segment<br>[1504, 1534, 0]"]
183["Segment<br>[1504, 1534, 0]"]
184["Segment<br>[1504, 1534, 0]"]
185["Segment<br>[1504, 1534, 0]"]
186["Segment<br>[1504, 1534, 0]"]
187["Segment<br>[1504, 1534, 0]"]
188["Segment<br>[1504, 1534, 0]"]
189["Segment<br>[1504, 1534, 0]"]
190["Segment<br>[1504, 1534, 0]"]
191["Segment<br>[1504, 1534, 0]"]
192["Segment<br>[1504, 1534, 0]"]
193["Segment<br>[1504, 1534, 0]"]
194["Segment<br>[1504, 1534, 0]"]
195["Segment<br>[1504, 1534, 0]"]
196["Segment<br>[1504, 1534, 0]"]
197["Segment<br>[1504, 1534, 0]"]
198["Segment<br>[1504, 1534, 0]"]
199["Segment<br>[1504, 1534, 0]"]
200["Segment<br>[1504, 1534, 0]"]
201["Segment<br>[1504, 1534, 0]"]
202["Segment<br>[1504, 1534, 0]"]
203["Segment<br>[1504, 1534, 0]"]
204["Segment<br>[1504, 1534, 0]"]
205["Segment<br>[1504, 1534, 0]"]
206["Segment<br>[1504, 1534, 0]"]
207["Segment<br>[1504, 1534, 0]"]
208["Segment<br>[1504, 1534, 0]"]
209["Segment<br>[1504, 1534, 0]"]
210["Segment<br>[1504, 1534, 0]"]
211["Segment<br>[1504, 1534, 0]"]
212["Segment<br>[1504, 1534, 0]"]
213["Segment<br>[1504, 1534, 0]"]
214["Segment<br>[1504, 1534, 0]"]
215["Segment<br>[1504, 1534, 0]"]
216["Segment<br>[1504, 1534, 0]"]
217["Segment<br>[1821, 1828, 0]"]
13["Path<br>[1608, 1645, 0]"]
14["Segment<br>[1296, 1334, 0]"]
15["Segment<br>[1296, 1334, 0]"]
16["Segment<br>[1296, 1334, 0]"]
17["Segment<br>[1296, 1334, 0]"]
18["Segment<br>[1296, 1334, 0]"]
19["Segment<br>[1296, 1334, 0]"]
20["Segment<br>[1296, 1334, 0]"]
21["Segment<br>[1296, 1334, 0]"]
22["Segment<br>[1296, 1334, 0]"]
23["Segment<br>[1296, 1334, 0]"]
24["Segment<br>[1296, 1334, 0]"]
25["Segment<br>[1296, 1334, 0]"]
26["Segment<br>[1296, 1334, 0]"]
27["Segment<br>[1296, 1334, 0]"]
28["Segment<br>[1296, 1334, 0]"]
29["Segment<br>[1296, 1334, 0]"]
30["Segment<br>[1296, 1334, 0]"]
31["Segment<br>[1296, 1334, 0]"]
32["Segment<br>[1296, 1334, 0]"]
33["Segment<br>[1296, 1334, 0]"]
34["Segment<br>[1296, 1334, 0]"]
35["Segment<br>[1296, 1334, 0]"]
36["Segment<br>[1296, 1334, 0]"]
37["Segment<br>[1296, 1334, 0]"]
38["Segment<br>[1296, 1334, 0]"]
39["Segment<br>[1296, 1334, 0]"]
40["Segment<br>[1296, 1334, 0]"]
41["Segment<br>[1296, 1334, 0]"]
42["Segment<br>[1296, 1334, 0]"]
43["Segment<br>[1296, 1334, 0]"]
44["Segment<br>[1296, 1334, 0]"]
45["Segment<br>[1296, 1334, 0]"]
46["Segment<br>[1296, 1334, 0]"]
47["Segment<br>[1296, 1334, 0]"]
48["Segment<br>[1296, 1334, 0]"]
49["Segment<br>[1296, 1334, 0]"]
50["Segment<br>[1296, 1334, 0]"]
51["Segment<br>[1296, 1334, 0]"]
52["Segment<br>[1296, 1334, 0]"]
53["Segment<br>[1296, 1334, 0]"]
54["Segment<br>[1296, 1334, 0]"]
55["Segment<br>[1296, 1334, 0]"]
56["Segment<br>[1296, 1334, 0]"]
57["Segment<br>[1296, 1334, 0]"]
58["Segment<br>[1296, 1334, 0]"]
59["Segment<br>[1296, 1334, 0]"]
60["Segment<br>[1296, 1334, 0]"]
61["Segment<br>[1296, 1334, 0]"]
62["Segment<br>[1296, 1334, 0]"]
63["Segment<br>[1296, 1334, 0]"]
64["Segment<br>[1296, 1334, 0]"]
65["Segment<br>[1296, 1334, 0]"]
66["Segment<br>[1296, 1334, 0]"]
67["Segment<br>[1296, 1334, 0]"]
68["Segment<br>[1296, 1334, 0]"]
69["Segment<br>[1296, 1334, 0]"]
70["Segment<br>[1296, 1334, 0]"]
71["Segment<br>[1296, 1334, 0]"]
72["Segment<br>[1296, 1334, 0]"]
73["Segment<br>[1296, 1334, 0]"]
74["Segment<br>[1296, 1334, 0]"]
75["Segment<br>[1296, 1334, 0]"]
76["Segment<br>[1296, 1334, 0]"]
77["Segment<br>[1296, 1334, 0]"]
78["Segment<br>[1296, 1334, 0]"]
79["Segment<br>[1296, 1334, 0]"]
80["Segment<br>[1296, 1334, 0]"]
81["Segment<br>[1296, 1334, 0]"]
82["Segment<br>[1296, 1334, 0]"]
83["Segment<br>[1296, 1334, 0]"]
84["Segment<br>[1296, 1334, 0]"]
85["Segment<br>[1296, 1334, 0]"]
86["Segment<br>[1296, 1334, 0]"]
87["Segment<br>[1296, 1334, 0]"]
88["Segment<br>[1296, 1334, 0]"]
89["Segment<br>[1296, 1334, 0]"]
90["Segment<br>[1296, 1334, 0]"]
91["Segment<br>[1296, 1334, 0]"]
92["Segment<br>[1296, 1334, 0]"]
93["Segment<br>[1296, 1334, 0]"]
94["Segment<br>[1296, 1334, 0]"]
95["Segment<br>[1296, 1334, 0]"]
96["Segment<br>[1296, 1334, 0]"]
97["Segment<br>[1296, 1334, 0]"]
98["Segment<br>[1296, 1334, 0]"]
99["Segment<br>[1296, 1334, 0]"]
100["Segment<br>[1296, 1334, 0]"]
101["Segment<br>[1296, 1334, 0]"]
102["Segment<br>[1296, 1334, 0]"]
103["Segment<br>[1296, 1334, 0]"]
104["Segment<br>[1296, 1334, 0]"]
105["Segment<br>[1296, 1334, 0]"]
106["Segment<br>[1296, 1334, 0]"]
107["Segment<br>[1296, 1334, 0]"]
108["Segment<br>[1296, 1334, 0]"]
109["Segment<br>[1296, 1334, 0]"]
110["Segment<br>[1296, 1334, 0]"]
111["Segment<br>[1296, 1334, 0]"]
112["Segment<br>[1296, 1334, 0]"]
113["Segment<br>[1296, 1334, 0]"]
114["Segment<br>[1296, 1334, 0]"]
115["Segment<br>[1711, 1809, 0]"]
116["Segment<br>[1524, 1554, 0]"]
117["Segment<br>[1524, 1554, 0]"]
118["Segment<br>[1524, 1554, 0]"]
119["Segment<br>[1524, 1554, 0]"]
120["Segment<br>[1524, 1554, 0]"]
121["Segment<br>[1524, 1554, 0]"]
122["Segment<br>[1524, 1554, 0]"]
123["Segment<br>[1524, 1554, 0]"]
124["Segment<br>[1524, 1554, 0]"]
125["Segment<br>[1524, 1554, 0]"]
126["Segment<br>[1524, 1554, 0]"]
127["Segment<br>[1524, 1554, 0]"]
128["Segment<br>[1524, 1554, 0]"]
129["Segment<br>[1524, 1554, 0]"]
130["Segment<br>[1524, 1554, 0]"]
131["Segment<br>[1524, 1554, 0]"]
132["Segment<br>[1524, 1554, 0]"]
133["Segment<br>[1524, 1554, 0]"]
134["Segment<br>[1524, 1554, 0]"]
135["Segment<br>[1524, 1554, 0]"]
136["Segment<br>[1524, 1554, 0]"]
137["Segment<br>[1524, 1554, 0]"]
138["Segment<br>[1524, 1554, 0]"]
139["Segment<br>[1524, 1554, 0]"]
140["Segment<br>[1524, 1554, 0]"]
141["Segment<br>[1524, 1554, 0]"]
142["Segment<br>[1524, 1554, 0]"]
143["Segment<br>[1524, 1554, 0]"]
144["Segment<br>[1524, 1554, 0]"]
145["Segment<br>[1524, 1554, 0]"]
146["Segment<br>[1524, 1554, 0]"]
147["Segment<br>[1524, 1554, 0]"]
148["Segment<br>[1524, 1554, 0]"]
149["Segment<br>[1524, 1554, 0]"]
150["Segment<br>[1524, 1554, 0]"]
151["Segment<br>[1524, 1554, 0]"]
152["Segment<br>[1524, 1554, 0]"]
153["Segment<br>[1524, 1554, 0]"]
154["Segment<br>[1524, 1554, 0]"]
155["Segment<br>[1524, 1554, 0]"]
156["Segment<br>[1524, 1554, 0]"]
157["Segment<br>[1524, 1554, 0]"]
158["Segment<br>[1524, 1554, 0]"]
159["Segment<br>[1524, 1554, 0]"]
160["Segment<br>[1524, 1554, 0]"]
161["Segment<br>[1524, 1554, 0]"]
162["Segment<br>[1524, 1554, 0]"]
163["Segment<br>[1524, 1554, 0]"]
164["Segment<br>[1524, 1554, 0]"]
165["Segment<br>[1524, 1554, 0]"]
166["Segment<br>[1524, 1554, 0]"]
167["Segment<br>[1524, 1554, 0]"]
168["Segment<br>[1524, 1554, 0]"]
169["Segment<br>[1524, 1554, 0]"]
170["Segment<br>[1524, 1554, 0]"]
171["Segment<br>[1524, 1554, 0]"]
172["Segment<br>[1524, 1554, 0]"]
173["Segment<br>[1524, 1554, 0]"]
174["Segment<br>[1524, 1554, 0]"]
175["Segment<br>[1524, 1554, 0]"]
176["Segment<br>[1524, 1554, 0]"]
177["Segment<br>[1524, 1554, 0]"]
178["Segment<br>[1524, 1554, 0]"]
179["Segment<br>[1524, 1554, 0]"]
180["Segment<br>[1524, 1554, 0]"]
181["Segment<br>[1524, 1554, 0]"]
182["Segment<br>[1524, 1554, 0]"]
183["Segment<br>[1524, 1554, 0]"]
184["Segment<br>[1524, 1554, 0]"]
185["Segment<br>[1524, 1554, 0]"]
186["Segment<br>[1524, 1554, 0]"]
187["Segment<br>[1524, 1554, 0]"]
188["Segment<br>[1524, 1554, 0]"]
189["Segment<br>[1524, 1554, 0]"]
190["Segment<br>[1524, 1554, 0]"]
191["Segment<br>[1524, 1554, 0]"]
192["Segment<br>[1524, 1554, 0]"]
193["Segment<br>[1524, 1554, 0]"]
194["Segment<br>[1524, 1554, 0]"]
195["Segment<br>[1524, 1554, 0]"]
196["Segment<br>[1524, 1554, 0]"]
197["Segment<br>[1524, 1554, 0]"]
198["Segment<br>[1524, 1554, 0]"]
199["Segment<br>[1524, 1554, 0]"]
200["Segment<br>[1524, 1554, 0]"]
201["Segment<br>[1524, 1554, 0]"]
202["Segment<br>[1524, 1554, 0]"]
203["Segment<br>[1524, 1554, 0]"]
204["Segment<br>[1524, 1554, 0]"]
205["Segment<br>[1524, 1554, 0]"]
206["Segment<br>[1524, 1554, 0]"]
207["Segment<br>[1524, 1554, 0]"]
208["Segment<br>[1524, 1554, 0]"]
209["Segment<br>[1524, 1554, 0]"]
210["Segment<br>[1524, 1554, 0]"]
211["Segment<br>[1524, 1554, 0]"]
212["Segment<br>[1524, 1554, 0]"]
213["Segment<br>[1524, 1554, 0]"]
214["Segment<br>[1524, 1554, 0]"]
215["Segment<br>[1524, 1554, 0]"]
216["Segment<br>[1524, 1554, 0]"]
217["Segment<br>[1869, 1876, 0]"]
218[Solid2d]
end
subgraph path220 [Path]
220["Path<br>[2309, 2388, 0]"]
221["Segment<br>[2394, 2421, 0]"]
222["Segment<br>[2427, 2455, 0]"]
223["Segment<br>[2461, 2489, 0]"]
224["Segment<br>[2495, 2611, 0]"]
225["Segment<br>[2617, 2722, 0]"]
226["Segment<br>[2728, 2735, 0]"]
220["Path<br>[2357, 2436, 0]"]
221["Segment<br>[2442, 2469, 0]"]
222["Segment<br>[2475, 2503, 0]"]
223["Segment<br>[2509, 2537, 0]"]
224["Segment<br>[2543, 2659, 0]"]
225["Segment<br>[2665, 2770, 0]"]
226["Segment<br>[2776, 2783, 0]"]
227[Solid2d]
end
1["Plane<br>[168, 185, 0]"]
2["Plane<br>[1038, 1055, 0]"]
6["Sweep Extrusion<br>[1117, 1145, 0]"]
2["Plane<br>[1058, 1075, 0]"]
6["Sweep Extrusion<br>[1137, 1165, 0]"]
7[Wall]
8["Cap Start"]
9["Cap End"]
10["SweepEdge Opposite"]
11["SweepEdge Adjacent"]
12["Plane<br>[1565, 1582, 0]"]
219["Sweep Extrusion<br>[1834, 1862, 0]"]
228["Sweep Extrusion<br>[2741, 2770, 0]"]
12["Plane<br>[1585, 1602, 0]"]
219["Sweep Extrusion<br>[1882, 1910, 0]"]
228["Sweep Extrusion<br>[2789, 2818, 0]"]
229[Wall]
230[Wall]
231[Wall]
@ -246,7 +246,7 @@ flowchart LR
238["SweepEdge Adjacent"]
239["SweepEdge Opposite"]
240["SweepEdge Adjacent"]
241["StartSketchOnFace<br>[2272, 2303, 0]"]
241["StartSketchOnFace<br>[2320, 2351, 0]"]
2 --- 3
3 --- 4
3 ---- 6

View File

@ -699,42 +699,15 @@ description: Result of parsing import_async.kcl
"init": {
"arguments": [
{
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"endElement": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "cmo",
"name": "f",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
"endInclusive": true,
"start": 0,
"startElement": {
"commentStart": 0,
"end": 0,
"raw": "0",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
},
"type": "ArrayRangeExpression",
"type": "ArrayRangeExpression"
},
{
"arg": {
"body": {
"body": [
{
@ -919,6 +892,7 @@ description: Result of parsing import_async.kcl
"type": "FunctionExpression",
"type": "FunctionExpression"
}
}
],
"callee": {
"abs_path": false,
@ -938,8 +912,44 @@ description: Result of parsing import_async.kcl
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"commentStart": 0,
"end": 0,
"endElement": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "cmo",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
"endInclusive": true,
"start": 0,
"startElement": {
"commentStart": 0,
"end": 0,
"raw": "0",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
},
"type": "ArrayRangeExpression",
"type": "ArrayRangeExpression"
}
},
"start": 0,
"type": "VariableDeclarator"
@ -965,22 +975,15 @@ description: Result of parsing import_async.kcl
"init": {
"arguments": [
{
"abs_path": false,
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "rs",
"name": "f",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
{
"arg": {
"body": {
"body": [
{
@ -1121,6 +1124,7 @@ description: Result of parsing import_async.kcl
"type": "FunctionExpression",
"type": "FunctionExpression"
}
}
],
"callee": {
"abs_path": false,
@ -1140,8 +1144,24 @@ description: Result of parsing import_async.kcl
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "rs",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
}
},
"start": 0,
"type": "VariableDeclarator"
@ -1172,22 +1192,15 @@ description: Result of parsing import_async.kcl
"init": {
"arguments": [
{
"abs_path": false,
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "angles",
"name": "f",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
{
"arg": {
"body": {
"body": [
{
@ -1332,6 +1345,7 @@ description: Result of parsing import_async.kcl
"type": "FunctionExpression",
"type": "FunctionExpression"
}
}
],
"callee": {
"abs_path": false,
@ -1351,8 +1365,24 @@ description: Result of parsing import_async.kcl
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "angles",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
}
},
"start": 0,
"type": "VariableDeclarator"
@ -1383,42 +1413,15 @@ description: Result of parsing import_async.kcl
"init": {
"arguments": [
{
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"endElement": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "cmo",
"name": "f",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
"endInclusive": true,
"start": 0,
"startElement": {
"commentStart": 0,
"end": 0,
"raw": "0",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
},
"type": "ArrayRangeExpression",
"type": "ArrayRangeExpression"
},
{
"arg": {
"body": {
"body": [
{
@ -1546,6 +1549,7 @@ description: Result of parsing import_async.kcl
"type": "FunctionExpression",
"type": "FunctionExpression"
}
}
],
"callee": {
"abs_path": false,
@ -1565,38 +1569,9 @@ description: Result of parsing import_async.kcl
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 0,
"type": "VariableDeclarator"
},
"end": 0,
"kind": "const",
"preComments": [
"",
"",
"// Map the involute curve"
],
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 0,
"declaration": {
"commentStart": 0,
"end": 0,
"id": {
"commentStart": 0,
"end": 0,
"name": "ys",
"start": 0,
"type": "Identifier"
},
"init": {
"arguments": [
{
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"commentStart": 0,
"end": 0,
"endElement": {
@ -1631,8 +1606,46 @@ description: Result of parsing import_async.kcl
},
"type": "ArrayRangeExpression",
"type": "ArrayRangeExpression"
}
},
"start": 0,
"type": "VariableDeclarator"
},
"end": 0,
"kind": "const",
"preComments": [
"",
"",
"// Map the involute curve"
],
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 0,
"declaration": {
"commentStart": 0,
"end": 0,
"id": {
"commentStart": 0,
"end": 0,
"name": "ys",
"start": 0,
"type": "Identifier"
},
"init": {
"arguments": [
{
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": "f",
"start": 0,
"type": "Identifier"
},
"arg": {
"body": {
"body": [
{
@ -1760,6 +1773,7 @@ description: Result of parsing import_async.kcl
"type": "FunctionExpression",
"type": "FunctionExpression"
}
}
],
"callee": {
"abs_path": false,
@ -1779,8 +1793,44 @@ description: Result of parsing import_async.kcl
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"commentStart": 0,
"end": 0,
"endElement": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "cmo",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
"endInclusive": true,
"start": 0,
"startElement": {
"commentStart": 0,
"end": 0,
"raw": "0",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
},
"type": "ArrayRangeExpression",
"type": "ArrayRangeExpression"
}
},
"start": 0,
"type": "VariableDeclarator"
@ -3188,6 +3238,79 @@ description: Result of parsing import_async.kcl
{
"arguments": [
{
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": "initial",
"start": 0,
"type": "Identifier"
},
"arg": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "start",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
}
},
{
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": "f",
"start": 0,
"type": "Identifier"
},
"arg": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "leftInvolute",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
}
}
],
"callee": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "reduce",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name"
},
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"commentStart": 0,
"end": 0,
"endElement": {
@ -3218,60 +3341,7 @@ description: Result of parsing import_async.kcl
},
"type": "ArrayRangeExpression",
"type": "ArrayRangeExpression"
},
{
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "start",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
{
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "leftInvolute",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
}
],
"callee": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "reduce",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name"
},
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
@ -3395,6 +3465,70 @@ description: Result of parsing import_async.kcl
{
"arguments": [
{
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": "initial",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 0,
"end": 0,
"start": 0,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
},
{
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": "f",
"start": 0,
"type": "Identifier"
},
"arg": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "rightInvolute",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
}
}
],
"callee": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "reduce",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name"
},
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"commentStart": 0,
"end": 0,
"endElement": {
@ -3425,51 +3559,7 @@ description: Result of parsing import_async.kcl
},
"type": "ArrayRangeExpression",
"type": "ArrayRangeExpression"
},
{
"commentStart": 0,
"end": 0,
"start": 0,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
},
{
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "rightInvolute",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
}
],
"callee": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "reduce",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name"
},
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [],

View File

@ -22,26 +22,26 @@ gearHeight = 3
// Interpolate points along the involute curve
cmo = 101
rs = map([0..cmo], fn(i) {
rs = map([0..cmo], f = fn(i) {
return baseDiameter / 2 + i / cmo * (tipDiameter - baseDiameter) / 2
})
// Calculate operating pressure angle
angles = map(rs, fn(r) {
angles = map(rs, f = fn(r) {
return toDegrees( acos(baseDiameter / 2 / r))
})
// Calculate the involute function
invas = map(angles, fn(a) {
invas = map(angles, f = fn(a) {
return tan(toRadians(a)) - toRadians(a)
})
// Map the involute curve
xs = map([0..cmo], fn(i) {
xs = map([0..cmo], f = fn(i) {
return rs[i] * cos(invas[i]: number(rad))
})
ys = map([0..cmo], fn(i) {
ys = map([0..cmo], f = fn(i) {
return rs[i] * sin(invas[i]: number(rad))
})
@ -67,13 +67,13 @@ fn rightInvolute(i, sg) {
// Draw gear teeth
start = startSketchOn(XY)
|> startProfile(at = [xs[101], ys[101]])
teeth = reduce([0..100], start, leftInvolute)
teeth = reduce([0..100], initial = start, f = leftInvolute)
|> arc(
angleStart = 0,
angleEnd = toothAngle,
radius = baseDiameter / 2,
)
|> reduce([1..101], %, rightInvolute)
|> reduce([1..101], initial = %, f = rightInvolute)
|> close()
|> extrude(length = gearHeight)
|> patternCircular3d(

View File

@ -25,28 +25,43 @@ gearHeight = 3
// Interpolate points along the involute curve
cmo = 101
rs = map([0..cmo], fn(i) {
rs = map(
[0..cmo],
f = fn(i) {
return baseDiameter / 2 + i / cmo * (tipDiameter - baseDiameter) / 2
})
},
)
// Calculate operating pressure angle
angles = map(rs, fn(r) {
angles = map(
rs,
f = fn(r) {
return toDegrees( acos(baseDiameter / 2 / r))
})
},
)
// Calculate the involute function
invas = map(angles, fn(a) {
invas = map(
angles,
f = fn(a) {
return tan(toRadians(a)) - toRadians(a)
})
},
)
// Map the involute curve
xs = map([0..cmo], fn(i) {
xs = map(
[0..cmo],
f = fn(i) {
return rs[i] * cos(invas[i]: number(rad))
})
},
)
ys = map([0..cmo], fn(i) {
ys = map(
[0..cmo],
f = fn(i) {
return rs[i] * sin(invas[i]: number(rad))
})
},
)
// Extrude the gear body
body = startSketchOn(XY)
@ -70,9 +85,9 @@ fn rightInvolute(i, sg) {
// Draw gear teeth
start = startSketchOn(XY)
|> startProfile(at = [xs[101], ys[101]])
teeth = reduce([0..100], start, leftInvolute)
teeth = reduce([0..100], initial = start, f = leftInvolute)
|> arc(angleStart = 0, angleEnd = toothAngle, radius = baseDiameter / 2)
|> reduce([1..101], %, rightInvolute)
|> reduce([1..101], initial = %, f = rightInvolute)
|> close()
|> extrude(length = gearHeight)
|> patternCircular3d(

View File

@ -288,7 +288,7 @@ flowchart LR
262["SweepEdge Adjacent"]
263["SweepEdge Opposite"]
264["SweepEdge Adjacent"]
265["CompositeSolid Intersect<br>[1935, 1965, 0]"]
265["CompositeSolid Intersect<br>[1997, 2027, 0]"]
1 --- 2
2 --- 3
2 --- 4

View File

@ -1999,22 +1999,15 @@ description: Result of parsing dodecahedron.kcl
"init": {
"arguments": [
{
"abs_path": false,
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "faceRotations",
"name": "f",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
{
"arg": {
"body": {
"body": [
{
@ -2266,6 +2259,7 @@ description: Result of parsing dodecahedron.kcl
"type": "FunctionExpression",
"type": "FunctionExpression"
}
}
],
"callee": {
"abs_path": false,
@ -2285,8 +2279,24 @@ description: Result of parsing dodecahedron.kcl
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "faceRotations",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
}
},
"start": 0,
"type": "VariableDeclarator"
@ -2321,22 +2331,15 @@ description: Result of parsing dodecahedron.kcl
"argument": {
"arguments": [
{
"abs_path": false,
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "arr",
"name": "initial",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
{
"arg": {
"commentStart": 0,
"end": 0,
"raw": "0",
@ -2347,8 +2350,18 @@ description: Result of parsing dodecahedron.kcl
"value": 0.0,
"suffix": "None"
}
}
},
{
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": "f",
"start": 0,
"type": "Identifier"
},
"arg": {
"body": {
"body": [
{
@ -2427,6 +2440,7 @@ description: Result of parsing dodecahedron.kcl
"type": "FunctionExpression",
"type": "FunctionExpression"
}
}
],
"callee": {
"abs_path": false,
@ -2446,8 +2460,24 @@ description: Result of parsing dodecahedron.kcl
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "arr",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
}
},
"commentStart": 0,
"end": 0,
@ -2822,22 +2852,15 @@ description: Result of parsing dodecahedron.kcl
"argument": {
"arguments": [
{
"abs_path": false,
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "remainingSolids",
"name": "initial",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
{
"arg": {
"abs_path": false,
"commentStart": 0,
"end": 0,
@ -2852,8 +2875,18 @@ description: Result of parsing dodecahedron.kcl
"start": 0,
"type": "Name",
"type": "Name"
}
},
{
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": "f",
"start": 0,
"type": "Identifier"
},
"arg": {
"abs_path": false,
"commentStart": 0,
"end": 0,
@ -2869,6 +2902,7 @@ description: Result of parsing dodecahedron.kcl
"type": "Name",
"type": "Name"
}
}
],
"callee": {
"abs_path": false,
@ -2888,8 +2922,24 @@ description: Result of parsing dodecahedron.kcl
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "remainingSolids",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
}
},
"commentStart": 0,
"end": 0,

View File

@ -789,8 +789,8 @@ description: Operations executed dodecahedron.kcl
"type": "FunctionCall",
"name": "createIntersection",
"functionSourceRange": [
1871,
2143,
1933,
2219,
0
],
"unlabeledArg": null,
@ -804,8 +804,8 @@ description: Operations executed dodecahedron.kcl
"type": "FunctionCall",
"name": "calculateArrayLength",
"functionSourceRange": [
1759,
1848,
1786,
1910,
0
],
"unlabeledArg": null,

View File

@ -1,238 +1,238 @@
```mermaid
flowchart LR
subgraph path2 [Path]
2["Path<br>[1348, 1398, 0]"]
3["Segment<br>[1348, 1398, 0]"]
2["Path<br>[1425, 1475, 0]"]
3["Segment<br>[1425, 1475, 0]"]
4[Solid2d]
end
subgraph path12 [Path]
12["Path<br>[1875, 1912, 0]"]
13["Segment<br>[1563, 1601, 0]"]
14["Segment<br>[1563, 1601, 0]"]
15["Segment<br>[1563, 1601, 0]"]
16["Segment<br>[1563, 1601, 0]"]
17["Segment<br>[1563, 1601, 0]"]
18["Segment<br>[1563, 1601, 0]"]
19["Segment<br>[1563, 1601, 0]"]
20["Segment<br>[1563, 1601, 0]"]
21["Segment<br>[1563, 1601, 0]"]
22["Segment<br>[1563, 1601, 0]"]
23["Segment<br>[1563, 1601, 0]"]
24["Segment<br>[1563, 1601, 0]"]
25["Segment<br>[1563, 1601, 0]"]
26["Segment<br>[1563, 1601, 0]"]
27["Segment<br>[1563, 1601, 0]"]
28["Segment<br>[1563, 1601, 0]"]
29["Segment<br>[1563, 1601, 0]"]
30["Segment<br>[1563, 1601, 0]"]
31["Segment<br>[1563, 1601, 0]"]
32["Segment<br>[1563, 1601, 0]"]
33["Segment<br>[1563, 1601, 0]"]
34["Segment<br>[1563, 1601, 0]"]
35["Segment<br>[1563, 1601, 0]"]
36["Segment<br>[1563, 1601, 0]"]
37["Segment<br>[1563, 1601, 0]"]
38["Segment<br>[1563, 1601, 0]"]
39["Segment<br>[1563, 1601, 0]"]
40["Segment<br>[1563, 1601, 0]"]
41["Segment<br>[1563, 1601, 0]"]
42["Segment<br>[1563, 1601, 0]"]
43["Segment<br>[1563, 1601, 0]"]
44["Segment<br>[1563, 1601, 0]"]
45["Segment<br>[1563, 1601, 0]"]
46["Segment<br>[1563, 1601, 0]"]
47["Segment<br>[1563, 1601, 0]"]
48["Segment<br>[1563, 1601, 0]"]
49["Segment<br>[1563, 1601, 0]"]
50["Segment<br>[1563, 1601, 0]"]
51["Segment<br>[1563, 1601, 0]"]
52["Segment<br>[1563, 1601, 0]"]
53["Segment<br>[1563, 1601, 0]"]
54["Segment<br>[1563, 1601, 0]"]
55["Segment<br>[1563, 1601, 0]"]
56["Segment<br>[1563, 1601, 0]"]
57["Segment<br>[1563, 1601, 0]"]
58["Segment<br>[1563, 1601, 0]"]
59["Segment<br>[1563, 1601, 0]"]
60["Segment<br>[1563, 1601, 0]"]
61["Segment<br>[1563, 1601, 0]"]
62["Segment<br>[1563, 1601, 0]"]
63["Segment<br>[1563, 1601, 0]"]
64["Segment<br>[1563, 1601, 0]"]
65["Segment<br>[1563, 1601, 0]"]
66["Segment<br>[1563, 1601, 0]"]
67["Segment<br>[1563, 1601, 0]"]
68["Segment<br>[1563, 1601, 0]"]
69["Segment<br>[1563, 1601, 0]"]
70["Segment<br>[1563, 1601, 0]"]
71["Segment<br>[1563, 1601, 0]"]
72["Segment<br>[1563, 1601, 0]"]
73["Segment<br>[1563, 1601, 0]"]
74["Segment<br>[1563, 1601, 0]"]
75["Segment<br>[1563, 1601, 0]"]
76["Segment<br>[1563, 1601, 0]"]
77["Segment<br>[1563, 1601, 0]"]
78["Segment<br>[1563, 1601, 0]"]
79["Segment<br>[1563, 1601, 0]"]
80["Segment<br>[1563, 1601, 0]"]
81["Segment<br>[1563, 1601, 0]"]
82["Segment<br>[1563, 1601, 0]"]
83["Segment<br>[1563, 1601, 0]"]
84["Segment<br>[1563, 1601, 0]"]
85["Segment<br>[1563, 1601, 0]"]
86["Segment<br>[1563, 1601, 0]"]
87["Segment<br>[1563, 1601, 0]"]
88["Segment<br>[1563, 1601, 0]"]
89["Segment<br>[1563, 1601, 0]"]
90["Segment<br>[1563, 1601, 0]"]
91["Segment<br>[1563, 1601, 0]"]
92["Segment<br>[1563, 1601, 0]"]
93["Segment<br>[1563, 1601, 0]"]
94["Segment<br>[1563, 1601, 0]"]
95["Segment<br>[1563, 1601, 0]"]
96["Segment<br>[1563, 1601, 0]"]
97["Segment<br>[1563, 1601, 0]"]
98["Segment<br>[1563, 1601, 0]"]
99["Segment<br>[1563, 1601, 0]"]
100["Segment<br>[1563, 1601, 0]"]
101["Segment<br>[1563, 1601, 0]"]
102["Segment<br>[1563, 1601, 0]"]
103["Segment<br>[1563, 1601, 0]"]
104["Segment<br>[1563, 1601, 0]"]
105["Segment<br>[1563, 1601, 0]"]
106["Segment<br>[1563, 1601, 0]"]
107["Segment<br>[1563, 1601, 0]"]
108["Segment<br>[1563, 1601, 0]"]
109["Segment<br>[1563, 1601, 0]"]
110["Segment<br>[1563, 1601, 0]"]
111["Segment<br>[1563, 1601, 0]"]
112["Segment<br>[1563, 1601, 0]"]
113["Segment<br>[1563, 1601, 0]"]
114["Segment<br>[1964, 2033, 0]"]
115["Segment<br>[1791, 1821, 0]"]
116["Segment<br>[1791, 1821, 0]"]
117["Segment<br>[1791, 1821, 0]"]
118["Segment<br>[1791, 1821, 0]"]
119["Segment<br>[1791, 1821, 0]"]
120["Segment<br>[1791, 1821, 0]"]
121["Segment<br>[1791, 1821, 0]"]
122["Segment<br>[1791, 1821, 0]"]
123["Segment<br>[1791, 1821, 0]"]
124["Segment<br>[1791, 1821, 0]"]
125["Segment<br>[1791, 1821, 0]"]
126["Segment<br>[1791, 1821, 0]"]
127["Segment<br>[1791, 1821, 0]"]
128["Segment<br>[1791, 1821, 0]"]
129["Segment<br>[1791, 1821, 0]"]
130["Segment<br>[1791, 1821, 0]"]
131["Segment<br>[1791, 1821, 0]"]
132["Segment<br>[1791, 1821, 0]"]
133["Segment<br>[1791, 1821, 0]"]
134["Segment<br>[1791, 1821, 0]"]
135["Segment<br>[1791, 1821, 0]"]
136["Segment<br>[1791, 1821, 0]"]
137["Segment<br>[1791, 1821, 0]"]
138["Segment<br>[1791, 1821, 0]"]
139["Segment<br>[1791, 1821, 0]"]
140["Segment<br>[1791, 1821, 0]"]
141["Segment<br>[1791, 1821, 0]"]
142["Segment<br>[1791, 1821, 0]"]
143["Segment<br>[1791, 1821, 0]"]
144["Segment<br>[1791, 1821, 0]"]
145["Segment<br>[1791, 1821, 0]"]
146["Segment<br>[1791, 1821, 0]"]
147["Segment<br>[1791, 1821, 0]"]
148["Segment<br>[1791, 1821, 0]"]
149["Segment<br>[1791, 1821, 0]"]
150["Segment<br>[1791, 1821, 0]"]
151["Segment<br>[1791, 1821, 0]"]
152["Segment<br>[1791, 1821, 0]"]
153["Segment<br>[1791, 1821, 0]"]
154["Segment<br>[1791, 1821, 0]"]
155["Segment<br>[1791, 1821, 0]"]
156["Segment<br>[1791, 1821, 0]"]
157["Segment<br>[1791, 1821, 0]"]
158["Segment<br>[1791, 1821, 0]"]
159["Segment<br>[1791, 1821, 0]"]
160["Segment<br>[1791, 1821, 0]"]
161["Segment<br>[1791, 1821, 0]"]
162["Segment<br>[1791, 1821, 0]"]
163["Segment<br>[1791, 1821, 0]"]
164["Segment<br>[1791, 1821, 0]"]
165["Segment<br>[1791, 1821, 0]"]
166["Segment<br>[1791, 1821, 0]"]
167["Segment<br>[1791, 1821, 0]"]
168["Segment<br>[1791, 1821, 0]"]
169["Segment<br>[1791, 1821, 0]"]
170["Segment<br>[1791, 1821, 0]"]
171["Segment<br>[1791, 1821, 0]"]
172["Segment<br>[1791, 1821, 0]"]
173["Segment<br>[1791, 1821, 0]"]
174["Segment<br>[1791, 1821, 0]"]
175["Segment<br>[1791, 1821, 0]"]
176["Segment<br>[1791, 1821, 0]"]
177["Segment<br>[1791, 1821, 0]"]
178["Segment<br>[1791, 1821, 0]"]
179["Segment<br>[1791, 1821, 0]"]
180["Segment<br>[1791, 1821, 0]"]
181["Segment<br>[1791, 1821, 0]"]
182["Segment<br>[1791, 1821, 0]"]
183["Segment<br>[1791, 1821, 0]"]
184["Segment<br>[1791, 1821, 0]"]
185["Segment<br>[1791, 1821, 0]"]
186["Segment<br>[1791, 1821, 0]"]
187["Segment<br>[1791, 1821, 0]"]
188["Segment<br>[1791, 1821, 0]"]
189["Segment<br>[1791, 1821, 0]"]
190["Segment<br>[1791, 1821, 0]"]
191["Segment<br>[1791, 1821, 0]"]
192["Segment<br>[1791, 1821, 0]"]
193["Segment<br>[1791, 1821, 0]"]
194["Segment<br>[1791, 1821, 0]"]
195["Segment<br>[1791, 1821, 0]"]
196["Segment<br>[1791, 1821, 0]"]
197["Segment<br>[1791, 1821, 0]"]
198["Segment<br>[1791, 1821, 0]"]
199["Segment<br>[1791, 1821, 0]"]
200["Segment<br>[1791, 1821, 0]"]
201["Segment<br>[1791, 1821, 0]"]
202["Segment<br>[1791, 1821, 0]"]
203["Segment<br>[1791, 1821, 0]"]
204["Segment<br>[1791, 1821, 0]"]
205["Segment<br>[1791, 1821, 0]"]
206["Segment<br>[1791, 1821, 0]"]
207["Segment<br>[1791, 1821, 0]"]
208["Segment<br>[1791, 1821, 0]"]
209["Segment<br>[1791, 1821, 0]"]
210["Segment<br>[1791, 1821, 0]"]
211["Segment<br>[1791, 1821, 0]"]
212["Segment<br>[1791, 1821, 0]"]
213["Segment<br>[1791, 1821, 0]"]
214["Segment<br>[1791, 1821, 0]"]
215["Segment<br>[1791, 1821, 0]"]
216["Segment<br>[2079, 2086, 0]"]
12["Path<br>[1952, 1989, 0]"]
13["Segment<br>[1640, 1678, 0]"]
14["Segment<br>[1640, 1678, 0]"]
15["Segment<br>[1640, 1678, 0]"]
16["Segment<br>[1640, 1678, 0]"]
17["Segment<br>[1640, 1678, 0]"]
18["Segment<br>[1640, 1678, 0]"]
19["Segment<br>[1640, 1678, 0]"]
20["Segment<br>[1640, 1678, 0]"]
21["Segment<br>[1640, 1678, 0]"]
22["Segment<br>[1640, 1678, 0]"]
23["Segment<br>[1640, 1678, 0]"]
24["Segment<br>[1640, 1678, 0]"]
25["Segment<br>[1640, 1678, 0]"]
26["Segment<br>[1640, 1678, 0]"]
27["Segment<br>[1640, 1678, 0]"]
28["Segment<br>[1640, 1678, 0]"]
29["Segment<br>[1640, 1678, 0]"]
30["Segment<br>[1640, 1678, 0]"]
31["Segment<br>[1640, 1678, 0]"]
32["Segment<br>[1640, 1678, 0]"]
33["Segment<br>[1640, 1678, 0]"]
34["Segment<br>[1640, 1678, 0]"]
35["Segment<br>[1640, 1678, 0]"]
36["Segment<br>[1640, 1678, 0]"]
37["Segment<br>[1640, 1678, 0]"]
38["Segment<br>[1640, 1678, 0]"]
39["Segment<br>[1640, 1678, 0]"]
40["Segment<br>[1640, 1678, 0]"]
41["Segment<br>[1640, 1678, 0]"]
42["Segment<br>[1640, 1678, 0]"]
43["Segment<br>[1640, 1678, 0]"]
44["Segment<br>[1640, 1678, 0]"]
45["Segment<br>[1640, 1678, 0]"]
46["Segment<br>[1640, 1678, 0]"]
47["Segment<br>[1640, 1678, 0]"]
48["Segment<br>[1640, 1678, 0]"]
49["Segment<br>[1640, 1678, 0]"]
50["Segment<br>[1640, 1678, 0]"]
51["Segment<br>[1640, 1678, 0]"]
52["Segment<br>[1640, 1678, 0]"]
53["Segment<br>[1640, 1678, 0]"]
54["Segment<br>[1640, 1678, 0]"]
55["Segment<br>[1640, 1678, 0]"]
56["Segment<br>[1640, 1678, 0]"]
57["Segment<br>[1640, 1678, 0]"]
58["Segment<br>[1640, 1678, 0]"]
59["Segment<br>[1640, 1678, 0]"]
60["Segment<br>[1640, 1678, 0]"]
61["Segment<br>[1640, 1678, 0]"]
62["Segment<br>[1640, 1678, 0]"]
63["Segment<br>[1640, 1678, 0]"]
64["Segment<br>[1640, 1678, 0]"]
65["Segment<br>[1640, 1678, 0]"]
66["Segment<br>[1640, 1678, 0]"]
67["Segment<br>[1640, 1678, 0]"]
68["Segment<br>[1640, 1678, 0]"]
69["Segment<br>[1640, 1678, 0]"]
70["Segment<br>[1640, 1678, 0]"]
71["Segment<br>[1640, 1678, 0]"]
72["Segment<br>[1640, 1678, 0]"]
73["Segment<br>[1640, 1678, 0]"]
74["Segment<br>[1640, 1678, 0]"]
75["Segment<br>[1640, 1678, 0]"]
76["Segment<br>[1640, 1678, 0]"]
77["Segment<br>[1640, 1678, 0]"]
78["Segment<br>[1640, 1678, 0]"]
79["Segment<br>[1640, 1678, 0]"]
80["Segment<br>[1640, 1678, 0]"]
81["Segment<br>[1640, 1678, 0]"]
82["Segment<br>[1640, 1678, 0]"]
83["Segment<br>[1640, 1678, 0]"]
84["Segment<br>[1640, 1678, 0]"]
85["Segment<br>[1640, 1678, 0]"]
86["Segment<br>[1640, 1678, 0]"]
87["Segment<br>[1640, 1678, 0]"]
88["Segment<br>[1640, 1678, 0]"]
89["Segment<br>[1640, 1678, 0]"]
90["Segment<br>[1640, 1678, 0]"]
91["Segment<br>[1640, 1678, 0]"]
92["Segment<br>[1640, 1678, 0]"]
93["Segment<br>[1640, 1678, 0]"]
94["Segment<br>[1640, 1678, 0]"]
95["Segment<br>[1640, 1678, 0]"]
96["Segment<br>[1640, 1678, 0]"]
97["Segment<br>[1640, 1678, 0]"]
98["Segment<br>[1640, 1678, 0]"]
99["Segment<br>[1640, 1678, 0]"]
100["Segment<br>[1640, 1678, 0]"]
101["Segment<br>[1640, 1678, 0]"]
102["Segment<br>[1640, 1678, 0]"]
103["Segment<br>[1640, 1678, 0]"]
104["Segment<br>[1640, 1678, 0]"]
105["Segment<br>[1640, 1678, 0]"]
106["Segment<br>[1640, 1678, 0]"]
107["Segment<br>[1640, 1678, 0]"]
108["Segment<br>[1640, 1678, 0]"]
109["Segment<br>[1640, 1678, 0]"]
110["Segment<br>[1640, 1678, 0]"]
111["Segment<br>[1640, 1678, 0]"]
112["Segment<br>[1640, 1678, 0]"]
113["Segment<br>[1640, 1678, 0]"]
114["Segment<br>[2055, 2124, 0]"]
115["Segment<br>[1868, 1898, 0]"]
116["Segment<br>[1868, 1898, 0]"]
117["Segment<br>[1868, 1898, 0]"]
118["Segment<br>[1868, 1898, 0]"]
119["Segment<br>[1868, 1898, 0]"]
120["Segment<br>[1868, 1898, 0]"]
121["Segment<br>[1868, 1898, 0]"]
122["Segment<br>[1868, 1898, 0]"]
123["Segment<br>[1868, 1898, 0]"]
124["Segment<br>[1868, 1898, 0]"]
125["Segment<br>[1868, 1898, 0]"]
126["Segment<br>[1868, 1898, 0]"]
127["Segment<br>[1868, 1898, 0]"]
128["Segment<br>[1868, 1898, 0]"]
129["Segment<br>[1868, 1898, 0]"]
130["Segment<br>[1868, 1898, 0]"]
131["Segment<br>[1868, 1898, 0]"]
132["Segment<br>[1868, 1898, 0]"]
133["Segment<br>[1868, 1898, 0]"]
134["Segment<br>[1868, 1898, 0]"]
135["Segment<br>[1868, 1898, 0]"]
136["Segment<br>[1868, 1898, 0]"]
137["Segment<br>[1868, 1898, 0]"]
138["Segment<br>[1868, 1898, 0]"]
139["Segment<br>[1868, 1898, 0]"]
140["Segment<br>[1868, 1898, 0]"]
141["Segment<br>[1868, 1898, 0]"]
142["Segment<br>[1868, 1898, 0]"]
143["Segment<br>[1868, 1898, 0]"]
144["Segment<br>[1868, 1898, 0]"]
145["Segment<br>[1868, 1898, 0]"]
146["Segment<br>[1868, 1898, 0]"]
147["Segment<br>[1868, 1898, 0]"]
148["Segment<br>[1868, 1898, 0]"]
149["Segment<br>[1868, 1898, 0]"]
150["Segment<br>[1868, 1898, 0]"]
151["Segment<br>[1868, 1898, 0]"]
152["Segment<br>[1868, 1898, 0]"]
153["Segment<br>[1868, 1898, 0]"]
154["Segment<br>[1868, 1898, 0]"]
155["Segment<br>[1868, 1898, 0]"]
156["Segment<br>[1868, 1898, 0]"]
157["Segment<br>[1868, 1898, 0]"]
158["Segment<br>[1868, 1898, 0]"]
159["Segment<br>[1868, 1898, 0]"]
160["Segment<br>[1868, 1898, 0]"]
161["Segment<br>[1868, 1898, 0]"]
162["Segment<br>[1868, 1898, 0]"]
163["Segment<br>[1868, 1898, 0]"]
164["Segment<br>[1868, 1898, 0]"]
165["Segment<br>[1868, 1898, 0]"]
166["Segment<br>[1868, 1898, 0]"]
167["Segment<br>[1868, 1898, 0]"]
168["Segment<br>[1868, 1898, 0]"]
169["Segment<br>[1868, 1898, 0]"]
170["Segment<br>[1868, 1898, 0]"]
171["Segment<br>[1868, 1898, 0]"]
172["Segment<br>[1868, 1898, 0]"]
173["Segment<br>[1868, 1898, 0]"]
174["Segment<br>[1868, 1898, 0]"]
175["Segment<br>[1868, 1898, 0]"]
176["Segment<br>[1868, 1898, 0]"]
177["Segment<br>[1868, 1898, 0]"]
178["Segment<br>[1868, 1898, 0]"]
179["Segment<br>[1868, 1898, 0]"]
180["Segment<br>[1868, 1898, 0]"]
181["Segment<br>[1868, 1898, 0]"]
182["Segment<br>[1868, 1898, 0]"]
183["Segment<br>[1868, 1898, 0]"]
184["Segment<br>[1868, 1898, 0]"]
185["Segment<br>[1868, 1898, 0]"]
186["Segment<br>[1868, 1898, 0]"]
187["Segment<br>[1868, 1898, 0]"]
188["Segment<br>[1868, 1898, 0]"]
189["Segment<br>[1868, 1898, 0]"]
190["Segment<br>[1868, 1898, 0]"]
191["Segment<br>[1868, 1898, 0]"]
192["Segment<br>[1868, 1898, 0]"]
193["Segment<br>[1868, 1898, 0]"]
194["Segment<br>[1868, 1898, 0]"]
195["Segment<br>[1868, 1898, 0]"]
196["Segment<br>[1868, 1898, 0]"]
197["Segment<br>[1868, 1898, 0]"]
198["Segment<br>[1868, 1898, 0]"]
199["Segment<br>[1868, 1898, 0]"]
200["Segment<br>[1868, 1898, 0]"]
201["Segment<br>[1868, 1898, 0]"]
202["Segment<br>[1868, 1898, 0]"]
203["Segment<br>[1868, 1898, 0]"]
204["Segment<br>[1868, 1898, 0]"]
205["Segment<br>[1868, 1898, 0]"]
206["Segment<br>[1868, 1898, 0]"]
207["Segment<br>[1868, 1898, 0]"]
208["Segment<br>[1868, 1898, 0]"]
209["Segment<br>[1868, 1898, 0]"]
210["Segment<br>[1868, 1898, 0]"]
211["Segment<br>[1868, 1898, 0]"]
212["Segment<br>[1868, 1898, 0]"]
213["Segment<br>[1868, 1898, 0]"]
214["Segment<br>[1868, 1898, 0]"]
215["Segment<br>[1868, 1898, 0]"]
216["Segment<br>[2184, 2191, 0]"]
217[Solid2d]
end
subgraph path219 [Path]
219["Path<br>[2567, 2667, 0]"]
220["Segment<br>[2673, 2700, 0]"]
221["Segment<br>[2706, 2734, 0]"]
222["Segment<br>[2740, 2768, 0]"]
223["Segment<br>[2774, 2861, 0]"]
224["Segment<br>[2867, 2943, 0]"]
225["Segment<br>[2949, 2956, 0]"]
219["Path<br>[2672, 2772, 0]"]
220["Segment<br>[2778, 2805, 0]"]
221["Segment<br>[2811, 2839, 0]"]
222["Segment<br>[2845, 2873, 0]"]
223["Segment<br>[2879, 2966, 0]"]
224["Segment<br>[2972, 3048, 0]"]
225["Segment<br>[3054, 3061, 0]"]
226[Solid2d]
end
1["Plane<br>[1325, 1342, 0]"]
5["Sweep Extrusion<br>[1404, 1432, 0]"]
1["Plane<br>[1402, 1419, 0]"]
5["Sweep Extrusion<br>[1481, 1509, 0]"]
6[Wall]
7["Cap Start"]
8["Cap End"]
9["SweepEdge Opposite"]
10["SweepEdge Adjacent"]
11["Plane<br>[1852, 1869, 0]"]
218["Sweep Extrusion<br>[2092, 2120, 0]"]
227["Sweep Extrusion<br>[2962, 2991, 0]"]
11["Plane<br>[1929, 1946, 0]"]
218["Sweep Extrusion<br>[2197, 2225, 0]"]
227["Sweep Extrusion<br>[3067, 3096, 0]"]
228[Wall]
229[Wall]
230[Wall]
@ -245,7 +245,7 @@ flowchart LR
237["SweepEdge Adjacent"]
238["SweepEdge Opposite"]
239["SweepEdge Adjacent"]
240["StartSketchOnFace<br>[2530, 2561, 0]"]
240["StartSketchOnFace<br>[2635, 2666, 0]"]
1 --- 2
2 --- 3
2 ---- 5

View File

@ -538,42 +538,15 @@ description: Result of parsing gear.kcl
"init": {
"arguments": [
{
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"endElement": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "cmo",
"name": "f",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
"endInclusive": true,
"start": 0,
"startElement": {
"commentStart": 0,
"end": 0,
"raw": "0",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
},
"type": "ArrayRangeExpression",
"type": "ArrayRangeExpression"
},
{
"arg": {
"body": {
"body": [
{
@ -758,6 +731,7 @@ description: Result of parsing gear.kcl
"type": "FunctionExpression",
"type": "FunctionExpression"
}
}
],
"callee": {
"abs_path": false,
@ -777,8 +751,44 @@ description: Result of parsing gear.kcl
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"commentStart": 0,
"end": 0,
"endElement": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "cmo",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
"endInclusive": true,
"start": 0,
"startElement": {
"commentStart": 0,
"end": 0,
"raw": "0",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
},
"type": "ArrayRangeExpression",
"type": "ArrayRangeExpression"
}
},
"start": 0,
"type": "VariableDeclarator"
@ -804,22 +814,15 @@ description: Result of parsing gear.kcl
"init": {
"arguments": [
{
"abs_path": false,
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "rs",
"name": "f",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
{
"arg": {
"body": {
"body": [
{
@ -960,6 +963,7 @@ description: Result of parsing gear.kcl
"type": "FunctionExpression",
"type": "FunctionExpression"
}
}
],
"callee": {
"abs_path": false,
@ -979,8 +983,24 @@ description: Result of parsing gear.kcl
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "rs",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
}
},
"start": 0,
"type": "VariableDeclarator"
@ -1011,22 +1031,15 @@ description: Result of parsing gear.kcl
"init": {
"arguments": [
{
"abs_path": false,
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "angles",
"name": "f",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
{
"arg": {
"body": {
"body": [
{
@ -1171,6 +1184,7 @@ description: Result of parsing gear.kcl
"type": "FunctionExpression",
"type": "FunctionExpression"
}
}
],
"callee": {
"abs_path": false,
@ -1190,8 +1204,24 @@ description: Result of parsing gear.kcl
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "angles",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
}
},
"start": 0,
"type": "VariableDeclarator"
@ -1222,42 +1252,15 @@ description: Result of parsing gear.kcl
"init": {
"arguments": [
{
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"endElement": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "cmo",
"name": "f",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
"endInclusive": true,
"start": 0,
"startElement": {
"commentStart": 0,
"end": 0,
"raw": "0",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
},
"type": "ArrayRangeExpression",
"type": "ArrayRangeExpression"
},
{
"arg": {
"body": {
"body": [
{
@ -1385,6 +1388,7 @@ description: Result of parsing gear.kcl
"type": "FunctionExpression",
"type": "FunctionExpression"
}
}
],
"callee": {
"abs_path": false,
@ -1404,38 +1408,9 @@ description: Result of parsing gear.kcl
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 0,
"type": "VariableDeclarator"
},
"end": 0,
"kind": "const",
"preComments": [
"",
"",
"// Map the involute curve"
],
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 0,
"declaration": {
"commentStart": 0,
"end": 0,
"id": {
"commentStart": 0,
"end": 0,
"name": "ys",
"start": 0,
"type": "Identifier"
},
"init": {
"arguments": [
{
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"commentStart": 0,
"end": 0,
"endElement": {
@ -1470,8 +1445,46 @@ description: Result of parsing gear.kcl
},
"type": "ArrayRangeExpression",
"type": "ArrayRangeExpression"
}
},
"start": 0,
"type": "VariableDeclarator"
},
"end": 0,
"kind": "const",
"preComments": [
"",
"",
"// Map the involute curve"
],
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 0,
"declaration": {
"commentStart": 0,
"end": 0,
"id": {
"commentStart": 0,
"end": 0,
"name": "ys",
"start": 0,
"type": "Identifier"
},
"init": {
"arguments": [
{
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": "f",
"start": 0,
"type": "Identifier"
},
"arg": {
"body": {
"body": [
{
@ -1599,6 +1612,7 @@ description: Result of parsing gear.kcl
"type": "FunctionExpression",
"type": "FunctionExpression"
}
}
],
"callee": {
"abs_path": false,
@ -1618,8 +1632,44 @@ description: Result of parsing gear.kcl
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"commentStart": 0,
"end": 0,
"endElement": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "cmo",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
"endInclusive": true,
"start": 0,
"startElement": {
"commentStart": 0,
"end": 0,
"raw": "0",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
},
"type": "ArrayRangeExpression",
"type": "ArrayRangeExpression"
}
},
"start": 0,
"type": "VariableDeclarator"
@ -3027,6 +3077,79 @@ description: Result of parsing gear.kcl
{
"arguments": [
{
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": "initial",
"start": 0,
"type": "Identifier"
},
"arg": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "start",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
}
},
{
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": "f",
"start": 0,
"type": "Identifier"
},
"arg": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "leftInvolute",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
}
}
],
"callee": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "reduce",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name"
},
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"commentStart": 0,
"end": 0,
"endElement": {
@ -3057,60 +3180,7 @@ description: Result of parsing gear.kcl
},
"type": "ArrayRangeExpression",
"type": "ArrayRangeExpression"
},
{
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "start",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
{
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "leftInvolute",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
}
],
"callee": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "reduce",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name"
},
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
@ -3234,6 +3304,70 @@ description: Result of parsing gear.kcl
{
"arguments": [
{
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": "initial",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 0,
"end": 0,
"start": 0,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
},
{
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": "f",
"start": 0,
"type": "Identifier"
},
"arg": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "rightInvolute",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
}
}
],
"callee": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "reduce",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name"
},
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"commentStart": 0,
"end": 0,
"endElement": {
@ -3264,51 +3398,7 @@ description: Result of parsing gear.kcl
},
"type": "ArrayRangeExpression",
"type": "ArrayRangeExpression"
},
{
"commentStart": 0,
"end": 0,
"start": 0,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
},
{
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "rightInvolute",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
}
],
"callee": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "reduce",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name"
},
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [],

View File

@ -2,60 +2,60 @@
flowchart LR
subgraph path2 [Path]
2["Path<br>[754, 790, 0]"]
3["Segment<br>[930, 994, 0]"]
4["Segment<br>[930, 994, 0]"]
5["Segment<br>[930, 994, 0]"]
6["Segment<br>[930, 994, 0]"]
7["Segment<br>[930, 994, 0]"]
8["Segment<br>[930, 994, 0]"]
9["Segment<br>[930, 994, 0]"]
10["Segment<br>[930, 994, 0]"]
11["Segment<br>[930, 994, 0]"]
12["Segment<br>[930, 994, 0]"]
13["Segment<br>[930, 994, 0]"]
14["Segment<br>[930, 994, 0]"]
15["Segment<br>[930, 994, 0]"]
16["Segment<br>[930, 994, 0]"]
17["Segment<br>[930, 994, 0]"]
18["Segment<br>[930, 994, 0]"]
19["Segment<br>[930, 994, 0]"]
20["Segment<br>[930, 994, 0]"]
21["Segment<br>[930, 994, 0]"]
22["Segment<br>[930, 994, 0]"]
23["Segment<br>[930, 994, 0]"]
24["Segment<br>[930, 994, 0]"]
25["Segment<br>[930, 994, 0]"]
26["Segment<br>[930, 994, 0]"]
27["Segment<br>[930, 994, 0]"]
28["Segment<br>[930, 994, 0]"]
29["Segment<br>[930, 994, 0]"]
30["Segment<br>[930, 994, 0]"]
31["Segment<br>[930, 994, 0]"]
32["Segment<br>[930, 994, 0]"]
33["Segment<br>[930, 994, 0]"]
34["Segment<br>[930, 994, 0]"]
35["Segment<br>[930, 994, 0]"]
36["Segment<br>[930, 994, 0]"]
37["Segment<br>[930, 994, 0]"]
38["Segment<br>[930, 994, 0]"]
39["Segment<br>[930, 994, 0]"]
40["Segment<br>[930, 994, 0]"]
41["Segment<br>[930, 994, 0]"]
42["Segment<br>[930, 994, 0]"]
43["Segment<br>[930, 994, 0]"]
44["Segment<br>[930, 994, 0]"]
45["Segment<br>[930, 994, 0]"]
46["Segment<br>[930, 994, 0]"]
47["Segment<br>[930, 994, 0]"]
48["Segment<br>[930, 994, 0]"]
49["Segment<br>[930, 994, 0]"]
50["Segment<br>[930, 994, 0]"]
51["Segment<br>[930, 994, 0]"]
52["Segment<br>[1058, 1076, 0]"]
3["Segment<br>[944, 1008, 0]"]
4["Segment<br>[944, 1008, 0]"]
5["Segment<br>[944, 1008, 0]"]
6["Segment<br>[944, 1008, 0]"]
7["Segment<br>[944, 1008, 0]"]
8["Segment<br>[944, 1008, 0]"]
9["Segment<br>[944, 1008, 0]"]
10["Segment<br>[944, 1008, 0]"]
11["Segment<br>[944, 1008, 0]"]
12["Segment<br>[944, 1008, 0]"]
13["Segment<br>[944, 1008, 0]"]
14["Segment<br>[944, 1008, 0]"]
15["Segment<br>[944, 1008, 0]"]
16["Segment<br>[944, 1008, 0]"]
17["Segment<br>[944, 1008, 0]"]
18["Segment<br>[944, 1008, 0]"]
19["Segment<br>[944, 1008, 0]"]
20["Segment<br>[944, 1008, 0]"]
21["Segment<br>[944, 1008, 0]"]
22["Segment<br>[944, 1008, 0]"]
23["Segment<br>[944, 1008, 0]"]
24["Segment<br>[944, 1008, 0]"]
25["Segment<br>[944, 1008, 0]"]
26["Segment<br>[944, 1008, 0]"]
27["Segment<br>[944, 1008, 0]"]
28["Segment<br>[944, 1008, 0]"]
29["Segment<br>[944, 1008, 0]"]
30["Segment<br>[944, 1008, 0]"]
31["Segment<br>[944, 1008, 0]"]
32["Segment<br>[944, 1008, 0]"]
33["Segment<br>[944, 1008, 0]"]
34["Segment<br>[944, 1008, 0]"]
35["Segment<br>[944, 1008, 0]"]
36["Segment<br>[944, 1008, 0]"]
37["Segment<br>[944, 1008, 0]"]
38["Segment<br>[944, 1008, 0]"]
39["Segment<br>[944, 1008, 0]"]
40["Segment<br>[944, 1008, 0]"]
41["Segment<br>[944, 1008, 0]"]
42["Segment<br>[944, 1008, 0]"]
43["Segment<br>[944, 1008, 0]"]
44["Segment<br>[944, 1008, 0]"]
45["Segment<br>[944, 1008, 0]"]
46["Segment<br>[944, 1008, 0]"]
47["Segment<br>[944, 1008, 0]"]
48["Segment<br>[944, 1008, 0]"]
49["Segment<br>[944, 1008, 0]"]
50["Segment<br>[944, 1008, 0]"]
51["Segment<br>[944, 1008, 0]"]
52["Segment<br>[1072, 1090, 0]"]
53[Solid2d]
end
1["Plane<br>[731, 748, 0]"]
54["Sweep Extrusion<br>[1130, 1168, 0]"]
54["Sweep Extrusion<br>[1144, 1182, 0]"]
55[Wall]
56[Wall]
57[Wall]

View File

@ -762,62 +762,15 @@ description: Result of parsing loop_tag.kcl
"init": {
"arguments": [
{
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"endElement": {
"commentStart": 0,
"end": 0,
"left": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "numSides",
"name": "initial",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
"operator": "-",
"right": {
"commentStart": 0,
"end": 0,
"raw": "1",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
},
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
"endInclusive": true,
"start": 0,
"startElement": {
"commentStart": 0,
"end": 0,
"raw": "1",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
},
"type": "ArrayRangeExpression",
"type": "ArrayRangeExpression"
},
{
"arg": {
"abs_path": false,
"commentStart": 0,
"end": 0,
@ -832,8 +785,18 @@ description: Result of parsing loop_tag.kcl
"start": 0,
"type": "Name",
"type": "Name"
}
},
{
"type": "LabeledArg",
"label": {
"commentStart": 0,
"end": 0,
"name": "f",
"start": 0,
"type": "Identifier"
},
"arg": {
"body": {
"body": [
{
@ -984,6 +947,7 @@ description: Result of parsing loop_tag.kcl
"type": "FunctionExpression",
"type": "FunctionExpression"
}
}
],
"callee": {
"abs_path": false,
@ -1003,8 +967,64 @@ description: Result of parsing loop_tag.kcl
"commentStart": 0,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"commentStart": 0,
"end": 0,
"endElement": {
"commentStart": 0,
"end": 0,
"left": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "numSides",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
"operator": "-",
"right": {
"commentStart": 0,
"end": 0,
"raw": "1",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
},
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
"endInclusive": true,
"start": 0,
"startElement": {
"commentStart": 0,
"end": 0,
"raw": "1",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
},
"type": "ArrayRangeExpression",
"type": "ArrayRangeExpression"
}
},
"start": 0,
"type": "VariableDeclarator"

View File

@ -26,8 +26,8 @@ initialSketch = startSketchOn(XY)
// Draw lines to form the base of the cylinder
finalSketch = reduce(
[1..numSides-1],
initialSketch,
fn(index, sketch) {
initial = initialSketch,
f = fn(index, sketch) {
return line(sketch, end = calculatePoint(index), tag = $problematicTag)
}
)

File diff suppressed because it is too large Load Diff

View File

@ -31,9 +31,13 @@ initialSketch = startSketchOn(XY)
|> startProfile(at = calculatePoint(0))
// Draw lines to form the base of the cylinder
finalSketch = reduce([1 .. numSides - 1], initialSketch, fn(index, sketch) {
finalSketch = reduce(
[1 .. numSides - 1],
initial = initialSketch,
f = fn(index, sketch) {
return line(sketch, end = calculatePoint(index), tag = $problematicTag)
})
},
)
// Close the sketch to complete the base
closedSketch = close(finalSketch)