diff --git a/crates/doc/src/tables.rs b/crates/doc/src/tables.rs index 5707e0c90..a240f98ca 100644 --- a/crates/doc/src/tables.rs +++ b/crates/doc/src/tables.rs @@ -476,6 +476,7 @@ impl DimStyle { match field { "textHeight" | "tolScale" => x.is_some_and(|x| x <= 0.0), "scale" | "arrowSize" | "tickSize" | "fixedExtLength" => x.is_some_and(|x| x < 0.0), + "decimals" | "altDecimals" | "tolDecimals" => x.is_some_and(|x| !(0.0..=8.0).contains(&x)), "fit" | "angularZeroSuppression" => x.is_some_and(|x| x > 3.0), "textMove" | "tolJust" | "arcSymbol" | "textFill" => x.is_some_and(|x| x > 2.0), "dimLineweight" | "extLineweight" => x.is_some_and(|x| !(-3.0..=211.0).contains(&x)), diff --git a/crates/engine/src/cmd.rs b/crates/engine/src/cmd.rs index cb9d7cadc..6c10bb65b 100644 --- a/crates/engine/src/cmd.rs +++ b/crates/engine/src/cmd.rs @@ -8,6 +8,8 @@ mod audit; pub(crate) mod blocks; pub mod clipboard; pub mod constraints; +mod dimstyle_cli; +mod dimstyles; mod draw; mod draw2; mod draworder; @@ -35,6 +37,7 @@ mod pline_opts; pub mod plotters; mod props; pub use blocks::library::{clear_library_cache, list_library, read_library_file}; +pub use dimstyle_cli::usable_dim_style_name; pub use draw2::breakline::BreaklineOptions; pub use props::MatchProps; pub(crate) use props::UNIT_RANGES; @@ -187,6 +190,8 @@ pub fn command_specs() -> &'static [CommandSpec] { v.extend(draw::specs()); v.extend(draw2::specs()); v.extend(annotate::specs()); + v.extend(dimstyles::specs()); + v.extend(dimstyle_cli::specs()); v.extend(mleader_edit::specs()); v.extend(annoscale::specs()); v.extend(hatch::specs()); diff --git a/crates/engine/src/cmd/dimstyle_cli.rs b/crates/engine/src/cmd/dimstyle_cli.rs new file mode 100644 index 000000000..707c72661 --- /dev/null +++ b/crates/engine/src/cmd/dimstyle_cli.rs @@ -0,0 +1,509 @@ +//! -DIMSTYLE, dimension styles at the command line (scripts, the keyboard): save the current +//! settings as a style (annotative or not), make a style current, list the current settings or +//! a style's or a dimension's, compare a style with the current one, give the current settings +//! to dimensions, list the styles. Also `dimstyle.overrides`, which sets the current style's +//! overrides (what the Dimension Style Manager's Override edits), in one undo step. + +use cadcraft_doc::{DimStyle, Drawing, EntityKind, Handle}; +use serde_json::{Value, json}; + +use super::machines::{SelOutcome, SelectPhase}; +use super::{CommandSpec, bad, bool_or, curves, str_param, targets}; +use crate::{Accept, EngineError, Input, Interactive, Prompt, Result, Session, Step}; + +const CMD: &str = "-dimstyle"; + +fn other(m: impl Into) -> EngineError { + EngineError::Other(m.into()) +} + +pub fn specs() -> Vec { + vec![ + CommandSpec::new("-dimstyle", "Dimension Style", run) + .params( + "{option: save | annotative | restore | status | variables | apply | list, name?, handle?, handles?, replace?: bool, pattern?} \ + → save (annotative: an annotative style): the current settings (style and its overrides) as style `name`, made current \ + (`replace` redefines one); restore: style `name` (or dimension `handle`'s style) made current; status: {variables} of the \ + current settings; variables: {variables} of style `name` or dimension `handle`; apply: the current settings given to \ + `handles` (default: the selection); list: {styles} matching `pattern` (*, ? and #)", + ) + .interactive(|_| Ok(Box::new(DashDimStyle::default()))), + CommandSpec::new("dimstyle.overrides", "Dimension Style Overrides", run_overrides).params( + "{