diff --git a/src/lang/std/__snapshots__/artifactGraph.test.ts.snap b/src/lang/std/__snapshots__/artifactGraph.test.ts.snap index 4a5beb7f2..6b375bd39 100644 --- a/src/lang/std/__snapshots__/artifactGraph.test.ts.snap +++ b/src/lang/std/__snapshots__/artifactGraph.test.ts.snap @@ -11,8 +11,8 @@ Map { ], ], "range": [ - 37, - 64, + 12, + 31, 0, ], }, diff --git a/src/wasm-lib/kcl/src/std/sketch.rs b/src/wasm-lib/kcl/src/std/sketch.rs index c456e3ba4..0afc3b5d4 100644 --- a/src/wasm-lib/kcl/src/std/sketch.rs +++ b/src/wasm-lib/kcl/src/std/sketch.rs @@ -1113,46 +1113,53 @@ async fn make_sketch_plane_from_orientation( exec_state: &mut ExecState, args: &Args, ) -> Result, KclError> { - let mut plane = Plane::from_plane_data(data.clone(), exec_state); + let plane = Plane::from_plane_data(data.clone(), exec_state); - // Get the default planes. - let default_planes = args - .ctx - .engine - .default_planes(&mut exec_state.id_generator, args.source_range) - .await?; - - plane.id = match data { - PlaneData::XY => default_planes.xy, - PlaneData::NegXY => default_planes.neg_xy, - PlaneData::XZ => default_planes.xz, - PlaneData::NegXZ => default_planes.neg_xz, - PlaneData::YZ => default_planes.yz, - PlaneData::NegYZ => default_planes.neg_yz, + // Create the plane on the fly. + let clobber = false; + let size = LengthUnit(60.0); + let hide = Some(true); + match data { + PlaneData::XY | PlaneData::NegXY | PlaneData::XZ | PlaneData::NegXZ | PlaneData::YZ | PlaneData::NegYZ => { + let x_axis = match data { + PlaneData::NegXY => Point3d::new(-1.0, 0.0, 0.0), + PlaneData::NegXZ => Point3d::new(-1.0, 0.0, 0.0), + PlaneData::NegYZ => Point3d::new(0.0, -1.0, 0.0), + _ => plane.x_axis, + }; + args.batch_modeling_cmd( + plane.id, + ModelingCmd::from(mcmd::MakePlane { + clobber, + origin: plane.origin.into(), + size, + x_axis: x_axis.into(), + y_axis: plane.y_axis.into(), + hide, + }), + ) + .await?; + } PlaneData::Plane { origin, x_axis, y_axis, z_axis: _, } => { - // Create the custom plane on the fly. - let id = exec_state.id_generator.next_uuid(); args.batch_modeling_cmd( - id, + plane.id, ModelingCmd::from(mcmd::MakePlane { - clobber: false, + clobber, origin: (*origin).into(), - size: LengthUnit(60.0), + size, x_axis: (*x_axis).into(), y_axis: (*y_axis).into(), - hide: Some(true), + hide, }), ) .await?; - - id } - }; + } Ok(Box::new(plane)) }