POC: solid_id as loft field
This commit is contained in:
		| @ -4,10 +4,7 @@ use std::num::NonZeroU32; | ||||
|  | ||||
| use anyhow::Result; | ||||
| use derive_docs::stdlib; | ||||
| use kcmc::{ | ||||
|     each_cmd as mcmd, length_unit::LengthUnit, ok_response::OkModelingCmdResponse, websocket::OkWebSocketResponseData, | ||||
|     ModelingCmd, | ||||
| }; | ||||
| use kcmc::{each_cmd as mcmd, length_unit::LengthUnit, ModelingCmd}; | ||||
| use kittycad_modeling_cmds as kcmc; | ||||
|  | ||||
| use crate::{ | ||||
| @ -145,9 +142,10 @@ async fn inner_loft( | ||||
|         })); | ||||
|     } | ||||
|  | ||||
|     let id: uuid::Uuid = exec_state.next_uuid(); | ||||
|     let resp = args | ||||
|         .send_modeling_cmd( | ||||
|     let id = exec_state.next_uuid(); | ||||
|     let solid_id = exec_state.next_uuid(); | ||||
|     // TODO: get engine team to add the solid_id field | ||||
|     args.batch_modeling_cmd( | ||||
|             id, | ||||
|             ModelingCmd::from(mcmd::Loft { | ||||
|                 section_ids: sketches.iter().map(|group| group.id).collect(), | ||||
| @ -155,24 +153,16 @@ async fn inner_loft( | ||||
|                 bez_approximate_rational, | ||||
|                 tolerance: LengthUnit(tolerance.unwrap_or(default_tolerance(&args.ctx.settings.units))), | ||||
|                 v_degree, | ||||
|                 solid_id, | ||||
|             }), | ||||
|         ) | ||||
|         .await?; | ||||
|  | ||||
|     let OkWebSocketResponseData::Modeling { | ||||
|         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) | ||||
|     // Take the sketch with the most paths, as its edges are spawning the loft faces | ||||
|     let mut desc_sorted_sketches = sketches.to_vec(); | ||||
|     desc_sorted_sketches.sort_by(|s0, s1| s1.paths.len().cmp(&s0.paths.len())); | ||||
|     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 | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user