feat(commands): integrate standard CAD commands and fix behavior gaps

Broad pass over the command set: integrate missing commands, wire
previously-unreachable ribbon/menu buttons, and correct name/behaviour
mismatches. Every UI command token now resolves (real handler where the
infrastructure exists, an honest "not yet implemented" status otherwise).

New commands:
- Draw: 3DPOLY, 2D solid (SO/SOLID2D), HELIX, TRACE, SKETCH, DIMCENTER
  (DCE/CENTERMARK)
- Modify/inquiry: REVERSE, MEASUREGEOM (MEA), DBLIST
- Data/manage: BASE, OVERKILL (exact-duplicate removal), AUDIT (read-only
  integrity report), SETVAR (system-variable get/set), SCRIPT (.scr runner),
  FINDNONPURGEABLE

Behaviour fixes:
- LINE and SPLINE gain Close/Undo; AREA computes area/perimeter in f64
  (correct at large coordinates)
- ATTEDIT/ATE unified so the alias and the ribbon button open the
  interactive editor; -ATTEDIT is the command-line form
- Linear/aligned/radius/diameter dimensions gain a text override (Text) and
  text angle (Angle) option
- INSERT gains Scale/Rotate options; COPY gains an Array option
- LINETYPE SET sets the current entity linetype; SETBYLAYER resets overrides
- UNDO accepts a step count

Integrations: standard dimension/block aliases (DLI/DRA/DAN, BMAKE,
EXPORTPDF, DDIM), drafting-aid and screen toggles (GRID/SNAP/POLAR/OSNAP/
DSETTINGS/CLEANSCREEN/QUICKPROPERTIES), viewport tiling
(CASCADE/HORIZONTAL/VERTICAL/VPJOIN), and customization entry points
(CUI/ALIASEDIT).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-06-28 19:27:35 +03:00
1 parent e04b580a70
commit 0ca3954b5d
32 files changed
+2763 -67

No files matched your search

+92 -3
View File
@@ -28,11 +28,25 @@ enum Step {
pub struct AlignedDimensionCommand {
step: Step,
/// Optional text that replaces the measured value (None = measurement).
text_override: Option<String>,
/// True while the next typed line is captured as the text override.
awaiting_text: bool,
/// Explicit text rotation in radians (None = follow the UCS/style).
text_angle: Option<f64>,
/// True while the next typed value is captured as the text angle.
awaiting_angle: bool,
}
impl AlignedDimensionCommand {
pub fn new() -> Self {
Self { step: Step::First }
Self {
step: Step::First,
text_override: None,
awaiting_text: false,
text_angle: None,
awaiting_angle: false,
}
}
}
@@ -42,10 +56,20 @@ impl CadCommand for AlignedDimensionCommand {
}
fn prompt(&self) -> String {
if self.awaiting_text {
return "DIMALIGNED Enter dimension text (blank = measured value):".into();
}
if self.awaiting_angle {
return "DIMALIGNED Specify text angle (degrees):".into();
}
match self.step {
Step::First => "DIMALIGNED Specify first extension line origin:".into(),
Step::Second(_) => "DIMALIGNED Specify second extension line origin:".into(),
Step::DimLine { .. } => "DIMALIGNED Specify dimension line location:".into(),
Step::Second(_) => {
"DIMALIGNED Specify second extension line origin [Text/Angle]:".into()
}
Step::DimLine { .. } => {
"DIMALIGNED Specify dimension line location [Text/Angle]:".into()
}
}
}
@@ -76,15 +100,80 @@ impl CadCommand for AlignedDimensionCommand {
dim.base.text_middle_point = v3((d1 + d2) * 0.5);
dim.base.insertion_point = dim.base.text_middle_point;
dim.base.actual_measurement = dim.measurement();
dim.base.user_text = self.text_override.clone();
// An explicit text angle overrides the default rotation.
if let Some(a) = self.text_angle {
dim.base.text_rotation = a;
}
CmdResult::CommitAndExit(EntityType::Dimension(Dimension::Aligned(dim)))
}
}
}
fn on_enter(&mut self) -> CmdResult {
// A bare Enter while entering override text/angle accepts the default.
if self.awaiting_text {
self.awaiting_text = false;
return CmdResult::NeedPoint;
}
if self.awaiting_angle {
self.awaiting_angle = false;
return CmdResult::NeedPoint;
}
CmdResult::Cancel
}
fn wants_text_input(&self) -> bool {
true
}
fn point_step_accepts_keywords(&self) -> bool {
// While entering the override text or angle it is a value, not a point
// step.
!self.awaiting_text && !self.awaiting_angle
}
fn wants_text_with_spaces(&self) -> bool {
// The override text may contain spaces.
self.awaiting_text
}
fn on_text_input(&mut self, text: &str) -> Option<CmdResult> {
if self.awaiting_text {
let t = text.trim();
// Blank (or the "<>" placeholder) keeps the measured value.
self.text_override = if t.is_empty() || t == "<>" {
None
} else {
Some(t.to_string())
};
self.awaiting_text = false;
return Some(CmdResult::NeedPoint);
}
if self.awaiting_angle {
let t = text.trim();
// Blank clears any explicit angle (follow the default again).
self.text_angle = if t.is_empty() {
None
} else {
t.parse::<f64>().ok().map(f64::to_radians)
};
self.awaiting_angle = false;
return Some(CmdResult::NeedPoint);
}
match text.trim().to_uppercase().as_str() {
"T" | "TEXT" | "M" | "MTEXT" => {
self.awaiting_text = true;
Some(CmdResult::NeedPoint)
}
"A" | "ANGLE" => {
self.awaiting_angle = true;
Some(CmdResult::NeedPoint)
}
_ => None,
}
}
fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
let (p1, p2) = match self.step {
Step::First => return None,
+1 -1
View File
@@ -178,4 +178,4 @@ fn angular_preview(vertex: Vec3, first: Vec3, second: Vec3, arc_pt: Vec3) -> Vec
// ── Autocomplete registry ─────────────────────────────────
inventory::submit!(crate::command::CommandRegistration { names: &["DIMANGULAR"] }); // AngularDimensionCommand
inventory::submit!(crate::command::CommandRegistration { names: &["DIMANGULAR", "DAN"] }); // AngularDimensionCommand
+85 -1
View File
@@ -28,12 +28,24 @@ enum Step {
pub struct DiameterDimensionCommand {
step: Step,
/// Optional text that replaces the measured value (None = measurement).
text_override: Option<String>,
/// True while the next typed line is captured as the text override.
awaiting_text: bool,
/// Explicit text rotation in radians (None = follow the UCS/style).
text_angle: Option<f64>,
/// True while the next typed value is captured as the text angle.
awaiting_angle: bool,
}
impl DiameterDimensionCommand {
pub fn new() -> Self {
Self {
step: Step::CenterPoint,
text_override: None,
awaiting_text: false,
text_angle: None,
awaiting_angle: false,
}
}
}
@@ -44,10 +56,18 @@ impl CadCommand for DiameterDimensionCommand {
}
fn prompt(&self) -> String {
if self.awaiting_text {
return "DIMDIAMETER Enter dimension text (blank = measured value):".into();
}
if self.awaiting_angle {
return "DIMDIAMETER Specify text angle (degrees):".into();
}
match self.step {
Step::CenterPoint => "DIMDIAMETER Specify center point:".into(),
Step::ArcPoint(_) => "DIMDIAMETER Specify point on circle:".into(),
Step::TextPoint { .. } => "DIMDIAMETER Specify dimension line location:".into(),
Step::TextPoint { .. } => {
"DIMDIAMETER Specify dimension line location [Text/Angle]:".into()
}
}
}
@@ -68,15 +88,79 @@ impl CadCommand for DiameterDimensionCommand {
dim.base.insertion_point = v3(pt);
dim.leader_length = arc_pt.distance(pt) as f64;
dim.base.actual_measurement = dim.measurement();
dim.base.user_text = self.text_override.clone();
// An explicit text angle overrides the default rotation.
if let Some(a) = self.text_angle {
dim.base.text_rotation = a;
}
CmdResult::CommitAndExit(EntityType::Dimension(Dimension::Diameter(dim)))
}
}
}
fn on_enter(&mut self) -> CmdResult {
// A bare Enter while entering override text accepts the measured value.
if self.awaiting_text {
self.awaiting_text = false;
return CmdResult::NeedPoint;
}
if self.awaiting_angle {
self.awaiting_angle = false;
return CmdResult::NeedPoint;
}
CmdResult::Cancel
}
fn wants_text_input(&self) -> bool {
true
}
fn point_step_accepts_keywords(&self) -> bool {
// While entering the override text or angle it is a value, not a point step.
!self.awaiting_text && !self.awaiting_angle
}
fn wants_text_with_spaces(&self) -> bool {
// The override text may contain spaces.
self.awaiting_text
}
fn on_text_input(&mut self, text: &str) -> Option<CmdResult> {
if self.awaiting_text {
let t = text.trim();
// Blank (or the "<>" placeholder) keeps the measured value.
self.text_override = if t.is_empty() || t == "<>" {
None
} else {
Some(t.to_string())
};
self.awaiting_text = false;
return Some(CmdResult::NeedPoint);
}
if self.awaiting_angle {
let t = text.trim();
// Blank clears any explicit angle (follow the default again).
self.text_angle = if t.is_empty() {
None
} else {
t.parse::<f64>().ok().map(f64::to_radians)
};
self.awaiting_angle = false;
return Some(CmdResult::NeedPoint);
}
match text.trim().to_uppercase().as_str() {
"T" | "TEXT" | "M" | "MTEXT" => {
self.awaiting_text = true;
Some(CmdResult::NeedPoint)
}
"A" | "ANGLE" => {
self.awaiting_angle = true;
Some(CmdResult::NeedPoint)
}
_ => None,
}
}
fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
match self.step {
Step::CenterPoint => None,
+90 -3
View File
@@ -41,6 +41,14 @@ enum Step {
pub struct LinearDimensionCommand {
step: Step,
ucs: Mat4,
/// Optional text that replaces the measured value (None = measurement).
text_override: Option<String>,
/// True while the next typed line is captured as the text override.
awaiting_text: bool,
/// Explicit text rotation in radians (None = follow the UCS/style).
text_angle: Option<f64>,
/// True while the next typed value is captured as the text angle.
awaiting_angle: bool,
}
impl LinearDimensionCommand {
@@ -48,6 +56,10 @@ impl LinearDimensionCommand {
Self {
step: Step::FirstPoint,
ucs: Mat4::IDENTITY,
text_override: None,
awaiting_text: false,
text_angle: None,
awaiting_angle: false,
}
}
}
@@ -62,10 +74,20 @@ impl CadCommand for LinearDimensionCommand {
}
fn prompt(&self) -> String {
if self.awaiting_text {
return "DIMLINEAR Enter dimension text (blank = measured value):".into();
}
if self.awaiting_angle {
return "DIMLINEAR Specify text angle (degrees):".into();
}
match self.step {
Step::FirstPoint => "DIMLINEAR Specify first extension line origin:".into(),
Step::SecondPoint(_) => "DIMLINEAR Specify second extension line origin:".into(),
Step::DimensionLine { .. } => "DIMLINEAR Specify dimension line location:".into(),
Step::SecondPoint(_) => {
"DIMLINEAR Specify second extension line origin [Text/Angle]:".into()
}
Step::DimensionLine { .. } => {
"DIMLINEAR Specify dimension line location [Text/Angle]:".into()
}
}
}
@@ -100,12 +122,26 @@ impl CadCommand for LinearDimensionCommand {
dim.base.text_middle_point = v3(linear_text_pos(first, second, pt, axis));
dim.base.insertion_point = dim.base.text_middle_point;
dim.base.actual_measurement = dim.measurement();
dim.base.user_text = self.text_override.clone();
// An explicit text angle overrides the UCS-derived rotation.
if let Some(a) = self.text_angle {
dim.base.text_rotation = a;
}
CmdResult::CommitAndExit(EntityType::Dimension(Dimension::Linear(dim)))
}
}
}
fn on_enter(&mut self) -> CmdResult {
// A bare Enter while entering override text/angle accepts the default.
if self.awaiting_text {
self.awaiting_text = false;
return CmdResult::NeedPoint;
}
if self.awaiting_angle {
self.awaiting_angle = false;
return CmdResult::NeedPoint;
}
CmdResult::Cancel
}
@@ -113,6 +149,57 @@ impl CadCommand for LinearDimensionCommand {
CmdResult::Cancel
}
fn wants_text_input(&self) -> bool {
true
}
fn point_step_accepts_keywords(&self) -> bool {
// While typing the override text or angle, route input as a value, not
// a point pick / keyword.
!self.awaiting_text && !self.awaiting_angle
}
fn wants_text_with_spaces(&self) -> bool {
// The override text may contain spaces.
self.awaiting_text
}
fn on_text_input(&mut self, text: &str) -> Option<CmdResult> {
if self.awaiting_text {
let t = text.trim();
// Blank (or the "<>" placeholder) keeps the measured value.
self.text_override = if t.is_empty() || t == "<>" {
None
} else {
Some(t.to_string())
};
self.awaiting_text = false;
return Some(CmdResult::NeedPoint);
}
if self.awaiting_angle {
let t = text.trim();
// Blank clears any explicit angle (follow the UCS/style again).
self.text_angle = if t.is_empty() {
None
} else {
t.parse::<f64>().ok().map(f64::to_radians)
};
self.awaiting_angle = false;
return Some(CmdResult::NeedPoint);
}
match text.trim().to_uppercase().as_str() {
"T" | "TEXT" | "M" | "MTEXT" => {
self.awaiting_text = true;
Some(CmdResult::NeedPoint)
}
"A" | "ANGLE" => {
self.awaiting_angle = true;
Some(CmdResult::NeedPoint)
}
_ => None,
}
}
fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
match self.step {
Step::FirstPoint => None,
@@ -178,4 +265,4 @@ fn linear_text_pos(first: Vec3, second: Vec3, def: Vec3, axis: Vec3) -> Vec3 {
// ── Autocomplete registry ─────────────────────────────────
inventory::submit!(crate::command::CommandRegistration { names: &["DIMLINEAR"] }); // LinearDimensionCommand
inventory::submit!(crate::command::CommandRegistration { names: &["DIMLINEAR", "DLI"] }); // LinearDimensionCommand
+86 -2
View File
@@ -26,12 +26,24 @@ enum Step {
pub struct RadiusDimensionCommand {
step: Step,
/// Optional text that replaces the measured value (None = measurement).
text_override: Option<String>,
/// True while the next typed line is captured as the text override.
awaiting_text: bool,
/// Explicit text rotation in radians (None = follow the UCS/style).
text_angle: Option<f64>,
/// True while the next typed value is captured as the text angle.
awaiting_angle: bool,
}
impl RadiusDimensionCommand {
pub fn new() -> Self {
Self {
step: Step::CenterPoint,
text_override: None,
awaiting_text: false,
text_angle: None,
awaiting_angle: false,
}
}
}
@@ -42,10 +54,18 @@ impl CadCommand for RadiusDimensionCommand {
}
fn prompt(&self) -> String {
if self.awaiting_text {
return "DIMRADIUS Enter dimension text (blank = measured value):".into();
}
if self.awaiting_angle {
return "DIMRADIUS Specify text angle (degrees):".into();
}
match self.step {
Step::CenterPoint => "DIMRADIUS Specify center point:".into(),
Step::RadiusPoint(_) => "DIMRADIUS Specify radius point:".into(),
Step::TextPoint { .. } => "DIMRADIUS Specify dimension line location:".into(),
Step::TextPoint { .. } => {
"DIMRADIUS Specify dimension line location [Text/Angle]:".into()
}
}
}
@@ -66,12 +86,26 @@ impl CadCommand for RadiusDimensionCommand {
dim.base.insertion_point = v3(pt);
dim.leader_length = point.distance(pt) as f64;
dim.base.actual_measurement = dim.measurement();
dim.base.user_text = self.text_override.clone();
// An explicit text angle overrides the default rotation.
if let Some(a) = self.text_angle {
dim.base.text_rotation = a;
}
CmdResult::CommitAndExit(EntityType::Dimension(Dimension::Radius(dim)))
}
}
}
fn on_enter(&mut self) -> CmdResult {
// A bare Enter while entering override text accepts the measured value.
if self.awaiting_text {
self.awaiting_text = false;
return CmdResult::NeedPoint;
}
if self.awaiting_angle {
self.awaiting_angle = false;
return CmdResult::NeedPoint;
}
CmdResult::Cancel
}
@@ -79,6 +113,56 @@ impl CadCommand for RadiusDimensionCommand {
CmdResult::Cancel
}
fn wants_text_input(&self) -> bool {
true
}
fn point_step_accepts_keywords(&self) -> bool {
// While entering the override text or angle it is a value, not a point step.
!self.awaiting_text && !self.awaiting_angle
}
fn wants_text_with_spaces(&self) -> bool {
// The override text may contain spaces.
self.awaiting_text
}
fn on_text_input(&mut self, text: &str) -> Option<CmdResult> {
if self.awaiting_text {
let t = text.trim();
// Blank (or the "<>" placeholder) keeps the measured value.
self.text_override = if t.is_empty() || t == "<>" {
None
} else {
Some(t.to_string())
};
self.awaiting_text = false;
return Some(CmdResult::NeedPoint);
}
if self.awaiting_angle {
let t = text.trim();
// Blank clears any explicit angle (follow the UCS/style again).
self.text_angle = if t.is_empty() {
None
} else {
t.parse::<f64>().ok().map(f64::to_radians)
};
self.awaiting_angle = false;
return Some(CmdResult::NeedPoint);
}
match text.trim().to_uppercase().as_str() {
"T" | "TEXT" | "M" | "MTEXT" => {
self.awaiting_text = true;
Some(CmdResult::NeedPoint)
}
"A" | "ANGLE" => {
self.awaiting_angle = true;
Some(CmdResult::NeedPoint)
}
_ => None,
}
}
fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
match self.step {
Step::CenterPoint => None,
@@ -122,4 +206,4 @@ fn preview_wire(points: Vec<Vec3>) -> WireModel {
// ── Autocomplete registry ─────────────────────────────────
inventory::submit!(crate::command::CommandRegistration { names: &["DIMRADIUS"] }); // RadiusDimensionCommand
inventory::submit!(crate::command::CommandRegistration { names: &["DIMRADIUS", "DRA"] }); // RadiusDimensionCommand