* Dialog curve picks keep their sketch (#3726) * Format Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Format Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Adapt context-menu test to Sel::SketchCurve's sketch field Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Path Flange picks keep their sketch too Path Flange (#4096) landed after this PR and still looked its path up in the newest sketch with those ids. --------- Co-authored-by: bherbruck <brennen.herbruck@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -88,7 +88,7 @@ fn apply(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
Sel::Occurrence { path } => {
|
||||
selected_occurrences.push(s.occurrence_placement(path)?.occurrence.to_string());
|
||||
}
|
||||
Sel::SketchCurve { id } | Sel::SketchPoint { id } | Sel::SketchConstraint { id } => entities.push(id.clone()),
|
||||
Sel::SketchCurve { id, .. } | Sel::SketchPoint { id } | Sel::SketchConstraint { id } => entities.push(id.clone()),
|
||||
Sel::Feature { id } => {
|
||||
if s.doc.feature(*id).is_none() {
|
||||
return Err(bad(cmd, format!("no feature {id}")));
|
||||
|
||||
@@ -342,7 +342,7 @@ fn describe(s: &Session, sel: &Sel) -> Option<Item> {
|
||||
let v = m.measure().volume;
|
||||
plain(Geo::Tris(tris), None, json!({"type": "body", "name": name, "closed": closed, "volume_mm3": closed.then_some(v)}))
|
||||
}
|
||||
Sel::SketchCurve { id } => sketch_curve(sketch_of(s, &st, None, |sk| sk.curve_index(id).is_some())?, id),
|
||||
Sel::SketchCurve { id, sketch } => sketch_curve(sketch_of(s, &st, *sketch, |sk| sk.curve_index(id).is_some())?, id),
|
||||
Sel::ExternalSketchCurve { sketch, id } => sketch_curve(sketch_of(s, &st, Some(*sketch), |_| true)?, id),
|
||||
Sel::SketchPoint { id } | Sel::ExternalSketchPoint { id, .. } => {
|
||||
let given = match sel {
|
||||
|
||||
@@ -78,7 +78,7 @@ fn chosen(s: &Session, p: &Value) -> Vec<String> {
|
||||
s.selection
|
||||
.iter()
|
||||
.filter_map(|sel| match sel {
|
||||
Sel::SketchCurve { id } | Sel::SketchPoint { id } => Some(id.clone()),
|
||||
Sel::SketchCurve { id, .. } | Sel::SketchPoint { id } => Some(id.clone()),
|
||||
_ => None,
|
||||
})
|
||||
.collect()
|
||||
@@ -321,8 +321,11 @@ fn paste(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
}
|
||||
// The pasted geometry is selected, ready to move.
|
||||
if s.active_sketch == Some(target) {
|
||||
s.selection =
|
||||
curves.iter().map(|id| Sel::SketchCurve { id: id.clone() }).chain(lone.iter().map(|id| Sel::SketchPoint { id: id.clone() })).collect();
|
||||
s.selection = curves
|
||||
.iter()
|
||||
.map(|id| Sel::SketchCurve { id: id.clone(), sketch: None })
|
||||
.chain(lone.iter().map(|id| Sel::SketchPoint { id: id.clone() }))
|
||||
.collect();
|
||||
}
|
||||
Ok(json!({"curves": curves, "points": lone, "constraints": constraints, "translate": [t.x, t.y], "sketch": info}))
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ fn copy_paste_keeps_internal_constraints_and_dimensions_and_drops_outside_ones()
|
||||
.and_then(|d| d.param.clone())
|
||||
.unwrap();
|
||||
// The paste is selected.
|
||||
let sel: Vec<_> = s.selection.iter().filter_map(|x| if let Sel::SketchCurve { id } = x { Some(id.clone()) } else { None }).collect();
|
||||
let sel: Vec<_> = s.selection.iter().filter_map(|x| if let Sel::SketchCurve { id, .. } = x { Some(id.clone()) } else { None }).collect();
|
||||
assert_eq!(sel, pasted);
|
||||
// The pasted rectangle is free to move (the original is held by the origin): dragging it moves it.
|
||||
run(&mut s, "sketch.drag", json!({"entity": pasted[0], "from": [p0[0].x, p0[0].y], "to": [p0[0].x + 5.0, p0[0].y + 5.0]}));
|
||||
@@ -138,8 +138,10 @@ fn every_kind_of_sketch_geometry_pastes() {
|
||||
all.push(point_id.clone());
|
||||
all.push(text_curve);
|
||||
// Copy from the selection, as Ctrl+C does.
|
||||
s.selection =
|
||||
all.iter().map(|id| if *id == point_id { Sel::SketchPoint { id: id.clone() } } else { Sel::SketchCurve { id: id.clone() } }).collect();
|
||||
s.selection = all
|
||||
.iter()
|
||||
.map(|id| if *id == point_id { Sel::SketchPoint { id: id.clone() } } else { Sel::SketchCurve { id: id.clone(), sketch: None } })
|
||||
.collect();
|
||||
run(&mut s, "sketch.copy", json!({}));
|
||||
let out = run(&mut s, "sketch.paste", json!({"translate": [0, 100]}));
|
||||
let sk = sketch(&s, sid);
|
||||
|
||||
Reference in New Issue
Block a user