forked from 1b-agent/opencadstudio-upstream
Feat: JOIN command — merge collinear Lines or co-circular Arcs
Selection-gathering mode: select objects, press Enter to apply. - Lines: checks collinearity + no-gap, merges into single line span - Arcs: checks same center/radius + contiguous angles, merges to Arc or Circle - Uses CmdResult::JoinEntities; geometry computed in cmd_result from document Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This commit is contained in:
1 parent
4b8ae08a19
commit
641cc2d70b
5 files changed
+246
-2
No files matched your search
@@ -371,6 +371,42 @@ impl H7CAD {
|
||||
self.restore_pre_cmd_tangent();
|
||||
self.command_line.push_output(&msg);
|
||||
}
|
||||
CmdResult::JoinEntities(handles) => {
|
||||
use crate::modules::home::modify::join::join_entities;
|
||||
let pairs: Vec<_> = handles.iter()
|
||||
.filter_map(|&h| self.tabs[i].scene.document.get_entity(h).map(|e| (h, e)))
|
||||
.collect();
|
||||
match join_entities(&pairs) {
|
||||
Some((to_remove, merged)) => {
|
||||
let label = self.history_label_from_active_cmd(i, "JOIN");
|
||||
self.push_undo_snapshot(i, label);
|
||||
self.tabs[i].scene.erase_entities(&to_remove);
|
||||
let count_in = to_remove.len();
|
||||
let count_out = merged.len();
|
||||
for e in merged {
|
||||
self.tabs[i].scene.add_entity(e);
|
||||
}
|
||||
self.tabs[i].dirty = true;
|
||||
self.tabs[i].scene.clear_preview_wire();
|
||||
self.tabs[i].active_cmd = None;
|
||||
self.tabs[i].snap_result = None;
|
||||
self.restore_pre_cmd_tangent();
|
||||
self.command_line.push_output(
|
||||
&format!("JOIN: {count_in} object(s) joined into {count_out}.")
|
||||
);
|
||||
self.refresh_properties();
|
||||
}
|
||||
None => {
|
||||
self.tabs[i].active_cmd = None;
|
||||
self.tabs[i].snap_result = None;
|
||||
self.tabs[i].scene.clear_preview_wire();
|
||||
self.restore_pre_cmd_tangent();
|
||||
self.command_line.push_error(
|
||||
"JOIN: objects are not collinear/co-circular or have gaps."
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
CmdResult::BreakEntity { handle, p1, p2 } => {
|
||||
use crate::modules::home::modify::break_cmd::break_entity;
|
||||
let replacement = self.tabs[i].scene.document
|
||||
|
||||
+9
-2
@@ -970,7 +970,14 @@ impl H7CAD {
|
||||
}
|
||||
}
|
||||
|
||||
// ── Break ────────────────────────────────────────────────────────
|
||||
// ── Break / Join ─────────────────────────────────────────────────
|
||||
"JOIN"|"J" => {
|
||||
use crate::modules::home::modify::join::JoinCommand;
|
||||
let cmd = JoinCommand::new();
|
||||
self.command_line.push_info(&cmd.prompt());
|
||||
self.tabs[i].active_cmd = Some(Box::new(cmd));
|
||||
}
|
||||
|
||||
"BREAK"|"BR" => {
|
||||
use crate::modules::home::modify::break_cmd::BreakInteractiveCommand;
|
||||
let cmd = BreakInteractiveCommand::new();
|
||||
@@ -1003,7 +1010,7 @@ impl H7CAD {
|
||||
"HELP"|"?" => {
|
||||
self.command_line.push_output(
|
||||
"Draw: LINE CIRCLE ARC PLINE RECT POLY POINT ELLIPSE SPLINE RAY XLINE HATCH | \
|
||||
Modify: MOVE COPY ROTATE SCALE MIRROR ERASE OFFSET EXTEND FILLET CHAMFER STRETCH EXPLODE TRIM BREAK | \
|
||||
Modify: MOVE COPY ROTATE SCALE MIRROR ERASE OFFSET EXTEND FILLET CHAMFER STRETCH EXPLODE TRIM BREAK JOIN | \
|
||||
Array: ARRAY ARRAYRECT ARRAYPOLAR ARRAYPATH | \
|
||||
Text: TEXT MTEXT LEADER MLEADER | \
|
||||
Dimension: DIMLINEAR DIMANGULAR DIMRADIUS | \
|
||||
|
||||
Reference in new issue
Block a user