Compare commits

...

5 Commits

Author SHA1 Message Date
ccb3edb0ec Update rust/kcl-lib/src/execution/memory.rs
Co-authored-by: Jonathan Tran <jonnytran@gmail.com>
2025-03-28 21:01:24 -07:00
252050468d ascii art diagram
Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-03-28 14:30:45 -07:00
358b34de4c Fix translate scale & better docs (#6053)
* change translate & scale to be better & docs

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* autocomplete

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* gen std

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* kcl-samples

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-03-28 21:14:29 +00:00
9973e5fde3 Fix to preserve comments when changing file units (#6052) 2025-03-28 21:07:53 +00:00
36875e05fd Fix .length on undefined WASM error (#6048) 2025-03-28 14:48:47 -04:00
26 changed files with 9402 additions and 2642 deletions

View File

@ -6,6 +6,10 @@ layout: manual
Rotate a solid or a sketch.
This is really useful for assembling parts together. You can create a part and then rotate it to the correct orientation.
For sketches, you can use this to rotate a sketch and then loft it with another sketch.
### Using Roll, Pitch, and Yaw
When rotating a part in 3D space, "roll," "pitch," and "yaw" refer to the three rotational axes used to describe its orientation: roll is rotation around the longitudinal axis (front-to-back), pitch is rotation around the lateral axis (wing-to-wing), and yaw is rotation around the vertical axis (up-down); essentially, it's like tilting the part on its side (roll), tipping the nose up or down (pitch), and turning it left or right (yaw).
@ -166,7 +170,7 @@ fn square() {
profile001 = square()
profile002 = square()
|> translate(translate = [0, 0, 20])
|> translate(x = 0, y = 0, z = 20)
|> rotate(axis = [0, 0, 1.0], angle = 45)
loft([profile001, profile002])

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -258,14 +258,6 @@ export const isErrorWhitelisted = (exception: Error) => {
foundInSpec: 'e2e/playwright/testing-settings.spec.ts',
},
// TODO: fix this error in the code
{
name: 'TypeError',
message: "Cannot read properties of undefined (reading 'length')",
stack: '',
project: 'Google Chrome',
foundInSpec: '', // many tests are impacted by this error
},
// TODO: fix this error in the code
{
name: 'ReferenceError',
message: '_testUtils is not defined',

View File

@ -12,7 +12,7 @@ import "car-tire.kcl" as carTire
import lugCount from "globals.kcl"
carRotor
|> translate(translate = [0, 0.5, 0])
|> translate(x = 0, y = 0.5, z = 0)
carWheel
lugNut
|> patternCircular3d(
@ -23,5 +23,5 @@ lugNut
rotateDuplicates = false,
)
brakeCaliper
|> translate(translate = [0, 0.5, 0])
|> translate(x = 0, y = 0.5, z = 0)
carTire

View File

@ -19,27 +19,27 @@ import pipe from "1120t74-pipe.kcl"
flange()
flange()
|> rotate(axis = [0, 1, 0], angle = 180)
|> translate(translate = [
0,
0,
flangeBackHeight * 2 + gasketThickness
])
|> translate(
x = 0,
y = 0,
z = flangeBackHeight * 2 + gasketThickness,
)
// place gasket between the flanges
gasket()
|> translate(translate = [
0,
0,
-flangeBackHeight - gasketThickness
])
|> translate(
x = 0,
y = 0,
z = -flangeBackHeight - gasketThickness
)
// place eight washers (four front, four back)
washer()
|> translate(translate = [
mountingHolePlacementDiameter / 2,
0,
flangeBaseThickness
])
|> translate(
x = mountingHolePlacementDiameter / 2,
y = 0,
z = flangeBaseThickness
)
|> patternCircular3d(
%,
instances = 4,
@ -57,11 +57,11 @@ washer()
// place four bolts
bolt()
|> translate(translate = [
mountingHolePlacementDiameter / 2,
0,
flangeBaseThickness + washerThickness
])
|> translate(
x = mountingHolePlacementDiameter / 2,
y = 0,
z = flangeBaseThickness + washerThickness,
)
|> rotate(roll = 90, pitch = 0, yaw = 0)
|> patternCircular3d(
%,
@ -74,11 +74,11 @@ bolt()
// place four hex nuts
hexNut()
|> translate(translate = [
mountingHolePlacementDiameter / 2,
0,
-(flangeBackHeight * 2 + gasketThickness + flangeBaseThickness + washerThickness + hexNutThickness)
])
|> translate(
x = mountingHolePlacementDiameter / 2,
y = 0,
z = -(flangeBackHeight * 2 + gasketThickness + flangeBaseThickness + washerThickness + hexNutThickness),
)
|> patternCircular3d(
%,
instances = 4,
@ -97,13 +97,11 @@ pipe()
yaw = 0,
)
|> translate(
%,
translate = [
0,
0,
flangeBaseThickness + flangeFrontHeight - 0.5
],
global = true,
%,
x = 0,
y = 0,
z = flangeBaseThickness + flangeFrontHeight - 0.5,
global = true,
)
pipe()
@ -114,11 +112,9 @@ pipe()
yaw = 0,
)
|> translate(
%,
translate = [
0,
0,
-(flangeBackHeight * 2 + gasketThickness + flangeBaseThickness + flangeFrontHeight - 0.5)
],
global = true,
%,
x = 0,
y = 0,
z = -(flangeBackHeight * 2 + gasketThickness + flangeBaseThickness + flangeFrontHeight - 0.5),
global = true,
)

View File

@ -20,51 +20,36 @@ body()
// import the antenna
antenna()
|> translate(translate = [-width / 2 + .45, -0.10, height / 2])
|> translate(x = -width / 2 + .45, y = -0.10, z = height / 2)
// import the case
case()
|> translate(translate = [0, -1, 0])
|> translate(x = 0, y = -1, z = 0)
// import the talk button
talkButton()
|> translate(translate = [width / 2, -thickness / 2, .5])
|> translate(x = width / 2, y = -thickness / 2, z = .5)
// import the frequency knob
knob()
|> translate(translate = [
width / 2 - 0.70,
-thickness / 2,
height / 2
])
|> translate(
x = width / 2 - 0.70,
y = -thickness / 2,
z = height / 2
)
// import the buttons
button()
|> translate(translate = [
-(screenWidth / 2 + tolerance),
-1,
screenYPosition
])
button()
|> translate(translate = [
-(screenWidth / 2 + tolerance),
-1,
screenYPosition - buttonHeight - (tolerance * 2)
])
button()
|> rotate(
%,
roll = 0,
pitch = 180,
yaw = 0,
)
|> translate(
translate = [
screenWidth / 2 + tolerance,
-1,
screenYPosition - buttonHeight
],
global = true,
x = -(screenWidth / 2 + tolerance),
y = -1,
z = screenYPosition
)
button()
|> translate(
x = -(screenWidth / 2 + tolerance),
y = -1,
z = screenYPosition - buttonHeight - (tolerance * 2)
)
button()
|> rotate(
@ -74,10 +59,21 @@ button()
yaw = 0,
)
|> translate(
translate = [
screenWidth / 2 + tolerance,
-1,
screenYPosition - (buttonHeight * 2) - (tolerance * 2)
],
x = screenWidth / 2 + tolerance,
y = -1,
z = screenYPosition - buttonHeight,
global = true,
)
button()
|> rotate(
%,
roll = 0,
pitch = 180,
yaw = 0,
)
|> translate(
x = screenWidth / 2 + tolerance,
y = -1,
z = screenYPosition - (buttonHeight * 2) - (tolerance * 2),
global = true,
)

View File

@ -1141,7 +1141,7 @@ mod tests {
let snippet = scale_fn.to_autocomplete_snippet().unwrap();
assert_eq!(
snippet,
r#"scale(${0:%}, scale = [${1:3.14}, ${2:3.14}, ${3:3.14}])${}"#
r#"scale(${0:%}, x = ${1:3.14}, y = ${2:3.14}, z = ${3:3.14})${}"#
);
}
@ -1152,7 +1152,7 @@ mod tests {
let snippet = translate_fn.to_autocomplete_snippet().unwrap();
assert_eq!(
snippet,
r#"translate(${0:%}, translate = [${1:3.14}, ${2:3.14}, ${3:3.14}])${}"#
r#"translate(${0:%}, x = ${1:3.14}, y = ${2:3.14}, z = ${3:3.14})${}"#
);
}

View File

@ -121,6 +121,13 @@ impl EngineConnection {
}
})?;
if value.is_null() || value.is_undefined() {
return Err(KclError::Engine(KclErrorDetails {
message: "Received null or undefined response from engine".into(),
source_ranges: vec![source_range],
}));
}
// Convert JsValue to a Uint8Array
let data = js_sys::Uint8Array::from(value);

View File

@ -201,6 +201,35 @@
//! check safety, it is not ever used for any decision. In any case, modifying the env storage is
//! must be safe if the env is in either state, so even if the transition happens at the same time
//! as the storage modification, it is ok.
//!
//! Here is an ascii art diagram of the memory system:
//!
//! +----------------------------+
//! | ProgramMemory |
//! |----------------------------|
//! | Envs: |
//! | |
//! | [ Env 1 ] |
//! | - Vars: { "a" = 10 } |
//! | - Epoch: 1 |
//! | - Owner ID: 0 | <- read-only
//! | |
//! | [ Env 2 ] |
//! | - Vars: { "b" = a } |
//! | - Epoch: 2 |
//! | - Owner ID: 42 | <- owned by Stack 42
//! | |
//! +-------------^--------------+
//! |
//! | shared, immutable OR
//! | uniquely owned mutable reference
//! +---------+---------+
//! | Stack 42 |
//! |-------------------|
//! | stack_id: 42 |
//! | env_stack: [2] |
//! | epoch: 2 |
//! +-------------------+
use std::{
cell::UnsafeCell,

View File

@ -2044,6 +2044,8 @@ let w = f() + f()
// Ensure the settings are as expected.
assert_eq!(settings_state, ctx.settings);
ctx.close().await;
}
#[tokio::test(flavor = "multi_thread")]
@ -2057,6 +2059,9 @@ let w = f() + f()
let program2 = crate::Program::parse_no_errs("z = x + 1").unwrap();
let result = ctx2.run_mock(program2, true).await.unwrap();
assert_eq!(result.variables.get("z").unwrap().as_f64().unwrap(), 3.0);
ctx.close().await;
ctx2.close().await;
}
#[tokio::test(flavor = "multi_thread")]

View File

@ -133,6 +133,13 @@ impl<T> Node<T> {
})
}
fn reset_source(&mut self) {
self.start = 0;
self.end = 0;
self.module_id = ModuleId::default();
self.comment_start = 0;
}
pub fn as_source_range(&self) -> SourceRange {
SourceRange::new(self.start, self.end, self.module_id)
}
@ -345,7 +352,10 @@ impl Node<Program> {
let mut found = false;
for node in &mut new_program.inner_attrs {
if node.name() == Some(annotations::SETTINGS) {
*node = Node::no_src(Annotation::new_from_meta_settings(&settings));
node.inner = Annotation::new_from_meta_settings(&settings);
// Previous source range no longer makes sense, but we want to
// preserve other things like comments.
node.reset_source();
found = true;
break;
}
@ -4140,6 +4150,50 @@ startSketchOn(XY)
r#"@settings(defaultLengthUnit = mm)
startSketchOn(XY)
"#
);
}
#[tokio::test(flavor = "multi_thread")]
async fn test_change_meta_settings_preserves_comments() {
let code = r#"// Title
// Set Units
@settings(defaultLengthUnit = in)
// Between
// Above Code
5
"#;
let program = crate::parsing::top_level_parse(code).unwrap();
let new_program = program
.change_meta_settings(crate::execution::MetaSettings {
default_length_units: crate::execution::types::UnitLen::Cm,
..Default::default()
})
.unwrap();
let result = new_program.meta_settings().unwrap();
assert!(result.is_some());
let meta_settings = result.unwrap();
assert_eq!(meta_settings.default_length_units, crate::execution::types::UnitLen::Cm);
let formatted = new_program.recast(&Default::default(), 0);
assert_eq!(
formatted,
r#"// Title
// Set Units
@settings(defaultLengthUnit = cm)
// Between
// Above Code
5
"#
);
}

View File

@ -28,15 +28,22 @@ pub async fn scale(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
]),
exec_state,
)?;
let scale = args.get_kw_arg("scale")?;
let scale_x = args.get_kw_arg("x")?;
let scale_y = args.get_kw_arg("y")?;
let scale_z = args.get_kw_arg("z")?;
let global = args.get_kw_arg_opt("global")?;
let objects = inner_scale(objects, scale, global, exec_state, args).await?;
let objects = inner_scale(objects, scale_x, scale_y, scale_z, global, exec_state, args).await?;
Ok(objects.into())
}
/// Scale a solid or a sketch.
///
/// This is really useful for resizing parts. You can create a part and then scale it to the
/// correct size.
///
/// For sketches, you can use this to scale a sketch and then loft it with another sketch.
///
/// By default the transform is applied in local sketch axis, therefore the origin will not move.
///
/// If you want to apply the transform in global space, set `global` to `true`. The origin of the
@ -78,7 +85,9 @@ pub async fn scale(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
/// |> hole(pipeHole, %)
/// |> sweep(path = sweepPath)
/// |> scale(
/// scale = [1.0, 1.0, 2.5],
/// x = 1.0,
/// y = 1.0,
/// z = 2.5,
/// )
/// ```
///
@ -89,7 +98,9 @@ pub async fn scale(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
///
/// cube
/// |> scale(
/// scale = [1.0, 1.0, 2.5],
/// x = 1.0,
/// y = 1.0,
/// z = 2.5,
/// )
/// ```
///
@ -124,7 +135,7 @@ pub async fn scale(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
/// parts = sweep([rectangleSketch, circleSketch], path = sweepPath)
///
/// // Scale the sweep.
/// scale(parts, scale = [1.0, 1.0, 0.5])
/// scale(parts, x = 1.0, y = 1.0, z = 0.5)
/// ```
#[stdlib {
name = "scale",
@ -133,13 +144,17 @@ pub async fn scale(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
unlabeled_first = true,
args = {
objects = {docs = "The solid, sketch, or set of solids or sketches to scale."},
scale = {docs = "The scale factor for the x, y, and z axes."},
x = {docs = "The scale factor for the x axis."},
y = {docs = "The scale factor for the y axis."},
z = {docs = "The scale factor for the z axis."},
global = {docs = "If true, the transform is applied in global space. The origin of the model will move. By default, the transform is applied in local sketch axis, therefore the origin will not move."}
}
}]
async fn inner_scale(
objects: SolidOrSketchOrImportedGeometry,
scale: [f64; 3],
x: f64,
y: f64,
z: f64,
global: Option<bool>,
exec_state: &mut ExecState,
args: Args,
@ -159,11 +174,7 @@ async fn inner_scale(
object_id,
transforms: vec![shared::ComponentTransform {
scale: Some(shared::TransformBy::<Point3d<f64>> {
property: Point3d {
x: scale[0],
y: scale[1],
z: scale[2],
},
property: Point3d { x, y, z },
set: false,
is_local: !global.unwrap_or(false),
}),
@ -190,15 +201,23 @@ pub async fn translate(exec_state: &mut ExecState, args: Args) -> Result<KclValu
]),
exec_state,
)?;
let translate = args.get_kw_arg("translate")?;
let translate_x = args.get_kw_arg("x")?;
let translate_y = args.get_kw_arg("y")?;
let translate_z = args.get_kw_arg("z")?;
let global = args.get_kw_arg_opt("global")?;
let objects = inner_translate(objects, translate, global, exec_state, args).await?;
let objects = inner_translate(objects, translate_x, translate_y, translate_z, global, exec_state, args).await?;
Ok(objects.into())
}
/// Move a solid or a sketch.
///
/// This is really useful for assembling parts together. You can create a part
/// and then move it to the correct location.
///
/// Translate is really useful for sketches if you want to move a sketch
/// and then rotate it using the `rotate` function to create a loft.
///
/// ```no_run
/// // Move a pipe.
///
@ -232,7 +251,9 @@ pub async fn translate(exec_state: &mut ExecState, args: Args) -> Result<KclValu
/// |> hole(pipeHole, %)
/// |> sweep(path = sweepPath)
/// |> translate(
/// translate = [1.0, 1.0, 2.5],
/// x = 1.0,
/// y = 1.0,
/// z = 2.5,
/// )
/// ```
///
@ -243,7 +264,9 @@ pub async fn translate(exec_state: &mut ExecState, args: Args) -> Result<KclValu
///
/// cube
/// |> translate(
/// translate = [1.0, 1.0, 2.5],
/// x = 1.0,
/// y = 1.0,
/// z = 2.5,
/// )
/// ```
///
@ -278,7 +301,7 @@ pub async fn translate(exec_state: &mut ExecState, args: Args) -> Result<KclValu
/// parts = sweep([rectangleSketch, circleSketch], path = sweepPath)
///
/// // Move the sweeps.
/// translate(parts, translate = [1.0, 1.0, 2.5])
/// translate(parts, x = 1.0, y = 1.0, z = 2.5)
/// ```
///
/// ```no_run
@ -301,7 +324,9 @@ pub async fn translate(exec_state: &mut ExecState, args: Args) -> Result<KclValu
///
/// square(10)
/// |> translate(
/// translate = [5, 5, 0],
/// x = 5,
/// y = 5,
/// z = 0,
/// )
/// |> extrude(
/// length = 10,
@ -324,7 +349,7 @@ pub async fn translate(exec_state: &mut ExecState, args: Args) -> Result<KclValu
/// profile001 = square()
///
/// profile002 = square()
/// |> translate(translate = [0, 0, 20])
/// |> translate(x = 0, y = 0, z = 20)
/// |> rotate(axis = [0, 0, 1.0], angle = 45)
///
/// loft([profile001, profile002])
@ -336,13 +361,17 @@ pub async fn translate(exec_state: &mut ExecState, args: Args) -> Result<KclValu
unlabeled_first = true,
args = {
objects = {docs = "The solid, sketch, or set of solids or sketches to move."},
translate = {docs = "The amount to move the solid or sketch in all three axes."},
x = {docs = "The amount to move the solid or sketch along the x axis."},
y = {docs = "The amount to move the solid or sketch along the y axis."},
z = {docs = "The amount to move the solid or sketch along the z axis."},
global = {docs = "If true, the transform is applied in global space. The origin of the model will move. By default, the transform is applied in local sketch axis, therefore the origin will not move."}
}
}]
async fn inner_translate(
objects: SolidOrSketchOrImportedGeometry,
translate: [f64; 3],
x: f64,
y: f64,
z: f64,
global: Option<bool>,
exec_state: &mut ExecState,
args: Args,
@ -363,9 +392,9 @@ async fn inner_translate(
transforms: vec![shared::ComponentTransform {
translate: Some(shared::TransformBy::<Point3d<LengthUnit>> {
property: shared::Point3d {
x: LengthUnit(translate[0]),
y: LengthUnit(translate[1]),
z: LengthUnit(translate[2]),
x: LengthUnit(x),
y: LengthUnit(y),
z: LengthUnit(z),
},
set: false,
is_local: !global.unwrap_or(false),
@ -506,6 +535,11 @@ pub async fn rotate(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
/// Rotate a solid or a sketch.
///
/// This is really useful for assembling parts together. You can create a part
/// and then rotate it to the correct orientation.
///
/// For sketches, you can use this to rotate a sketch and then loft it with another sketch.
///
/// ### Using Roll, Pitch, and Yaw
///
/// When rotating a part in 3D space, "roll," "pitch," and "yaw" refer to the
@ -667,7 +701,7 @@ pub async fn rotate(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
/// profile001 = square()
///
/// profile002 = square()
/// |> translate(translate = [0, 0, 20])
/// |> translate(x = 0, y = 0, z = 20)
/// |> rotate(axis = [0, 0, 1.0], angle = 45)
///
/// loft([profile001, profile002])

View File

@ -151,54 +151,65 @@ description: Result of parsing import_transform.kcl
"label": {
"commentStart": 159,
"end": 0,
"name": "translate",
"name": "x",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 171,
"elements": [
{
"commentStart": 172,
"end": 0,
"raw": "3.14",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 3.14,
"suffix": "None"
}
},
{
"commentStart": 178,
"end": 0,
"raw": "3.14",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 3.14,
"suffix": "None"
}
},
{
"commentStart": 184,
"end": 0,
"raw": "3.14",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 3.14,
"suffix": "None"
}
}
],
"commentStart": 163,
"end": 0,
"raw": "3.14",
"start": 0,
"type": "ArrayExpression",
"type": "ArrayExpression"
"type": "Literal",
"type": "Literal",
"value": {
"value": 3.14,
"suffix": "None"
}
}
},
{
"type": "LabeledArg",
"label": {
"commentStart": 169,
"end": 0,
"name": "y",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 173,
"end": 0,
"raw": "3.14",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 3.14,
"suffix": "None"
}
}
},
{
"type": "LabeledArg",
"label": {
"commentStart": 179,
"end": 0,
"name": "z",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 183,
"end": 0,
"raw": "3.14",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 3.14,
"suffix": "None"
}
}
}
],
@ -235,65 +246,76 @@ description: Result of parsing import_transform.kcl
{
"type": "LabeledArg",
"label": {
"commentStart": 205,
"commentStart": 203,
"end": 0,
"name": "scale",
"name": "x",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 213,
"elements": [
{
"commentStart": 214,
"end": 0,
"raw": "3.14",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 3.14,
"suffix": "None"
}
},
{
"commentStart": 220,
"end": 0,
"raw": "3.14",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 3.14,
"suffix": "None"
}
},
{
"commentStart": 226,
"end": 0,
"raw": "3.14",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 3.14,
"suffix": "None"
}
}
],
"commentStart": 207,
"end": 0,
"raw": "3.14",
"start": 0,
"type": "ArrayExpression",
"type": "ArrayExpression"
"type": "Literal",
"type": "Literal",
"value": {
"value": 3.14,
"suffix": "None"
}
}
},
{
"type": "LabeledArg",
"label": {
"commentStart": 213,
"end": 0,
"name": "y",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 217,
"end": 0,
"raw": "3.14",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 3.14,
"suffix": "None"
}
}
},
{
"type": "LabeledArg",
"label": {
"commentStart": 223,
"end": 0,
"name": "z",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 227,
"end": 0,
"raw": "3.14",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 3.14,
"suffix": "None"
}
}
}
],
"callee": {
"abs_path": false,
"commentStart": 196,
"commentStart": 194,
"end": 0,
"name": {
"commentStart": 196,
"commentStart": 194,
"end": 0,
"name": "scale",
"start": 0,
@ -303,13 +325,13 @@ description: Result of parsing import_transform.kcl
"start": 0,
"type": "Name"
},
"commentStart": 196,
"commentStart": 194,
"end": 0,
"start": 0,
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"commentStart": 202,
"commentStart": 200,
"end": 0,
"start": 0,
"type": "PipeSubstitution",

View File

@ -7,5 +7,5 @@ screw
pitch = 3.14,
yaw = 3.14,
)
|> translate(%, translate = [3.14, 3.14, 3.14])
|> scale(%, scale = [3.14, 3.14, 3.14])
|> translate(%, x = 3.14, y = 3.14, z = 3.14)
|> scale(%, x = 3.14, y = 3.14, z = 3.14)

View File

@ -11,5 +11,15 @@ screw
pitch = 3.14,
yaw = 3.14,
)
|> translate(%, translate = [3.14, 3.14, 3.14])
|> scale(%, scale = [3.14, 3.14, 3.14])
|> translate(
%,
x = 3.14,
y = 3.14,
z = 3.14,
)
|> scale(
%,
x = 3.14,
y = 3.14,
z = 3.14,
)

View File

@ -168,54 +168,65 @@ description: Result of parsing car-wheel-assembly.kcl
"label": {
"commentStart": 366,
"end": 0,
"name": "translate",
"name": "x",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 378,
"elements": [
{
"commentStart": 379,
"end": 0,
"raw": "0",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
},
{
"commentStart": 382,
"end": 0,
"raw": "0.5",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.5,
"suffix": "None"
}
},
{
"commentStart": 387,
"end": 0,
"raw": "0",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
}
],
"commentStart": 370,
"end": 0,
"raw": "0",
"start": 0,
"type": "ArrayExpression",
"type": "ArrayExpression"
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
}
},
{
"type": "LabeledArg",
"label": {
"commentStart": 373,
"end": 0,
"name": "y",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 377,
"end": 0,
"raw": "0.5",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.5,
"suffix": "None"
}
}
},
{
"type": "LabeledArg",
"label": {
"commentStart": 382,
"end": 0,
"name": "z",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 386,
"end": 0,
"raw": "0",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
}
}
],
@ -253,14 +264,14 @@ description: Result of parsing car-wheel-assembly.kcl
"type": "ExpressionStatement"
},
{
"commentStart": 391,
"commentStart": 389,
"end": 0,
"expression": {
"abs_path": false,
"commentStart": 391,
"commentStart": 389,
"end": 0,
"name": {
"commentStart": 391,
"commentStart": 389,
"end": 0,
"name": "carWheel",
"start": 0,
@ -276,16 +287,16 @@ description: Result of parsing car-wheel-assembly.kcl
"type": "ExpressionStatement"
},
{
"commentStart": 400,
"commentStart": 398,
"end": 0,
"expression": {
"body": [
{
"abs_path": false,
"commentStart": 400,
"commentStart": 398,
"end": 0,
"name": {
"commentStart": 400,
"commentStart": 398,
"end": 0,
"name": "lugNut",
"start": 0,
@ -301,14 +312,14 @@ description: Result of parsing car-wheel-assembly.kcl
{
"type": "LabeledArg",
"label": {
"commentStart": 438,
"commentStart": 436,
"end": 0,
"name": "arcDegrees",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 451,
"commentStart": 449,
"end": 0,
"raw": "360",
"start": 0,
@ -323,17 +334,17 @@ description: Result of parsing car-wheel-assembly.kcl
{
"type": "LabeledArg",
"label": {
"commentStart": 463,
"commentStart": 461,
"end": 0,
"name": "axis",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 470,
"commentStart": 468,
"elements": [
{
"commentStart": 471,
"commentStart": 469,
"end": 0,
"raw": "0",
"start": 0,
@ -345,7 +356,7 @@ description: Result of parsing car-wheel-assembly.kcl
}
},
{
"commentStart": 474,
"commentStart": 472,
"end": 0,
"raw": "1",
"start": 0,
@ -357,7 +368,7 @@ description: Result of parsing car-wheel-assembly.kcl
}
},
{
"commentStart": 477,
"commentStart": 475,
"end": 0,
"raw": "0",
"start": 0,
@ -378,17 +389,17 @@ description: Result of parsing car-wheel-assembly.kcl
{
"type": "LabeledArg",
"label": {
"commentStart": 488,
"commentStart": 486,
"end": 0,
"name": "center",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 497,
"commentStart": 495,
"elements": [
{
"commentStart": 498,
"commentStart": 496,
"end": 0,
"raw": "0",
"start": 0,
@ -400,7 +411,7 @@ description: Result of parsing car-wheel-assembly.kcl
}
},
{
"commentStart": 501,
"commentStart": 499,
"end": 0,
"raw": "0",
"start": 0,
@ -412,7 +423,7 @@ description: Result of parsing car-wheel-assembly.kcl
}
},
{
"commentStart": 504,
"commentStart": 502,
"end": 0,
"raw": "0",
"start": 0,
@ -433,7 +444,7 @@ description: Result of parsing car-wheel-assembly.kcl
{
"type": "LabeledArg",
"label": {
"commentStart": 515,
"commentStart": 513,
"end": 0,
"name": "instances",
"start": 0,
@ -441,10 +452,10 @@ description: Result of parsing car-wheel-assembly.kcl
},
"arg": {
"abs_path": false,
"commentStart": 527,
"commentStart": 525,
"end": 0,
"name": {
"commentStart": 527,
"commentStart": 525,
"end": 0,
"name": "lugCount",
"start": 0,
@ -459,14 +470,14 @@ description: Result of parsing car-wheel-assembly.kcl
{
"type": "LabeledArg",
"label": {
"commentStart": 544,
"commentStart": 542,
"end": 0,
"name": "rotateDuplicates",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 563,
"commentStart": 561,
"end": 0,
"raw": "false",
"start": 0,
@ -478,10 +489,10 @@ description: Result of parsing car-wheel-assembly.kcl
],
"callee": {
"abs_path": false,
"commentStart": 412,
"commentStart": 410,
"end": 0,
"name": {
"commentStart": 412,
"commentStart": 410,
"end": 0,
"name": "patternCircular3d",
"start": 0,
@ -491,7 +502,7 @@ description: Result of parsing car-wheel-assembly.kcl
"start": 0,
"type": "Name"
},
"commentStart": 412,
"commentStart": 410,
"end": 0,
"start": 0,
"type": "CallExpressionKw",
@ -499,7 +510,7 @@ description: Result of parsing car-wheel-assembly.kcl
"unlabeled": null
}
],
"commentStart": 400,
"commentStart": 398,
"end": 0,
"start": 0,
"type": "PipeExpression",
@ -510,16 +521,16 @@ description: Result of parsing car-wheel-assembly.kcl
"type": "ExpressionStatement"
},
{
"commentStart": 577,
"commentStart": 575,
"end": 0,
"expression": {
"body": [
{
"abs_path": false,
"commentStart": 577,
"commentStart": 575,
"end": 0,
"name": {
"commentStart": 577,
"commentStart": 575,
"end": 0,
"name": "brakeCaliper",
"start": 0,
@ -535,65 +546,76 @@ description: Result of parsing car-wheel-assembly.kcl
{
"type": "LabeledArg",
"label": {
"commentStart": 605,
"commentStart": 603,
"end": 0,
"name": "translate",
"name": "x",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 617,
"elements": [
{
"commentStart": 618,
"end": 0,
"raw": "0",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
},
{
"commentStart": 621,
"end": 0,
"raw": "0.5",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.5,
"suffix": "None"
}
},
{
"commentStart": 626,
"end": 0,
"raw": "0",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
}
],
"commentStart": 607,
"end": 0,
"raw": "0",
"start": 0,
"type": "ArrayExpression",
"type": "ArrayExpression"
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
}
},
{
"type": "LabeledArg",
"label": {
"commentStart": 610,
"end": 0,
"name": "y",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 614,
"end": 0,
"raw": "0.5",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.5,
"suffix": "None"
}
}
},
{
"type": "LabeledArg",
"label": {
"commentStart": 619,
"end": 0,
"name": "z",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 623,
"end": 0,
"raw": "0",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
}
}
],
"callee": {
"abs_path": false,
"commentStart": 595,
"commentStart": 593,
"end": 0,
"name": {
"commentStart": 595,
"commentStart": 593,
"end": 0,
"name": "translate",
"start": 0,
@ -603,7 +625,7 @@ description: Result of parsing car-wheel-assembly.kcl
"start": 0,
"type": "Name"
},
"commentStart": 595,
"commentStart": 593,
"end": 0,
"start": 0,
"type": "CallExpressionKw",
@ -611,7 +633,7 @@ description: Result of parsing car-wheel-assembly.kcl
"unlabeled": null
}
],
"commentStart": 577,
"commentStart": 575,
"end": 0,
"start": 0,
"type": "PipeExpression",
@ -622,14 +644,14 @@ description: Result of parsing car-wheel-assembly.kcl
"type": "ExpressionStatement"
},
{
"commentStart": 630,
"commentStart": 626,
"end": 0,
"expression": {
"abs_path": false,
"commentStart": 630,
"commentStart": 626,
"end": 0,
"name": {
"commentStart": 630,
"commentStart": 626,
"end": 0,
"name": "carTire",
"start": 0,

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -2097,54 +2097,65 @@ description: Result of parsing scale_after_fillet.kcl
"label": {
"commentStart": 1593,
"end": 0,
"name": "scale",
"name": "x",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 1601,
"elements": [
{
"commentStart": 1602,
"end": 0,
"raw": "3.14",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 3.14,
"suffix": "None"
}
},
{
"commentStart": 1608,
"end": 0,
"raw": "3.14",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 3.14,
"suffix": "None"
}
},
{
"commentStart": 1614,
"end": 0,
"raw": "3.14",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 3.14,
"suffix": "None"
}
}
],
"commentStart": 1597,
"end": 0,
"raw": "3.14",
"start": 0,
"type": "ArrayExpression",
"type": "ArrayExpression"
"type": "Literal",
"type": "Literal",
"value": {
"value": 3.14,
"suffix": "None"
}
}
},
{
"type": "LabeledArg",
"label": {
"commentStart": 1603,
"end": 0,
"name": "y",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 1607,
"end": 0,
"raw": "3.14",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 3.14,
"suffix": "None"
}
}
},
{
"type": "LabeledArg",
"label": {
"commentStart": 1613,
"end": 0,
"name": "z",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 1617,
"end": 0,
"raw": "3.14",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 3.14,
"suffix": "None"
}
}
}
],
@ -2177,7 +2188,7 @@ description: Result of parsing scale_after_fillet.kcl
"nonCodeNodes": {
"1": [
{
"commentStart": 1620,
"commentStart": 1622,
"end": 0,
"start": 0,
"type": "NonCodeNode",

View File

@ -52,6 +52,6 @@ export fn bolt() {
}
bolt()
|> scale(scale = [3.14, 3.14, 3.14])
|> scale(x = 3.14, y = 3.14, z = 3.14)
// https://www.mcmaster.com/91251a404/

View File

@ -56,6 +56,6 @@ export fn bolt() {
}
bolt()
|> scale(scale = [3.14, 3.14, 3.14])
|> scale(x = 3.14, y = 3.14, z = 3.14)
// https://www.mcmaster.com/91251a404/

View File

@ -2097,54 +2097,65 @@ description: Result of parsing translate_after_fillet.kcl
"label": {
"commentStart": 1597,
"end": 0,
"name": "translate",
"name": "x",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 1601,
"end": 0,
"raw": "10",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 10.0,
"suffix": "None"
}
}
},
{
"type": "LabeledArg",
"label": {
"commentStart": 1605,
"end": 0,
"name": "y",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 1609,
"elements": [
{
"commentStart": 1610,
"end": 0,
"raw": "10",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 10.0,
"suffix": "None"
}
},
{
"commentStart": 1614,
"end": 0,
"raw": "0",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
},
{
"commentStart": 1617,
"end": 0,
"raw": "0",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
}
],
"end": 0,
"raw": "0",
"start": 0,
"type": "ArrayExpression",
"type": "ArrayExpression"
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
}
},
{
"type": "LabeledArg",
"label": {
"commentStart": 1612,
"end": 0,
"name": "z",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 1616,
"end": 0,
"raw": "0",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
}
}
],
@ -2177,7 +2188,7 @@ description: Result of parsing translate_after_fillet.kcl
"nonCodeNodes": {
"1": [
{
"commentStart": 1620,
"commentStart": 1618,
"end": 0,
"start": 0,
"type": "NonCodeNode",

View File

@ -52,6 +52,6 @@ export fn bolt() {
}
bolt()
|> translate(translate = [10, 0, 0])
|> translate(x = 10, y = 0, z = 0)
// https://www.mcmaster.com/91251a404/

View File

@ -56,6 +56,6 @@ export fn bolt() {
}
bolt()
|> translate(translate = [10, 0, 0])
|> translate(x = 10, y = 0, z = 0)
// https://www.mcmaster.com/91251a404/