Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add building the artifact graph in sketch mode #5093

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/lang/KclSingleton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ export class KclManager {
this.lastSuccessfulProgramMemory = execState.memory
this.lastSuccessfulOperations = execState.operations
}
this.engineCommandManager.updateArtifactGraph(execState.artifactGraph)
}
cancelAllExecutions() {
this._cancelTokens.forEach((_, key) => {
Expand Down
19 changes: 10 additions & 9 deletions src/wasm-lib/kcl/src/execution/artifact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,10 +580,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;

Expand Down Expand Up @@ -693,7 +690,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,
Expand Down Expand Up @@ -734,7 +731,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();
Expand Down Expand Up @@ -764,7 +761,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();
Expand Down Expand Up @@ -852,6 +849,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 {
Expand All @@ -867,7 +868,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(KclErrorDetails {
message:format!(
Expand All @@ -878,7 +879,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(KclErrorDetails {
message:format!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ flowchart LR
20["SweepEdge Adjacent"]
21["SweepEdge Opposite"]
22["SweepEdge Adjacent"]
23["EdgeCut Fillet<br>[202, 284, 0]"]
1 --- 2
2 --- 3
2 --- 4
Expand Down Expand Up @@ -57,4 +58,5 @@ flowchart LR
8 --- 20
8 --- 21
8 --- 22
16 <--x 23
```
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ flowchart LR
20["SweepEdge Adjacent"]
21["SweepEdge Opposite"]
22["SweepEdge Adjacent"]
23["EdgeCut Fillet<br>[202, 288, 0]"]
1 --- 2
2 --- 3
2 --- 4
Expand Down Expand Up @@ -57,4 +58,5 @@ flowchart LR
8 --- 20
8 --- 21
8 --- 22
18 <--x 23
```
Loading