Feat: DIVIDE and MEASURE commands — place points along entities

DIVIDE (DIV): entity pick → type N → places N-1 Point entities at equal spacing.
MEASURE (ME): entity pick → type distance → places points at fixed intervals.

Supported entities: Line, Arc, Circle, LwPolyline.
Uses CmdResult::DivideEntity / MeasureEntity with geometry computed in cmd_result.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Hakan Seven 2026-04-02 23:43:33 +03:00
commit ae0a4b12b5
5 changed files with 294 additions and 1 deletions

View file

@ -371,6 +371,46 @@ impl H7CAD {
self.restore_pre_cmd_tangent();
self.command_line.push_output(&msg);
}
CmdResult::DivideEntity { handle, n } => {
use crate::modules::home::inquiry::divide::divide_entity;
let pts = self.tabs[i].scene.document
.get_entity(handle)
.map(|e| divide_entity(e, n))
.unwrap_or_default();
let count = pts.len();
if count > 0 {
self.push_undo_snapshot(i, "DIVIDE");
for p in pts { self.tabs[i].scene.add_entity(p); }
self.tabs[i].dirty = true;
self.command_line.push_output(&format!("DIVIDE: {count} point(s) placed."));
} else {
self.command_line.push_error("DIVIDE: entity type not supported or N < 2.");
}
self.tabs[i].active_cmd = None;
self.tabs[i].snap_result = None;
self.tabs[i].scene.clear_preview_wire();
self.restore_pre_cmd_tangent();
}
CmdResult::MeasureEntity { handle, segment_length } => {
use crate::modules::home::inquiry::divide::measure_entity;
let pts = self.tabs[i].scene.document
.get_entity(handle)
.map(|e| measure_entity(e, segment_length))
.unwrap_or_default();
let count = pts.len();
if count > 0 {
self.push_undo_snapshot(i, "MEASURE");
for p in pts { self.tabs[i].scene.add_entity(p); }
self.tabs[i].dirty = true;
self.command_line.push_output(&format!("MEASURE: {count} point(s) placed."));
} else {
self.command_line.push_error("MEASURE: entity type not supported or distance too large.");
}
self.tabs[i].active_cmd = None;
self.tabs[i].snap_result = None;
self.tabs[i].scene.clear_preview_wire();
self.restore_pre_cmd_tangent();
}
CmdResult::JoinEntities(handles) => {
use crate::modules::home::modify::join::join_entities;
let pairs: Vec<_> = handles.iter()

View file

@ -985,6 +985,20 @@ impl H7CAD {
self.tabs[i].active_cmd = Some(Box::new(cmd));
}
"DIVIDE"|"DIV" => {
use crate::modules::home::inquiry::divide::DivideCommand;
let cmd = DivideCommand::new();
self.command_line.push_info(&cmd.prompt());
self.tabs[i].active_cmd = Some(Box::new(cmd));
}
"MEASURE"|"ME" => {
use crate::modules::home::inquiry::divide::MeasureCommand;
let cmd = MeasureCommand::new();
self.command_line.push_info(&cmd.prompt());
self.tabs[i].active_cmd = Some(Box::new(cmd));
}
// ── Inquiry ──────────────────────────────────────────────────────
"DIST"|"DI" => {
use crate::modules::home::inquiry::dist::DistCommand;
@ -1014,7 +1028,7 @@ impl H7CAD {
Array: ARRAY ARRAYRECT ARRAYPOLAR ARRAYPATH | \
Text: TEXT MTEXT LEADER MLEADER | \
Dimension: DIMLINEAR DIMANGULAR DIMRADIUS | \
Inquiry: DIST ID AREA LIST | \
Inquiry: DIST ID AREA LIST | Draw on entity: DIVIDE MEASURE | \
View: ZOOM EXTENTS VIEW LIST/SAVE/RESTORE/DELETE | \
Layer: LAYER LIST/NEW/ON/OFF/FREEZE/THAW/LOCK/UNLOCK/COLOR/SET | \
Viewport: MVIEW VPLAYER VPORTS MS PS DRAWORDER | \