Convert all lengths to mm for engine calls

Signed-off-by: Nick Cameron <nrc@ncameron.org>
This commit is contained in:
Nick Cameron
2025-04-11 13:17:19 +12:00
parent 6288ab5f2f
commit f93979c648
301 changed files with 20915 additions and 17482 deletions

View File

@ -15,8 +15,7 @@ use crate::{
pub async fn offset_plane(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let std_plane = args.get_unlabeled_kw_arg("plane")?;
let offset: TyF64 = args.get_kw_arg_typed("offset", &RuntimeType::length(), exec_state)?;
let plane = inner_offset_plane(std_plane, offset.n, exec_state).await?;
make_offset_plane_in_engine(&plane, exec_state, &args).await?;
let plane = inner_offset_plane(std_plane, offset, exec_state, &args).await?;
Ok(KclValue::Plane { value: Box::new(plane) })
}
@ -112,13 +111,19 @@ pub async fn offset_plane(exec_state: &mut ExecState, args: Args) -> Result<KclV
offset = { docs = "Distance from the standard plane this new plane will be created at." },
}
}]
async fn inner_offset_plane(plane: PlaneData, offset: f64, exec_state: &mut ExecState) -> Result<Plane, KclError> {
async fn inner_offset_plane(
plane: PlaneData,
offset: TyF64,
exec_state: &mut ExecState,
args: &Args,
) -> Result<Plane, KclError> {
let mut plane = Plane::from_plane_data(plane, exec_state);
// Though offset planes might be derived from standard planes, they are not
// standard planes themselves.
plane.value = PlaneType::Custom;
plane.origin += plane.z_axis * offset;
plane.origin += plane.z_axis * offset.to_length_units(plane.origin.units);
make_offset_plane_in_engine(&plane, exec_state, args).await?;
Ok(plane)
}