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

View File

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

View File

@ -51,16 +51,16 @@ sketch002 = startSketchOn(sketch001, seg03)
center = [-1.25, 1],
radius = mountingHoleDiameter / 2,
}, %)
|> patternLinear2d({
|> patternLinear2d(
instances = 2,
distance = 2.5,
axis = [-1, 0],
}, %)
|> patternLinear2d({
)
|> patternLinear2d(
instances = 2,
distance = 4,
axis = [0, 1],
}, %)
)
|> extrude(%, length = -thickness-.01)
sketch003 = startSketchOn(sketch001, seg04)
@ -68,11 +68,11 @@ sketch003 = startSketchOn(sketch001, seg04)
center = [1, -1],
radius = mountingHoleDiameter / 2,
}, %)
|> patternLinear2d({
|> patternLinear2d(
instances = 2,
distance = 4,
axis = [1, 0],
}, %)
)
|> 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
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:
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();
assert_eq!(
snippet,
r#"patternCircular3d({
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:%})${}"#
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})${}"#
);
}
@ -1006,11 +1000,7 @@ mod tests {
let snippet = pattern_fn.to_autocomplete_snippet().unwrap();
assert_eq!(
snippet,
r#"patternLinear2d({
instances = ${0:10},
distance = ${1:3.14},
axis = [${2:3.14}, ${3:3.14}],
}, ${4:%})${}"#
r#"patternLinear2d(${0:%}, instances = ${1:10}, distance = ${2:3.14}, axis = [${3:3.14}, ${4:3.14}])${}"#
);
}

View File

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

View File

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

View File

@ -442,13 +442,6 @@ impl Args {
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>
where
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 {
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
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";
/// 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.
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
#[ts(export)]
@ -689,10 +673,13 @@ mod tests {
/// A linear pattern on a 2D sketch.
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>) =
super::args::FromArgs::from_args(&args, 0)?;
let sketch_set: SketchSet = args.get_unlabeled_kw_arg("sketchSet")?;
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 {
message:
"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())
}
@ -711,31 +699,41 @@ pub async fn pattern_linear_2d(exec_state: &mut ExecState, args: Args) -> Result
/// ```no_run
/// exampleSketch = startSketchOn('XZ')
/// |> circle({ center = [0, 0], radius = 1 }, %)
/// |> patternLinear2d({
/// |> patternLinear2d(
/// axis = [1, 0],
/// instances = 7,
/// distance = 4
/// }, %)
/// )
///
/// example = extrude(exampleSketch, length = 1)
/// ```
#[stdlib {
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(
data: LinearPattern2dData,
sketch_set: SketchSet,
instances: u32,
distance: f64,
axis: [f64; 2],
use_original: Option<bool>,
exec_state: &mut ExecState,
args: Args,
) -> Result<Vec<Box<Sketch>>, KclError> {
let axis = data.axis;
let [x, y] = axis;
let axis_len = f64::sqrt(x * x + y * y);
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| {
let d = data.distance * (i as f64);
let d = distance * (i as f64);
let translate = (normalized_axis * d).with_z(0.0).map(LengthUnit);
vec![Transform {
translate,
@ -755,10 +753,13 @@ async fn inner_pattern_linear_2d(
/// A linear pattern on a 3D model.
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>) =
super::args::FromArgs::from_args(&args, 0)?;
let solid_set: SolidSet = args.get_unlabeled_kw_arg("solidSet")?;
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 {
message:
"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())
}
@ -783,30 +784,40 @@ pub async fn pattern_linear_3d(exec_state: &mut ExecState, args: Args) -> Result
/// |> close()
///
/// example = extrude(exampleSketch, length = 1)
/// |> patternLinear3d({
/// |> patternLinear3d(
/// axis = [1, 0, 1],
/// instances = 7,
/// distance = 6
/// }, %)
/// )
/// ```
#[stdlib {
name = "patternLinear3d",
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(
data: LinearPattern3dData,
solid_set: SolidSet,
instances: u32,
distance: f64,
axis: [f64; 3],
use_original: Option<bool>,
exec_state: &mut ExecState,
args: Args,
) -> Result<Vec<Box<Solid>>, KclError> {
let axis = data.axis;
let [x, y, z] = axis;
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 transforms: Vec<_> = (1..data.instances)
let transforms: Vec<_> = (1..instances)
.map(|i| {
let d = data.distance * (i as f64);
let d = distance * (i as f64);
let translate = (normalized_axis * d).map(LengthUnit);
vec![Transform {
translate,
@ -828,7 +839,7 @@ async fn inner_pattern_linear_3d(
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
#[ts(export)]
#[serde(rename_all = "camelCase")]
pub struct CircularPattern2dData {
struct CircularPattern2dData {
/// 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.
@ -870,7 +881,7 @@ pub struct CircularPattern3dData {
pub use_original: Option<bool>,
}
pub enum CircularPattern {
enum CircularPattern {
ThreeD(CircularPattern3dData),
TwoD(CircularPattern2dData),
}
@ -941,9 +952,24 @@ impl CircularPattern {
/// A circular pattern on a 2D sketch.
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())
}
@ -959,21 +985,36 @@ pub async fn pattern_circular_2d(exec_state: &mut ExecState, args: Args) -> Resu
/// |> line(end = [-1, 0])
/// |> line(end = [0, -5])
/// |> close()
/// |> patternCircular2d({
/// |> patternCircular2d(
/// center = [0, 0],
/// instances = 13,
/// arcDegrees = 360,
/// rotateDuplicates = true
/// }, %)
/// )
///
/// example = extrude(exampleSketch, length = 1)
/// ```
#[stdlib {
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(
data: CircularPattern2dData,
sketch_set: SketchSet,
instances: u32,
center: [f64; 2],
arc_degrees: f64,
rotate_duplicates: bool,
use_original: Option<bool>,
exec_state: &mut ExecState,
args: Args,
) -> Result<Vec<Box<Sketch>>, KclError> {
@ -982,6 +1023,13 @@ async fn inner_pattern_circular_2d(
if args.ctx.context_type == crate::execution::ContextType::Mock {
return Ok(starting_sketches);
}
let data = CircularPattern2dData {
instances,
center,
arc_degrees,
rotate_duplicates,
use_original,
};
let mut sketches = Vec::new();
for sketch in starting_sketches.iter() {
@ -1008,9 +1056,36 @@ async fn inner_pattern_circular_2d(
/// A circular pattern on a 3D model.
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())
}
@ -1024,21 +1099,38 @@ pub async fn pattern_circular_3d(exec_state: &mut ExecState, args: Args) -> Resu
/// |> circle({ center = [0, 0], radius = 1 }, %)
///
/// example = extrude(exampleSketch, length = -5)
/// |> patternCircular3d({
/// |> patternCircular3d(
/// axis = [1, -1, 0],
/// center = [10, -20, 0],
/// instances = 11,
/// arcDegrees = 360,
/// rotateDuplicates = true
/// }, %)
/// )
/// ```
#[stdlib {
name = "patternCircular3d",
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(
data: CircularPattern3dData,
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,
args: Args,
) -> Result<Vec<Box<Solid>>, KclError> {
@ -1055,6 +1147,14 @@ async fn inner_pattern_circular_3d(
}
let mut solids = Vec::new();
let data = CircularPattern3dData {
instances,
axis,
center,
arc_degrees,
rotate_duplicates,
use_original,
};
for solid in starting_solids.iter() {
let geometries = pattern_circular(
CircularPattern::ThreeD(data.clone()),

View File

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

View File

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

View File

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

View File

@ -1,6 +1,7 @@
---
source: kcl/src/simulation_tests.rs
description: Result of parsing circular_pattern3d_a_pattern.kcl
snapshot_kind: text
---
{
"Ok": {
@ -321,7 +322,7 @@ description: Result of parsing circular_pattern3d_a_pattern.kcl
},
{
"declaration": {
"end": 276,
"end": 277,
"id": {
"end": 186,
"name": "pattn1",
@ -331,115 +332,88 @@ description: Result of parsing circular_pattern3d_a_pattern.kcl
"init": {
"arguments": [
{
"end": 260,
"properties": [
{
"end": 225,
"key": {
"end": 213,
"name": "axis",
"start": 209,
"type": "Identifier"
},
"start": 209,
"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": "LabeledArg",
"label": {
"type": "Identifier",
"name": "axis"
},
"arg": {
"elements": [
{
"end": 234,
"raw": "1",
"start": 233,
"type": "Literal",
"type": "Literal",
"value": {
"value": 7.0,
"value": 1.0,
"suffix": "None"
}
}
},
{
"end": 258,
"key": {
"end": 254,
"name": "distance",
"start": 246,
"type": "Identifier"
},
"start": 246,
"type": "ObjectProperty",
"value": {
"end": 258,
"raw": "6",
"start": 257,
{
"end": 237,
"raw": "0",
"start": 236,
"type": "Literal",
"type": "Literal",
"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"
}
}
}
],
"start": 205,
"type": "ObjectExpression",
"type": "ObjectExpression"
],
"end": 241,
"start": 232,
"type": "ArrayExpression",
"type": "ArrayExpression"
}
},
{
"end": 275,
"name": "exampleSketch",
"start": 262,
"type": "Identifier",
"type": "Identifier"
"type": "LabeledArg",
"label": {
"type": "Identifier",
"name": "instances"
},
"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": {
@ -448,15 +422,22 @@ description: Result of parsing circular_pattern3d_a_pattern.kcl
"start": 189,
"type": "Identifier"
},
"end": 276,
"end": 277,
"start": 189,
"type": "CallExpression",
"type": "CallExpression"
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"end": 221,
"name": "exampleSketch",
"start": 208,
"type": "Identifier",
"type": "Identifier"
}
},
"start": 180,
"type": "VariableDeclarator"
},
"end": 276,
"end": 277,
"kind": "const",
"start": 180,
"type": "VariableDeclaration",
@ -464,241 +445,213 @@ description: Result of parsing circular_pattern3d_a_pattern.kcl
},
{
"declaration": {
"end": 430,
"end": 432,
"id": {
"end": 284,
"end": 285,
"name": "pattn2",
"start": 278,
"start": 279,
"type": "Identifier"
},
"init": {
"arguments": [
{
"end": 421,
"properties": [
{
"end": 325,
"key": {
"end": 313,
"name": "axis",
"start": 309,
"type": "Identifier"
},
"start": 309,
"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": "LabeledArg",
"label": {
"type": "Identifier",
"name": "axis"
},
"arg": {
"elements": [
{
"end": 328,
"raw": "0",
"start": 327,
"type": "Literal",
"type": "Literal",
"value": {
"value": 41.0,
"value": 0.0,
"suffix": "None"
}
}
},
{
"end": 391,
"key": {
"end": 385,
"name": "arcDegrees",
"start": 375,
"type": "Identifier"
},
"start": 375,
"type": "ObjectProperty",
"value": {
"end": 391,
"raw": "360",
"start": 388,
{
"end": 331,
"raw": "0",
"start": 330,
"type": "Literal",
"type": "Literal",
"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"
}
}
},
{
"end": 419,
"key": {
"end": 411,
"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": 335,
"start": 326,
"type": "ArrayExpression",
"type": "ArrayExpression"
}
},
{
"end": 429,
"name": "pattn1",
"start": 423,
"type": "Identifier",
"type": "Identifier"
"type": "LabeledArg",
"label": {
"type": "Identifier",
"name": "center"
},
"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": {
"end": 304,
"end": 305,
"name": "patternCircular3d",
"start": 287,
"start": 288,
"type": "Identifier"
},
"end": 430,
"start": 287,
"type": "CallExpression",
"type": "CallExpression"
"end": 432,
"start": 288,
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"end": 315,
"name": "pattn1",
"start": 309,
"type": "Identifier",
"type": "Identifier"
}
},
"start": 278,
"start": 279,
"type": "VariableDeclarator"
},
"end": 430,
"end": 432,
"kind": "const",
"start": 278,
"start": 279,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
}
],
"end": 431,
"end": 433,
"nonCodeMeta": {
"nonCodeNodes": {
"0": [
@ -713,8 +666,8 @@ description: Result of parsing circular_pattern3d_a_pattern.kcl
],
"1": [
{
"end": 278,
"start": 276,
"end": 279,
"start": 277,
"type": "NonCodeNode",
"value": {
"type": "newLine"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,4 +3,11 @@ helper001 = startSketchOn('XZ')
|> startProfileAt([0, 0], %)
|> 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
description: Operations executed helix_simple.kcl
snapshot_kind: text
---
[
{
@ -26,43 +27,43 @@ description: Operations executed helix_simple.kcl
"labeledArgs": {
"angleStart": {
"sourceRange": [
170,
171,
173,
174,
0
]
},
"axis": {
"sourceRange": [
234,
241,
247,
254,
0
]
},
"ccw": {
"sourceRange": [
179,
183,
184,
188,
0
]
},
"length": {
"sourceRange": [
211,
213,
220,
222,
0
]
},
"radius": {
"sourceRange": [
224,
225,
235,
236,
0
]
},
"revolutions": {
"sourceRange": [
199,
200,
206,
207,
0
]
}
@ -70,7 +71,7 @@ description: Operations executed helix_simple.kcl
"name": "helix",
"sourceRange": [
151,
242,
257,
0
],
"type": "StdLibCall",

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -6,10 +6,18 @@ exampleSketch = startSketchOn('XZ')
|> close()
|> extrude(length = 1)
pattn1 = patternLinear3d({
axis: [1, 0, 0],
instances: 7,
distance: 6
}, exampleSketch)
pattn1 = patternLinear3d(
exampleSketch,
axis = [1, 0, 0],
instances = 7,
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)
]
}, %)
|> patternLinear3d({
axis: [0, -1, 0],
instances: 2,
distance: length + 2 * thk - (tabLength * 4 / 3)
}, %)
|> patternLinear3d(
axis = [0, -1, 0],
instances = 2,
distance = length + 2 * thk - (tabLength * 4 / 3)
)
// build the tabs of the mounting bracket (left side)
const tabsL = startSketchOn(tabPlane)
@ -123,11 +123,11 @@ const tabsL = startSketchOn(tabPlane)
getNextAdjacentEdge(edge22)
]
}, %)
|> patternLinear3d({
axis: [0, -1, 0],
instances: 2,
distance: length + 2 * thk - (tabLength * 4 / 3)
}, %)
|> patternLinear3d(
axis = [0, -1, 0],
instances = 2,
distance = length + 2 * thk - (tabLength * 4 / 3)
)
// define a plane for retention bumps
const retPlane = {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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