From 563ed6751b30476974a365a183e3f1a50d1348ba Mon Sep 17 00:00:00 2001 From: Jonathan Tran Date: Fri, 14 Mar 2025 15:37:56 -0400 Subject: [PATCH] Change tolerance to use the module units --- rust/kcl-lib/src/std/fillet.rs | 2 +- rust/kcl-lib/src/std/loft.rs | 2 +- rust/kcl-lib/src/std/revolve.rs | 10 ++++++++-- rust/kcl-lib/src/std/sweep.rs | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/rust/kcl-lib/src/std/fillet.rs b/rust/kcl-lib/src/std/fillet.rs index 62dbeed0d..2f622cc23 100644 --- a/rust/kcl-lib/src/std/fillet.rs +++ b/rust/kcl-lib/src/std/fillet.rs @@ -167,7 +167,7 @@ async fn inner_fillet( edge_id, object_id: solid.id, radius: LengthUnit(radius), - tolerance: LengthUnit(tolerance.unwrap_or(default_tolerance(&args.ctx.settings.units))), + tolerance: LengthUnit(tolerance.unwrap_or_else(|| default_tolerance(&exec_state.length_unit().into()))), cut_type: CutType::Fillet, // We make this a none so that we can remove it in the future. face_id: None, diff --git a/rust/kcl-lib/src/std/loft.rs b/rust/kcl-lib/src/std/loft.rs index d31ca6873..41f65011e 100644 --- a/rust/kcl-lib/src/std/loft.rs +++ b/rust/kcl-lib/src/std/loft.rs @@ -149,7 +149,7 @@ async fn inner_loft( section_ids: sketches.iter().map(|group| group.id).collect(), base_curve_index, bez_approximate_rational, - tolerance: LengthUnit(tolerance.unwrap_or(default_tolerance(&args.ctx.settings.units))), + tolerance: LengthUnit(tolerance.unwrap_or_else(|| default_tolerance(&exec_state.length_unit().into()))), v_degree, }), ) diff --git a/rust/kcl-lib/src/std/revolve.rs b/rust/kcl-lib/src/std/revolve.rs index aba2782cc..4df5a0140 100644 --- a/rust/kcl-lib/src/std/revolve.rs +++ b/rust/kcl-lib/src/std/revolve.rs @@ -239,7 +239,10 @@ async fn inner_revolve( target: sketch.id.into(), axis, origin, - tolerance: LengthUnit(data.tolerance.unwrap_or(default_tolerance(&args.ctx.settings.units))), + tolerance: LengthUnit( + data.tolerance + .unwrap_or_else(|| default_tolerance(&exec_state.length_unit().into())), + ), axis_is_2d: true, }), ) @@ -253,7 +256,10 @@ async fn inner_revolve( angle, target: sketch.id.into(), edge_id, - tolerance: LengthUnit(data.tolerance.unwrap_or(default_tolerance(&args.ctx.settings.units))), + tolerance: LengthUnit( + data.tolerance + .unwrap_or_else(|| default_tolerance(&exec_state.length_unit().into())), + ), }), ) .await?; diff --git a/rust/kcl-lib/src/std/sweep.rs b/rust/kcl-lib/src/std/sweep.rs index 982dcafa4..e86161382 100644 --- a/rust/kcl-lib/src/std/sweep.rs +++ b/rust/kcl-lib/src/std/sweep.rs @@ -163,7 +163,7 @@ async fn inner_sweep( target: sketch.id.into(), trajectory, sectional: sectional.unwrap_or(false), - tolerance: LengthUnit(tolerance.unwrap_or(default_tolerance(&args.ctx.settings.units))), + tolerance: LengthUnit(tolerance.unwrap_or_else(|| default_tolerance(&exec_state.length_unit().into()))), }), ) .await?;