From e52965cfb0da220085ef61b6abaf7d9196ee7164 Mon Sep 17 00:00:00 2001 From: ramox81 <184937705+ramox81@users.noreply.github.com> Date: Fri, 11 Sep 2026 09:33:05 +0300 Subject: [PATCH] Expose Delete Duplicate Objects in the Modify extension --- assets/icons/modify_overkill.svg | 1 + src/app/commands/styleprops.rs | 11 +++++++++-- src/ui/ribbon/modify_tools/12_overkill.rs | 6 ++++++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 assets/icons/modify_overkill.svg create mode 100644 src/ui/ribbon/modify_tools/12_overkill.rs diff --git a/assets/icons/modify_overkill.svg b/assets/icons/modify_overkill.svg new file mode 100644 index 000000000..3ddb7bfa8 --- /dev/null +++ b/assets/icons/modify_overkill.svg @@ -0,0 +1 @@ + diff --git a/src/app/commands/styleprops.rs b/src/app/commands/styleprops.rs index b99da19b4..80d607030 100644 --- a/src/app/commands/styleprops.rs +++ b/src/app/commands/styleprops.rs @@ -685,10 +685,17 @@ impl OpenCADStudio { // ── OVERKILL — delete duplicate (identical) objects ────────── // Removes objects that are identical in geometry AND properties to // another object (compared with the handle ignored). Operates on - // the current selection, or the whole drawing when nothing is + // the current selection, gathering objects first when nothing is // selected. Conservative: only exact duplicates are removed. "OVERKILL" => { use acadrust::Handle; + if self.tabs[i].scene.selected.is_empty() { + use crate::modules::draw::select::SelectObjectsCommand; + let selection = SelectObjectsCommand::new("OVERKILL"); + self.command_line.push_info(&selection.prompt()); + self.tabs[i].active_cmd = Some(Box::new(selection)); + return Some(self.finish_dispatch(cmd)); + } let selected: std::collections::HashSet = self.tabs[i] .scene .selected_entities() @@ -702,7 +709,7 @@ impl OpenCADStudio { .document .entities() .filter(|e| { - (selected.is_empty() || selected.contains(&e.common().handle.value())) + selected.contains(&e.common().handle.value()) && !self.tabs[i].scene.is_layer_locked(e.common().handle) }) .map(|e| { diff --git a/src/ui/ribbon/modify_tools/12_overkill.rs b/src/ui/ribbon/modify_tools/12_overkill.rs new file mode 100644 index 000000000..0c7f90e0e --- /dev/null +++ b/src/ui/ribbon/modify_tools/12_overkill.rs @@ -0,0 +1,6 @@ +Tool { + command: "OVERKILL", + label: "Delete Duplicate Objects", + icon: include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/assets/icons/modify_overkill.svg")), + options: &[], +}