SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Merge origin/main into feat/profiles-by-curve-ids
CypherNaugh_0x4c466466a2fc
diff --cc crates/engine/src/cmd/edit.rsindex 528075baf1,f18010dfac..cbcfff75a7--- a/crates/engine/src/cmd/edit.rs+++ b/crates/engine/src/cmd/edit.rs@@@ -190,29 -195,52 +195,75 @@@ fn merge(dst: &mut Value, src: &Value,}}+/// `profiles` (also a loft section's) given as the feature commands take it (`"all"`,+/// `[index]`, `[{curves}]`, `[{point}]`...) becomes the stored form; the stored form passes.+fn command_profiles(set: &Value, cmd: &str) -> Result<Value> {+ let conv = |v: &mut Value| -> Result<()> {+ if let Some(pv) = v.get("profiles").filter(|x| x.get("type").is_none()) {+ let sel = super::features::profiles(&json!({"profiles": pv}), cmd)?;+ let sv = serde_json::to_value(sel).map_err(|e| EngineError::Other(e.to_string()))?;+ if let Some(o) = v.as_object_mut() {+ o.insert("profiles".into(), sv);+ }+ }+ Ok(())+ };+ let mut set = set.clone();+ conv(&mut set)?;+ if let Some(secs) = set.get_mut("sections").and_then(Value::as_array_mut) {+ for sec in secs.iter_mut().take(10_000) {+ conv(sec)?;+ }+ }+ Ok(set)+}++ /// Fields of a stored feature left out of its definition: bookkeeping timeline.edit recomputes, and+ /// the name and suppression, which timeline.rename and timeline.suppress change.+ const NOT_EDITABLE: &[&str] = &["id", "type", "name", "suppressed", "param_names", "edge_refs", "edge_names", "face_names"];++ fn inspect_feature(s: &mut Session, p: &Value) -> Result<Value> {+ let cmd = "timeline.inspect";+ let id = feature_id(s, p.get("feature"), cmd)?;+ let f = s.doc.feature(id).ok_or_else(|| bad(cmd, "feature"))?;+ let mut def = serde_json::to_value(f).map_err(|e| EngineError::Other(e.to_string()))?;+ let mut omitted = Vec::new();+ if let Some(o) = def.as_object_mut() {+ for k in NOT_EDITABLE {+ o.remove(*k);+ }+ // Large payloads that timeline.edit cannot change.+ let heavy: &[(&str, &str)] = match &f.kind {+ FeatureKind::Sketch { .. } => &[("sketch", "the sketch geometry (sketch.inspect; edit it with the sketch commands)")],+ FeatureKind::Import { .. } => &[("step", "the imported STEP text"), ("components", "the imported product tree")],+ FeatureKind::MeshImport { .. } => &[("meshes", "the imported meshes")],+ _ => &[],+ };+ for (k, why) in heavy {+ if o.remove(*k).is_some() {+ omitted.push(json!({"field": k, "what": why}));+ }+ }+ }+ let inputs: Vec<Value> = f+ .kind+ .inputs()+ .into_iter()+ .enumerate()+ .map(|(i, (label, e, k))| {+ json!({"label": label, "param": f.param_names.get(i).filter(|n| !n.is_empty()), "expression": e, "unit": k.default_unit()})+ })+ .collect();+ let marker = s.doc.marker.unwrap_or(usize::MAX);+ let rolled_back = s.doc.features.iter().position(|x| x.id == id).is_some_and(|i| i >= marker);+ let r = s.model.result(id);+ Ok(json!({+ "id": f.id, "name": f.name, "type": f.kind.type_name(), "suppressed": f.suppressed, "rolled_back": rolled_back,+ "definition": def, "omitted": omitted, "inputs": inputs,+ "error": r.and_then(|r| r.error.clone()), "warning": r.and_then(|r| r.warning.clone()),+ }))+ }+fn edit_feature(s: &mut Session, p: &Value) -> Result<Value> {let cmd = "timeline.edit";let id = feature_id(s, p.get("feature"), cmd)?;