Skip to content

Commit

Permalink
Allow standard planes to appear in the artifact graph (#4594)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtran authored and jessfraz committed Dec 5, 2024
1 parent 75be4b9 commit fb35565
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/lang/std/__snapshots__/artifactGraph.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Map {
],
],
"range": [
37,
64,
12,
31,
0,
],
},
Expand Down
55 changes: 31 additions & 24 deletions src/wasm-lib/kcl/src/std/sketch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1113,46 +1113,53 @@ async fn make_sketch_plane_from_orientation(
exec_state: &mut ExecState,
args: &Args,
) -> Result<Box<Plane>, 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))
}
Expand Down

0 comments on commit fb35565

Please sign in to comment.