Allow standard planes to appear in the artifact graph (#4594)

This commit is contained in:
Jonathan Tran
2024-12-04 16:06:02 -05:00
committed by GitHub
parent 023a659491
commit ea3d604b73
2 changed files with 33 additions and 26 deletions

View File

@ -11,8 +11,8 @@ Map {
], ],
], ],
"range": [ "range": [
37, 12,
64, 31,
0, 0,
], ],
}, },

View File

@ -1113,46 +1113,53 @@ async fn make_sketch_plane_from_orientation(
exec_state: &mut ExecState, exec_state: &mut ExecState,
args: &Args, args: &Args,
) -> Result<Box<Plane>, KclError> { ) -> 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. // Create the plane on the fly.
let default_planes = args let clobber = false;
.ctx let size = LengthUnit(60.0);
.engine let hide = Some(true);
.default_planes(&mut exec_state.id_generator, args.source_range) 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?; .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,
PlaneData::Plane { PlaneData::Plane {
origin, origin,
x_axis, x_axis,
y_axis, y_axis,
z_axis: _, z_axis: _,
} => { } => {
// Create the custom plane on the fly.
let id = exec_state.id_generator.next_uuid();
args.batch_modeling_cmd( args.batch_modeling_cmd(
id, plane.id,
ModelingCmd::from(mcmd::MakePlane { ModelingCmd::from(mcmd::MakePlane {
clobber: false, clobber,
origin: (*origin).into(), origin: (*origin).into(),
size: LengthUnit(60.0), size,
x_axis: (*x_axis).into(), x_axis: (*x_axis).into(),
y_axis: (*y_axis).into(), y_axis: (*y_axis).into(),
hide: Some(true), hide,
}), }),
) )
.await?; .await?;
id
} }
}; }
Ok(Box::new(plane)) Ok(Box::new(plane))
} }