KCL: Linear/circular pattern in stdlib should use kwargs (#5315)

Part of https://github.com/KittyCAD/modeling-app/issues/4600
This commit is contained in:
Adam Chalmers
2025-02-11 16:06:47 -06:00
committed by GitHub
parent ed8a0e4aaa
commit c68e5d7774
49 changed files with 26313 additions and 1376 deletions

File diff suppressed because one or more lines are too long

View File

@ -33,7 +33,14 @@ helix(revolutions: number, angle_start: number, ccw?: bool, radius: number, axis
```js ```js
// Create a helix around the Z axis. // Create a helix around the Z axis.
helixPath = helix(angleStart = 0, ccw = true, revolutions = 5, length = 10, radius = 5, axis = 'Z') helixPath = helix(
angleStart = 0,
ccw = true,
revolutions = 5,
length = 10,
radius = 5,
axis = 'Z',
)
// Create a spring by sweeping around the helix path. // Create a spring by sweeping around the helix path.
springSketch = startSketchOn('YZ') springSketch = startSketchOn('YZ')
@ -49,7 +56,14 @@ helper001 = startSketchOn('XZ')
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line(end = [0, 10], tag = $edge001) |> line(end = [0, 10], tag = $edge001)
helixPath = helix(angleStart = 0, ccw = true, revolutions = 5, length = 10, radius = 5, axis = edge001) helixPath = helix(
angleStart = 0,
ccw = true,
revolutions = 5,
length = 10,
radius = 5,
axis = edge001,
)
// Create a spring by sweeping around the helix path. // Create a spring by sweeping around the helix path.
springSketch = startSketchOn('XY') springSketch = startSketchOn('XY')
@ -61,12 +75,19 @@ springSketch = startSketchOn('XY')
```js ```js
// Create a helix around a custom axis. // Create a helix around a custom axis.
helixPath = helix(angleStart = 0, ccw = true, revolutions = 5, length = 10, radius = 5, axis = { helixPath = helix(
angleStart = 0,
ccw = true,
revolutions = 5,
length = 10,
radius = 5,
axis = {
custom = { custom = {
axis = [0, 0, 1.0], axis = [0, 0, 1.0],
origin = [0, 0.25, 0] origin = [0, 0.25, 0]
} }
}) },
)
// Create a spring by sweeping around the helix path. // Create a spring by sweeping around the helix path.
springSketch = startSketchOn('XY') springSketch = startSketchOn('XY')

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@ Repeat a 2-dimensional sketch some number of times along a partial or
complete circle some specified number of times. Each object may additionally be rotated along the circle, ensuring orentation of the solid with respect to the center of the circle is maintained. complete circle some specified number of times. Each object may additionally be rotated along the circle, ensuring orentation of the solid with respect to the center of the circle is maintained.
```js ```js
patternCircular2d(data: CircularPattern2dData, sketch_set: SketchSet) -> [Sketch] patternCircular2d(sketch_set: SketchSet, instances: integer, center: [number], arc_degrees: number, rotate_duplicates: bool, use_original?: bool) -> [Sketch]
``` ```
@ -17,8 +17,12 @@ patternCircular2d(data: CircularPattern2dData, sketch_set: SketchSet) -> [Sketch
| Name | Type | Description | Required | | Name | Type | Description | Required |
|----------|------|-------------|----------| |----------|------|-------------|----------|
| `data` | [`CircularPattern2dData`](/docs/kcl/types/CircularPattern2dData) | Data for a circular pattern on a 2D sketch. | Yes | | `sketch_set` | [`SketchSet`](/docs/kcl/types/SketchSet) | Which sketch(es) to pattern | Yes |
| `sketch_set` | [`SketchSet`](/docs/kcl/types/SketchSet) | A sketch or a group of sketches. | Yes | | `instances` | `integer` | The number of total instances. Must be greater than or equal to 1. This includes the original entity. For example, if instances is 2, there will be two copies -- the original, and one new copy. If instances is 1, this has no effect. | Yes |
| `center` | `[number]` | The center about which to make the pattern. This is a 2D vector. | Yes |
| `arc_degrees` | `number` | The arc angle (in degrees) to place the repetitions. Must be greater than 0. | Yes |
| `rotate_duplicates` | `bool` | Whether or not to rotate the duplicates as they are copied. | Yes |
| `use_original` | `bool` | If the target was sketched on an extrusion, setting this will use the original sketch as the target, not the entire joined solid. Defaults to false. | No |
### Returns ### Returns
@ -34,12 +38,12 @@ exampleSketch = startSketchOn('XZ')
|> line(end = [-1, 0]) |> line(end = [-1, 0])
|> line(end = [0, -5]) |> line(end = [0, -5])
|> close() |> close()
|> patternCircular2d({ |> patternCircular2d(
center = [0, 0], center = [0, 0],
instances = 13, instances = 13,
arcDegrees = 360, arcDegrees = 360,
rotateDuplicates = true rotateDuplicates = true,
}, %) )
example = extrude(exampleSketch, length = 1) example = extrude(exampleSketch, length = 1)
``` ```

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@ Repeat a 2-dimensional sketch along some dimension, with a dynamic amount
of distance between each repetition, some specified number of times. of distance between each repetition, some specified number of times.
```js ```js
patternLinear2d(data: LinearPattern2dData, sketch_set: SketchSet, use_original?: bool) -> [Sketch] patternLinear2d(sketch_set: SketchSet, instances: integer, distance: number, axis: [number], use_original?: bool) -> [Sketch]
``` ```
@ -17,9 +17,11 @@ patternLinear2d(data: LinearPattern2dData, sketch_set: SketchSet, use_original?:
| Name | Type | Description | Required | | Name | Type | Description | Required |
|----------|------|-------------|----------| |----------|------|-------------|----------|
| `data` | [`LinearPattern2dData`](/docs/kcl/types/LinearPattern2dData) | Data for a linear pattern on a 2D sketch. | Yes | | `sketch_set` | [`SketchSet`](/docs/kcl/types/SketchSet) | The sketch(es) to duplicate | Yes |
| `sketch_set` | [`SketchSet`](/docs/kcl/types/SketchSet) | A sketch or a group of sketches. | Yes | | `instances` | `integer` | The number of total instances. Must be greater than or equal to 1. This includes the original entity. For example, if instances is 2, there will be two copies -- the original, and one new copy. If instances is 1, this has no effect. | Yes |
| `use_original` | `bool` | | No | | `distance` | `number` | Distance between each repetition. Also known as 'spacing'. | Yes |
| `axis` | `[number]` | The axis of the pattern. A 2D vector. | Yes |
| `use_original` | `bool` | If the target was sketched on an extrusion, setting this will use the original sketch as the target, not the entire joined solid. Defaults to false. | No |
### Returns ### Returns
@ -31,11 +33,7 @@ patternLinear2d(data: LinearPattern2dData, sketch_set: SketchSet, use_original?:
```js ```js
exampleSketch = startSketchOn('XZ') exampleSketch = startSketchOn('XZ')
|> circle({ center = [0, 0], radius = 1 }, %) |> circle({ center = [0, 0], radius = 1 }, %)
|> patternLinear2d({ |> patternLinear2d(axis = [1, 0], instances = 7, distance = 4)
axis = [1, 0],
instances = 7,
distance = 4
}, %)
example = extrude(exampleSketch, length = 1) example = extrude(exampleSketch, length = 1)
``` ```

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -59,7 +59,14 @@ sweepSketch = startSketchOn('XY')
// Create a helix around the Z axis. // Create a helix around the Z axis.
helixPath = helix(angleStart = 0, ccw = true, revolutions = 4, length = 10, radius = 5, axis = 'Z') helixPath = helix(
angleStart = 0,
ccw = true,
revolutions = 4,
length = 10,
radius = 5,
axis = 'Z',
)
// Create a spring by sweeping around the helix path. // Create a spring by sweeping around the helix path.
springSketch = startSketchOn('YZ') springSketch = startSketchOn('YZ')

View File

@ -1117,13 +1117,14 @@ openSketch = startSketchOn('XY')
}) => { }) => {
// One dumb hardcoded screen pixel value // One dumb hardcoded screen pixel value
const testPoint = { x: 620, y: 257 } const testPoint = { x: 620, y: 257 }
const expectedOutput = `helix001 = helix(revolutions = 1, angleStart = 360, counterClockWise = false, radius = 5, axis = 'X', length = 5)` const expectedOutput = `helix001 = helix( revolutions = 1, angleStart = 360, counterClockWise = false, radius = 5, axis = 'X', length = 5,)`
const expectedLine = `revolutions=1,`
await homePage.goToModelingScene() await homePage.goToModelingScene()
await test.step(`Look for the red of the default plane`, async () => { // await test.step(`Look for the red of the default plane`, async () => {
await scene.expectPixelColor([96, 52, 52], testPoint, 15) // await scene.expectPixelColor([96, 52, 52], testPoint, 15)
}) // })
await test.step(`Go through the command bar flow`, async () => { await test.step(`Go through the command bar flow`, async () => {
await toolbar.helixButton.click() await toolbar.helixButton.click()
await cmdBar.expectState({ await cmdBar.expectState({
@ -1154,7 +1155,7 @@ openSketch = startSketchOn('XY')
await editor.expectEditor.toContain(expectedOutput) await editor.expectEditor.toContain(expectedOutput)
await editor.expectState({ await editor.expectState({
diagnostics: [], diagnostics: [],
activeLines: [expectedOutput], activeLines: [expectedLine],
highlightedCode: '', highlightedCode: '',
}) })
// Red plane is now gone, white helix is there // Red plane is now gone, white helix is there

View File

@ -192,11 +192,11 @@ extrude001 = extrude(sketch001, length = 50)
|> line(end = [0, -1]) |> line(end = [0, -1])
|> close() |> close()
|> extrude(length = 1) |> extrude(length = 1)
|> patternLinear3d({ |> patternLinear3d(
axis: [1, 0, 1], axis = [1, 0, 1],
repetitions: 3, repetitions = 3,
distance: 6 distance = 6,
}, %)` )`
) )
}) })
await page.setBodyDimensions({ width: 1000, height: 500 }) await page.setBodyDimensions({ width: 1000, height: 500 })

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

After

Width:  |  Height:  |  Size: 76 KiB

View File

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

View File

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

View File

@ -51,16 +51,16 @@ sketch002 = startSketchOn(sketch001, seg03)
center = [-1.25, 1], center = [-1.25, 1],
radius = mountingHoleDiameter / 2, radius = mountingHoleDiameter / 2,
}, %) }, %)
|> patternLinear2d({ |> patternLinear2d(
instances = 2, instances = 2,
distance = 2.5, distance = 2.5,
axis = [-1, 0], axis = [-1, 0],
}, %) )
|> patternLinear2d({ |> patternLinear2d(
instances = 2, instances = 2,
distance = 4, distance = 4,
axis = [0, 1], axis = [0, 1],
}, %) )
|> extrude(%, length = -thickness-.01) |> extrude(%, length = -thickness-.01)
sketch003 = startSketchOn(sketch001, seg04) sketch003 = startSketchOn(sketch001, seg04)
@ -68,11 +68,11 @@ sketch003 = startSketchOn(sketch001, seg04)
center = [1, -1], center = [1, -1],
radius = mountingHoleDiameter / 2, radius = mountingHoleDiameter / 2,
}, %) }, %)
|> patternLinear2d({ |> patternLinear2d(
instances = 2, instances = 2,
distance = 4, distance = 4,
axis = [1, 0], axis = [1, 0],
}, %) )
|> extrude(%, length = -thickness-0.1) |> extrude(%, length = -thickness-0.1)
` `

View File

@ -36,5 +36,11 @@ run-sim-test test_name:
{{cita}} -p kcl-lib -- simulation_tests::{{test_name}}::unparse {{cita}} -p kcl-lib -- simulation_tests::{{test_name}}::unparse
TWENTY_TWENTY=overwrite {{cita}} -p kcl-lib -- tests::{{test_name}}::kcl_test_execute TWENTY_TWENTY=overwrite {{cita}} -p kcl-lib -- tests::{{test_name}}::kcl_test_execute
overwrite-sim-test test_name:
EXPECTORATE=overwrite {{cita}} -p kcl-lib -- simulation_tests::{{test_name}}::parse
EXPECTORATE=overwrite {{cita}} -p kcl-lib -- simulation_tests::{{test_name}}::unparse
{{cita}} -p kcl-lib -- tests::{{test_name}}::kcl_test_execute
test: test:
export RUST_BRACKTRACE="full" && cargo nextest run --workspace --test-threads=1 export RUST_BRACKTRACE="full" && cargo nextest run --workspace --test-threads=1

View File

@ -944,13 +944,7 @@ mod tests {
let snippet = pattern_fn.to_autocomplete_snippet().unwrap(); let snippet = pattern_fn.to_autocomplete_snippet().unwrap();
assert_eq!( assert_eq!(
snippet, snippet,
r#"patternCircular3d({ r#"patternCircular3d(${0:%}, instances = ${1:10}, axis = [${2:3.14}, ${3:3.14}, ${4:3.14}], center = [${5:3.14}, ${6:3.14}, ${7:3.14}], arc_degrees = ${8:3.14}, rotate_duplicates = ${9:false})${}"#
instances = ${0:10},
axis = [${1:3.14}, ${2:3.14}, ${3:3.14}],
center = [${4:3.14}, ${5:3.14}, ${6:3.14}],
arcDegrees = ${7:3.14},
rotateDuplicates = ${8:false},
}, ${9:%})${}"#
); );
} }
@ -1006,11 +1000,7 @@ mod tests {
let snippet = pattern_fn.to_autocomplete_snippet().unwrap(); let snippet = pattern_fn.to_autocomplete_snippet().unwrap();
assert_eq!( assert_eq!(
snippet, snippet,
r#"patternLinear2d({ r#"patternLinear2d(${0:%}, instances = ${1:10}, distance = ${2:3.14}, axis = [${3:3.14}, ${4:3.14}])${}"#
instances = ${0:10},
distance = ${1:3.14},
axis = [${2:3.14}, ${3:3.14}],
}, ${4:%})${}"#
); );
} }

View File

@ -1542,13 +1542,13 @@ sphere = startSketchOn('XZ')
}, %) }, %)
|> close() |> close()
|> revolve({ axis: 'x' }, %) |> revolve({ axis: 'x' }, %)
|> patternCircular3d({ |> patternCircular3d(
axis: [0, 0, 1], axis = [0, 0, 1],
center: [0, 0, 0], center = [0, 0, 0],
repetitions: 10, repetitions = 10,
arcDegrees: 360, arcDegrees = 360,
rotateDuplicates: true rotateDuplicates = true,
}, %) )
// Sketch and revolve the outside bearing // Sketch and revolve the outside bearing
outsideRevolve = startSketchOn('XZ') outsideRevolve = startSketchOn('XZ')
@ -1643,13 +1643,13 @@ sphere = startSketchOn('XZ')
}, %) }, %)
|> close() |> close()
|> revolve({ axis = 'x' }, %) |> revolve({ axis = 'x' }, %)
|> patternCircular3d({ |> patternCircular3d(
axis = [0, 0, 1], axis = [0, 0, 1],
center = [0, 0, 0], center = [0, 0, 0],
repetitions = 10, repetitions = 10,
arcDegrees = 360, arcDegrees = 360,
rotateDuplicates = true rotateDuplicates = true,
}, %) )
// Sketch and revolve the outside bearing // Sketch and revolve the outside bearing
outsideRevolve = startSketchOn('XZ') outsideRevolve = startSketchOn('XZ')

View File

@ -180,12 +180,12 @@ pub async fn appearance(_exec_state: &mut ExecState, args: Args) -> Result<KclVa
/// color = '#ff0000', /// color = '#ff0000',
/// metalness = 90, /// metalness = 90,
/// roughness = 90 /// roughness = 90
/// ) /// )
/// |> patternLinear3d({ /// |> patternLinear3d(
/// axis = [1, 0, 1], /// axis = [1, 0, 1],
/// instances = 7, /// instances = 7,
/// distance = 6 /// distance = 6
/// }, %) /// )
/// ``` /// ```
/// ///
/// ```no_run /// ```no_run
@ -199,16 +199,16 @@ pub async fn appearance(_exec_state: &mut ExecState, args: Args) -> Result<KclVa
/// |> close() /// |> close()
/// ///
/// example = extrude(exampleSketch, length = 1) /// example = extrude(exampleSketch, length = 1)
/// |> patternLinear3d({ /// |> patternLinear3d(
/// axis = [1, 0, 1], /// axis = [1, 0, 1],
/// instances = 7, /// instances = 7,
/// distance = 6 /// distance = 6
/// }, %) /// )
/// |> appearance( /// |> appearance(
/// color = '#ff0000', /// color = '#ff0000',
/// metalness = 90, /// metalness = 90,
/// roughness = 90 /// roughness = 90
/// ) /// )
/// ``` /// ```
/// ///
/// ```no_run /// ```no_run
@ -219,12 +219,12 @@ pub async fn appearance(_exec_state: &mut ExecState, args: Args) -> Result<KclVa
/// |> line(end = [-1, 0]) /// |> line(end = [-1, 0])
/// |> line(end = [0, -5]) /// |> line(end = [0, -5])
/// |> close() /// |> close()
/// |> patternCircular2d({ /// |> patternCircular2d(
/// center = [0, 0], /// center = [0, 0],
/// instances = 13, /// instances = 13,
/// arcDegrees = 360, /// arcDegrees = 360,
/// rotateDuplicates = true /// rotateDuplicates = true
/// }, %) /// )
/// ///
/// example = extrude(exampleSketch, length = 1) /// example = extrude(exampleSketch, length = 1)
/// |> appearance( /// |> appearance(

View File

@ -442,13 +442,6 @@ impl Args {
FromArgs::from_args(self, 0) FromArgs::from_args(self, 0)
} }
pub(crate) fn get_data_and_solid_set<'a, T>(&'a self) -> Result<(T, SolidSet), KclError>
where
T: serde::de::DeserializeOwned + FromKclValue<'a> + Sized,
{
FromArgs::from_args(self, 0)
}
pub(crate) fn get_data_and_solid<'a, T>(&'a self) -> Result<(T, Box<Solid>), KclError> pub(crate) fn get_data_and_solid<'a, T>(&'a self) -> Result<(T, Box<Solid>), KclError>
where where
T: serde::de::DeserializeOwned + FromKclValue<'a> + Sized, T: serde::de::DeserializeOwned + FromKclValue<'a> + Sized,
@ -945,72 +938,6 @@ impl<'a> FromKclValue<'a> for kittycad_modeling_cmds::coord::Direction {
} }
} }
impl<'a> FromKclValue<'a> for super::patterns::CircularPattern3dData {
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
let obj = arg.as_object()?;
let_field_of!(obj, instances);
let_field_of!(obj, arc_degrees "arcDegrees");
let_field_of!(obj, rotate_duplicates "rotateDuplicates");
let_field_of!(obj, axis);
let_field_of!(obj, center);
let_field_of!(obj, use_original? "useOriginal");
Some(Self {
instances,
axis,
center,
arc_degrees,
rotate_duplicates,
use_original,
})
}
}
impl<'a> FromKclValue<'a> for super::patterns::CircularPattern2dData {
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
let obj = arg.as_object()?;
let_field_of!(obj, instances);
let_field_of!(obj, arc_degrees "arcDegrees");
let_field_of!(obj, rotate_duplicates "rotateDuplicates");
let_field_of!(obj, center);
let_field_of!(obj, use_original? "useOriginal");
Some(Self {
instances,
center,
arc_degrees,
rotate_duplicates,
use_original,
})
}
}
impl<'a> FromKclValue<'a> for super::patterns::LinearPattern3dData {
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
let obj = arg.as_object()?;
let_field_of!(obj, distance);
let_field_of!(obj, instances);
let_field_of!(obj, axis);
Some(Self {
instances,
distance,
axis,
})
}
}
impl<'a> FromKclValue<'a> for super::patterns::LinearPattern2dData {
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
let obj = arg.as_object()?;
let_field_of!(obj, distance);
let_field_of!(obj, instances);
let_field_of!(obj, axis);
Some(Self {
instances,
distance,
axis,
})
}
}
impl<'a> FromKclValue<'a> for super::sketch::BezierData { impl<'a> FromKclValue<'a> for super::sketch::BezierData {
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> { fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
let obj = arg.as_object()?; let obj = arg.as_object()?;

View File

@ -29,22 +29,6 @@ use crate::{
const MUST_HAVE_ONE_INSTANCE: &str = "There must be at least 1 instance of your geometry"; const MUST_HAVE_ONE_INSTANCE: &str = "There must be at least 1 instance of your geometry";
/// Data for a linear pattern on a 2D sketch.
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
#[ts(export)]
#[serde(rename_all = "camelCase")]
pub struct LinearPattern2dData {
/// The number of total instances. Must be greater than or equal to 1.
/// This includes the original entity. For example, if instances is 2,
/// there will be two copies -- the original, and one new copy.
/// If instances is 1, this has no effect.
pub instances: u32,
/// The distance between each repetition. This can also be referred to as spacing.
pub distance: f64,
/// The axis of the pattern. This is a 2D vector.
pub axis: [f64; 2],
}
/// Data for a linear pattern on a 3D model. /// Data for a linear pattern on a 3D model.
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)] #[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
#[ts(export)] #[ts(export)]
@ -689,10 +673,13 @@ mod tests {
/// A linear pattern on a 2D sketch. /// A linear pattern on a 2D sketch.
pub async fn pattern_linear_2d(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> { pub async fn pattern_linear_2d(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let (data, sketch_set, use_original): (LinearPattern2dData, SketchSet, Option<bool>) = let sketch_set: SketchSet = args.get_unlabeled_kw_arg("sketchSet")?;
super::args::FromArgs::from_args(&args, 0)?; let instances: u32 = args.get_kw_arg("instances")?;
let distance: f64 = args.get_kw_arg("distance")?;
let axis: [f64; 2] = args.get_kw_arg("axis")?;
let use_original: Option<bool> = args.get_kw_arg_opt("useOriginal")?;
if data.axis == [0.0, 0.0] { if axis == [0.0, 0.0] {
return Err(KclError::Semantic(KclErrorDetails { return Err(KclError::Semantic(KclErrorDetails {
message: message:
"The axis of the linear pattern cannot be the zero vector. Otherwise they will just duplicate in place." "The axis of the linear pattern cannot be the zero vector. Otherwise they will just duplicate in place."
@ -701,7 +688,8 @@ pub async fn pattern_linear_2d(exec_state: &mut ExecState, args: Args) -> Result
})); }));
} }
let sketches = inner_pattern_linear_2d(data, sketch_set, use_original, exec_state, args).await?; let sketches =
inner_pattern_linear_2d(sketch_set, instances, distance, axis, use_original, exec_state, args).await?;
Ok(sketches.into()) Ok(sketches.into())
} }
@ -711,31 +699,41 @@ pub async fn pattern_linear_2d(exec_state: &mut ExecState, args: Args) -> Result
/// ```no_run /// ```no_run
/// exampleSketch = startSketchOn('XZ') /// exampleSketch = startSketchOn('XZ')
/// |> circle({ center = [0, 0], radius = 1 }, %) /// |> circle({ center = [0, 0], radius = 1 }, %)
/// |> patternLinear2d({ /// |> patternLinear2d(
/// axis = [1, 0], /// axis = [1, 0],
/// instances = 7, /// instances = 7,
/// distance = 4 /// distance = 4
/// }, %) /// )
/// ///
/// example = extrude(exampleSketch, length = 1) /// example = extrude(exampleSketch, length = 1)
/// ``` /// ```
#[stdlib { #[stdlib {
name = "patternLinear2d", name = "patternLinear2d",
keywords = true,
unlabeled_first = true,
args = {
sketch_set = { docs = "The sketch(es) to duplicate" },
instances = { docs = "The number of total instances. Must be greater than or equal to 1. This includes the original entity. For example, if instances is 2, there will be two copies -- the original, and one new copy. If instances is 1, this has no effect." },
distance = { docs = "Distance between each repetition. Also known as 'spacing'."},
axis = { docs = "The axis of the pattern. A 2D vector." },
use_original = { docs = "If the target was sketched on an extrusion, setting this will use the original sketch as the target, not the entire joined solid. Defaults to false." },
}
}] }]
async fn inner_pattern_linear_2d( async fn inner_pattern_linear_2d(
data: LinearPattern2dData,
sketch_set: SketchSet, sketch_set: SketchSet,
instances: u32,
distance: f64,
axis: [f64; 2],
use_original: Option<bool>, use_original: Option<bool>,
exec_state: &mut ExecState, exec_state: &mut ExecState,
args: Args, args: Args,
) -> Result<Vec<Box<Sketch>>, KclError> { ) -> Result<Vec<Box<Sketch>>, KclError> {
let axis = data.axis;
let [x, y] = axis; let [x, y] = axis;
let axis_len = f64::sqrt(x * x + y * y); let axis_len = f64::sqrt(x * x + y * y);
let normalized_axis = kcmc::shared::Point2d::from([x / axis_len, y / axis_len]); let normalized_axis = kcmc::shared::Point2d::from([x / axis_len, y / axis_len]);
let transforms: Vec<_> = (1..data.instances) let transforms: Vec<_> = (1..instances)
.map(|i| { .map(|i| {
let d = data.distance * (i as f64); let d = distance * (i as f64);
let translate = (normalized_axis * d).with_z(0.0).map(LengthUnit); let translate = (normalized_axis * d).with_z(0.0).map(LengthUnit);
vec![Transform { vec![Transform {
translate, translate,
@ -755,10 +753,13 @@ async fn inner_pattern_linear_2d(
/// A linear pattern on a 3D model. /// A linear pattern on a 3D model.
pub async fn pattern_linear_3d(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> { pub async fn pattern_linear_3d(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let (data, solid_set, use_original): (LinearPattern3dData, SolidSet, Option<bool>) = let solid_set: SolidSet = args.get_unlabeled_kw_arg("solidSet")?;
super::args::FromArgs::from_args(&args, 0)?; let instances: u32 = args.get_kw_arg("instances")?;
let distance: f64 = args.get_kw_arg("distance")?;
let axis: [f64; 3] = args.get_kw_arg("axis")?;
let use_original: Option<bool> = args.get_kw_arg_opt("useOriginal")?;
if data.axis == [0.0, 0.0, 0.0] { if axis == [0.0, 0.0, 0.0] {
return Err(KclError::Semantic(KclErrorDetails { return Err(KclError::Semantic(KclErrorDetails {
message: message:
"The axis of the linear pattern cannot be the zero vector. Otherwise they will just duplicate in place." "The axis of the linear pattern cannot be the zero vector. Otherwise they will just duplicate in place."
@ -767,7 +768,7 @@ pub async fn pattern_linear_3d(exec_state: &mut ExecState, args: Args) -> Result
})); }));
} }
let solids = inner_pattern_linear_3d(data, solid_set, use_original, exec_state, args).await?; let solids = inner_pattern_linear_3d(solid_set, instances, distance, axis, use_original, exec_state, args).await?;
Ok(solids.into()) Ok(solids.into())
} }
@ -783,30 +784,40 @@ pub async fn pattern_linear_3d(exec_state: &mut ExecState, args: Args) -> Result
/// |> close() /// |> close()
/// ///
/// example = extrude(exampleSketch, length = 1) /// example = extrude(exampleSketch, length = 1)
/// |> patternLinear3d({ /// |> patternLinear3d(
/// axis = [1, 0, 1], /// axis = [1, 0, 1],
/// instances = 7, /// instances = 7,
/// distance = 6 /// distance = 6
/// }, %) /// )
/// ``` /// ```
#[stdlib { #[stdlib {
name = "patternLinear3d", name = "patternLinear3d",
feature_tree_operation = true, feature_tree_operation = true,
keywords = true,
unlabeled_first = true,
args = {
solid_set = { docs = "The solid(s) to duplicate" },
instances = { docs = "The number of total instances. Must be greater than or equal to 1. This includes the original entity. For example, if instances is 2, there will be two copies -- the original, and one new copy. If instances is 1, this has no effect." },
distance = { docs = "Distance between each repetition. Also known as 'spacing'."},
axis = { docs = "The axis of the pattern. A 2D vector." },
use_original = { docs = "If the target was sketched on an extrusion, setting this will use the original sketch as the target, not the entire joined solid. Defaults to false." },
}
}] }]
async fn inner_pattern_linear_3d( async fn inner_pattern_linear_3d(
data: LinearPattern3dData,
solid_set: SolidSet, solid_set: SolidSet,
instances: u32,
distance: f64,
axis: [f64; 3],
use_original: Option<bool>, use_original: Option<bool>,
exec_state: &mut ExecState, exec_state: &mut ExecState,
args: Args, args: Args,
) -> Result<Vec<Box<Solid>>, KclError> { ) -> Result<Vec<Box<Solid>>, KclError> {
let axis = data.axis;
let [x, y, z] = axis; let [x, y, z] = axis;
let axis_len = f64::sqrt(x * x + y * y + z * z); let axis_len = f64::sqrt(x * x + y * y + z * z);
let normalized_axis = kcmc::shared::Point3d::from([x / axis_len, y / axis_len, z / axis_len]); let normalized_axis = kcmc::shared::Point3d::from([x / axis_len, y / axis_len, z / axis_len]);
let transforms: Vec<_> = (1..data.instances) let transforms: Vec<_> = (1..instances)
.map(|i| { .map(|i| {
let d = data.distance * (i as f64); let d = distance * (i as f64);
let translate = (normalized_axis * d).map(LengthUnit); let translate = (normalized_axis * d).map(LengthUnit);
vec![Transform { vec![Transform {
translate, translate,
@ -828,7 +839,7 @@ async fn inner_pattern_linear_3d(
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)] #[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
#[ts(export)] #[ts(export)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct CircularPattern2dData { struct CircularPattern2dData {
/// The number of total instances. Must be greater than or equal to 1. /// The number of total instances. Must be greater than or equal to 1.
/// This includes the original entity. For example, if instances is 2, /// This includes the original entity. For example, if instances is 2,
/// there will be two copies -- the original, and one new copy. /// there will be two copies -- the original, and one new copy.
@ -870,7 +881,7 @@ pub struct CircularPattern3dData {
pub use_original: Option<bool>, pub use_original: Option<bool>,
} }
pub enum CircularPattern { enum CircularPattern {
ThreeD(CircularPattern3dData), ThreeD(CircularPattern3dData),
TwoD(CircularPattern2dData), TwoD(CircularPattern2dData),
} }
@ -941,9 +952,24 @@ impl CircularPattern {
/// A circular pattern on a 2D sketch. /// A circular pattern on a 2D sketch.
pub async fn pattern_circular_2d(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> { pub async fn pattern_circular_2d(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let (data, sketch_set): (CircularPattern2dData, SketchSet) = args.get_data_and_sketch_set()?; let sketch_set: SketchSet = args.get_unlabeled_kw_arg("sketchSet")?;
let instances: u32 = args.get_kw_arg("instances")?;
let center: [f64; 2] = args.get_kw_arg("center")?;
let arc_degrees: f64 = args.get_kw_arg("arcDegrees")?;
let rotate_duplicates: bool = args.get_kw_arg("rotateDuplicates")?;
let use_original: Option<bool> = args.get_kw_arg_opt("useOriginal")?;
let sketches = inner_pattern_circular_2d(data, sketch_set, exec_state, args).await?; let sketches = inner_pattern_circular_2d(
sketch_set,
instances,
center,
arc_degrees,
rotate_duplicates,
use_original,
exec_state,
args,
)
.await?;
Ok(sketches.into()) Ok(sketches.into())
} }
@ -959,21 +985,36 @@ pub async fn pattern_circular_2d(exec_state: &mut ExecState, args: Args) -> Resu
/// |> line(end = [-1, 0]) /// |> line(end = [-1, 0])
/// |> line(end = [0, -5]) /// |> line(end = [0, -5])
/// |> close() /// |> close()
/// |> patternCircular2d({ /// |> patternCircular2d(
/// center = [0, 0], /// center = [0, 0],
/// instances = 13, /// instances = 13,
/// arcDegrees = 360, /// arcDegrees = 360,
/// rotateDuplicates = true /// rotateDuplicates = true
/// }, %) /// )
/// ///
/// example = extrude(exampleSketch, length = 1) /// example = extrude(exampleSketch, length = 1)
/// ``` /// ```
#[stdlib { #[stdlib {
name = "patternCircular2d", name = "patternCircular2d",
keywords = true,
unlabeled_first = true,
args = {
sketch_set = { docs = "Which sketch(es) to pattern" },
instances = { docs = "The number of total instances. Must be greater than or equal to 1. This includes the original entity. For example, if instances is 2, there will be two copies -- the original, and one new copy. If instances is 1, this has no effect."},
center = { docs = "The center about which to make the pattern. This is a 2D vector."},
arc_degrees = { docs = "The arc angle (in degrees) to place the repetitions. Must be greater than 0."},
rotate_duplicates= { docs = "Whether or not to rotate the duplicates as they are copied."},
use_original= { docs = "If the target was sketched on an extrusion, setting this will use the original sketch as the target, not the entire joined solid. Defaults to false."},
}
}] }]
#[allow(clippy::too_many_arguments)]
async fn inner_pattern_circular_2d( async fn inner_pattern_circular_2d(
data: CircularPattern2dData,
sketch_set: SketchSet, sketch_set: SketchSet,
instances: u32,
center: [f64; 2],
arc_degrees: f64,
rotate_duplicates: bool,
use_original: Option<bool>,
exec_state: &mut ExecState, exec_state: &mut ExecState,
args: Args, args: Args,
) -> Result<Vec<Box<Sketch>>, KclError> { ) -> Result<Vec<Box<Sketch>>, KclError> {
@ -982,6 +1023,13 @@ async fn inner_pattern_circular_2d(
if args.ctx.context_type == crate::execution::ContextType::Mock { if args.ctx.context_type == crate::execution::ContextType::Mock {
return Ok(starting_sketches); return Ok(starting_sketches);
} }
let data = CircularPattern2dData {
instances,
center,
arc_degrees,
rotate_duplicates,
use_original,
};
let mut sketches = Vec::new(); let mut sketches = Vec::new();
for sketch in starting_sketches.iter() { for sketch in starting_sketches.iter() {
@ -1008,9 +1056,36 @@ async fn inner_pattern_circular_2d(
/// A circular pattern on a 3D model. /// A circular pattern on a 3D model.
pub async fn pattern_circular_3d(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> { pub async fn pattern_circular_3d(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let (data, solid_set): (CircularPattern3dData, SolidSet) = args.get_data_and_solid_set()?; let solid_set: SolidSet = args.get_unlabeled_kw_arg("solidSet")?;
// The number of total instances. Must be greater than or equal to 1.
// This includes the original entity. For example, if instances is 2,
// there will be two copies -- the original, and one new copy.
// If instances is 1, this has no effect.
let instances: u32 = args.get_kw_arg("instances")?;
// The axis around which to make the pattern. This is a 3D vector.
let axis: [f64; 3] = args.get_kw_arg("axis")?;
// The center about which to make the pattern. This is a 3D vector.
let center: [f64; 3] = args.get_kw_arg("center")?;
// The arc angle (in degrees) to place the repetitions. Must be greater than 0.
let arc_degrees: f64 = args.get_kw_arg("arcDegrees")?;
// Whether or not to rotate the duplicates as they are copied.
let rotate_duplicates: bool = args.get_kw_arg("rotateDuplicates")?;
// If the target being patterned is itself a pattern, then, should you use the original solid,
// or the pattern?
let use_original: Option<bool> = args.get_kw_arg_opt("useOriginal")?;
let solids = inner_pattern_circular_3d(data, solid_set, exec_state, args).await?; let solids = inner_pattern_circular_3d(
solid_set,
instances,
axis,
center,
arc_degrees,
rotate_duplicates,
use_original,
exec_state,
args,
)
.await?;
Ok(solids.into()) Ok(solids.into())
} }
@ -1024,21 +1099,38 @@ pub async fn pattern_circular_3d(exec_state: &mut ExecState, args: Args) -> Resu
/// |> circle({ center = [0, 0], radius = 1 }, %) /// |> circle({ center = [0, 0], radius = 1 }, %)
/// ///
/// example = extrude(exampleSketch, length = -5) /// example = extrude(exampleSketch, length = -5)
/// |> patternCircular3d({ /// |> patternCircular3d(
/// axis = [1, -1, 0], /// axis = [1, -1, 0],
/// center = [10, -20, 0], /// center = [10, -20, 0],
/// instances = 11, /// instances = 11,
/// arcDegrees = 360, /// arcDegrees = 360,
/// rotateDuplicates = true /// rotateDuplicates = true
/// }, %) /// )
/// ``` /// ```
#[stdlib { #[stdlib {
name = "patternCircular3d", name = "patternCircular3d",
feature_tree_operation = true, feature_tree_operation = true,
keywords = true,
unlabeled_first = true,
args = {
solid_set = { docs = "Which solid(s) to pattern" },
instances = { docs = "The number of total instances. Must be greater than or equal to 1. This includes the original entity. For example, if instances is 2, there will be two copies -- the original, and one new copy. If instances is 1, this has no effect."},
axis = { docs = "The axis around which to make the pattern. This is a 3D vector"},
center = { docs = "The center about which to make the pattern. This is a 3D vector."},
arc_degrees = { docs = "The arc angle (in degrees) to place the repetitions. Must be greater than 0."},
rotate_duplicates = { docs = "Whether or not to rotate the duplicates as they are copied."},
use_original = { docs = "If the target was sketched on an extrusion, setting this will use the original sketch as the target, not the entire joined solid. Defaults to false."},
}
}] }]
#[allow(clippy::too_many_arguments)]
async fn inner_pattern_circular_3d( async fn inner_pattern_circular_3d(
data: CircularPattern3dData,
solid_set: SolidSet, solid_set: SolidSet,
instances: u32,
axis: [f64; 3],
center: [f64; 3],
arc_degrees: f64,
rotate_duplicates: bool,
use_original: Option<bool>,
exec_state: &mut ExecState, exec_state: &mut ExecState,
args: Args, args: Args,
) -> Result<Vec<Box<Solid>>, KclError> { ) -> Result<Vec<Box<Solid>>, KclError> {
@ -1055,6 +1147,14 @@ async fn inner_pattern_circular_3d(
} }
let mut solids = Vec::new(); let mut solids = Vec::new();
let data = CircularPattern3dData {
instances,
axis,
center,
arc_degrees,
rotate_duplicates,
use_original,
};
for solid in starting_solids.iter() { for solid in starting_solids.iter() {
let geometries = pattern_circular( let geometries = pattern_circular(
CircularPattern::ThreeD(data.clone()), CircularPattern::ThreeD(data.clone()),

View File

@ -331,8 +331,25 @@ impl CallExpressionKw {
.iter() .iter()
.map(|arg| arg.recast(options, indentation_level, ctxt)), .map(|arg| arg.recast(options, indentation_level, ctxt)),
); );
let args = arg_list.join(", "); let args = arg_list.clone().join(", ");
format!("{indent}{name}({args})") if arg_list.len() >= 4 {
let inner_indentation = if ctxt == ExprContext::Pipe {
options.get_indentation_offset_pipe(indentation_level + 1)
} else {
options.get_indentation(indentation_level + 1)
};
let mut args = arg_list.join(&format!(",\n{inner_indentation}"));
args.push(',');
let args = args;
let end_indent = if ctxt == ExprContext::Pipe {
options.get_indentation_offset_pipe(indentation_level)
} else {
options.get_indentation(indentation_level)
};
format!("{indent}{name}(\n{inner_indentation}{args}\n{end_indent})")
} else {
format!("{indent}{name}({args})")
}
} }
} }
@ -1060,13 +1077,13 @@ sphere = startSketchOn('XZ')
}, %) }, %)
|> close() |> close()
|> revolve({ axis: 'x' }, %) |> revolve({ axis: 'x' }, %)
|> patternCircular3d({ |> patternCircular3d(
axis = [0, 0, 1], axis = [0, 0, 1],
center = [0, 0, 0], center = [0, 0, 0],
repetitions = 10, repetitions = 10,
arcDegrees = 360, arcDegrees = 360,
rotateDuplicates = true rotateDuplicates = true
}, %) )
// Sketch and revolve the outside bearing // Sketch and revolve the outside bearing
outsideRevolve = startSketchOn('XZ') outsideRevolve = startSketchOn('XZ')
@ -1127,13 +1144,13 @@ sphere = startSketchOn('XZ')
}, %) }, %)
|> close() |> close()
|> revolve({ axis = 'x' }, %) |> revolve({ axis = 'x' }, %)
|> patternCircular3d({ |> patternCircular3d(
axis = [0, 0, 1], axis = [0, 0, 1],
center = [0, 0, 0], center = [0, 0, 0],
repetitions = 10, repetitions = 10,
arcDegrees = 360, arcDegrees = 360,
rotateDuplicates = true rotateDuplicates = true,
}, %) )
// Sketch and revolve the outside bearing // Sketch and revolve the outside bearing
outsideRevolve = startSketchOn('XZ') outsideRevolve = startSketchOn('XZ')
@ -1458,11 +1475,11 @@ tabs_r = startSketchOn({
radius = hole_diam / 2 radius = hole_diam / 2
}, %), %) }, %), %)
|> extrude(-thk, %) |> extrude(-thk, %)
|> patternLinear3d({ |> patternLinear3d(
axis = [0, -1, 0], axis = [0, -1, 0],
repetitions = 1, repetitions = 1,
distance = length - 10 distance = length - 10
}, %) )
// build the tabs of the mounting bracket (left side) // build the tabs of the mounting bracket (left side)
tabs_l = startSketchOn({ tabs_l = startSketchOn({
plane: { plane: {
@ -1485,11 +1502,7 @@ tabs_l = startSketchOn({
radius = hole_diam / 2 radius = hole_diam / 2
}, %), %) }, %), %)
|> extrude(-thk, %) |> extrude(-thk, %)
|> patternLinear3d({ |> patternLinear3d(axis = [0, -1, 0], repetitions = 1, distance = length - 10)
axis = [0, -1, 0],
repetitions = 1,
distance = length - 10
}, %)
"#; "#;
let program = crate::parsing::top_level_parse(some_program_string).unwrap(); let program = crate::parsing::top_level_parse(some_program_string).unwrap();
@ -1583,11 +1596,7 @@ tabs_r = startSketchOn({
radius = hole_diam / 2 radius = hole_diam / 2
}, %), %) }, %), %)
|> extrude(-thk, %) |> extrude(-thk, %)
|> patternLinear3d({ |> patternLinear3d(axis = [0, -1, 0], repetitions = 1, distance = length - 10)
axis = [0, -1, 0],
repetitions = 1,
distance = length - 10
}, %)
// build the tabs of the mounting bracket (left side) // build the tabs of the mounting bracket (left side)
tabs_l = startSketchOn({ tabs_l = startSketchOn({
plane = { plane = {
@ -1610,11 +1619,7 @@ tabs_l = startSketchOn({
radius = hole_diam / 2 radius = hole_diam / 2
}, %), %) }, %), %)
|> extrude(-thk, %) |> extrude(-thk, %)
|> patternLinear3d({ |> patternLinear3d(axis = [0, -1, 0], repetitions = 1, distance = length - 10)
axis = [0, -1, 0],
repetitions = 1,
distance = length - 10
}, %)
"# "#
); );
} }

View File

@ -1,6 +1,7 @@
--- ---
source: kcl/src/simulation_tests.rs source: kcl/src/simulation_tests.rs
description: Result of parsing big_number_angle_to_match_length_x.kcl description: Result of parsing big_number_angle_to_match_length_x.kcl
snapshot_kind: text
--- ---
{ {
"Ok": { "Ok": {

View File

@ -631,7 +631,7 @@ snapshot_kind: text
"cmdId": "[uuid]", "cmdId": "[uuid]",
"range": [ "range": [
189, 189,
276, 277,
0 0
], ],
"command": { "command": {
@ -819,8 +819,8 @@ snapshot_kind: text
{ {
"cmdId": "[uuid]", "cmdId": "[uuid]",
"range": [ "range": [
287, 288,
430, 432,
0 0
], ],
"command": { "command": {
@ -844,8 +844,8 @@ snapshot_kind: text
{ {
"cmdId": "[uuid]", "cmdId": "[uuid]",
"range": [ "range": [
287, 288,
430, 432,
0 0
], ],
"command": { "command": {
@ -869,8 +869,8 @@ snapshot_kind: text
{ {
"cmdId": "[uuid]", "cmdId": "[uuid]",
"range": [ "range": [
287, 288,
430, 432,
0 0
], ],
"command": { "command": {
@ -894,8 +894,8 @@ snapshot_kind: text
{ {
"cmdId": "[uuid]", "cmdId": "[uuid]",
"range": [ "range": [
287, 288,
430, 432,
0 0
], ],
"command": { "command": {
@ -919,8 +919,8 @@ snapshot_kind: text
{ {
"cmdId": "[uuid]", "cmdId": "[uuid]",
"range": [ "range": [
287, 288,
430, 432,
0 0
], ],
"command": { "command": {
@ -944,8 +944,8 @@ snapshot_kind: text
{ {
"cmdId": "[uuid]", "cmdId": "[uuid]",
"range": [ "range": [
287, 288,
430, 432,
0 0
], ],
"command": { "command": {
@ -969,8 +969,8 @@ snapshot_kind: text
{ {
"cmdId": "[uuid]", "cmdId": "[uuid]",
"range": [ "range": [
287, 288,
430, 432,
0 0
], ],
"command": { "command": {

View File

@ -1,6 +1,7 @@
--- ---
source: kcl/src/simulation_tests.rs source: kcl/src/simulation_tests.rs
description: Result of parsing circular_pattern3d_a_pattern.kcl description: Result of parsing circular_pattern3d_a_pattern.kcl
snapshot_kind: text
--- ---
{ {
"Ok": { "Ok": {
@ -321,7 +322,7 @@ description: Result of parsing circular_pattern3d_a_pattern.kcl
}, },
{ {
"declaration": { "declaration": {
"end": 276, "end": 277,
"id": { "id": {
"end": 186, "end": 186,
"name": "pattn1", "name": "pattn1",
@ -331,115 +332,88 @@ description: Result of parsing circular_pattern3d_a_pattern.kcl
"init": { "init": {
"arguments": [ "arguments": [
{ {
"end": 260, "type": "LabeledArg",
"properties": [ "label": {
{ "type": "Identifier",
"end": 225, "name": "axis"
"key": { },
"end": 213, "arg": {
"name": "axis", "elements": [
"start": 209, {
"type": "Identifier" "end": 234,
}, "raw": "1",
"start": 209, "start": 233,
"type": "ObjectProperty",
"value": {
"elements": [
{
"end": 218,
"raw": "1",
"start": 217,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
},
{
"end": 221,
"raw": "0",
"start": 220,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
},
{
"end": 224,
"raw": "0",
"start": 223,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
}
],
"end": 225,
"start": 216,
"type": "ArrayExpression",
"type": "ArrayExpression"
}
},
{
"end": 242,
"key": {
"end": 238,
"name": "instances",
"start": 229,
"type": "Identifier"
},
"start": 229,
"type": "ObjectProperty",
"value": {
"end": 242,
"raw": "7",
"start": 241,
"type": "Literal", "type": "Literal",
"type": "Literal", "type": "Literal",
"value": { "value": {
"value": 7.0, "value": 1.0,
"suffix": "None" "suffix": "None"
} }
}
},
{
"end": 258,
"key": {
"end": 254,
"name": "distance",
"start": 246,
"type": "Identifier"
}, },
"start": 246, {
"type": "ObjectProperty", "end": 237,
"value": { "raw": "0",
"end": 258, "start": 236,
"raw": "6",
"start": 257,
"type": "Literal", "type": "Literal",
"type": "Literal", "type": "Literal",
"value": { "value": {
"value": 6.0, "value": 0.0,
"suffix": "None"
}
},
{
"end": 240,
"raw": "0",
"start": 239,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None" "suffix": "None"
} }
} }
} ],
], "end": 241,
"start": 205, "start": 232,
"type": "ObjectExpression", "type": "ArrayExpression",
"type": "ObjectExpression" "type": "ArrayExpression"
}
}, },
{ {
"end": 275, "type": "LabeledArg",
"name": "exampleSketch", "label": {
"start": 262, "type": "Identifier",
"type": "Identifier", "name": "instances"
"type": "Identifier" },
"arg": {
"end": 258,
"raw": "7",
"start": 257,
"type": "Literal",
"type": "Literal",
"value": {
"value": 7.0,
"suffix": "None"
}
}
},
{
"type": "LabeledArg",
"label": {
"type": "Identifier",
"name": "distance"
},
"arg": {
"end": 274,
"raw": "6",
"start": 273,
"type": "Literal",
"type": "Literal",
"value": {
"value": 6.0,
"suffix": "None"
}
}
} }
], ],
"callee": { "callee": {
@ -448,15 +422,22 @@ description: Result of parsing circular_pattern3d_a_pattern.kcl
"start": 189, "start": 189,
"type": "Identifier" "type": "Identifier"
}, },
"end": 276, "end": 277,
"start": 189, "start": 189,
"type": "CallExpression", "type": "CallExpressionKw",
"type": "CallExpression" "type": "CallExpressionKw",
"unlabeled": {
"end": 221,
"name": "exampleSketch",
"start": 208,
"type": "Identifier",
"type": "Identifier"
}
}, },
"start": 180, "start": 180,
"type": "VariableDeclarator" "type": "VariableDeclarator"
}, },
"end": 276, "end": 277,
"kind": "const", "kind": "const",
"start": 180, "start": 180,
"type": "VariableDeclaration", "type": "VariableDeclaration",
@ -464,241 +445,213 @@ description: Result of parsing circular_pattern3d_a_pattern.kcl
}, },
{ {
"declaration": { "declaration": {
"end": 430, "end": 432,
"id": { "id": {
"end": 284, "end": 285,
"name": "pattn2", "name": "pattn2",
"start": 278, "start": 279,
"type": "Identifier" "type": "Identifier"
}, },
"init": { "init": {
"arguments": [ "arguments": [
{ {
"end": 421, "type": "LabeledArg",
"properties": [ "label": {
{ "type": "Identifier",
"end": 325, "name": "axis"
"key": { },
"end": 313, "arg": {
"name": "axis", "elements": [
"start": 309, {
"type": "Identifier" "end": 328,
}, "raw": "0",
"start": 309, "start": 327,
"type": "ObjectProperty",
"value": {
"elements": [
{
"end": 318,
"raw": "0",
"start": 317,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
},
{
"end": 321,
"raw": "0",
"start": 320,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
},
{
"end": 324,
"raw": "1",
"start": 323,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
}
],
"end": 325,
"start": 316,
"type": "ArrayExpression",
"type": "ArrayExpression"
}
},
{
"end": 353,
"key": {
"end": 335,
"name": "center",
"start": 329,
"type": "Identifier"
},
"start": 329,
"type": "ObjectProperty",
"value": {
"elements": [
{
"argument": {
"end": 342,
"raw": "20",
"start": 340,
"type": "Literal",
"type": "Literal",
"value": {
"value": 20.0,
"suffix": "None"
}
},
"end": 342,
"operator": "-",
"start": 339,
"type": "UnaryExpression",
"type": "UnaryExpression"
},
{
"argument": {
"end": 347,
"raw": "20",
"start": 345,
"type": "Literal",
"type": "Literal",
"value": {
"value": 20.0,
"suffix": "None"
}
},
"end": 347,
"operator": "-",
"start": 344,
"type": "UnaryExpression",
"type": "UnaryExpression"
},
{
"argument": {
"end": 352,
"raw": "20",
"start": 350,
"type": "Literal",
"type": "Literal",
"value": {
"value": 20.0,
"suffix": "None"
}
},
"end": 352,
"operator": "-",
"start": 349,
"type": "UnaryExpression",
"type": "UnaryExpression"
}
],
"end": 353,
"start": 338,
"type": "ArrayExpression",
"type": "ArrayExpression"
}
},
{
"end": 371,
"key": {
"end": 366,
"name": "instances",
"start": 357,
"type": "Identifier"
},
"start": 357,
"type": "ObjectProperty",
"value": {
"end": 371,
"raw": "41",
"start": 369,
"type": "Literal", "type": "Literal",
"type": "Literal", "type": "Literal",
"value": { "value": {
"value": 41.0, "value": 0.0,
"suffix": "None" "suffix": "None"
} }
}
},
{
"end": 391,
"key": {
"end": 385,
"name": "arcDegrees",
"start": 375,
"type": "Identifier"
}, },
"start": 375, {
"type": "ObjectProperty", "end": 331,
"value": { "raw": "0",
"end": 391, "start": 330,
"raw": "360",
"start": 388,
"type": "Literal", "type": "Literal",
"type": "Literal", "type": "Literal",
"value": { "value": {
"value": 360.0, "value": 0.0,
"suffix": "None"
}
},
{
"end": 334,
"raw": "1",
"start": 333,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None" "suffix": "None"
} }
} }
}, ],
{ "end": 335,
"end": 419, "start": 326,
"key": { "type": "ArrayExpression",
"end": 411, "type": "ArrayExpression"
"name": "rotateDuplicates", }
"start": 395,
"type": "Identifier"
},
"start": 395,
"type": "ObjectProperty",
"value": {
"end": 419,
"raw": "false",
"start": 414,
"type": "Literal",
"type": "Literal",
"value": false
}
}
],
"start": 305,
"type": "ObjectExpression",
"type": "ObjectExpression"
}, },
{ {
"end": 429, "type": "LabeledArg",
"name": "pattn1", "label": {
"start": 423, "type": "Identifier",
"type": "Identifier", "name": "center"
"type": "Identifier" },
"arg": {
"elements": [
{
"argument": {
"end": 352,
"raw": "20",
"start": 350,
"type": "Literal",
"type": "Literal",
"value": {
"value": 20.0,
"suffix": "None"
}
},
"end": 352,
"operator": "-",
"start": 349,
"type": "UnaryExpression",
"type": "UnaryExpression"
},
{
"argument": {
"end": 357,
"raw": "20",
"start": 355,
"type": "Literal",
"type": "Literal",
"value": {
"value": 20.0,
"suffix": "None"
}
},
"end": 357,
"operator": "-",
"start": 354,
"type": "UnaryExpression",
"type": "UnaryExpression"
},
{
"argument": {
"end": 362,
"raw": "20",
"start": 360,
"type": "Literal",
"type": "Literal",
"value": {
"value": 20.0,
"suffix": "None"
}
},
"end": 362,
"operator": "-",
"start": 359,
"type": "UnaryExpression",
"type": "UnaryExpression"
}
],
"end": 363,
"start": 348,
"type": "ArrayExpression",
"type": "ArrayExpression"
}
},
{
"type": "LabeledArg",
"label": {
"type": "Identifier",
"name": "instances"
},
"arg": {
"end": 381,
"raw": "41",
"start": 379,
"type": "Literal",
"type": "Literal",
"value": {
"value": 41.0,
"suffix": "None"
}
}
},
{
"type": "LabeledArg",
"label": {
"type": "Identifier",
"name": "arcDegrees"
},
"arg": {
"end": 401,
"raw": "360",
"start": 398,
"type": "Literal",
"type": "Literal",
"value": {
"value": 360.0,
"suffix": "None"
}
}
},
{
"type": "LabeledArg",
"label": {
"type": "Identifier",
"name": "rotateDuplicates"
},
"arg": {
"end": 429,
"raw": "false",
"start": 424,
"type": "Literal",
"type": "Literal",
"value": false
}
} }
], ],
"callee": { "callee": {
"end": 304, "end": 305,
"name": "patternCircular3d", "name": "patternCircular3d",
"start": 287, "start": 288,
"type": "Identifier" "type": "Identifier"
}, },
"end": 430, "end": 432,
"start": 287, "start": 288,
"type": "CallExpression", "type": "CallExpressionKw",
"type": "CallExpression" "type": "CallExpressionKw",
"unlabeled": {
"end": 315,
"name": "pattn1",
"start": 309,
"type": "Identifier",
"type": "Identifier"
}
}, },
"start": 278, "start": 279,
"type": "VariableDeclarator" "type": "VariableDeclarator"
}, },
"end": 430, "end": 432,
"kind": "const", "kind": "const",
"start": 278, "start": 279,
"type": "VariableDeclaration", "type": "VariableDeclaration",
"type": "VariableDeclaration" "type": "VariableDeclaration"
} }
], ],
"end": 431, "end": 433,
"nonCodeMeta": { "nonCodeMeta": {
"nonCodeNodes": { "nonCodeNodes": {
"0": [ "0": [
@ -713,8 +666,8 @@ description: Result of parsing circular_pattern3d_a_pattern.kcl
], ],
"1": [ "1": [
{ {
"end": 278, "end": 279,
"start": 276, "start": 277,
"type": "NonCodeNode", "type": "NonCodeNode",
"value": { "value": {
"type": "newLine" "type": "newLine"

View File

@ -6,16 +6,18 @@ exampleSketch = startSketchOn('XZ')
|> close(%) |> close(%)
|> extrude(length = 1) |> extrude(length = 1)
pattn1 = patternLinear3d({ pattn1 = patternLinear3d(
exampleSketch,
axis = [1, 0, 0], axis = [1, 0, 0],
instances = 7, instances = 7,
distance = 6 distance = 6,
}, exampleSketch) )
pattn2 = patternCircular3d({ pattn2 = patternCircular3d(
pattn1,
axis = [0, 0, 1], axis = [0, 0, 1],
center = [-20, -20, -20], center = [-20, -20, -20],
instances = 41, instances = 41,
arcDegrees = 360, arcDegrees = 360,
rotateDuplicates = false rotateDuplicates = false,
}, pattn1) )

View File

@ -44,17 +44,24 @@ snapshot_kind: text
}, },
{ {
"labeledArgs": { "labeledArgs": {
"data": { "axis": {
"sourceRange": [ "sourceRange": [
205, 232,
260, 241,
0 0
] ]
}, },
"solid_set": { "distance": {
"sourceRange": [ "sourceRange": [
262, 273,
275, 274,
0
]
},
"instances": {
"sourceRange": [
257,
258,
0 0
] ]
} }
@ -62,24 +69,51 @@ snapshot_kind: text
"name": "patternLinear3d", "name": "patternLinear3d",
"sourceRange": [ "sourceRange": [
189, 189,
276, 277,
0 0
], ],
"type": "StdLibCall", "type": "StdLibCall",
"unlabeledArg": null "unlabeledArg": {
"sourceRange": [
208,
221,
0
]
}
}, },
{ {
"labeledArgs": { "labeledArgs": {
"data": { "arcDegrees": {
"sourceRange": [ "sourceRange": [
305, 398,
421, 401,
0 0
] ]
}, },
"solid_set": { "axis": {
"sourceRange": [ "sourceRange": [
423, 326,
335,
0
]
},
"center": {
"sourceRange": [
348,
363,
0
]
},
"instances": {
"sourceRange": [
379,
381,
0
]
},
"rotateDuplicates": {
"sourceRange": [
424,
429, 429,
0 0
] ]
@ -87,11 +121,17 @@ snapshot_kind: text
}, },
"name": "patternCircular3d", "name": "patternCircular3d",
"sourceRange": [ "sourceRange": [
287, 288,
430, 432,
0 0
], ],
"type": "StdLibCall", "type": "StdLibCall",
"unlabeledArg": null "unlabeledArg": {
"sourceRange": [
309,
315,
0
]
}
} }
] ]

View File

@ -1,6 +1,7 @@
--- ---
source: kcl/src/simulation_tests.rs source: kcl/src/simulation_tests.rs
description: Artifact commands helix_simple.kcl description: Artifact commands helix_simple.kcl
snapshot_kind: text
--- ---
[ [
{ {
@ -383,7 +384,7 @@ description: Artifact commands helix_simple.kcl
"cmdId": "[uuid]", "cmdId": "[uuid]",
"range": [ "range": [
151, 151,
242, 257,
0 0
], ],
"command": { "command": {

View File

@ -5,7 +5,7 @@ flowchart LR
3["Segment<br>[102, 137, 0]"] 3["Segment<br>[102, 137, 0]"]
end end
1["Plane<br>[46, 65, 0]"] 1["Plane<br>[46, 65, 0]"]
4["Helix<br>[151, 242, 0]"] 4["Helix<br>[151, 257, 0]"]
1 --- 2 1 --- 2
2 --- 3 2 --- 3
3 <--x 4 3 <--x 4

View File

@ -1,6 +1,7 @@
--- ---
source: kcl/src/simulation_tests.rs source: kcl/src/simulation_tests.rs
description: Result of parsing helix_simple.kcl description: Result of parsing helix_simple.kcl
snapshot_kind: text
--- ---
{ {
"Ok": { "Ok": {
@ -171,7 +172,7 @@ description: Result of parsing helix_simple.kcl
}, },
{ {
"declaration": { "declaration": {
"end": 242, "end": 257,
"id": { "id": {
"end": 148, "end": 148,
"name": "helixPath", "name": "helixPath",
@ -187,9 +188,9 @@ description: Result of parsing helix_simple.kcl
"name": "angleStart" "name": "angleStart"
}, },
"arg": { "arg": {
"end": 171, "end": 174,
"raw": "0", "raw": "0",
"start": 170, "start": 173,
"type": "Literal", "type": "Literal",
"type": "Literal", "type": "Literal",
"value": { "value": {
@ -205,9 +206,9 @@ description: Result of parsing helix_simple.kcl
"name": "ccw" "name": "ccw"
}, },
"arg": { "arg": {
"end": 183, "end": 188,
"raw": "true", "raw": "true",
"start": 179, "start": 184,
"type": "Literal", "type": "Literal",
"type": "Literal", "type": "Literal",
"value": true "value": true
@ -220,9 +221,9 @@ description: Result of parsing helix_simple.kcl
"name": "revolutions" "name": "revolutions"
}, },
"arg": { "arg": {
"end": 200, "end": 207,
"raw": "5", "raw": "5",
"start": 199, "start": 206,
"type": "Literal", "type": "Literal",
"type": "Literal", "type": "Literal",
"value": { "value": {
@ -238,9 +239,9 @@ description: Result of parsing helix_simple.kcl
"name": "length" "name": "length"
}, },
"arg": { "arg": {
"end": 213, "end": 222,
"raw": "10", "raw": "10",
"start": 211, "start": 220,
"type": "Literal", "type": "Literal",
"type": "Literal", "type": "Literal",
"value": { "value": {
@ -256,9 +257,9 @@ description: Result of parsing helix_simple.kcl
"name": "radius" "name": "radius"
}, },
"arg": { "arg": {
"end": 225, "end": 236,
"raw": "5", "raw": "5",
"start": 224, "start": 235,
"type": "Literal", "type": "Literal",
"type": "Literal", "type": "Literal",
"value": { "value": {
@ -274,9 +275,9 @@ description: Result of parsing helix_simple.kcl
"name": "axis" "name": "axis"
}, },
"arg": { "arg": {
"end": 241, "end": 254,
"name": "edge001", "name": "edge001",
"start": 234, "start": 247,
"type": "Identifier", "type": "Identifier",
"type": "Identifier" "type": "Identifier"
} }
@ -288,7 +289,7 @@ description: Result of parsing helix_simple.kcl
"start": 151, "start": 151,
"type": "Identifier" "type": "Identifier"
}, },
"end": 242, "end": 257,
"start": 151, "start": 151,
"type": "CallExpressionKw", "type": "CallExpressionKw",
"type": "CallExpressionKw", "type": "CallExpressionKw",
@ -297,14 +298,14 @@ description: Result of parsing helix_simple.kcl
"start": 139, "start": 139,
"type": "VariableDeclarator" "type": "VariableDeclarator"
}, },
"end": 242, "end": 257,
"kind": "const", "kind": "const",
"start": 139, "start": 139,
"type": "VariableDeclaration", "type": "VariableDeclaration",
"type": "VariableDeclaration" "type": "VariableDeclaration"
} }
], ],
"end": 243, "end": 258,
"nonCodeMeta": { "nonCodeMeta": {
"nonCodeNodes": { "nonCodeNodes": {
"0": [ "0": [

View File

@ -3,4 +3,11 @@ helper001 = startSketchOn('XZ')
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line(end = [0, 10], tag = $edge001) |> line(end = [0, 10], tag = $edge001)
helixPath = helix(angleStart = 0, ccw = true, revolutions = 5, length = 10, radius = 5, axis = edge001) helixPath = helix(
angleStart = 0,
ccw = true,
revolutions = 5,
length = 10,
radius = 5,
axis = edge001,
)

View File

@ -1,6 +1,7 @@
--- ---
source: kcl/src/simulation_tests.rs source: kcl/src/simulation_tests.rs
description: Operations executed helix_simple.kcl description: Operations executed helix_simple.kcl
snapshot_kind: text
--- ---
[ [
{ {
@ -26,43 +27,43 @@ description: Operations executed helix_simple.kcl
"labeledArgs": { "labeledArgs": {
"angleStart": { "angleStart": {
"sourceRange": [ "sourceRange": [
170, 173,
171, 174,
0 0
] ]
}, },
"axis": { "axis": {
"sourceRange": [ "sourceRange": [
234, 247,
241, 254,
0 0
] ]
}, },
"ccw": { "ccw": {
"sourceRange": [ "sourceRange": [
179, 184,
183, 188,
0 0
] ]
}, },
"length": { "length": {
"sourceRange": [ "sourceRange": [
211, 220,
213, 222,
0 0
] ]
}, },
"radius": { "radius": {
"sourceRange": [ "sourceRange": [
224, 235,
225, 236,
0 0
] ]
}, },
"revolutions": { "revolutions": {
"sourceRange": [ "sourceRange": [
199, 206,
200, 207,
0 0
] ]
} }
@ -70,7 +71,7 @@ description: Operations executed helix_simple.kcl
"name": "helix", "name": "helix",
"sourceRange": [ "sourceRange": [
151, 151,
242, 257,
0 0
], ],
"type": "StdLibCall", "type": "StdLibCall",

View File

@ -1,6 +1,7 @@
--- ---
source: kcl/src/simulation_tests.rs source: kcl/src/simulation_tests.rs
description: Program memory after executing helix_simple.kcl description: Program memory after executing helix_simple.kcl
snapshot_kind: text
--- ---
{ {
"environments": [ "environments": [
@ -86,7 +87,7 @@ description: Program memory after executing helix_simple.kcl
{ {
"sourceRange": [ "sourceRange": [
151, 151,
242, 257,
0 0
] ]
} }

View File

@ -631,7 +631,7 @@ snapshot_kind: text
"cmdId": "[uuid]", "cmdId": "[uuid]",
"range": [ "range": [
189, 189,
276, 277,
0 0
], ],
"command": { "command": {
@ -819,8 +819,8 @@ snapshot_kind: text
{ {
"cmdId": "[uuid]", "cmdId": "[uuid]",
"range": [ "range": [
287, 288,
367, 369,
0 0
], ],
"command": { "command": {
@ -1008,8 +1008,8 @@ snapshot_kind: text
{ {
"cmdId": "[uuid]", "cmdId": "[uuid]",
"range": [ "range": [
287, 288,
367, 369,
0 0
], ],
"command": { "command": {
@ -1197,8 +1197,8 @@ snapshot_kind: text
{ {
"cmdId": "[uuid]", "cmdId": "[uuid]",
"range": [ "range": [
287, 288,
367, 369,
0 0
], ],
"command": { "command": {
@ -1386,8 +1386,8 @@ snapshot_kind: text
{ {
"cmdId": "[uuid]", "cmdId": "[uuid]",
"range": [ "range": [
287, 288,
367, 369,
0 0
], ],
"command": { "command": {
@ -1575,8 +1575,8 @@ snapshot_kind: text
{ {
"cmdId": "[uuid]", "cmdId": "[uuid]",
"range": [ "range": [
287, 288,
367, 369,
0 0
], ],
"command": { "command": {
@ -1764,8 +1764,8 @@ snapshot_kind: text
{ {
"cmdId": "[uuid]", "cmdId": "[uuid]",
"range": [ "range": [
287, 288,
367, 369,
0 0
], ],
"command": { "command": {
@ -1953,8 +1953,8 @@ snapshot_kind: text
{ {
"cmdId": "[uuid]", "cmdId": "[uuid]",
"range": [ "range": [
287, 288,
367, 369,
0 0
], ],
"command": { "command": {

View File

@ -1,6 +1,7 @@
--- ---
source: kcl/src/simulation_tests.rs source: kcl/src/simulation_tests.rs
description: Result of parsing linear_pattern3d_a_pattern.kcl description: Result of parsing linear_pattern3d_a_pattern.kcl
snapshot_kind: text
--- ---
{ {
"Ok": { "Ok": {
@ -321,7 +322,7 @@ description: Result of parsing linear_pattern3d_a_pattern.kcl
}, },
{ {
"declaration": { "declaration": {
"end": 276, "end": 277,
"id": { "id": {
"end": 186, "end": 186,
"name": "pattn1", "name": "pattn1",
@ -331,115 +332,88 @@ description: Result of parsing linear_pattern3d_a_pattern.kcl
"init": { "init": {
"arguments": [ "arguments": [
{ {
"end": 260, "type": "LabeledArg",
"properties": [ "label": {
{ "type": "Identifier",
"end": 225, "name": "axis"
"key": { },
"end": 213, "arg": {
"name": "axis", "elements": [
"start": 209, {
"type": "Identifier" "end": 234,
}, "raw": "1",
"start": 209, "start": 233,
"type": "ObjectProperty",
"value": {
"elements": [
{
"end": 218,
"raw": "1",
"start": 217,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
},
{
"end": 221,
"raw": "0",
"start": 220,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
},
{
"end": 224,
"raw": "0",
"start": 223,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
}
],
"end": 225,
"start": 216,
"type": "ArrayExpression",
"type": "ArrayExpression"
}
},
{
"end": 242,
"key": {
"end": 238,
"name": "instances",
"start": 229,
"type": "Identifier"
},
"start": 229,
"type": "ObjectProperty",
"value": {
"end": 242,
"raw": "7",
"start": 241,
"type": "Literal", "type": "Literal",
"type": "Literal", "type": "Literal",
"value": { "value": {
"value": 7.0, "value": 1.0,
"suffix": "None" "suffix": "None"
} }
}
},
{
"end": 258,
"key": {
"end": 254,
"name": "distance",
"start": 246,
"type": "Identifier"
}, },
"start": 246, {
"type": "ObjectProperty", "end": 237,
"value": { "raw": "0",
"end": 258, "start": 236,
"raw": "6",
"start": 257,
"type": "Literal", "type": "Literal",
"type": "Literal", "type": "Literal",
"value": { "value": {
"value": 6.0, "value": 0.0,
"suffix": "None"
}
},
{
"end": 240,
"raw": "0",
"start": 239,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None" "suffix": "None"
} }
} }
} ],
], "end": 241,
"start": 205, "start": 232,
"type": "ObjectExpression", "type": "ArrayExpression",
"type": "ObjectExpression" "type": "ArrayExpression"
}
}, },
{ {
"end": 275, "type": "LabeledArg",
"name": "exampleSketch", "label": {
"start": 262, "type": "Identifier",
"type": "Identifier", "name": "instances"
"type": "Identifier" },
"arg": {
"end": 258,
"raw": "7",
"start": 257,
"type": "Literal",
"type": "Literal",
"value": {
"value": 7.0,
"suffix": "None"
}
}
},
{
"type": "LabeledArg",
"label": {
"type": "Identifier",
"name": "distance"
},
"arg": {
"end": 274,
"raw": "6",
"start": 273,
"type": "Literal",
"type": "Literal",
"value": {
"value": 6.0,
"suffix": "None"
}
}
} }
], ],
"callee": { "callee": {
@ -448,15 +422,22 @@ description: Result of parsing linear_pattern3d_a_pattern.kcl
"start": 189, "start": 189,
"type": "Identifier" "type": "Identifier"
}, },
"end": 276, "end": 277,
"start": 189, "start": 189,
"type": "CallExpression", "type": "CallExpressionKw",
"type": "CallExpression" "type": "CallExpressionKw",
"unlabeled": {
"end": 221,
"name": "exampleSketch",
"start": 208,
"type": "Identifier",
"type": "Identifier"
}
}, },
"start": 180, "start": 180,
"type": "VariableDeclarator" "type": "VariableDeclarator"
}, },
"end": 276, "end": 277,
"kind": "const", "kind": "const",
"start": 180, "start": 180,
"type": "VariableDeclaration", "type": "VariableDeclaration",
@ -464,84 +445,49 @@ description: Result of parsing linear_pattern3d_a_pattern.kcl
}, },
{ {
"declaration": { "declaration": {
"end": 367, "end": 369,
"id": { "id": {
"end": 284, "end": 285,
"name": "pattn2", "name": "pattn2",
"start": 278, "start": 279,
"type": "Identifier" "type": "Identifier"
}, },
"init": { "init": {
"arguments": [ "arguments": [
{ {
"end": 358, "type": "LabeledArg",
"properties": [ "label": {
{ "type": "Identifier",
"end": 323, "name": "axis"
"key": { },
"end": 311, "arg": {
"name": "axis", "elements": [
"start": 307, {
"type": "Identifier" "end": 326,
"raw": "0",
"start": 325,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
}, },
"start": 307, {
"type": "ObjectProperty", "end": 329,
"value": { "raw": "0",
"elements": [ "start": 328,
{ "type": "Literal",
"end": 316, "type": "Literal",
"raw": "0", "value": {
"start": 315, "value": 0.0,
"type": "Literal", "suffix": "None"
"type": "Literal", }
"value": {
"value": 0.0,
"suffix": "None"
}
},
{
"end": 319,
"raw": "0",
"start": 318,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
},
{
"end": 322,
"raw": "1",
"start": 321,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
}
],
"end": 323,
"start": 314,
"type": "ArrayExpression",
"type": "ArrayExpression"
}
},
{
"end": 339,
"key": {
"end": 335,
"name": "distance",
"start": 327,
"type": "Identifier"
}, },
"start": 327, {
"type": "ObjectProperty", "end": 332,
"value": {
"end": 339,
"raw": "1", "raw": "1",
"start": 338, "start": 331,
"type": "Literal", "type": "Literal",
"type": "Literal", "type": "Literal",
"value": { "value": {
@ -549,64 +495,79 @@ description: Result of parsing linear_pattern3d_a_pattern.kcl
"suffix": "None" "suffix": "None"
} }
} }
}, ],
{ "end": 333,
"end": 356, "start": 324,
"key": { "type": "ArrayExpression",
"end": 352, "type": "ArrayExpression"
"name": "instances", }
"start": 343,
"type": "Identifier"
},
"start": 343,
"type": "ObjectProperty",
"value": {
"end": 356,
"raw": "7",
"start": 355,
"type": "Literal",
"type": "Literal",
"value": {
"value": 7.0,
"suffix": "None"
}
}
}
],
"start": 303,
"type": "ObjectExpression",
"type": "ObjectExpression"
}, },
{ {
"end": 366, "type": "LabeledArg",
"name": "pattn1", "label": {
"start": 360, "type": "Identifier",
"type": "Identifier", "name": "distance"
"type": "Identifier" },
"arg": {
"end": 349,
"raw": "1",
"start": 348,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
}
},
{
"type": "LabeledArg",
"label": {
"type": "Identifier",
"name": "instances"
},
"arg": {
"end": 366,
"raw": "7",
"start": 365,
"type": "Literal",
"type": "Literal",
"value": {
"value": 7.0,
"suffix": "None"
}
}
} }
], ],
"callee": { "callee": {
"end": 302, "end": 303,
"name": "patternLinear3d", "name": "patternLinear3d",
"start": 287, "start": 288,
"type": "Identifier" "type": "Identifier"
}, },
"end": 367, "end": 369,
"start": 287, "start": 288,
"type": "CallExpression", "type": "CallExpressionKw",
"type": "CallExpression" "type": "CallExpressionKw",
"unlabeled": {
"end": 313,
"name": "pattn1",
"start": 307,
"type": "Identifier",
"type": "Identifier"
}
}, },
"start": 278, "start": 279,
"type": "VariableDeclarator" "type": "VariableDeclarator"
}, },
"end": 367, "end": 369,
"kind": "const", "kind": "const",
"start": 278, "start": 279,
"type": "VariableDeclaration", "type": "VariableDeclaration",
"type": "VariableDeclaration" "type": "VariableDeclaration"
} }
], ],
"end": 368, "end": 370,
"nonCodeMeta": { "nonCodeMeta": {
"nonCodeNodes": { "nonCodeNodes": {
"0": [ "0": [
@ -621,8 +582,8 @@ description: Result of parsing linear_pattern3d_a_pattern.kcl
], ],
"1": [ "1": [
{ {
"end": 278, "end": 279,
"start": 276, "start": 277,
"type": "NonCodeNode", "type": "NonCodeNode",
"value": { "value": {
"type": "newLine" "type": "newLine"

View File

@ -6,14 +6,16 @@ exampleSketch = startSketchOn('XZ')
|> close(%) |> close(%)
|> extrude(length = 1) |> extrude(length = 1)
pattn1 = patternLinear3d({ pattn1 = patternLinear3d(
exampleSketch,
axis = [1, 0, 0], axis = [1, 0, 0],
instances = 7, instances = 7,
distance = 6 distance = 6,
}, exampleSketch) )
pattn2 = patternLinear3d({ pattn2 = patternLinear3d(
pattn1,
axis = [0, 0, 1], axis = [0, 0, 1],
distance = 1, distance = 1,
instances = 7 instances = 7,
}, pattn1) )

View File

@ -44,17 +44,24 @@ snapshot_kind: text
}, },
{ {
"labeledArgs": { "labeledArgs": {
"data": { "axis": {
"sourceRange": [ "sourceRange": [
205, 232,
260, 241,
0 0
] ]
}, },
"solid_set": { "distance": {
"sourceRange": [ "sourceRange": [
262, 273,
275, 274,
0
]
},
"instances": {
"sourceRange": [
257,
258,
0 0
] ]
} }
@ -62,24 +69,37 @@ snapshot_kind: text
"name": "patternLinear3d", "name": "patternLinear3d",
"sourceRange": [ "sourceRange": [
189, 189,
276, 277,
0 0
], ],
"type": "StdLibCall", "type": "StdLibCall",
"unlabeledArg": null "unlabeledArg": {
"sourceRange": [
208,
221,
0
]
}
}, },
{ {
"labeledArgs": { "labeledArgs": {
"data": { "axis": {
"sourceRange": [ "sourceRange": [
303, 324,
358, 333,
0 0
] ]
}, },
"solid_set": { "distance": {
"sourceRange": [ "sourceRange": [
360, 348,
349,
0
]
},
"instances": {
"sourceRange": [
365,
366, 366,
0 0
] ]
@ -87,11 +107,17 @@ snapshot_kind: text
}, },
"name": "patternLinear3d", "name": "patternLinear3d",
"sourceRange": [ "sourceRange": [
287, 288,
367, 369,
0 0
], ],
"type": "StdLibCall", "type": "StdLibCall",
"unlabeledArg": null "unlabeledArg": {
"sourceRange": [
307,
313,
0
]
}
} }
] ]

View File

@ -1,6 +1,7 @@
--- ---
source: kcl/src/simulation_tests.rs source: kcl/src/simulation_tests.rs
description: Result of parsing sketch-on-chamfer-two-times-different-order.kcl description: Result of parsing sketch-on-chamfer-two-times-different-order.kcl
snapshot_kind: text
--- ---
{ {
"Ok": { "Ok": {

View File

@ -1,6 +1,7 @@
--- ---
source: kcl/src/simulation_tests.rs source: kcl/src/simulation_tests.rs
description: Result of parsing sketch-on-chamfer-two-times.kcl description: Result of parsing sketch-on-chamfer-two-times.kcl
snapshot_kind: text
--- ---
{ {
"Ok": { "Ok": {

View File

@ -1,6 +1,7 @@
--- ---
source: kcl/src/simulation_tests.rs source: kcl/src/simulation_tests.rs
description: Result of parsing sketch_on_face_after_fillets_referencing_face.kcl description: Result of parsing sketch_on_face_after_fillets_referencing_face.kcl
snapshot_kind: text
--- ---
{ {
"Ok": { "Ok": {

View File

@ -6,10 +6,18 @@ exampleSketch = startSketchOn('XZ')
|> close() |> close()
|> extrude(length = 1) |> extrude(length = 1)
pattn1 = patternLinear3d({ pattn1 = patternLinear3d(
axis: [1, 0, 0], exampleSketch,
instances: 7, axis = [1, 0, 0],
distance: 6 instances = 7,
}, exampleSketch) distance = 6,
)
pattn2 = patternCircular3d({axis: [0,0, 1], center: [-20, -20, -20], instances: 41, arcDegrees: 360, rotateDuplicates: false}, pattn1) pattn2 = patternCircular3d(
pattn1,
axis = [0,0, 1],
center = [-20, -20, -20],
instances = 41,
arcDegrees = 360,
rotateDuplicates = false,
)

View File

@ -95,11 +95,11 @@ const tabsR = startSketchOn(tabPlane)
getNextAdjacentEdge(edge13) getNextAdjacentEdge(edge13)
] ]
}, %) }, %)
|> patternLinear3d({ |> patternLinear3d(
axis: [0, -1, 0], axis = [0, -1, 0],
instances: 2, instances = 2,
distance: length + 2 * thk - (tabLength * 4 / 3) distance = length + 2 * thk - (tabLength * 4 / 3)
}, %) )
// build the tabs of the mounting bracket (left side) // build the tabs of the mounting bracket (left side)
const tabsL = startSketchOn(tabPlane) const tabsL = startSketchOn(tabPlane)
@ -123,11 +123,11 @@ const tabsL = startSketchOn(tabPlane)
getNextAdjacentEdge(edge22) getNextAdjacentEdge(edge22)
] ]
}, %) }, %)
|> patternLinear3d({ |> patternLinear3d(
axis: [0, -1, 0], axis = [0, -1, 0],
instances: 2, instances = 2,
distance: length + 2 * thk - (tabLength * 4 / 3) distance = length + 2 * thk - (tabLength * 4 / 3)
}, %) )
// define a plane for retention bumps // define a plane for retention bumps
const retPlane = { const retPlane = {

View File

@ -95,11 +95,11 @@ const tabsR = startSketchOn(tabPlane)
getNextAdjacentEdge(edge11) getNextAdjacentEdge(edge11)
] ]
}, %) }, %)
|> patternLinear3d({ |> patternLinear3d(
axis: [0, -1, 0], axis = [0, -1, 0],
instances: 2, instances = 2,
distance: length + 2 * thk - (tabLength * 4 / 3) distance = length + 2 * thk - (tabLength * 4 / 3)
}, %) )
// build the tabs of the mounting bracket (left side) // build the tabs of the mounting bracket (left side)
const tabsL = startSketchOn(tabPlane) const tabsL = startSketchOn(tabPlane)
@ -123,11 +123,11 @@ const tabsL = startSketchOn(tabPlane)
getNextAdjacentEdge(edge22) getNextAdjacentEdge(edge22)
] ]
}, %) }, %)
|> patternLinear3d({ |> patternLinear3d(
axis: [0, -1, 0], axis = [0, -1, 0],
instances: 2, instances = 2,
distance: length + 2 * thk - (tabLength * 4 / 3) distance = length + 2 * thk - (tabLength * 4 / 3)
}, %) )
// define a plane for retention bumps // define a plane for retention bumps
const retPlane = { const retPlane = {

View File

@ -43,14 +43,14 @@ const peg = startSketchOn(s, "end")
-(total_width / 2 - wSegments), -(total_width / 2 - wSegments),
-(total_length / 2 - lSegments) -(total_length / 2 - lSegments)
], radius: bumpDiam / 2 }, %) ], radius: bumpDiam / 2 }, %)
|> patternLinear2d({ |> patternLinear2d(
axis: [1, 0], axis = [1, 0],
instances: 6, instances = 6,
distance: 7 distance = 7
}, %) )
|> patternLinear2d({ |> patternLinear2d(
axis: [0, 1], axis = [0, 1],
instances: 10, instances = 10,
distance: 7 distance = 7
}, %) )
|> extrude(length = bumpHeight) |> extrude(length = bumpHeight)

View File

@ -6,14 +6,16 @@ exampleSketch = startSketchOn('XZ')
|> close() |> close()
|> extrude(length = 1) |> extrude(length = 1)
pattn1 = patternLinear3d({ pattn1 = patternLinear3d(
axis: [1, 0, 0], exampleSketch,
instances: 7, axis = [1, 0, 0],
distance: 6 instances = 7,
}, exampleSketch) distance = 6
)
pattn2 = patternLinear3d({ pattn2 = patternLinear3d(
axis: [0, 0, 1], pattn1,
distance: 1, axis = [0, 0, 1],
instances: 7 distance = 1,
}, pattn1) instances = 7
)

View File

@ -710,11 +710,11 @@ const sketch004fl = startSketchOn(extrude002fl, 'START')
], %, $rectangleSegmentC003fl) ], %, $rectangleSegmentC003fl)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, 1], axis = [0, 1],
instances: railHeight, instances = railHeight,
distance: 0.62 + 0.62 + 0.5 distance = 0.62 + 0.62 + 0.5
}, %) )
const extrude004fl = extrude(sketch004fl, length = -thickness) const extrude004fl = extrude(sketch004fl, length = -thickness)
// EIA-310-D standard hole pattern // EIA-310-D standard hole pattern
@ -731,11 +731,11 @@ const sketch005fl = startSketchOn(extrude002fl, 'START')
], %, $rectangleSegmentC004fl) ], %, $rectangleSegmentC004fl)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, 1], axis = [0, 1],
instances: railHeight, instances = railHeight,
distance: 0.62 + 0.62 + 0.5 distance = 0.62 + 0.62 + 0.5
}, %) )
const extrude005fl = extrude(sketch005fl, length = -thickness) const extrude005fl = extrude(sketch005fl, length = -thickness)
// EIA-310-D standard hole pattern // EIA-310-D standard hole pattern
@ -755,11 +755,11 @@ const sketch006fl = startSketchOn(extrude002fl, 'START')
], %, $rectangleSegmentC005fl) ], %, $rectangleSegmentC005fl)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, 1], axis = [0, 1],
instances: railHeight, instances = railHeight,
distance: 0.62 + 0.62 + 0.5 distance = 0.62 + 0.62 + 0.5
}, %) )
const extrude006fl = extrude(sketch006fl, length = -thickness) const extrude006fl = extrude(sketch006fl, length = -thickness)
// EIA-310-D standard hole pattern // EIA-310-D standard hole pattern
@ -776,11 +776,11 @@ const sketch007fl = startSketchOn(extrude001fl, 'START')
], %, $rectangleSegmentC006fl) ], %, $rectangleSegmentC006fl)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, 1], axis = [0, 1],
instances: railHeight, instances = railHeight,
distance: 0.62 + 0.62 + 0.5 distance = 0.62 + 0.62 + 0.5
}, %) )
const extrude007fl = extrude(sketch007fl, length = -thickness) const extrude007fl = extrude(sketch007fl, length = -thickness)
// EIA-310-D standard hole pattern // EIA-310-D standard hole pattern
@ -797,11 +797,11 @@ const sketch008fl = startSketchOn(extrude001fl, 'START')
], %, $rectangleSegmentC007fl) ], %, $rectangleSegmentC007fl)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, 1], axis = [0, 1],
instances: railHeight, instances = railHeight,
distance: 0.62 + 0.62 + 0.5 distance = 0.62 + 0.62 + 0.5
}, %) )
const extrude008fl = extrude(sketch008fl, length = -thickness) const extrude008fl = extrude(sketch008fl, length = -thickness)
// EIA-310-D standard hole pattern // EIA-310-D standard hole pattern
@ -821,11 +821,11 @@ const sketch009fl = startSketchOn(extrude001fl, 'START')
], %, $rectangleSegmentC008fl) ], %, $rectangleSegmentC008fl)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, 1], axis = [0, 1],
instances: railHeight, instances = railHeight,
distance: 0.62 + 0.62 + 0.5 distance = 0.62 + 0.62 + 0.5
}, %) )
const extrude009fl = extrude(sketch009fl, length = -thickness) const extrude009fl = extrude(sketch009fl, length = -thickness)
// define slots // define slots
@ -839,11 +839,11 @@ const sketch010fl = startSketchOn(extrude001fl, 'START')
|> xLine(-0.75 + .438, %) |> xLine(-0.75 + .438, %)
|> tangentialArcTo([profileStartX(%), profileStartY(%)], %) |> tangentialArcTo([profileStartX(%), profileStartY(%)], %)
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, 1], axis = [0, 1],
instances: 2, instances = 2,
distance: 1.22 distance = 1.22
}, %) )
const extrude010fl = extrude(sketch010fl, length = -thickness) const extrude010fl = extrude(sketch010fl, length = -thickness)
// define slots // define slots
@ -877,11 +877,11 @@ const sketch012fl = startSketchOn(extrude001fl, 'START')
|> xLine(-0.75 + .438, %) |> xLine(-0.75 + .438, %)
|> tangentialArcTo([profileStartX(%), profileStartY(%)], %) |> tangentialArcTo([profileStartX(%), profileStartY(%)], %)
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, -1], axis = [0, -1],
instances: 2, instances = 2,
distance: 1.22 distance = 1.22
}, %) )
const extrude012fl = extrude(sketch012fl, length = -thickness) const extrude012fl = extrude(sketch012fl, length = -thickness)
// FRONT RIGHT VERTICAL RAIL // FRONT RIGHT VERTICAL RAIL
@ -992,11 +992,11 @@ const sketch004fr = startSketchOn(extrude002fr, 'START')
], %, $rectangleSegmentC003fr) ], %, $rectangleSegmentC003fr)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, 1], axis = [0, 1],
instances: railHeight, instances = railHeight,
distance: 0.62 + 0.62 + 0.5 distance = 0.62 + 0.62 + 0.5
}, %) )
const extrude004fr = extrude(sketch004fr, length = -thickness) const extrude004fr = extrude(sketch004fr, length = -thickness)
// EIA-310-D standard hole pattern // EIA-310-D standard hole pattern
@ -1016,11 +1016,11 @@ const sketch005fr = startSketchOn(extrude002fr, 'START')
], %, $rectangleSegmentC004fr) ], %, $rectangleSegmentC004fr)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, 1], axis = [0, 1],
instances: railHeight, instances = railHeight,
distance: 0.62 + 0.62 + 0.5 distance = 0.62 + 0.62 + 0.5
}, %) )
const extrude005fr = extrude(sketch005fr, length = -thickness) const extrude005fr = extrude(sketch005fr, length = -thickness)
// EIA-310-D standard hole pattern // EIA-310-D standard hole pattern
@ -1040,11 +1040,11 @@ const sketch006fr = startSketchOn(extrude002fr, 'START')
], %, $rectangleSegmentC005fr) ], %, $rectangleSegmentC005fr)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, 1], axis = [0, 1],
instances: railHeight, instances = railHeight,
distance: 0.62 + 0.62 + 0.5 distance = 0.62 + 0.62 + 0.5
}, %) )
const extrude006fr = extrude(sketch006fr, length = -thickness) const extrude006fr = extrude(sketch006fr, length = -thickness)
// EIA-310-D standard hole pattern // EIA-310-D standard hole pattern
@ -1064,11 +1064,11 @@ const sketch007fr = startSketchOn(extrude001fr, 'START')
], %, $rectangleSegmentC006fr) ], %, $rectangleSegmentC006fr)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, 1], axis = [0, 1],
instances: railHeight, instances = railHeight,
distance: 0.62 + 0.62 + 0.5 distance = 0.62 + 0.62 + 0.5
}, %) )
const extrude007fr = extrude(sketch007fr, length = -thickness) const extrude007fr = extrude(sketch007fr, length = -thickness)
// EIA-310-D standard hole pattern // EIA-310-D standard hole pattern
@ -1088,11 +1088,11 @@ const sketch008fr = startSketchOn(extrude001fr, 'START')
], %, $rectangleSegmentC007fr) ], %, $rectangleSegmentC007fr)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, 1], axis = [0, 1],
instances: railHeight, instances = railHeight,
distance: 0.62 + 0.62 + 0.5 distance = 0.62 + 0.62 + 0.5
}, %) )
const extrude008fr = extrude(sketch008fr, length = -thickness) const extrude008fr = extrude(sketch008fr, length = -thickness)
// EIA-310-D standard hole pattern // EIA-310-D standard hole pattern
@ -1112,11 +1112,11 @@ const sketch009fr = startSketchOn(extrude001fr, 'START')
], %, $rectangleSegmentC008fr) ], %, $rectangleSegmentC008fr)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, 1], axis = [0, 1],
instances: railHeight, instances = railHeight,
distance: 0.62 + 0.62 + 0.5 distance = 0.62 + 0.62 + 0.5
}, %) )
const extrude009fr = extrude(sketch009fr, length = -thickness) const extrude009fr = extrude(sketch009fr, length = -thickness)
// define slots // define slots
@ -1133,11 +1133,11 @@ const sketch010fr = startSketchOn(extrude001fr, 'START')
|> xLine(-0.75 + .438, %) |> xLine(-0.75 + .438, %)
|> tangentialArcTo([profileStartX(%), profileStartY(%)], %) |> tangentialArcTo([profileStartX(%), profileStartY(%)], %)
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, 1], axis = [0, 1],
instances: 2, instances = 2,
distance: 1.22 distance = 1.22
}, %) )
const extrude010fr = extrude(sketch010fr, length = -thickness) const extrude010fr = extrude(sketch010fr, length = -thickness)
// define slots // define slots
@ -1171,11 +1171,11 @@ const sketch012fr = startSketchOn(extrude001fr, 'START')
|> xLine(-0.75 + .438, %) |> xLine(-0.75 + .438, %)
|> tangentialArcTo([profileStartX(%), profileStartY(%)], %) |> tangentialArcTo([profileStartX(%), profileStartY(%)], %)
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, -1], axis = [0, -1],
instances: 2, instances = 2,
distance: 1.22 distance = 1.22
}, %) )
const extrude012fr = extrude(sketch012fr, length = -thickness) const extrude012fr = extrude(sketch012fr, length = -thickness)
// RIGHT REAR VERTICAL RAIL // RIGHT REAR VERTICAL RAIL
@ -1286,11 +1286,11 @@ const sketch004rr = startSketchOn(extrude002rr, 'START')
], %, $rectangleSegmentC003rr) ], %, $rectangleSegmentC003rr)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, 1], axis = [0, 1],
instances: railHeight, instances = railHeight,
distance: 0.62 + 0.62 + 0.5 distance = 0.62 + 0.62 + 0.5
}, %) )
const extrude004rr = extrude(sketch004rr, length = -thickness) const extrude004rr = extrude(sketch004rr, length = -thickness)
// EIA-310-D standard hole pattern // EIA-310-D standard hole pattern
@ -1310,11 +1310,11 @@ const sketch005rr = startSketchOn(extrude002rr, 'START')
], %, $rectangleSegmentC004rr) ], %, $rectangleSegmentC004rr)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, 1], axis = [0, 1],
instances: railHeight, instances = railHeight,
distance: 0.62 + 0.62 + 0.5 distance = 0.62 + 0.62 + 0.5
}, %) )
const extrude005rr = extrude(sketch005rr, length = -thickness) const extrude005rr = extrude(sketch005rr, length = -thickness)
// EIA-310-D standard hole pattern // EIA-310-D standard hole pattern
@ -1334,11 +1334,11 @@ const sketch006rr = startSketchOn(extrude002rr, 'START')
], %, $rectangleSegmentC005rr) ], %, $rectangleSegmentC005rr)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, 1], axis = [0, 1],
instances: railHeight, instances = railHeight,
distance: 0.62 + 0.62 + 0.5 distance = 0.62 + 0.62 + 0.5
}, %) )
const extrude006rr = extrude(sketch006rr, length = -thickness) const extrude006rr = extrude(sketch006rr, length = -thickness)
// EIA-310-D standard hole pattern // EIA-310-D standard hole pattern
@ -1358,11 +1358,11 @@ const sketch007rr = startSketchOn(extrude001rr, 'START')
], %, $rectangleSegmentC006rr) ], %, $rectangleSegmentC006rr)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, 1], axis = [0, 1],
instances: railHeight, instances = railHeight,
distance: 0.62 + 0.62 + 0.5 distance = 0.62 + 0.62 + 0.5
}, %) )
const extrude007rr = extrude(sketch007rr, length = -thickness) const extrude007rr = extrude(sketch007rr, length = -thickness)
// EIA-310-D standard hole pattern // EIA-310-D standard hole pattern
@ -1382,11 +1382,11 @@ const sketch008rr = startSketchOn(extrude001rr, 'START')
], %, $rectangleSegmentC007rr) ], %, $rectangleSegmentC007rr)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, 1], axis = [0, 1],
instances: railHeight, instances = railHeight,
distance: 0.62 + 0.62 + 0.5 distance = 0.62 + 0.62 + 0.5
}, %) )
const extrude008rr = extrude(sketch008rr, length = -thickness) const extrude008rr = extrude(sketch008rr, length = -thickness)
// EIA-310-D standard hole pattern // EIA-310-D standard hole pattern
@ -1406,11 +1406,11 @@ const sketch009rr = startSketchOn(extrude001rr, 'START')
], %, $rectangleSegmentC008rr) ], %, $rectangleSegmentC008rr)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, 1], axis = [0, 1],
instances: railHeight, instances = railHeight,
distance: 0.62 + 0.62 + 0.5 distance = 0.62 + 0.62 + 0.5
}, %) )
const extrude009rr = extrude(sketch009rr, length = -thickness) const extrude009rr = extrude(sketch009rr, length = -thickness)
// define slots // define slots
@ -1427,11 +1427,11 @@ const sketch010rr = startSketchOn(extrude001rr, 'START')
|> xLine(-0.75 + .438, %) |> xLine(-0.75 + .438, %)
|> tangentialArcTo([profileStartX(%), profileStartY(%)], %) |> tangentialArcTo([profileStartX(%), profileStartY(%)], %)
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, 1], axis = [0, 1],
instances: 2, instances = 2,
distance: 1.22 distance = 1.22
}, %) )
const extrude010rr = extrude(sketch010rr, length = -thickness) const extrude010rr = extrude(sketch010rr, length = -thickness)
// define slots // define slots
@ -1465,11 +1465,11 @@ const sketch012rr = startSketchOn(extrude001rr, 'START')
|> xLine(-0.75 + .438, %) |> xLine(-0.75 + .438, %)
|> tangentialArcTo([profileStartX(%), profileStartY(%)], %) |> tangentialArcTo([profileStartX(%), profileStartY(%)], %)
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, -1], axis = [0, -1],
instances: 2, instances = 2,
distance: 1.22 distance = 1.22
}, %) )
const extrude012rr = extrude(sketch012rr, length = -thickness) const extrude012rr = extrude(sketch012rr, length = -thickness)
// REAR LEFT VETCIAL RAIL // REAR LEFT VETCIAL RAIL
@ -1579,11 +1579,11 @@ const sketch004rl = startSketchOn(extrude002rl, 'START')
], %, $rectangleSegmentC003rl) ], %, $rectangleSegmentC003rl)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, 1], axis = [0, 1],
instances: railHeight, instances = railHeight,
distance: 0.62 + 0.62 + 0.5 distance = 0.62 + 0.62 + 0.5
}, %) )
const extrude004rl = extrude(sketch004rl, length = -thickness) const extrude004rl = extrude(sketch004rl, length = -thickness)
// EIA-310-D standard hole pattern // EIA-310-D standard hole pattern
@ -1603,11 +1603,11 @@ const sketch005rl = startSketchOn(extrude002rl, 'START')
], %, $rectangleSegmentC004rl) ], %, $rectangleSegmentC004rl)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, 1], axis = [0, 1],
instances: railHeight, instances = railHeight,
distance: 0.62 + 0.62 + 0.5 distance = 0.62 + 0.62 + 0.5
}, %) )
const extrude005rl = extrude(sketch005rl, length = -thickness) const extrude005rl = extrude(sketch005rl, length = -thickness)
// EIA-310-D standard hole pattern // EIA-310-D standard hole pattern
@ -1627,11 +1627,11 @@ const sketch006rl = startSketchOn(extrude002rl, 'START')
], %, $rectangleSegmentC005rl) ], %, $rectangleSegmentC005rl)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, 1], axis = [0, 1],
instances: railHeight, instances = railHeight,
distance: 0.62 + 0.62 + 0.5 distance = 0.62 + 0.62 + 0.5
}, %) )
const extrude006rl = extrude(sketch006rl, length = -thickness) const extrude006rl = extrude(sketch006rl, length = -thickness)
// EIA-310-D standard hole pattern // EIA-310-D standard hole pattern
@ -1651,11 +1651,11 @@ const sketch007rl = startSketchOn(extrude001rl, 'START')
], %, $rectangleSegmentC006rl) ], %, $rectangleSegmentC006rl)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, 1], axis = [0, 1],
instances: railHeight, instances = railHeight,
distance: 0.62 + 0.62 + 0.5 distance = 0.62 + 0.62 + 0.5
}, %) )
const extrude007rl = extrude(sketch007rl, length = -thickness) const extrude007rl = extrude(sketch007rl, length = -thickness)
// EIA-310-D standard hole pattern // EIA-310-D standard hole pattern
@ -1675,11 +1675,11 @@ const sketch008rl = startSketchOn(extrude001rl, 'START')
], %, $rectangleSegmentC007rl) ], %, $rectangleSegmentC007rl)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, 1], axis = [0, 1],
instances: railHeight, instances = railHeight,
distance: 0.62 + 0.62 + 0.5 distance = 0.62 + 0.62 + 0.5
}, %) )
const extrude008rl = extrude(sketch008rl, length = -thickness) const extrude008rl = extrude(sketch008rl, length = -thickness)
// EIA-310-D standard hole pattern // EIA-310-D standard hole pattern
@ -1699,11 +1699,11 @@ const sketch009rl = startSketchOn(extrude001rl, 'START')
], %, $rectangleSegmentC008rl) ], %, $rectangleSegmentC008rl)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, 1], axis = [0, 1],
instances: railHeight, instances = railHeight,
distance: 0.62 + 0.62 + 0.5 distance = 0.62 + 0.62 + 0.5
}, %) )
const extrude009rl = extrude(sketch009rl, length = -thickness) const extrude009rl = extrude(sketch009rl, length = -thickness)
// define slots // define slots
@ -1720,11 +1720,11 @@ const sketch010rl = startSketchOn(extrude001rl, 'START')
|> xLine(-0.75 + .438, %) |> xLine(-0.75 + .438, %)
|> tangentialArcTo([profileStartX(%), profileStartY(%)], %) |> tangentialArcTo([profileStartX(%), profileStartY(%)], %)
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, 1], axis = [0, 1],
instances: 2, instances = 2,
distance: 1.22 distance = 1.22
}, %) )
const extrude010rl = extrude(sketch010rl, length = -thickness) const extrude010rl = extrude(sketch010rl, length = -thickness)
// define slots // define slots
@ -1758,11 +1758,11 @@ const sketch012rl = startSketchOn(extrude001rl, 'START')
|> xLine(-0.75 + .438, %) |> xLine(-0.75 + .438, %)
|> tangentialArcTo([profileStartX(%), profileStartY(%)], %) |> tangentialArcTo([profileStartX(%), profileStartY(%)], %)
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, -1], axis = [0, -1],
instances: 2, instances = 2,
distance: 1.22 distance = 1.22
}, %) )
const extrude012rl = extrude(sketch012rl, length = -thickness) const extrude012rl = extrude(sketch012rl, length = -thickness)
// GENERATE SERVER MODELS // GENERATE SERVER MODELS

View File

@ -719,11 +719,11 @@ const sketch010fl = startSketchOn(extrude001fl, 'START')
|> xLine(-0.75 + .438, %) |> xLine(-0.75 + .438, %)
|> tangentialArcTo([profileStartX(%), profileStartY(%)], %) |> tangentialArcTo([profileStartX(%), profileStartY(%)], %)
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, 1], axis = [0, 1],
instances: 2, instances = 2,
distance: 1.22 distance = 1.22
}, %) )
const extrude010fl = extrude(sketch010fl, length = -thickness) const extrude010fl = extrude(sketch010fl, length = -thickness)
// define slots // define slots
@ -757,11 +757,11 @@ const sketch012fl = startSketchOn(extrude001fl, 'START')
|> xLine(-0.75 + .438, %) |> xLine(-0.75 + .438, %)
|> tangentialArcTo([profileStartX(%), profileStartY(%)], %) |> tangentialArcTo([profileStartX(%), profileStartY(%)], %)
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, -1], axis = [0, -1],
instances: 2, instances = 2,
distance: 1.22 distance = 1.22
}, %) )
const extrude012fl = extrude(sketch012fl, length = -thickness) const extrude012fl = extrude(sketch012fl, length = -thickness)
// FRONT RIGHT VERTICAL RAIL // FRONT RIGHT VERTICAL RAIL
@ -869,11 +869,11 @@ const sketch010fr = startSketchOn(extrude001fr, 'START')
|> xLine(-0.75 + .438, %) |> xLine(-0.75 + .438, %)
|> tangentialArcTo([profileStartX(%), profileStartY(%)], %) |> tangentialArcTo([profileStartX(%), profileStartY(%)], %)
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, 1], axis = [0, 1],
instances: 2, instances = 2,
distance: 1.22 distance = 1.22
}, %) )
const extrude010fr = extrude(sketch010fr, length = -thickness) const extrude010fr = extrude(sketch010fr, length = -thickness)
// define slots // define slots
@ -907,11 +907,11 @@ const sketch012fr = startSketchOn(extrude001fr, 'START')
|> xLine(-0.75 + .438, %) |> xLine(-0.75 + .438, %)
|> tangentialArcTo([profileStartX(%), profileStartY(%)], %) |> tangentialArcTo([profileStartX(%), profileStartY(%)], %)
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, -1], axis = [0, -1],
instances: 2, instances = 2,
distance: 1.22 distance = 1.22
}, %) )
const extrude012fr = extrude(sketch012fr, length = -thickness) const extrude012fr = extrude(sketch012fr, length = -thickness)
// RIGHT REAR VERTICAL RAIL // RIGHT REAR VERTICAL RAIL
@ -1019,11 +1019,11 @@ const sketch010rr = startSketchOn(extrude001rr, 'START')
|> xLine(-0.75 + .438, %) |> xLine(-0.75 + .438, %)
|> tangentialArcTo([profileStartX(%), profileStartY(%)], %) |> tangentialArcTo([profileStartX(%), profileStartY(%)], %)
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, 1], axis = [0, 1],
instances: 2, instances = 2,
distance: 1.22 distance = 1.22
}, %) )
const extrude010rr = extrude(sketch010rr, length = -thickness) const extrude010rr = extrude(sketch010rr, length = -thickness)
// define slots // define slots
@ -1057,11 +1057,11 @@ const sketch012rr = startSketchOn(extrude001rr, 'START')
|> xLine(-0.75 + .438, %) |> xLine(-0.75 + .438, %)
|> tangentialArcTo([profileStartX(%), profileStartY(%)], %) |> tangentialArcTo([profileStartX(%), profileStartY(%)], %)
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, -1], axis = [0, -1],
instances: 2, instances = 2,
distance: 1.22 distance = 1.22
}, %) )
const extrude012rr = extrude(sketch012rr, length = -thickness) const extrude012rr = extrude(sketch012rr, length = -thickness)
// REAR LEFT VETCIAL RAIL // REAR LEFT VETCIAL RAIL
@ -1168,11 +1168,11 @@ const sketch010rl = startSketchOn(extrude001rl, 'START')
|> xLine(-0.75 + .438, %) |> xLine(-0.75 + .438, %)
|> tangentialArcTo([profileStartX(%), profileStartY(%)], %) |> tangentialArcTo([profileStartX(%), profileStartY(%)], %)
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, 1], axis = [0, 1],
instances: 2, instances = 2,
distance: 1.22 distance = 1.22
}, %) )
const extrude010rl = extrude(sketch010rl, length = -thickness) const extrude010rl = extrude(sketch010rl, length = -thickness)
// define slots // define slots
@ -1206,11 +1206,11 @@ const sketch012rl = startSketchOn(extrude001rl, 'START')
|> xLine(-0.75 + .438, %) |> xLine(-0.75 + .438, %)
|> tangentialArcTo([profileStartX(%), profileStartY(%)], %) |> tangentialArcTo([profileStartX(%), profileStartY(%)], %)
|> close() |> close()
|> patternLinear2d({ |> patternLinear2d(
axis: [0, -1], axis = [0, -1],
instances: 2, instances = 2,
distance: 1.22 distance = 1.22
}, %) )
const extrude012rl = extrude(sketch012rl, length = -thickness) const extrude012rl = extrude(sketch012rl, length = -thickness)
// Define planes so the server can be moved // Define planes so the server can be moved

View File

@ -66,16 +66,16 @@ const peg = startSketchOn(s, 'end')
-(pitch*(wbumps-1)/2), -(pitch*(wbumps-1)/2),
-(pitch*(lbumps-1)/2) -(pitch*(lbumps-1)/2)
], radius: bumpDiam / 2 }, %) ], radius: bumpDiam / 2 }, %)
|> patternLinear2d({ |> patternLinear2d(
axis: [1, 0], axis = [1, 0],
instances: wbumps, instances = wbumps,
distance: pitch distance = pitch
}, %) )
|> patternLinear2d({ |> patternLinear2d(
axis: [0, 1], axis = [0, 1],
instances: lbumps, instances = lbumps,
distance: pitch distance = pitch
}, %) )
|> extrude(bumpHeight, %) |> extrude(bumpHeight, %)
// |> patternTransform(int(totalBumps-1), tr, %) // |> patternTransform(int(totalBumps-1), tr, %)

View File

@ -348,7 +348,7 @@ async fn kcl_test_patterns_linear_basic_with_math() {
distance = 5 distance = 5
part = startSketchOn('XY') part = startSketchOn('XY')
|> circle({ center: [0,0], radius: 2 }, %) |> circle({ center: [0,0], radius: 2 }, %)
|> patternLinear2d({axis: [0,1], instances: num, distance: distance - 1}, %) |> patternLinear2d(axis = [0,1], instances = num, distance = distance - 1)
|> extrude(length = 1) |> extrude(length = 1)
"#; "#;
@ -360,7 +360,7 @@ part = startSketchOn('XY')
async fn kcl_test_patterns_linear_basic() { async fn kcl_test_patterns_linear_basic() {
let code = r#"part = startSketchOn('XY') let code = r#"part = startSketchOn('XY')
|> circle({ center: [0,0], radius: 2 }, %) |> circle({ center: [0,0], radius: 2 }, %)
|> patternLinear2d({axis: [0,1], instances: 13, distance: 4}, %) |> patternLinear2d(axis = [0,1], instances = 13, distance = 4)
|> extrude(length = 1) |> extrude(length = 1)
"#; "#;
@ -377,7 +377,7 @@ async fn kcl_test_patterns_linear_basic_3d() {
|> line(end = [0, -1]) |> line(end = [0, -1])
|> close() |> close()
|> extrude(length = 1) |> extrude(length = 1)
|> patternLinear3d({axis: [1, 0, 1], instances: 4, distance: 6}, %) |> patternLinear3d(axis = [1, 0, 1], instances = 4, distance = 6)
"#; "#;
let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap();
@ -388,7 +388,7 @@ async fn kcl_test_patterns_linear_basic_3d() {
async fn kcl_test_patterns_linear_basic_negative_distance() { async fn kcl_test_patterns_linear_basic_negative_distance() {
let code = r#"part = startSketchOn('XY') let code = r#"part = startSketchOn('XY')
|> circle({ center: [0,0], radius: 2 }, %) |> circle({ center: [0,0], radius: 2 }, %)
|> patternLinear2d({axis: [0,1], instances: 13, distance: -2}, %) |> patternLinear2d(axis = [0,1], instances = 13, distance = -2)
|> extrude(length = 1) |> extrude(length = 1)
"#; "#;
@ -400,7 +400,7 @@ async fn kcl_test_patterns_linear_basic_negative_distance() {
async fn kcl_test_patterns_linear_basic_negative_axis() { async fn kcl_test_patterns_linear_basic_negative_axis() {
let code = r#"part = startSketchOn('XY') let code = r#"part = startSketchOn('XY')
|> circle({ center: [0,0], radius: 2 }, %) |> circle({ center: [0,0], radius: 2 }, %)
|> patternLinear2d({axis: [0,-1], instances: 13, distance: 2}, %) |> patternLinear2d(axis = [0,-1], instances = 13, distance = 2)
|> extrude(length = 1) |> extrude(length = 1)
"#; "#;
@ -412,7 +412,7 @@ async fn kcl_test_patterns_linear_basic_negative_axis() {
async fn kcl_test_patterns_linear_basic_holes() { async fn kcl_test_patterns_linear_basic_holes() {
let code = r#"circles = startSketchOn('XY') let code = r#"circles = startSketchOn('XY')
|> circle({ center: [5, 5], radius: 1 }, %) |> circle({ center: [5, 5], radius: 1 }, %)
|> patternLinear2d({axis: [1,1], instances: 13, distance: 3}, %) |> patternLinear2d(axis = [1,1], instances = 13, distance = 3)
rectangle = startSketchOn('XY') rectangle = startSketchOn('XY')
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
@ -433,7 +433,7 @@ rectangle = startSketchOn('XY')
async fn kcl_test_patterns_circular_basic_2d() { async fn kcl_test_patterns_circular_basic_2d() {
let code = r#"part = startSketchOn('XY') let code = r#"part = startSketchOn('XY')
|> circle({ center: [0,0], radius: 2 }, %) |> circle({ center: [0,0], radius: 2 }, %)
|> patternCircular2d({center: [20, 20], instances: 13, arcDegrees: 210, rotateDuplicates: true}, %) |> patternCircular2d(center = [20, 20], instances = 13, arcDegrees = 210, rotateDuplicates = true)
|> extrude(length = 1) |> extrude(length = 1)
"#; "#;
@ -450,7 +450,7 @@ async fn kcl_test_patterns_circular_basic_3d() {
|> line(end = [0, -1]) |> line(end = [0, -1])
|> close() |> close()
|> extrude(length = 1) |> extrude(length = 1)
|> patternCircular3d({axis: [0,0, 1], center: [-20, -20, -20], instances: 41, arcDegrees: 360, rotateDuplicates: false}, %) |> patternCircular3d(axis = [0,0, 1], center = [-20, -20, -20], instances = 41, arcDegrees = 360, rotateDuplicates = false)
"#; "#;
let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap();
@ -466,7 +466,7 @@ async fn kcl_test_patterns_circular_3d_tilted_axis() {
|> line(end = [0, -1]) |> line(end = [0, -1])
|> close() |> close()
|> extrude(length = 1) |> extrude(length = 1)
|> patternCircular3d({axis: [1,1,0], center: [10, 0, 10], instances: 11, arcDegrees: 360, rotateDuplicates: true}, %) |> patternCircular3d(axis = [1,1,0], center = [10, 0, 10], instances = 11, arcDegrees = 360, rotateDuplicates = true)
"#; "#;
let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap();
@ -1417,11 +1417,12 @@ sketch002 = plane001
let extrudes = [sketch001, sketch002] let extrudes = [sketch001, sketch002]
pattn1 = patternLinear3d({ pattn1 = patternLinear3d(
axis: [0, 1, 0], extrudes,
instances: 3, axis = [0, 1, 0],
distance: 20 instances = 3,
}, extrudes) distance = 20
)
"#; "#;
let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap();
@ -1558,17 +1559,17 @@ async fn kcl_test_linear_pattern3d_filleted_sketch() {
part001 = cube([0,0], 20) part001 = cube([0,0], 20)
|> close(tag = $line1) |> close(tag = $line1)
|> extrude(length = 20) |> extrude(length = 20)
|> fillet({ |> fillet({
radius: 10, radius: 10,
tags: [getOppositeEdge(line1)] tags: [getOppositeEdge(line1)]
}, %) }, %)
pattn1 = patternLinear3d({
axis: [1, 0, 0],
instances: 4,
distance: 40
}, part001)
pattn1 = patternLinear3d(
part001,
axis = [1, 0, 0],
instances = 4,
distance = 40
)
"#; "#;
let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap();
@ -1594,7 +1595,7 @@ part001 = cube([0,0], 20)
tags: [getOppositeEdge(line1)] tags: [getOppositeEdge(line1)]
}, %) }, %)
pattn2 = patternCircular3d({axis: [0,0, 1], center: [-20, -20, -20], instances: 5, arcDegrees: 360, rotateDuplicates: false}, part001) pattn2 = patternCircular3d(part001, axis = [0,0, 1], center = [-20, -20, -20], instances = 5, arcDegrees = 360, rotateDuplicates = false)
"#; "#;
@ -1621,8 +1622,7 @@ part001 = cube([0,0], 20)
tags: [getOppositeEdge(line1)] tags: [getOppositeEdge(line1)]
}, %) }, %)
pattn2 = patternCircular3d({axis: [0,0, 1], center: [-20, -20, -20], instances: 5, arcDegrees: 360, rotateDuplicates: false}, part001) pattn2 = patternCircular3d(part001, axis = [0,0, 1], center = [-20, -20, -20], instances = 5, arcDegrees = 360, rotateDuplicates = false)
"#; "#;
let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap();
@ -1748,12 +1748,12 @@ async fn kcl_test_arc_error_same_start_end() {
radius: 1.5 radius: 1.5
}, %) }, %)
|> close() |> close()
|> patternCircular2d({ |> patternCircular2d(
arcDegrees: 360, arcDegrees = 360,
center: [0, 0], center = [0, 0],
instances: 6, instances = 6,
rotateDuplicates: true rotateDuplicates = true
}, %) )
"#; "#;
let result = execute_and_snapshot(code, UnitLength::Mm, None).await; let result = execute_and_snapshot(code, UnitLength::Mm, None).await;