From 8103277647341e1b31497f0760b6448f15bcea05 Mon Sep 17 00:00:00 2001 From: Jonathan Tran Date: Thu, 16 Jan 2025 18:49:35 -0500 Subject: [PATCH] Add building the artifact graph in sketch mode --- src/wasm-lib/kcl/src/execution/artifact.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/wasm-lib/kcl/src/execution/artifact.rs b/src/wasm-lib/kcl/src/execution/artifact.rs index 3dfb2a3ba4..287a3d6899 100644 --- a/src/wasm-lib/kcl/src/execution/artifact.rs +++ b/src/wasm-lib/kcl/src/execution/artifact.rs @@ -572,10 +572,7 @@ fn artifacts_to_update( let uuid = artifact_command.cmd_id; let id = ArtifactId::new(uuid); - let Some(response) = responses.get(&uuid) else { - // Response not found or not successful. - return Ok(Vec::new()); - }; + let response = responses.get(&uuid); let cmd = &artifact_command.command; @@ -679,7 +676,7 @@ fn artifacts_to_update( new_path.seg_ids = vec![id]; return_arr.push(Artifact::Path(new_path)); } - if let OkModelingCmdResponse::ClosePath(close_path) = response { + if let Some(OkModelingCmdResponse::ClosePath(close_path)) = response { return_arr.push(Artifact::Solid2d(Solid2d { id: close_path.face_id.into(), path_id, @@ -720,7 +717,7 @@ fn artifacts_to_update( return Ok(return_arr); } ModelingCmd::Loft(loft_cmd) => { - let OkModelingCmdResponse::Loft(_) = response else { + let Some(OkModelingCmdResponse::Loft(_)) = response else { return Ok(Vec::new()); }; let mut return_arr = Vec::new(); @@ -749,7 +746,7 @@ fn artifacts_to_update( return Ok(return_arr); } ModelingCmd::Solid3dGetExtrusionFaceInfo(_) => { - let OkModelingCmdResponse::Solid3dGetExtrusionFaceInfo(face_info) = response else { + let Some(OkModelingCmdResponse::Solid3dGetExtrusionFaceInfo(face_info)) = response else { return Ok(Vec::new()); }; let mut return_arr = Vec::new(); @@ -831,6 +828,10 @@ fn artifacts_to_update( ModelingCmd::Solid3dGetOppositeEdge(_) => SweepEdgeSubType::Opposite, _ => unreachable!(), }; + // We need a response to continue. + if response.is_none() { + return Ok(Vec::new()); + } let face_id = ArtifactId::new(*face_id); let edge_id = ArtifactId::new(*edge_id); let Some(Artifact::Wall(wall)) = artifacts.get(&face_id) else { @@ -846,7 +847,7 @@ fn artifacts_to_update( return Ok(Vec::new()); }; let response_edge_id = match response { - OkModelingCmdResponse::Solid3dGetNextAdjacentEdge(r) => { + Some(OkModelingCmdResponse::Solid3dGetNextAdjacentEdge(r)) => { let Some(edge_id) = r.edge else { return Err(KclError::internal(format!( "Expected Solid3dGetNextAdjacentEdge response to have an edge ID, but found none: id={id:?}, {response:?}" @@ -854,7 +855,7 @@ fn artifacts_to_update( }; edge_id.into() } - OkModelingCmdResponse::Solid3dGetOppositeEdge(r) => r.edge.into(), + Some(OkModelingCmdResponse::Solid3dGetOppositeEdge(r)) => r.edge.into(), _ => { return Err(KclError::internal(format!( "Expected Solid3dGetNextAdjacentEdge or Solid3dGetOppositeEdge response, but got: id={id:?}, {response:?}"