Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
de73d8c
Text formulas and fields: =... in text, dimensions and leaders; UPDAT…
claude Oct 27, 2026
124b7b4
HATCH: pick points near the view, boundary warnings, open-curve and b…
claude Oct 27, 2026
cd15b3e
Keep the hatch background helpers beside the other xdata applications
claude Oct 27, 2026
43087b5
Register the CADCRAFTFORMULA xdata application in the APPID table
claude Oct 27, 2026
826e71f
Merge branch 'split/text-formulas' into split/hatch
claude Oct 27, 2026
70c1858
Same description of the folder picker in every part
claude Oct 27, 2026
8675424
Text formulas: review fixes
claude Oct 27, 2026
a59dfd1
Merge the text-formula review fixes
claude Oct 27, 2026
5af81ab
Hatch: review fixes
claude Oct 27, 2026
3bcfb17
Text formulas: ^ left to right; a replaced AutoCAD field is not writt…
claude Oct 27, 2026
670e041
Merge the text-formula review fixes
claude Oct 27, 2026
6616657
Custom patterns: the folder isn't read on every keystroke
claude Oct 27, 2026
f20306e
Merge upstream main (release 0.14.0)
claude Oct 28, 2026
3fa4ecf
Merge the text-formula part (with upstream main 0.14.0)
claude Oct 28, 2026
ec32ad2
Keep DXF finishing within upstream's complexity limit
claude Oct 28, 2026
2fc041b
CLI perf drawing: the text formula field
claude Oct 28, 2026
ca8f2b3
Merge the review fixes of split/text-formulas
claude Oct 28, 2026
aa8c500
fmt
claude Oct 28, 2026
ae9e57f
Merge upstream main (0.15.1) into the text formula part
claude Oct 31, 2026
039a064
Merge split/text-formulas (with upstream main 0.15.1)
claude Oct 31, 2026
98139c3
Text formulas: the formula field in upstream 0.15's new objects and r…
claude Oct 31, 2026
b8603b3
Merge split/text-formulas (with upstream main 0.15.1)
claude Oct 31, 2026
90c9d06
Text formulas: an AutoCAD field the reader declines is kept on save
claude Oct 31, 2026
fded7c0
Hatch: a numeric background outside 0..=256 is refused
claude Oct 31, 2026
780f469
Merge upstream main into split/text-formulas
claude Oct 31, 2026
2b2879f
Merge split/text-formulas into split/hatch
claude Oct 31, 2026
466fe69
Merge upstream main into split/text-formulas
claude Nov 2, 2026
f90bc00
Merge split/text-formulas into split/hatch
claude Nov 2, 2026
ffa7310
Text formulas: Chinese labels for Text Formulas and Update Fields
claude Nov 2, 2026
eb87356
Fit upstream 0.15.1: the new fields in its added objects and tests
claude Nov 2, 2026
60709f6
Text formulas: an AutoCAD field's text is saved as read while the fie…
claude Nov 2, 2026
56da08c
Merge split/text-formulas into split/hatch
claude Nov 2, 2026
5fe9571
Merge upstream main into split/text-formulas
claude Nov 4, 2026
c96a06e
Merge split/text-formulas into split/hatch
claude Nov 4, 2026
3bf07c1
Fit main: the new fields in its added tests
claude Nov 4, 2026
748d920
Text formulas: a block reference's attribute formulas are worked out …
claude Nov 4, 2026
5836826
HATCH: a block reference's closed outline bounds a hatch picked by Se…
claude Nov 4, 2026
ddcb031
Merge split/text-formulas into split/hatch
claude Nov 4, 2026
2144528
Merge upstream main into split/text-formulas
claude Nov 4, 2026
f22ff80
Fit main: the new fields in its added code and tests
claude Nov 4, 2026
fe50a54
Merge split/text-formulas into split/hatch
claude Nov 4, 2026
0c0d027
Merge upstream main into split/text-formulas
claude Nov 5, 2026
90cb853
Merge split/text-formulas into split/hatch
claude Nov 5, 2026
420d851
Merge remote-tracking branch 'upstream/main' into split/text-formulas
claude Nov 13, 2026
1fe6131
Merge branch 'split/text-formulas' into split/hatch
claude Nov 13, 2026
57783dc
Merge upstream main into split/text-formulas
claude Nov 17, 2026
29472ae
Merge split/text-formulas into split/hatch
claude Nov 17, 2026
4c6774c
Merge upstream/main into split/text-formulas
claude Nov 20, 2026
2f5d3ad
Merge text-formulas into split/hatch
claude Nov 20, 2026
d48d599
Merge upstream/main into split/text-formulas (with FredApps's fixes f…
claude Nov 20, 2026
2187800
Merge text-formulas into split/hatch
claude Nov 20, 2026
64a2d34
Hatch background: its APPID is written again after the merge
claude Nov 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apps/cadcraft-cli/src/perf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ fn synthetic(n: usize, side: f64) -> Result<cadcraft_engine::doc::Drawing, cadcr
plinegen: false,
}),
_ => EntityKind::Text(d::Text {
formula: None,
insert: v3(x, y),
align_pt: None,
height: s * 0.2,
Expand Down
1 change: 1 addition & 0 deletions apps/cadcraft/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ fn services() -> Services {
Services {
pick_open: Some(Box::new(|| file_dialog(&Pick::Open).pick_file().map(|p| p.to_string_lossy().to_string()))),
pick_save: Some(Box::new(|name: &str| file_dialog(&Pick::Save(name.into())).save_file().map(|p| p.to_string_lossy().to_string()))),
pick_folder: Some(Box::new(|| rfd::FileDialog::new().pick_folder().map(|p| p.to_string_lossy().to_string()))),
// macOS shows the dialogs as sheets (`sheet::start_pick`), set once the window exists.
start_pick: None,
// APPLOAD: AutoLISP routines only, starting where the last one was loaded from.
Expand Down
1 change: 1 addition & 0 deletions crates/constraints/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ fn invalid_references_and_purge() {
let t = add_e(
&mut d,
EntityKind::Text(cadcraft_doc::Text {
formula: None,
insert: v(0.0, 0.0),
align_pt: None,
height: 1.0,
Expand Down
4 changes: 4 additions & 0 deletions crates/doc/src/entity/dim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ pub struct DimMarks {
/// Inspection frame, label and rate (DIMINSPECT).
#[serde(skip_serializing_if = "Option::is_none")]
pub inspect: Option<Inspection>,
/// A formula for the dimension text (`=<>/2`, `=TEXT(<>,"0.0")&" mm"`; `<>` is the
/// measurement); `Dimension::text` holds the last result.
#[serde(skip_serializing_if = "Option::is_none")]
pub formula: Option<String>,
}

impl DimMarks {
Expand Down
8 changes: 8 additions & 0 deletions crates/doc/src/entity/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ pub struct Text {
pub halign: HAlign,
#[serde(default)]
pub valign: VAlign,
/// The formula the text shows the result of: `=...` (CADCraft text formulas) or an AutoCAD
/// field code (`%<\AcVar date \f "dd.MM.yyyy">%`). `value` holds the last result.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub formula: Option<String>,
}

impl Text {
Expand Down Expand Up @@ -83,6 +87,10 @@ pub struct MText {
/// one column.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub columns: Option<MTextColumns>,
/// The formula the text shows the result of (see [`Text::formula`]); `contents` holds the
/// last result.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub formula: Option<String>,
}

fn attach_tl() -> u8 {
Expand Down
3 changes: 3 additions & 0 deletions crates/doc/src/extents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,7 @@ mod tests {

fn text(halign: HAlign, valign: VAlign) -> Text {
Text {
formula: None,
insert: Vec3::new(0.0, 0.0, 0.0),
align_pt: Some(Vec3::new(0.0, 0.0, 0.0)),
height: 1.0,
Expand All @@ -618,6 +619,7 @@ mod tests {

fn mtext(contents: &str, width: f64) -> crate::MText {
crate::MText {
formula: None,
insert: Vec3::new(10.0, 10.0, 0.0),
height: 2.5,
width,
Expand Down Expand Up @@ -684,6 +686,7 @@ mod tests {
#[test]
fn multileader_text_is_inside_its_bounds() {
let mtext = crate::MText {
formula: None,
insert: Vec3::new(25.45, 0.0, 0.0),
height: 5.0,
width: 0.0,
Expand Down
12 changes: 11 additions & 1 deletion crates/doc/src/foreign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,21 @@ pub struct ForeignExtra {
pub color_book: Option<(String, String)>,
/// Other unmodelled property groups (material 347, shadow mode 284).
pub props: Vec<RawTag>,
/// A TEXT or MTEXT with an AutoCAD field: the formula the field was read as and the text the
/// file showed. While the formula is unchanged the text is written back as read, so it
/// matches the value cached in the field and AutoCAD keeps the field (it works it out again
/// itself); CADCraft shows the field worked out for today meanwhile.
pub field_text: Option<(String, String)>,
}

impl ForeignExtra {
pub fn is_empty(&self) -> bool {
self.xdict.is_none() && self.reactors.is_empty() && self.xdata.is_empty() && self.color_book.is_none() && self.props.is_empty()
self.xdict.is_none()
&& self.reactors.is_empty()
&& self.xdata.is_empty()
&& self.color_book.is_none()
&& self.props.is_empty()
&& self.field_text.is_none()
}
}

Expand Down
5 changes: 5 additions & 0 deletions crates/doc/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ fn visible_attributes_of_a_missing_block_still_count() {
let attrib = |invisible: bool| Attrib {
tag: "TAG".into(),
text: Text {
formula: None,
insert: Vec3::new(1000.0, 1000.0, 0.0),
align_pt: None,
height: 10.0,
Expand Down Expand Up @@ -433,6 +434,7 @@ fn plain_attrib(tag: &str) -> Attrib {
Attrib {
tag: tag.into(),
text: Text {
formula: None,
insert: Vec3::ZERO,
align_pt: None,
height: 1.0,
Expand Down Expand Up @@ -573,6 +575,7 @@ fn attdef_in_block_is_ignored_in_insert_extents() {
EntityKind::AttDef(Attrib {
tag: "TAG".into(),
text: Text {
formula: None,
insert: Vec3::new(5000.0, 5000.0, 0.0),
align_pt: None,
height: 1.0,
Expand All @@ -598,6 +601,7 @@ fn attdef_in_block_is_ignored_in_insert_extents() {

fn text_kind(value: &str) -> EntityKind {
EntityKind::Text(Text {
formula: None,
insert: Vec3::new(10.0, 10.0, 0.0),
align_pt: None,
height: 2.0,
Expand All @@ -613,6 +617,7 @@ fn text_kind(value: &str) -> EntityKind {

fn mtext_kind(contents: &str) -> EntityKind {
EntityKind::MText(MText {
formula: None,
insert: Vec3::new(10.0, 10.0, 0.0),
height: 2.0,
width: 0.0,
Expand Down
2 changes: 2 additions & 0 deletions crates/engine/src/cmd/annotate/leader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ impl Interactive for LeaderM {
};
let text = picked.and_then(|h| s.doc().ok()?.entity(h).cloned()).and_then(|e| match &e.kind {
EntityKind::Text(t) => Some(MText {
formula: None,
insert: t.insert,
height: t.height,
width: 0.0,
Expand Down Expand Up @@ -298,6 +299,7 @@ fn add_leader(s: &mut Session, pts: &[Vec2], spline: bool, arrow: bool, ann: Ann
(false, false) => (6, 0.0),
};
Some(s.add_entity(EntityKind::MText(MText {
formula: None,
insert: v3(end + Vec2::new(dir * z.gap, lift)),
height: z.text,
width: 0.0,
Expand Down
1 change: 1 addition & 0 deletions crates/engine/src/cmd/annotate/mleader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ fn mleader_kind(s: &Session, pts: &[Vec2], text: &str, landing: bool) -> Option<
landing: v3(*landing_pt),
dogleg,
text: (!text.is_empty()).then(|| MText {
formula: None,
insert: v3(tpos),
height: th,
width: 0.0,
Expand Down
1 change: 1 addition & 0 deletions crates/engine/src/cmd/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ fn attdef_kind(
EntityKind::AttDef(Attrib {
tag: tag.to_ascii_uppercase(),
text: Text {
formula: None,
insert: v3(at),
align_pt: if left { None } else { Some(v3(at)) },
height,
Expand Down
1 change: 1 addition & 0 deletions crates/engine/src/cmd/blocks/attdef.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ impl AttdefM {
s.add_entity(EntityKind::AttDef(Attrib {
tag: self.tag.to_uppercase(),
text: Text {
formula: None,
insert: v3(self.at),
align_pt: if left { None } else { Some(v3(self.at)) },
height: self.height,
Expand Down
4 changes: 4 additions & 0 deletions crates/engine/src/cmd/blocks/attedit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,16 @@ fn all_in_space(s: &Session) -> Result<Vec<Handle>> {
/// Change attribute `k` of block reference `h`; returns whether its value changed.
fn edit(s: &mut Session, (h, k): (Handle, usize), f: impl FnOnce(&str) -> Option<String>) -> Result<bool> {
let mut changed = false;
let env = crate::textformula::env(s);
s.doc_mut()?.modify_entity(h, |e| {
if let EntityKind::Insert(ins) = &mut e.kind
&& let Some(a) = ins.attribs.get_mut(k)
&& let Some(v) = f(&a.text.value).filter(|v| *v != a.text.value)
{
set_value(&mut a.text, v);
// A typed value replaces the attribute's formula (or field); a typed formula is kept
// and shows its result.
crate::textformula::apply_text(&mut a.text, &env, true);
changed = true;
}
})?;
Expand Down
2 changes: 2 additions & 0 deletions crates/engine/src/cmd/draw/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub(crate) fn make_text(s: &Session, at: Vec2, value: &str, height: f64, rotatio
let (h, v) = j;
let left = h == HAlign::Left && v == VAlign::Baseline;
EntityKind::Text(Text {
formula: None,
insert: v3(at),
align_pt: if left { None } else { Some(v3(at)) },
height,
Expand Down Expand Up @@ -82,6 +83,7 @@ pub(super) fn run_mtext(s: &mut Session, p: &Value) -> Result<Value> {
};
let width = f64_or(p, "width", 0.0).max(0.0);
let k = EntityKind::MText(MText {
formula: None,
insert: v3(at),
height,
width,
Expand Down
5 changes: 4 additions & 1 deletion crates/engine/src/cmd/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,10 @@ fn read_bytes(bytes: &[u8], name: &str, path: Option<String>) -> Result<ReadFile
Ok(ReadFile { drawing, binary_dxf: craft_dxf::is_binary(bytes), name: name.to_string(), path })
}

fn add_read(s: &mut Session, drawing: Drawing, binary_dxf: bool, name: &str, path: Option<String>) -> usize {
fn add_read(s: &mut Session, mut drawing: Drawing, binary_dxf: bool, name: &str, path: Option<String>) -> usize {
// Formulas and fields (dates) worked out for today.
let env = crate::textformula::Env { now: crate::textformula::local_now(), file: file_name(name), sheet: "Model".into(), measured: None };
crate::textformula::refresh(&mut drawing, &env);
let notes = drawing.read_notes.clone();
let i = s.open_drawing(drawing, &file_name(name), path);
if let Some(st) = s.docs.get_mut(i) {
Expand Down
Loading
Loading