Feat: ALIGN command (AL) — align objects using 1 or 2 point pairs

Workflow: select objects → 1st src/dst pair → 2nd src/dst pair (optional) → Enter.
- 1 pair: pure translation (src1 → dst1)
- 2 pairs: translate + rotate in XZ plane; optional uniform scale (Y/N prompt)

Transform applied as 3 sequential scene.transform_entities calls:
translate to origin → scale → rotate → translate to dst1.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Sonnet 4.6 committed 2026-04-02 23:46:48 +03:00
1 parent f6efe7a06a
commit b27b612b5d
5 files changed
+249 -1

No files matched your search

+52
View File
@@ -371,6 +371,58 @@ impl H7CAD {
self.restore_pre_cmd_tangent();
self.command_line.push_output(&msg);
}
CmdResult::AlignSelected { handles, src1, dst1, angle_rad, scale } => {
if handles.is_empty() {
self.tabs[i].active_cmd = None;
self.tabs[i].snap_result = None;
self.tabs[i].scene.clear_preview_wire();
self.restore_pre_cmd_tangent();
} else {
let label = self.history_label_from_active_cmd(i, "ALIGN");
self.push_undo_snapshot(i, label);
// Step 1: translate so src1 is at origin
self.tabs[i].scene.transform_entities(
&handles,
&crate::command::EntityTransform::Translate(-src1),
);
// Step 2: uniform scale (only when != 1)
if (scale - 1.0).abs() > 1e-4 {
self.tabs[i].scene.transform_entities(
&handles,
&crate::command::EntityTransform::Scale {
center: glam::Vec3::ZERO,
factor: scale,
},
);
}
// Step 3: rotate in XZ plane by angle_rad
if angle_rad.abs() > 1e-4 {
self.tabs[i].scene.transform_entities(
&handles,
&crate::command::EntityTransform::Rotate {
center: glam::Vec3::ZERO,
angle_rad,
},
);
}
// Step 4: translate to dst1
self.tabs[i].scene.transform_entities(
&handles,
&crate::command::EntityTransform::Translate(dst1),
);
self.tabs[i].dirty = true;
self.tabs[i].scene.deselect_all();
for h in &handles {
self.tabs[i].scene.select_entity(*h, false);
}
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("ALIGN: applied.");
self.refresh_properties();
}
}
CmdResult::LengthenEntity { handle, pick_pt, mode } => {
use crate::modules::home::modify::lengthen::lengthen_entity;
let result = self.tabs[i].scene.document
+8 -1
View File
@@ -985,6 +985,13 @@ impl H7CAD {
self.tabs[i].active_cmd = Some(Box::new(cmd));
}
"ALIGN"|"AL" => {
use crate::modules::home::modify::align::AlignCommand;
let cmd = AlignCommand::new();
self.command_line.push_info(&cmd.prompt());
self.tabs[i].active_cmd = Some(Box::new(cmd));
}
"LENGTHEN"|"LEN" => {
use crate::modules::home::modify::lengthen::LengthenCommand;
let cmd = LengthenCommand::new();
@@ -1031,7 +1038,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 JOIN LENGTHEN | \
Modify: MOVE COPY ROTATE SCALE MIRROR ERASE OFFSET EXTEND FILLET CHAMFER STRETCH EXPLODE TRIM BREAK JOIN LENGTHEN ALIGN | \
Array: ARRAY ARRAYRECT ARRAYPOLAR ARRAYPATH | \
Text: TEXT MTEXT LEADER MLEADER | \
Dimension: DIMLINEAR DIMANGULAR DIMRADIUS | \