POC: solid_id as loft field
This commit is contained in:
@ -4,10 +4,7 @@ use std::num::NonZeroU32;
|
|||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use derive_docs::stdlib;
|
use derive_docs::stdlib;
|
||||||
use kcmc::{
|
use kcmc::{each_cmd as mcmd, length_unit::LengthUnit, ModelingCmd};
|
||||||
each_cmd as mcmd, length_unit::LengthUnit, ok_response::OkModelingCmdResponse, websocket::OkWebSocketResponseData,
|
|
||||||
ModelingCmd,
|
|
||||||
};
|
|
||||||
use kittycad_modeling_cmds as kcmc;
|
use kittycad_modeling_cmds as kcmc;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@ -145,9 +142,10 @@ async fn inner_loft(
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
let id: uuid::Uuid = exec_state.next_uuid();
|
let id = exec_state.next_uuid();
|
||||||
let resp = args
|
let solid_id = exec_state.next_uuid();
|
||||||
.send_modeling_cmd(
|
// TODO: get engine team to add the solid_id field
|
||||||
|
args.batch_modeling_cmd(
|
||||||
id,
|
id,
|
||||||
ModelingCmd::from(mcmd::Loft {
|
ModelingCmd::from(mcmd::Loft {
|
||||||
section_ids: sketches.iter().map(|group| group.id).collect(),
|
section_ids: sketches.iter().map(|group| group.id).collect(),
|
||||||
@ -155,24 +153,16 @@ async fn inner_loft(
|
|||||||
bez_approximate_rational,
|
bez_approximate_rational,
|
||||||
tolerance: LengthUnit(tolerance.unwrap_or(default_tolerance(&args.ctx.settings.units))),
|
tolerance: LengthUnit(tolerance.unwrap_or(default_tolerance(&args.ctx.settings.units))),
|
||||||
v_degree,
|
v_degree,
|
||||||
|
solid_id,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let OkWebSocketResponseData::Modeling {
|
// Take the sketch with the most paths, as its edges are spawning the loft faces
|
||||||
modeling_response: OkModelingCmdResponse::Loft(data),
|
|
||||||
} = &resp
|
|
||||||
else {
|
|
||||||
return Err(KclError::Engine(KclErrorDetails {
|
|
||||||
message: format!("mcmd::Loft response was not as expected: {:?}", resp),
|
|
||||||
source_ranges: vec![args.source_range],
|
|
||||||
}));
|
|
||||||
};
|
|
||||||
|
|
||||||
// Take the sketch with the most paths, and override its id with the loft's solid_id (to get its faces)
|
|
||||||
let mut desc_sorted_sketches = sketches.to_vec();
|
let mut desc_sorted_sketches = sketches.to_vec();
|
||||||
desc_sorted_sketches.sort_by(|s0, s1| s1.paths.len().cmp(&s0.paths.len()));
|
desc_sorted_sketches.sort_by(|s0, s1| s1.paths.len().cmp(&s0.paths.len()));
|
||||||
let mut sketch = desc_sorted_sketches[0].clone();
|
let mut sketch = desc_sorted_sketches[0].clone();
|
||||||
sketch.id = data.solid_id;
|
// Overwrite the sketch id with the loft id, so it gets picked up to get the face info in post_extrude
|
||||||
|
sketch.id = solid_id;
|
||||||
do_post_extrude(sketch, 0.0, exec_state, args).await
|
do_post_extrude(sketch, 0.0, exec_state, args).await
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user