SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Paste saved linked designs at the viewport pointer (#2430) (#2433)
amolinari-autotex07be3f885226
diff --git a/crates/engine/src/cmd/component.rs b/crates/engine/src/cmd/component.rsindex 847737fc41..bbd341e450 100644--- a/crates/engine/src/cmd/component.rs+++ b/crates/engine/src/cmd/component.rs@@ -107,7 +107,7 @@ pub(super) fn valid_position(m: &Mat) -> bool {&& (m[3][3] - 1.0).abs() < 1e-9}-fn new_component(s: &mut Session, p: &Value) -> Result<Value> {+pub(super) fn new_component(s: &mut Session, p: &Value) -> Result<Value> {let cmd = "component.create";let parent = if p.get("parent").is_some() { component(s, p, "parent", cmd)? } else { s.active_component };let parent_path = if let Some(value) = p.get("parent_path") {@@ -312,7 +312,7 @@ fn move_sketches(s: &mut Session, p: &Value) -> Result<Value> {Ok(json!({"sketches": ids, "component": to}))}-fn copy_occurrence(s: &mut Session, p: &Value) -> Result<Value> {+pub(super) fn copy_occurrence(s: &mut Session, p: &Value) -> Result<Value> {let cmd = "occurrence.copy";let selected = if p.get("occurrence").is_some() {let o = occurrence(s, p, cmd)?;diff --git a/crates/engine/src/cmd/component_link.rs b/crates/engine/src/cmd/component_link.rsindex 343c674911..95f029e3f6 100644--- a/crates/engine/src/cmd/component_link.rs+++ b/crates/engine/src/cmd/component_link.rs@@ -23,7 +23,8 @@ mod relink_tests;pub static COMMANDS: &[CommandSpec] = &[CommandSpec::new("component.insert_design", "Insert Design", insert_design).at("SOLID", "ASSEMBLE").icon("component").params("path: a .solidcraft design → a new component linked to it, holding its solid bodies as placed in that design; \- name? (default: the design's name); parent?: component id or name (default: the active one); translate?: [x,y,z]",+ name? (default: the design's name); parent?: component id or name (default: the active one); translate?: [x,y,z]; \+ reuse?: bool (default false): insert another occurrence of an existing link to the same file",),CommandSpec::new("component.update_links", "Update Links", update_links).icon("update").params("component?: id or name (default: every linked component) — reads the linked designs again and replaces their bodies where they changed",@@ -147,13 +148,23 @@ fn insert_design(s: &mut Session, p: &Value) -> Result<Value> {Some(v) => vec3(v).filter(|t| t.is_finite() && t.len() < 1e9).ok_or_else(|| bad(cmd, "`translate` must be [x, y, z] in mm"))?,};let file = absolute(Path::new(given));+ if s.path.as_deref().is_some_and(|own| absolute(Path::new(own)) == file) {+ return Err(bad(cmd, "a design can't be linked into itself"));+ }+ if p.get("reuse").and_then(Value::as_bool).unwrap_or(false) {+ let existing = s.doc.links.iter().find(|(_, link)| absolute(&resolve(s.path.as_deref(), &link.path)) == file).map(|(id, _)| *id);+ if let Some(component) = existing {+ let parent = p.get("parent").cloned().unwrap_or_else(|| json!(s.active_component));+ return super::component::copy_occurrence(s, &json!({"component": component, "parent": parent, "translate": translate}));+ }+ }let (design_name, sf) = linked_bodies(&file, s.path.as_deref())?;let name = str_(p, "name").filter(|n| !n.trim().is_empty()).map(str::to_string).unwrap_or(design_name);let mut create = json!({"name": name, "activate": false});if let Some(parent) = p.get("parent") {create["parent"] = parent.clone();}- let made = s.execute("component.create", &create)?;+ let made = super::component::new_component(s, &create)?;let comp = made["component"].as_u64().ok_or_else(|| bad(cmd, "the component was not created"))?;let occ = made["occurrence"].as_u64();let id = s.doc_mut().add_feature(sf.kind, Some(&name))?;diff --git a/crates/ui-egui/src/context_menu.rs b/crates/ui-egui/src/context_menu.rsindex 0c1d9e4a5c..b71b08e23b 100644--- a/crates/ui-egui/src/context_menu.rs+++ b/crates/ui-egui/src/context_menu.rs@@ -733,6 +733,8 @@ fn component_items(app: &SolveApp, id: u64) -> Vec<Item> {}v.push(cmd(app, "component.create", "New Component").with(json!({ "parent": id })));if id == 0 {+ v.push(act("ui.copyDesign", "Copy", "").key("Ctrl+C"));+ v.push(act("ui.paste", "Paste", "").key("Ctrl+V").on(crate::edit_clipboard::can_paste(app)));v.push(cmd(app, "component.from_bodies", "Create Components from Bodies").with(json!({ "bodies": names })).on(!bodies.is_empty()));}v.push(Item::sep());@@ -945,6 +947,7 @@ pub fn run_item(app: &mut SolveApp, item: &Item, at: Pos2) {}}"ui.copy" => drop(crate::edit_clipboard::copy(app)),+ "ui.copyDesign" => drop(crate::edit_clipboard::copy_design(app)),"ui.cut" => drop(crate::edit_clipboard::cut(app)),"ui.paste" => drop(crate::edit_clipboard::paste(app, Some(at))),"ui.editSketchPattern" => {diff --git a/crates/ui-egui/src/documents.rs b/crates/ui-egui/src/documents.rsindex fced2be8a0..5b869b2795 100644--- a/crates/ui-egui/src/documents.rs+++ b/crates/ui-egui/src/documents.rs@@ -22,6 +22,7 @@ pub struct DocSlot {pre_sketch_cam: Option<Camera>,pre_sketch_marker: Option<Option<usize>>,view: DocView,+ occurrence_move: Option<crate::browser::OccMove>,}/// The per-design part of the UI state (what is hidden, shown or locked).@@ -36,7 +37,7 @@ struct DocView {impl DocSlot {fn new(session: Session) -> DocSlot {- DocSlot { session, cam: Camera::default(), pre_sketch_cam: None, pre_sketch_marker: None, view: DocView::default() }+ DocSlot { session, cam: Camera::default(), pre_sketch_cam: None, pre_sketch_marker: None, view: DocView::default(), occurrence_move: None }}}@@ -111,6 +112,7 @@ fn swap_in(app: &mut SolveApp, slot: DocSlot) -> DocSlot {pre_sketch_cam: std::mem::replace(&mut app.pre_sketch_cam, slot.pre_sketch_cam),pre_sketch_marker: std::mem::replace(&mut app.pre_sketch_marker, slot.pre_sketch_marker),view: take_view(app),+ occurrence_move: std::mem::replace(&mut app.tree.occurrence_move, slot.occurrence_move),};put_view(app, slot.view);// Preferences the session holds go with the user, not the tab (#680).diff --git a/crates/ui-egui/src/edit_clipboard.rs b/crates/ui-egui/src/edit_clipboard.rsindex 3806474e64..312167a4e3 100644--- a/crates/ui-egui/src/edit_clipboard.rs+++ b/crates/ui-egui/src/edit_clipboard.rs@@ -42,16 +42,39 @@ fn sketch_selection(app: &SolveApp) -> Vec<String> {/// Is there something Copy would copy?pub fn can_copy(app: &SolveApp) -> bool {- if app.session.active_sketch.is_some() { !sketch_selection(app).is_empty() } else { !crate::timeline::selected_feature_ids(app).is_empty() }+ if app.session.active_sketch.is_some() {+ !sketch_selection(app).is_empty()+ } else {+ app.tree.picked_components == [0] || !crate::timeline::selected_feature_ids(app).is_empty()+ }}/// Is there something Paste would paste here?pub fn can_paste(app: &SolveApp) -> bool {- if app.session.active_sketch.is_some() { app.session.sketch_clipboard.is_some() } else { !app.session.clipboard.is_empty() }+ if app.session.active_sketch.is_some() {+ app.session.sketch_clipboard.is_some()+ } else {+ app.linked_design_clipboard.is_some() || !app.session.clipboard.is_empty()+ }+}++/// Copy the saved root design. The path stays in this app, outside per-document sessions.+pub fn copy_design(app: &mut SolveApp) -> bool {+ let Some(path) = app.session.path.clone().filter(|_| !app.session.is_dirty()) else {+ app.set_status("Save this design before copying it as a linked component", true);+ return false;+ };+ app.linked_design_clipboard = Some(path);+ leave_text(format!("SolidCraft linked design: {}", app.session.doc.name));+ app.set_status("Copied design: switch to the assembly and paste to insert a linked component", false);+ true}/// Copy the selection: sketch geometry in a sketch, otherwise timeline features.pub fn copy(app: &mut SolveApp) -> bool {+ if app.session.active_sketch.is_none() && app.tree.picked_components == [0] {+ return copy_design(app);+ }if app.session.active_sketch.is_some() {let entities = sketch_selection(app);if entities.is_empty() {@@ -59,6 +82,7 @@ pub fn copy(app: &mut SolveApp) -> bool {return false;}let Ok(out) = app.run("sketch.copy", json!({ "entities": entities })) else { return false };+ app.linked_design_clipboard = None;let n = out.get("curves").and_then(Value::as_u64).unwrap_or(0) + out.get("points").and_then(Value::as_u64).unwrap_or(0);let k = out.get("constraints").and_then(Value::as_u64).unwrap_or(0);let text = format!("SolidCraft sketch geometry: {n} entities, {k} constraints and dimensions");@@ -72,6 +96,7 @@ pub fn copy(app: &mut SolveApp) -> bool {return false;}let Ok(out) = app.run("timeline.copy", json!({ "features": features })) else { return false };+ app.linked_design_clipboard = None;let names: Vec<&str> = out.get("copied").and_then(Value::as_array).map(|a| a.iter().filter_map(Value::as_str).collect()).unwrap_or_default();app.set_status(format!("Copied {}", names.join(", ")), false);leave_text(format!("SolidCraft features: {}", names.join(", ")));@@ -90,6 +115,7 @@ pub fn cut(app: &mut SolveApp) -> bool {return false;}let Ok(out) = app.run("sketch.cut", json!({ "entities": entities })) else { return false };+ app.linked_design_clipboard = None;let n = out.get("curves").and_then(Value::as_u64).unwrap_or(0) + out.get("points").and_then(Value::as_u64).unwrap_or(0);app.set_status(format!("Cut {n} sketch entities"), false);leave_text(format!("SolidCraft sketch geometry: {n} entities"));@@ -125,6 +151,19 @@ pub fn paste(app: &mut SolveApp, at: Option<Pos2>) -> bool {app.set_status(format!("Pasted {n} sketch entities (selected: drag them, or press M to move them)"), false);return true;}+ if let Some(path) = app.linked_design_clipboard.clone() {+ let (parent_path, translate) = paste_placement(app, at);+ let Ok(out) = app.run("component.insert_design", json!({"path": path, "reuse": true, "translate":translate})) else { return false };+ if let Some(id) = out.get("occurrence").and_then(Value::as_u64) {+ let mut movement = crate::browser::OccMove::new(id);+ movement.path = parent_path;+ movement.path.push(id);+ movement.baseline = app.session.doc.occurrences.iter().find(|o| o.id == id).map(|o| o.transform);+ app.tree.occurrence_move = Some(movement);+ }+ app.set_status("Pasted linked component: use Move/Copy to position it", false);+ return true;+ }if app.session.clipboard.is_empty() {app.set_status("Nothing to paste: copy timeline features first", true);return false;@@ -132,6 +171,38 @@ pub fn paste(app: &mut SolveApp, at: Option<Pos2>) -> bool {app.run("timeline.paste", json!({})).is_ok()}+/// Place the copied design's origin on the pointed solid surface, otherwise its parent's+/// XY plane. With no viewport point or a parallel/behind-camera ray, use the parent origin.+fn paste_placement(app: &SolveApp, at: Option<Pos2>) -> (Vec<u64>, [f64; 3]) {+ use solidcraft_engine::{doc, geom::Vec3};+ let path = app.session.active_occurrence_path.clone().unwrap_or_else(|| app.session.doc.first_path(app.session.active_component));+ let frame = app.session.occurrence_placement(&path).map(|p| p.world).unwrap_or(doc::IDENTITY);+ let origin = doc::apply_point(&frame, Vec3::ZERO);+ let at = at.zip(app.viewport.rect).filter(|(point, rect)| rect.contains(*point));+ let point = at+ .and_then(|(at, rect)| {+ let projection = crate::viewport::projection(app, rect);+ if let Some(point) = crate::viewport::pick_all(app, &projection, at).into_iter().find_map(|hit| match hit {+ crate::viewport::Hit::Face { point, .. } => Some(point),+ _ => None,+ }) {+ return point.is_finite().then_some(point);+ }+ let (ray_origin, ray_direction) = projection.ray(at);+ let normal = doc::apply_vector(&frame, Vec3::Z);+ let denominator = ray_direction.dot(normal);+ if denominator.abs() < 1e-9 {+ return None;+ }+ let distance = (origin - ray_origin).dot(normal) / denominator;+ let point = ray_origin + ray_direction * distance;+ (distance >= 0.0 && point.is_finite()).then_some(point)+ })+ .unwrap_or(origin);+ let local = doc::mat_inverse(&frame).map(|inverse| doc::apply_point(&inverse, point)).filter(|p| p.is_finite()).unwrap_or(Vec3::ZERO);+ (path, [local.x, local.y, local.z])+}+/// The frame's Copy, Cut and Paste events (and Ctrl+C / Ctrl+X / Ctrl+V sent as key presses), plus any/// clipboard text a menu's Copy left. Called by the global shortcuts when no text field has the/// keyboard.diff --git a/crates/ui-egui/src/edit_clipboard_tests.rs b/crates/ui-egui/src/edit_clipboard_tests.rsindex b0967aaf3b..a12d571a7f 100644--- a/crates/ui-egui/src/edit_clipboard_tests.rs+++ b/crates/ui-egui/src/edit_clipboard_tests.rs@@ -162,3 +162,185 @@ fn ctrl_x_cuts_the_sketch_selection_and_ctrl_v_brings_it_back() {let labels: Vec<&str> = menu["result"]["items"].as_array().unwrap().iter().filter_map(|i| i["label"].as_str()).collect();assert!(labels.contains(&"Cut"), "{labels:?}");}++struct ContributionPart(std::path::PathBuf);+impl ContributionPart {+ fn new() -> Self {+ let stamp = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_nanos();+ Self(std::env::temp_dir().join(format!("solidcraft-linked-clipboard-{}-{stamp}.solidcraft", std::process::id())))+ }+}+impl Drop for ContributionPart {+ fn drop(&mut self) {+ let _ = std::fs::remove_file(&self.0);+ }+}+fn contribution_saved_part(file: &ContributionPart) -> crate::SolveApp {+ let mut app = crate::SolveApp::new(solidcraft_engine::Session::default(), crate::Services::default());+ app.run("solid.box", json!({"length":20,"width":10,"height":5,"body_name":"Plate"})).unwrap();+ app.run("file.save", json!({"path":file.0.to_string_lossy()})).unwrap();+ app.tree.picked_components = vec![0];+ app+}++#[test]+fn contribution_linked_design_clipboard_crosses_tabs_reuses_links_and_undoes_once() {+ let file = ContributionPart::new();+ let mut app = contribution_saved_part(&file);+ assert!(super::can_copy(&app));+ assert!(super::copy(&mut app));+ crate::documents::open_tab(&mut app, solidcraft_engine::Session::default()).unwrap();+ assert!(super::can_paste(&app));+ for n in 1..=2 {+ assert!(super::paste(&mut app, None), "{:?}", app.status);+ assert_eq!(app.session.doc.components.len(), 1);+ assert_eq!(app.session.doc.links.len(), 1);+ assert_eq!(app.session.doc.features.len(), 1);+ assert_eq!(app.session.doc.occurrences.len(), n);+ assert_eq!(app.session.undo.len(), n);+ assert!(app.session.doc.occurrences.iter().all(|o| !o.grounded));+ assert!(app.tree.occurrence_move.is_some());+ }+ app.tree.occurrence_move = None;+ app.run("edit.undo", json!({})).unwrap();+ assert_eq!(app.session.doc.occurrences.len(), 1);+ app.run("edit.undo", json!({})).unwrap();+ assert!(app.session.doc.links.is_empty());+ assert!(app.session.doc.components.is_empty());+ app.run("edit.redo", json!({})).unwrap();+ assert_eq!(app.session.doc.links.len(), 1);+ crate::documents::switch(&mut app, 0);+ assert_eq!(app.session.doc.features.len(), 1, "the source is untouched");+}++#[test]+fn contribution_occurrence_move_panel_belongs_to_its_document() {+ let file = ContributionPart::new();+ let mut app = contribution_saved_part(&file);+ assert!(super::copy(&mut app));+ crate::documents::open_tab(&mut app, solidcraft_engine::Session::default()).unwrap();+ assert!(super::paste(&mut app, None));+ let id = app.tree.occurrence_move.as_ref().unwrap().occurrence;+ app.run("occurrence.move", json!({"occurrence":id,"translate":[10,0,0],"capture":false})).unwrap();+ let pending = app.session.pending_moves.clone();+ crate::documents::switch(&mut app, 0);+ assert!(app.tree.occurrence_move.is_none());+ assert!(app.session.doc.occurrences.is_empty());+ crate::documents::switch(&mut app, 1);+ assert_eq!(app.tree.occurrence_move.as_ref().unwrap().occurrence, id);+ assert_eq!(app.session.pending_moves, pending);+}++#[test]+fn contribution_linked_paste_uses_the_pointer_and_pending_numeric_move() {+ use solidcraft_engine::geom::Vec3;+ let file = ContributionPart::new();+ let mut h = crate::scenario::Harness::new();+ h.app = contribution_saved_part(&file);+ assert!(super::copy(&mut h.app));+ crate::documents::open_tab(&mut h.app, solidcraft_engine::Session::default()).unwrap();+ h.app.run("solid.box", json!({"length":80,"width":50,"height":8,"body_name":"Destination"})).unwrap();+ h.app.fit_view();+ h.frames(3);+ let projection = crate::viewport::projection(&h.app, h.app.viewport.rect.unwrap());+ let pointed = Vec3::new(40., 25., 8.);+ let at = projection.to_screen(pointed).unwrap();+ let undo = h.app.session.undo.len();+ assert!(super::paste(&mut h.app, Some(at)));+ h.frames(3);+ let path = h.app.tree.occurrence_move.as_ref().unwrap().path.clone();+ let initial = solidcraft_engine::doc::apply_point(&h.app.session.occurrence_placement(&path).unwrap().world, Vec3::ZERO);+ assert!((initial - pointed).len() < 1e-5, "{initial:?}");+ assert_eq!(h.app.session.undo.len(), undo + 1);+ let camera = h.app.cam;+ let field = h.call("ui.at", json!({"handle":"occurrence-move:distance:0"}));+ h.call("ui.click", json!({"x":field["result"][0],"y":field["result"][1],"double":true}));+ h.frames(2);+ h.step(&json!({"key":"A","cmd":true})).unwrap();+ h.step(&json!({"text":"12"})).unwrap();+ h.step(&json!({"key":"Enter"})).unwrap();+ h.frames(3);+ let moved = solidcraft_engine::doc::apply_point(&h.app.session.occurrence_placement(&path).unwrap().world, Vec3::ZERO);+ assert!(moved.x > initial.x + 10., "numeric move must retain the pasted occurrence: {initial:?} -> {moved:?}");+ assert_eq!(h.app.cam, camera, "numeric editing does not move the camera");+ let movement = h.app.tree.occurrence_move.as_ref().unwrap();+ assert!((movement.translate[0] - (moved.x - initial.x)).abs() < 1e-5);+ assert_eq!(h.app.session.undo.len(), undo + 1, "pending movement does not split the initial paste undo");+ h.app.run("edit.undo", json!({})).unwrap();+ h.frames(3);+ assert!(h.app.session.doc.links.is_empty());+ assert!(h.app.tree.occurrence_move.is_none());+ crate::documents::switch(&mut h.app, 0);+ assert_eq!(h.app.session.doc.features.len(), 1, "source geometry stays untouched");+}++#[test]+fn contribution_paste_pointer_uses_parent_coordinates_and_safe_fallbacks() {+ use solidcraft_engine::{doc, geom::Vec3};+ let mut h = crate::scenario::Harness::new();+ let parent = h.app.run("component.create", json!({"name":"Parent"})).unwrap();+ h.app+ .run("occurrence.move", json!({"occurrence":parent["occurrence"],"translate":[20,30,10],"axis":[1,0,0],"angle":"45 deg","capture":true}))+ .unwrap();+ h.frames(3);+ let path = vec![parent["occurrence"].as_u64().unwrap()];+ h.app.run("component.activate", json!({"component":parent["component"],"occurrence":parent["occurrence"],"path":path})).unwrap();+ let (actual, zero) = super::paste_placement(&h.app, None);+ assert_eq!(actual, path);+ assert_eq!(zero, [0.; 3]);+ assert_eq!(super::paste_placement(&h.app, Some(egui::pos2(-100., -100.))).1, [0.; 3]);+ let frame = h.app.session.occurrence_placement(&path).unwrap().world;+ let target = doc::apply_point(&frame, Vec3::new(5., 7., 0.));+ h.app.cam.target = target;+ h.app.cam.distance = 100.;+ h.frames(2);+ let projection = crate::viewport::projection(&h.app, h.app.viewport.rect.unwrap());+ let at = projection.to_screen(target).unwrap();+ let (_, local) = super::paste_placement(&h.app, Some(at));+ assert!((Vec3::new(local[0], local[1], local[2]) - Vec3::new(5., 7., 0.)).len() < 1e-5, "{local:?}");+}++#[test]+fn contribution_linked_clipboard_refuses_unsaved_dirty_self_and_missing_sources() {+ let file = ContributionPart::new();+ let mut app = crate::SolveApp::new(solidcraft_engine::Session::default(), crate::Services::default());+ assert!(!super::copy_design(&mut app));+ app = contribution_saved_part(&file);+ assert!(super::copy_design(&mut app));+ let doc = app.session.doc.clone();+ assert!(!super::paste(&mut app, None));+ assert_eq!(app.session.doc, doc);+ app.run("solid.box", json!({"length":2,"width":2,"height":2,"corner":[30,0,0]})).unwrap();+ assert!(!super::copy_design(&mut app));+ crate::documents::open_tab(&mut app, solidcraft_engine::Session::default()).unwrap();+ std::fs::remove_file(&file.0).unwrap();+ assert!(!super::paste(&mut app, None));+ assert!(app.session.doc.features.is_empty());+ assert!(app.session.undo.is_empty());+}++#[test]+fn contribution_feature_copy_replaces_the_linked_design_clipboard() {+ let file = ContributionPart::new();+ let mut app = contribution_saved_part(&file);+ assert!(super::copy(&mut app));+ app.tree.picked_components.clear();+ app.session.selection = vec![Sel::Feature { id: app.session.doc.features[0].id }];+ assert!(super::copy(&mut app));+ assert!(app.linked_design_clipboard.is_none());+ assert!(!app.session.clipboard.is_empty());+}++#[test]+fn contribution_native_copy_paste_events_insert_the_saved_design_in_another_tab() {+ let file = ContributionPart::new();+ let mut h = Harness::new();+ h.app = contribution_saved_part(&file);+ h.frames(3);+ clipboard_event(&mut h, egui::Event::Copy, None);+ assert!(h.app.linked_design_clipboard.is_some());+ crate::documents::open_tab(&mut h.app, solidcraft_engine::Session::default()).unwrap();+ clipboard_event(&mut h, egui::Event::Paste("SolidCraft linked design".into()), None);+ assert_eq!(h.app.session.doc.links.len(), 1, "{:?}", h.app.status);+ assert_eq!(h.app.session.undo.len(), 1);+}diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rsindex 37a7b1d6e8..9b17c23cad 100644--- a/crates/ui-egui/src/lib.rs+++ b/crates/ui-egui/src/lib.rs@@ -327,6 +327,8 @@ pub struct SolveApp {pub menu: context_menu::MenuState,/// Browser tree state (reveal, groups being edited, occurrence moves).pub tree: browser::TreeState,+ /// A saved design copied for insertion into another open document.+ pub linked_design_clipboard: Option<String>,/// The S box (command search at the cursor): recent and pinned commands.pub sbox: shortcut_box::ShortcutBox,/// Keyboard shortcuts the user changed.@@ -461,6 +463,7 @@ impl SolveApp {palette: palette::Palette::default(),menu: context_menu::MenuState::default(),tree: browser::TreeState::default(),+ linked_design_clipboard: None,sbox: shortcut_box::ShortcutBox::default(),keymap: keymap::Keymap::default(),help: help::HelpState::default(),diff --git a/docs/linked-design-paste.md b/docs/linked-design-paste.mdnew file mode 100644index 0000000000..30cc690e10--- /dev/null+++ b/docs/linked-design-paste.md@@ -0,0 +1,9 @@+# Pasting a linked design++Save the source design without pending changes, select its root in the Browser and copy it. Switch to the destination document and paste. The result is an ungrounded occurrence linked to the saved source; repeated pastes reuse that component definition. The source design is not modified.++The copied design's origin is placed on the solid surface under the viewport pointer. Over empty space, the view ray is intersected with the active parent component's XY plane. If there is no viewport pointer, or that ray is parallel, behind the camera or invalid, placement uses the parent origin. World points are converted into the parent's coordinates, including a rotated or nested parent. Keyboard and viewport context-menu paste use this same rule.++Initial placement is part of the paste's single undo step. Move/Copy numeric fields adjust pending distances and angles after insertion. Capture All Positions and Revert All Positions retain their existing pending-position behavior. A document's Move/Copy context stays with its own tab.++The pre-existing occurrence arrow input repair is proposed separately in #3015 (issue #3014). Pointer placement does not include or duplicate that shared viewport patch. Combined trials include both changes; this clipboard PR remains independently scoped.