forked from 1b-agent/opencadstudio-upstream
feat(array): ARRAYEDIT Source edits what an associative array repeats
ARRAYEDIT picks an associative array (or takes the preselected one) and its Source option opens the objects every item repeats in the Block Editor; saving there updates all items at once. Counts and spacings stay in Properties. Refs #1109 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
780b54489e
commit
881d237629
26 files changed
+187
No files matched your search
@@ -301,6 +301,45 @@ impl OpenCADStudio {
|
||||
}
|
||||
}
|
||||
|
||||
// ARRAYEDIT — edit an associative array; a preselected one skips
|
||||
// the pick.
|
||||
"ARRAYEDIT" => {
|
||||
use crate::modules::draw::modify::arrayedit::ArrayEditCommand;
|
||||
let selected = self.tabs[i].scene.selected_handles_in_order();
|
||||
let array = match selected.as_slice() {
|
||||
[handle] => Some(*handle),
|
||||
_ => None,
|
||||
};
|
||||
self.tabs[i].scene.deselect_all();
|
||||
let command = ArrayEditCommand::new(array);
|
||||
self.command_line.push_info(&command.prompt());
|
||||
self.tabs[i].active_cmd = Some(Box::new(command));
|
||||
}
|
||||
|
||||
// ARRAYEDIT Source: edit the objects the array repeats in the
|
||||
// Block Editor; every item follows when it is saved.
|
||||
cmd if cmd.starts_with("ARRAYEDIT_SOURCE:") => {
|
||||
let handle = codec::Handle::new(
|
||||
cmd["ARRAYEDIT_SOURCE:".len()..].parse().unwrap_or(0),
|
||||
);
|
||||
let document = &self.tabs[i].scene.document;
|
||||
let source = crate::scene::assoc_array::array_of_insert(document, handle)
|
||||
.and_then(|array| {
|
||||
document
|
||||
.block_records
|
||||
.iter()
|
||||
.find(|record| record.handle == array.source_block)
|
||||
.map(|record| record.name.clone())
|
||||
});
|
||||
match source {
|
||||
Some(name) => return Some(self.dispatch_command(&format!("BEDIT_OPEN:{name}"))),
|
||||
None => self.command_line.push_error(
|
||||
crate::t!("ARRAYEDIT: the selected object is not an associative array.")
|
||||
.as_ref(),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
// PASTESPEC — offer the copied objects now; the system clipboard's
|
||||
// text joins the formats once read (Message::PasteSpecial).
|
||||
"PASTESPEC" => {
|
||||
|
||||
Reference in new issue
Block a user