diff --git a/src/app/commands/layers.rs b/src/app/commands/layers.rs index 01d9d14a5..bc5540107 100644 --- a/src/app/commands/layers.rs +++ b/src/app/commands/layers.rs @@ -745,6 +745,43 @@ impl OpenCADStudio { } } + // LAYCUR: the selected objects move to the current layer. + "LAYCUR" => { + let handles: Vec<_> = self.tabs[i] + .scene + .selected_entities() + .into_iter() + .map(|(h, _)| h) + .collect(); + if handles.is_empty() { + use crate::modules::draw::select::SelectObjectsCommand; + let cmd = SelectObjectsCommand::new("LAYCUR"); + self.command_line.push_info(&cmd.prompt()); + self.tabs[i].active_cmd = Some(Box::new(cmd)); + } else { + let layer = self.tabs[i].scene.document.header.current_layer_name.clone(); + let editable: Vec<_> = handles + .into_iter() + .filter(|handle| !self.tabs[i].scene.is_layer_locked(*handle)) + .collect(); + self.push_undo_snapshot(i, "LAYCUR"); + for handle in &editable { + if let Some(entity) = self.tabs[i].scene.document.get_entity_mut(*handle) { + entity.common_mut().layer = layer.clone(); + } + } + // The new layer's ByLayer colour, linetype and lineweight + // show at once. + self.invalidate_property_targets(i, &editable); + self.tabs[i].dirty = true; + self.tabs[i].scene.deselect_all(); + self.command_line.push_info( + crate::tf!("{} object(s) changed to layer \"{layer}\".", editable.len()) + .as_ref(), + ); + } + } + "LAYMATCH" | "LAYMCH" => { use crate::modules::draw::layers::match_layer::LayMatchCommand; let dest: Vec<_> = self.tabs[i] diff --git a/src/app/control/mod.rs b/src/app/control/mod.rs index bbe0eba25..d551e705f 100644 --- a/src/app/control/mod.rs +++ b/src/app/control/mod.rs @@ -384,6 +384,7 @@ fn command_selection_policy(name: &str) -> &'static str { "GROUP", "LAYFRZ", "LAYLCK", + "LAYCUR", "LAYMCUR", "LAYOFF", "LAYULK", diff --git a/src/modules/draw/layers/match_layer.rs b/src/modules/draw/layers/match_layer.rs index 426c5609e..0a88bd436 100644 --- a/src/modules/draw/layers/match_layer.rs +++ b/src/modules/draw/layers/match_layer.rs @@ -82,5 +82,5 @@ impl CadCommand for LayMatchCommand { // ── Autocomplete registry ───────────────────────────────── inventory::submit!(crate::command::CommandRegistration { - names: &["LAYMATCH", "LAYMCH"] + names: &["LAYMATCH", "LAYMCH", "LAYCUR"] }); // LayMatchCommand diff --git a/src/modules/draw/select.rs b/src/modules/draw/select.rs index ffe77ad73..76417cfb5 100644 --- a/src/modules/draw/select.rs +++ b/src/modules/draw/select.rs @@ -379,6 +379,7 @@ inventory::submit!(crate::command::CommandRegistration { "GROUP", "LAYFRZ", "LAYLCK", + "LAYCUR", "LAYMCUR", "LAYOFF", "LAYULK",