make sure all enter sketch mode are with the stuff they need in the same batch order always (#5646)
* updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * comment out Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * update artifacts Signed-off-by: Jess Frazelle <github@jessfraz.com> * small Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * last of the artifacts Signed-off-by: Jess Frazelle <github@jessfraz.com> * update playwirght Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * add crazy multi-profile test Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * steps Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix artifact graph Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * cleanup Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates ; Signed-off-by: Jess Frazelle <github@jessfraz.com> * more artifact grph Signed-off-by: Jess Frazelle <github@jessfraz.com> * turn back on playwright Signed-off-by: Jess Frazelle <github@jessfraz.com> * fmt Signed-off-by: Jess Frazelle <github@jessfraz.com> * playwright fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * playwright fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
@ -1,12 +1,14 @@
|
||||
use std::{any::type_name, collections::HashMap, num::NonZeroU32};
|
||||
|
||||
use anyhow::Result;
|
||||
use kcmc::{websocket::OkWebSocketResponseData, ModelingCmd};
|
||||
use kcmc::{
|
||||
websocket::{ModelingCmdReq, OkWebSocketResponseData},
|
||||
ModelingCmd,
|
||||
};
|
||||
use kittycad_modeling_cmds as kcmc;
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::shapes::PolygonType;
|
||||
use crate::{
|
||||
errors::{KclError, KclErrorDetails},
|
||||
execution::{
|
||||
@ -16,7 +18,11 @@ use crate::{
|
||||
},
|
||||
parsing::ast::types::TagNode,
|
||||
source_range::SourceRange,
|
||||
std::{shapes::SketchOrSurface, sketch::FaceTag, sweep::SweepPath},
|
||||
std::{
|
||||
shapes::{PolygonType, SketchOrSurface},
|
||||
sketch::FaceTag,
|
||||
sweep::SweepPath,
|
||||
},
|
||||
ModuleId,
|
||||
};
|
||||
|
||||
@ -254,6 +260,11 @@ impl Args {
|
||||
self.ctx.engine.batch_modeling_cmd(id, self.source_range, &cmd).await
|
||||
}
|
||||
|
||||
// Add multiple modeling commands to the batch but don't fire them right away.
|
||||
pub(crate) async fn batch_modeling_cmds(&self, cmds: &[ModelingCmdReq]) -> Result<(), crate::errors::KclError> {
|
||||
self.ctx.engine.batch_modeling_cmds(self.source_range, cmds).await
|
||||
}
|
||||
|
||||
// Add a modeling command to the batch that gets executed at the end of the file.
|
||||
// This is good for something like fillet or chamfer where the engine would
|
||||
// eat the path id if we executed it right away.
|
||||
|
@ -5,8 +5,13 @@ use std::collections::HashMap;
|
||||
use anyhow::Result;
|
||||
use kcl_derive_docs::stdlib;
|
||||
use kcmc::{
|
||||
each_cmd as mcmd, length_unit::LengthUnit, ok_response::OkModelingCmdResponse, output::ExtrusionFaceInfo,
|
||||
shared::ExtrusionFaceCapType, websocket::OkWebSocketResponseData, ModelingCmd,
|
||||
each_cmd as mcmd,
|
||||
length_unit::LengthUnit,
|
||||
ok_response::OkModelingCmdResponse,
|
||||
output::ExtrusionFaceInfo,
|
||||
shared::ExtrusionFaceCapType,
|
||||
websocket::{ModelingCmdReq, OkWebSocketResponseData},
|
||||
ModelingCmd,
|
||||
};
|
||||
use kittycad_modeling_cmds as kcmc;
|
||||
use uuid::Uuid;
|
||||
@ -95,50 +100,24 @@ async fn inner_extrude(
|
||||
exec_state: &mut ExecState,
|
||||
args: Args,
|
||||
) -> Result<SolidSet, KclError> {
|
||||
let id = exec_state.next_uuid();
|
||||
|
||||
// Extrude the element(s).
|
||||
let sketches: Vec<Sketch> = sketch_set.into();
|
||||
let mut solids = Vec::new();
|
||||
for sketch in &sketches {
|
||||
// Before we extrude, we need to enable the sketch mode.
|
||||
// We do this here in case extrude is called out of order.
|
||||
args.batch_modeling_cmd(
|
||||
exec_state.next_uuid(),
|
||||
ModelingCmd::from(mcmd::EnableSketchMode {
|
||||
animated: false,
|
||||
ortho: false,
|
||||
entity_id: sketch.on.id(),
|
||||
adjust_camera: false,
|
||||
planar_normal: if let SketchSurface::Plane(plane) = &sketch.on {
|
||||
// We pass in the normal for the plane here.
|
||||
Some(plane.z_axis.into())
|
||||
} else {
|
||||
None
|
||||
},
|
||||
}),
|
||||
)
|
||||
let id = exec_state.next_uuid();
|
||||
args.batch_modeling_cmds(&sketch.build_sketch_mode_cmds(
|
||||
exec_state,
|
||||
ModelingCmdReq {
|
||||
cmd_id: id.into(),
|
||||
cmd: ModelingCmd::from(mcmd::Extrude {
|
||||
target: sketch.id.into(),
|
||||
distance: LengthUnit(length),
|
||||
faces: Default::default(),
|
||||
}),
|
||||
},
|
||||
))
|
||||
.await?;
|
||||
|
||||
// TODO: We're reusing the same UUID for multiple commands. This seems
|
||||
// like the artifact graph would never be able to find all the
|
||||
// responses.
|
||||
args.batch_modeling_cmd(
|
||||
id,
|
||||
ModelingCmd::from(mcmd::Extrude {
|
||||
target: sketch.id.into(),
|
||||
distance: LengthUnit(length),
|
||||
faces: Default::default(),
|
||||
}),
|
||||
)
|
||||
.await?;
|
||||
|
||||
// Disable the sketch mode.
|
||||
args.batch_modeling_cmd(
|
||||
exec_state.next_uuid(),
|
||||
ModelingCmd::SketchModeDisable(mcmd::SketchModeDisable::default()),
|
||||
)
|
||||
.await?;
|
||||
solids.push(do_post_extrude(sketch.clone(), id.into(), length, exec_state, args.clone()).await?);
|
||||
}
|
||||
|
||||
|
@ -334,6 +334,7 @@ async fn inner_get_next_adjacent_edge(
|
||||
}),
|
||||
)
|
||||
.await?;
|
||||
|
||||
let OkWebSocketResponseData::Modeling {
|
||||
modeling_response: OkModelingCmdResponse::Solid3dGetNextAdjacentEdge(adjacent_edge),
|
||||
} = &resp
|
||||
|
@ -4,7 +4,7 @@ use anyhow::Result;
|
||||
use indexmap::IndexMap;
|
||||
use kcl_derive_docs::stdlib;
|
||||
use kcmc::shared::Point2d as KPoint2d; // Point2d is already defined in this pkg, to impl ts_rs traits.
|
||||
use kcmc::{each_cmd as mcmd, length_unit::LengthUnit, shared::Angle, ModelingCmd};
|
||||
use kcmc::{each_cmd as mcmd, length_unit::LengthUnit, shared::Angle, websocket::ModelingCmdReq, ModelingCmd};
|
||||
use kittycad_modeling_cmds as kcmc;
|
||||
use kittycad_modeling_cmds::shared::PathSegment;
|
||||
use parse_display::{Display, FromStr};
|
||||
@ -230,6 +230,7 @@ async fn straight_line(
|
||||
}),
|
||||
)
|
||||
.await?;
|
||||
|
||||
let end = if is_absolute {
|
||||
point
|
||||
} else {
|
||||
@ -1217,38 +1218,43 @@ pub(crate) async fn inner_start_profile_at(
|
||||
_ => {}
|
||||
}
|
||||
|
||||
// Enter sketch mode on the surface.
|
||||
// We call this here so you can reuse the sketch surface for multiple sketches.
|
||||
let id = exec_state.next_uuid();
|
||||
args.batch_modeling_cmd(
|
||||
id,
|
||||
ModelingCmd::from(mcmd::EnableSketchMode {
|
||||
animated: false,
|
||||
ortho: false,
|
||||
entity_id: sketch_surface.id(),
|
||||
adjust_camera: false,
|
||||
planar_normal: if let SketchSurface::Plane(plane) = &sketch_surface {
|
||||
// We pass in the normal for the plane here.
|
||||
Some(plane.z_axis.into())
|
||||
} else {
|
||||
None
|
||||
},
|
||||
}),
|
||||
)
|
||||
.await?;
|
||||
|
||||
let id = exec_state.next_uuid();
|
||||
let enable_sketch_id = exec_state.next_uuid();
|
||||
let path_id = exec_state.next_uuid();
|
||||
|
||||
args.batch_modeling_cmd(path_id, ModelingCmd::from(mcmd::StartPath::default()))
|
||||
.await?;
|
||||
args.batch_modeling_cmd(
|
||||
id,
|
||||
ModelingCmd::from(mcmd::MovePathPen {
|
||||
path: path_id.into(),
|
||||
to: KPoint2d::from(to).with_z(0.0).map(LengthUnit),
|
||||
}),
|
||||
)
|
||||
let move_pen_id = exec_state.next_uuid();
|
||||
args.batch_modeling_cmds(&[
|
||||
// Enter sketch mode on the surface.
|
||||
// We call this here so you can reuse the sketch surface for multiple sketches.
|
||||
ModelingCmdReq {
|
||||
cmd: ModelingCmd::from(mcmd::EnableSketchMode {
|
||||
animated: false,
|
||||
ortho: false,
|
||||
entity_id: sketch_surface.id(),
|
||||
adjust_camera: false,
|
||||
planar_normal: if let SketchSurface::Plane(plane) = &sketch_surface {
|
||||
// We pass in the normal for the plane here.
|
||||
Some(plane.z_axis.into())
|
||||
} else {
|
||||
None
|
||||
},
|
||||
}),
|
||||
cmd_id: enable_sketch_id.into(),
|
||||
},
|
||||
ModelingCmdReq {
|
||||
cmd: ModelingCmd::from(mcmd::StartPath::default()),
|
||||
cmd_id: path_id.into(),
|
||||
},
|
||||
ModelingCmdReq {
|
||||
cmd: ModelingCmd::from(mcmd::MovePathPen {
|
||||
path: path_id.into(),
|
||||
to: KPoint2d::from(to).with_z(0.0).map(LengthUnit),
|
||||
}),
|
||||
cmd_id: move_pen_id.into(),
|
||||
},
|
||||
ModelingCmdReq {
|
||||
cmd: ModelingCmd::SketchModeDisable(mcmd::SketchModeDisable::default()),
|
||||
cmd_id: exec_state.next_uuid().into(),
|
||||
},
|
||||
])
|
||||
.await?;
|
||||
|
||||
let current_path = BasePath {
|
||||
@ -1257,7 +1263,7 @@ pub(crate) async fn inner_start_profile_at(
|
||||
tag: tag.clone(),
|
||||
units: sketch_surface.units(),
|
||||
geo_meta: GeoMeta {
|
||||
id,
|
||||
id: move_pen_id,
|
||||
metadata: args.source_range.into(),
|
||||
},
|
||||
};
|
||||
@ -1419,16 +1425,6 @@ pub(crate) async fn inner_close(
|
||||
args.batch_modeling_cmd(id, ModelingCmd::from(mcmd::ClosePath { path_id: sketch.id }))
|
||||
.await?;
|
||||
|
||||
// If we are sketching on a plane we can close the sketch now.
|
||||
if let SketchSurface::Plane(_) = sketch.on {
|
||||
// We were on a plane, disable the sketch mode.
|
||||
args.batch_modeling_cmd(
|
||||
exec_state.next_uuid(),
|
||||
ModelingCmd::SketchModeDisable(mcmd::SketchModeDisable::default()),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
let current_path = Path::ToPoint {
|
||||
base: BasePath {
|
||||
from: from.into(),
|
||||
|
Reference in New Issue
Block a user