Feature fields: a type for each role (Expr, BodyName, FacePick…) (#1273)

Thanks @jijinbei.
This commit is contained in:
JIJINBEI authored and GitHub committed 2026-10-16 00:28:12 -04:00
1 parent 3333f8a62b
commit 44968dbfe6
59 files changed
+1505 -1043

No files matched your search

+6 -6
View File
@@ -200,8 +200,8 @@ impl Mapper<'_> {
fn make_expr(&mut self, m: &Mat, v: &Value) -> Option<Value> {
let a = v.as_array().filter(|a| a.len() == 3)?;
let c = |i: usize| match a.get(i)? {
Value::Number(n) => n.as_f64().filter(|x| x.is_finite()).map(|x| format!("{x}")),
Value::String(e) => Some(e.clone()),
Value::Number(n) => n.as_f64().filter(|x| x.is_finite()).map(|x| solidcraft_doc::Expr::new(format!("{x}"))),
Value::String(e) => Some(solidcraft_doc::Expr::new(e.as_str())),
_ => None,
};
let mut p = [c(0)?, c(1)?, c(2)?];
@@ -349,9 +349,9 @@ pub fn to_local(s: &Session, id: &str, params: &Value) -> Option<Value> {
&& let solidcraft_doc::FeatureKind::Revolve { axis: solidcraft_doc::AxisRef::Line { origin, dir }, .. } = &feature.kind
{
let frame = context.active_component_frame();
let displayed = serde_json::json!({"origin":pt(apply_point(&frame,*origin)),"dir":pt(apply_vector(&frame,*dir))});
let displayed = serde_json::json!({"origin":pt(apply_point(&frame,origin.0)),"dir":pt(apply_vector(&frame,dir.0))});
if params.get("params").and_then(|p| p.get("axis")) == Some(&displayed) {
inner["axis"] = serde_json::json!({"origin":pt(*origin),"dir":pt(*dir)});
inner["axis"] = serde_json::json!({"origin":pt(origin.0),"dir":pt(dir.0)});
}
}
let points = match (&feature.kind, cmd) {
@@ -361,9 +361,9 @@ pub fn to_local(s: &Session, id: &str, params: &Value) -> Option<Value> {
};
for (key, point) in points {
if let Some(point) = point {
let displayed = pt(apply_point(&context.active_component_frame(), point));
let displayed = pt(apply_point(&context.active_component_frame(), point.0));
if params.get("params").and_then(|p| p.get(key)) == Some(&displayed) {
inner[key] = pt(point);
inner[key] = pt(point.0);
}
}
}