Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
cc0e3c7
Dynamic blocks: a stretch or move carries a multiline attribute's tex…
codyvogt Oct 13, 2026
b6cd666
Test: a stretched multiline attribute survives a save
codyvogt Oct 20, 2026
d35ee3a
Block reference grips: none on locked or invisible attributes; a move…
codyvogt Oct 13, 2026
ee06979
Dynamic block references: rotation and flip parameters and their rota…
codyvogt Oct 13, 2026
ebeb263
Dynamic blocks: rotation and flip grips, flip state after the points,…
codyvogt Oct 13, 2026
6977a58
Dynamic blocks: rotation test compares with a plain bound, not an app…
codyvogt Oct 13, 2026
e0fa2af
Dynamic blocks: the rotation grip is where its grip object is, and a …
codyvogt Oct 14, 2026
95f7f66
Dynamic blocks: an angle parameter shows and is typed as the drawing …
codyvogt Oct 14, 2026
8431018
Dynamic blocks: the flip grip is a block arrow, as AutoCAD draws it
codyvogt Oct 14, 2026
98db116
Dynamic blocks: flipped text keeps its mirrored footprint, as AutoCAD…
codyvogt Oct 14, 2026
74498ff
Dynamic blocks: the rotation grip's Dynamic Input shows one angle box
codyvogt Oct 14, 2026
7f85a54
Dynamic blocks: a value record takes its shape from its parameter
codyvogt Oct 20, 2026
cae6f75
Docs: the dynamic block data row says what can be changed now
codyvogt Oct 20, 2026
b19fa36
Dynamic blocks: a flip value's state is written after both its points
codyvogt Oct 23, 2026
ca56d00
Prompt: the picker's doc stays on picker, the angle's on angle
codyvogt Oct 23, 2026
7f6033c
Dynamic blocks: a rotate or flip selection that repeats an object tur…
codyvogt Oct 23, 2026
28d240c
Dynamic blocks: the actions' bookkeeping moves into ActionRun
codyvogt Oct 28, 2026
eeb213d
Dynamic blocks: a grip on a value list or increments marks its stops …
codyvogt Oct 13, 2026
4f671b7
Dynamic blocks: an angle's tick marks are where its grip will be
codyvogt Oct 14, 2026
46acac7
Dynamic blocks: array actions, polar and XY parameters
codyvogt Oct 20, 2026
7cd5ef3
Dynamic block grips: list XY corner parts as a drag takes them
codyvogt Oct 20, 2026
5721b77
Docs: the dynamic block data row lists polar, XY and array changes
codyvogt Oct 20, 2026
e6fce40
Dynamic blocks: an angle just short of a full turn shows as 0, not 360
codyvogt Oct 20, 2026
201b568
Tests: the array and rotate/flip tests join the io and engine test bi…
codyvogt Oct 23, 2026
b471e59
Dynamic blocks: scale actions
codyvogt Oct 20, 2026
fc8caca
Dynamic blocks: polar stretch actions; scale by an XY parameter's dia…
codyvogt Oct 20, 2026
50060af
Docs: the dynamic block data row lists scale and polar stretch actions
codyvogt Oct 20, 2026
e74cac5
Docs: DWG save of drawings with scale actions needs #1725
codyvogt Oct 20, 2026
dc55e72
Tests: scale and polar stretch tests join the io test binary; Scale's…
codyvogt Oct 23, 2026
fc82a2f
Dynamic blocks: base point and alignment parameters; lookups of angle…
codyvogt Oct 20, 2026
e265c5c
Docs: the dynamic block data row lists base point, alignment and look…
codyvogt Oct 20, 2026
241cc6a
Docs: the dynamic block data row names the fixed-base rotate and scal…
codyvogt Oct 20, 2026
db3e14f
Tests: the base point, alignment and lookup tests join the io test bi…
codyvogt Oct 23, 2026
5e8d4e7
Snap: gather_in takes the object to skip, like its siblings' argument…
codyvogt Oct 28, 2026
9f7440c
Merge branch 'main' of https://github.com/storytold/cadcraft into fea…
codyvogt Oct 31, 2026
7050d6d
Merge branch 'main' of https://github.com/storytold/cadcraft into fea…
codyvogt Oct 31, 2026
2c77569
Merge branch 'main' of https://github.com/storytold/cadcraft into HEAD
codyvogt Oct 31, 2026
c000580
Merge commit '7050d6dc2d49214162e2d93c2de591db35af3472' into HEAD
codyvogt Oct 31, 2026
41d20af
Docs: leave the parity docs to the maintainers (AGENTS.md: PRs don't …
codyvogt Nov 1, 2026
2513204
Docs: leave the parity docs to the maintainers (AGENTS.md: PRs don't …
codyvogt Nov 1, 2026
309c902
Docs: leave the parity docs to the maintainers (AGENTS.md: PRs don't …
codyvogt Nov 1, 2026
8428fbb
Merge branch 'main' of https://github.com/storytold/cadcraft into HEAD
codyvogt Nov 2, 2026
9df1e11
Merge branch 'main' of https://github.com/storytold/cadcraft into fea…
codyvogt Nov 2, 2026
8aea81d
Merge remote-tracking branch 'origin/feat/dynblock-array' into feat/d…
codyvogt Nov 2, 2026
843ee07
Merge commit '8aea81d682f248b711acc6ad5ec3d940f840fe25' into HEAD
codyvogt Nov 2, 2026
a17af99
Merge branch 'main' of https://github.com/storytold/cadcraft into HEAD
codyvogt Nov 2, 2026
2d5988c
Merge branch 'main' of https://github.com/storytold/cadcraft into fea…
codyvogt Nov 2, 2026
f4fd603
Merge remote-tracking branch 'origin/feat/dynblock-array' into feat/d…
codyvogt Nov 2, 2026
cec1d2b
Merge commit 'f4fd603acf4449f8943b5860264421ad85c502c1' into HEAD
codyvogt Nov 2, 2026
d11c7f3
Merge branch 'main' of https://github.com/storytold/cadcraft into fea…
codyvogt Nov 2, 2026
34d8896
Tests: the DWG scale action test matches the Scale struct variant
codyvogt Nov 2, 2026
bb32810
Merge main into feat/dynblock-scale; the DWG scale action test matche…
codyvogt Nov 3, 2026
858e114
Merge branch 'main' of https://github.com/storytold/cadcraft into fea…
codyvogt Nov 3, 2026
797b83b
Merge branch 'main' of https://github.com/storytold/cadcraft into HEAD
codyvogt Nov 3, 2026
7f3687f
Merge commit 'bb32810f' into HEAD
codyvogt Nov 3, 2026
eb87758
Merge commit '858e1146e78fbb0ff266777c85091f23eec283c1' into HEAD
codyvogt Nov 3, 2026
4d872f8
Merge #1723's fixes into feat/dynblock-params
codyvogt Nov 3, 2026
84c3243
Merge branch 'main' of https://github.com/storytold/cadcraft into HEAD
codyvogt Nov 4, 2026
72fafd2
Merge branch 'main' of https://github.com/storytold/cadcraft into fea…
codyvogt Nov 4, 2026
e28ebc6
Merge remote-tracking branch 'origin/feat/dynblock-array' into feat/d…
codyvogt Nov 4, 2026
e789f77
Merge commit 'e28ebc6958feb5990178b0ea9d3b6230e3b4a25d' into HEAD
codyvogt Nov 4, 2026
105930e
Merge storytold/cadcraft main into feat/dynblock-params
codyvogt Nov 16, 2026
95aefd1
Tests: block references built in tests give the clip main added
codyvogt Nov 16, 2026
b92da35
Merge storytold/cadcraft main into feat/dynblock-params
codyvogt Nov 21, 2026
d1a4809
Merge #963: Dynamic blocks: a stretch or move carries a multiline att…
tanish2k09 Nov 23, 2026
b418e68
Merge #993: Block reference grips: none on locked or invisible attrib…
tanish2k09 Nov 23, 2026
e2cd875
Merge #1752: Dynamic blocks: base point and alignment parameters; loo…
tanish2k09 Nov 23, 2026
c862f8a
Dynamic blocks: the array budget is taken before offsets are kept; a …
codyvogt Nov 24, 2026
522ed59
Dynamic blocks: an XY distance past the number range is refused; a po…
codyvogt Nov 24, 2026
ced6984
Alignment grips: targets stay on a ray and off layers frozen in the v…
codyvogt Nov 24, 2026
8fb4d81
Merge #1752 again: the six review fixes (array budget, alignment grip…
tanish2k09 Nov 24, 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
293 changes: 246 additions & 47 deletions crates/doc/src/dynblock.rs

Large diffs are not rendered by default.

1,242 changes: 1,111 additions & 131 deletions crates/doc/src/dynblock/apply.rs

Large diffs are not rendered by default.

154 changes: 151 additions & 3 deletions crates/doc/src/dynblock/grips.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
//! The grips of a dynamic block reference, as AutoCAD shows them on a selected reference: an
//! arrow at each end of a distance (linear parameter), a square at a position (point parameter)
//! and a down-pointing triangle for a list (visibility states, lookup values). Dragging an arrow
//! or square is [`super::drag_grip`]; a list grip offers its property's choices.
//! arrow at each end of a distance (linear parameter), a square at a position (point parameter),
//! a circle at the end of an angle (rotation parameter), a flip arrow across a reflection line
//! (flip parameter), a down-pointing triangle for a list (visibility states, lookup values) and a
//! pentagon pointing across the alignment direction at an alignment's base point (alignment
//! parameter; dragged next to an object it aligns the reference with it, [`super::align_grip`]).
//! Dragging an arrow, square or circle is [`super::drag_grip`]; a flip grip flips at a click; a
//! list grip offers its property's choices.
//!
//! With a visibility parameter, a state lists the grips shown in it; the others are hidden.

Expand All @@ -26,6 +30,13 @@ pub enum GripPart {
End,
/// A one-point parameter's point (a position, a visibility or lookup grip).
At,
/// An XY parameter's corner at the base's X and the end's Y (listed as `blocks.reference.grip`
/// takes it, as [`GripPart::name`] names it).
#[serde(rename = "basex-endy")]
BaseXEndY,
/// An XY parameter's corner at the end's X and the base's Y.
#[serde(rename = "basey-endx")]
BaseYEndX,
}

impl GripPart {
Expand All @@ -34,18 +45,37 @@ impl GripPart {
GripPart::Base => "base",
GripPart::End => "end",
GripPart::At => "at",
GripPart::BaseXEndY => "basex-endy",
GripPart::BaseYEndX => "basey-endx",
}
}
pub fn from_name(s: &str) -> Option<GripPart> {
match s.trim().to_ascii_lowercase().as_str() {
"base" => Some(GripPart::Base),
"end" => Some(GripPart::End),
"at" => Some(GripPart::At),
"basex-endy" => Some(GripPart::BaseXEndY),
"basey-endx" => Some(GripPart::BaseYEndX),
_ => None,
}
}
}

#[cfg(test)]
mod tests {
use super::GripPart;

/// A grip is listed with the part name `blocks.reference.grip` takes back.
#[test]
fn listed_part_names_are_the_names_a_drag_takes() {
for p in [GripPart::Base, GripPart::End, GripPart::At, GripPart::BaseXEndY, GripPart::BaseYEndX] {
let listed = serde_json::to_value(p).ok().and_then(|v| v.as_str().map(str::to_string)).unwrap_or_default();
assert_eq!(listed, p.name());
assert_eq!(GripPart::from_name(&listed), Some(p));
}
}
}

/// How a grip looks and what it does.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
Expand All @@ -56,6 +86,13 @@ pub enum GripShape {
Point,
/// A down-pointing triangle: click it for the property's choices.
List,
/// A circle at the end of an angle: drag it to turn the angle.
Rotation,
/// An arrow across a reflection line: click it to flip (its choices are the two states).
Flip,
/// A pentagon pointing to the left of an alignment's direction: drag it next to an object to
/// align the reference with it.
Alignment,
}

/// One grip of a dynamic block reference.
Expand Down Expand Up @@ -102,6 +139,15 @@ fn ends_used(m: &DynamicBlock, node: i32) -> Option<(bool, bool)> {
used
}

/// Where a grip object at `g` (from its parameter's base, in the dynamic block) is when the
/// parameter's line `home` (base to end, in the block) is now `now` from `base`: kept along and
/// across the line as it turns, moves or stretches. `home` and `now` aren't zero.
fn carried(g: Vec2, home: Vec2, base: Vec2, now: Vec2) -> Vec2 {
let (u0, u) = (home * (1.0 / home.len()), now * (1.0 / now.len()));
let (along, across) = (g.dot(u0) / home.len(), u0.x * g.y - u0.y * g.x);
base + now * along + u.perp() * across
}

fn point<S: serde::Serializer>(p: &Vec2, s: S) -> Result<S::Ok, S::Error> {
[p.x, p.y].serialize(s)
}
Expand All @@ -120,6 +166,7 @@ pub fn grips(d: &Drawing, insert: Handle) -> Vec<DynGrip> {
};
// The grips the current visibility state shows (all of them without visibility states).
let objects: HashMap<i32, Handle> = m.grip_objects.iter().copied().collect();
let points: HashMap<i32, Vec3> = m.grip_points.iter().copied().collect();
let mut shown_in_state: Option<HashSet<Handle>> = None;
let mut visibility_node = None;
for p in &m.parameters {
Expand Down Expand Up @@ -171,6 +218,87 @@ pub fn grips(d: &Drawing, insert: Handle) -> Vec<DynGrip> {
}
}
}
ParameterKind::Rotation { base: hb, end: he, label, .. } => {
let (b, e) = match r.values.get(&p.node) {
Some(Value::Points { base, end }) => (*base, *end),
_ => (*hb, *he),
};
let id = grip(1);
let (home, now) = ((*he - *hb).xy(), (e - b).xy());
if shown(p.node, id) && home.len() > 1e-12 && now.len() > 1e-12 {
// The grip object's place (AutoCAD draws the circle there, not at the radius'
// end), turned and moved with the radius.
let at = carried(points.get(&id).copied().unwrap_or(*he).xy() - hb.xy(), home, b.xy(), now);
let at = Vec3::new(at.x, at.y, b.z);
let u = at - b;
let u = if u.len() > 1e-12 { u * (1.0 / u.len()) } else { Vec3::new(1.0, 0.0, 0.0) };
let (at, dir) = (world(at), toward(at, u));
out.push(DynGrip {
node: p.node,
part: GripPart::End,
shape: GripShape::Rotation,
at,
dir,
property: label.clone(),
choices: Vec::new(),
});
}
}
ParameterKind::Flip { base: hb, end: he, label, states, .. } => {
let (b, e, flipped) = match r.values.get(&p.node) {
Some(Value::Flip { base, end, flipped }) => (*base, *end, *flipped),
_ => (*hb, *he, false),
};
let id = grip(0);
let (home, now) = ((*he - *hb).xy(), (e - b).xy());
if shown(p.node, id) && home.len() > 1e-12 && now.len() > 1e-12 {
// The grip object's place, kept along and across the reflection line as the
// line turns or moves with other actions.
let g = points.get(&id).copied().unwrap_or(*hb).xy() - hb.xy();
let at = carried(g, home, b.xy(), now);
let u = now * (1.0 / now.len());
let across_dir = if flipped { -u.perp() } else { u.perp() };
let (at3, dir) = (Vec3::new(at.x, at.y, b.z), toward(Vec3::new(at.x, at.y, b.z), across_dir.to3(0.0)));
out.push(DynGrip {
node: p.node,
part: GripPart::Base,
shape: GripShape::Flip,
at: world(at3),
dir,
property: label.clone(),
choices: states.to_vec(),
});
}
}
// Squares at the base and the end (a polar parameter), and at the two other corners of
// the rectangle they span (an XY parameter), for the grips the parameter has; an end
// no action follows has none.
ParameterKind::Polar { base, end, label, .. } | ParameterKind::Xy { base, end, x_label: label, .. } => {
let (b, e) = match r.values.get(&p.node) {
Some(Value::Points { base, end }) => (*base, *end),
_ => (*base, *end),
};
let used = ends_used(&m, p.node).map_or([true, true], |(base, end)| [base, end]);
let mut corners = vec![(0, GripPart::Base, b, used[0]), (1, GripPart::End, e, used[1])];
if matches!(p.kind, ParameterKind::Xy { .. }) {
let both = used[0] && used[1];
corners.push((2, GripPart::BaseXEndY, Vec3::new(b.x, e.y, b.z), both));
corners.push((3, GripPart::BaseYEndX, Vec3::new(e.x, b.y, b.z), both));
}
for (i, part, at, used) in corners {
if used && shown(p.node, grip(i)) {
out.push(DynGrip {
node: p.node,
part,
shape: GripShape::Point,
at: world(at),
dir: Vec2::ZERO,
property: label.clone(),
choices: Vec::new(),
});
}
}
}
ParameterKind::Point { at, label, .. } => {
let at = match r.values.get(&p.node) {
Some(Value::Point { at }) => *at,
Expand All @@ -189,6 +317,26 @@ pub fn grips(d: &Drawing, insert: Handle) -> Vec<DynGrip> {
});
}
}
// At the base point, pointing to the left of the direction (as AutoCAD draws it).
ParameterKind::Alignment { base, end, .. } => {
let (b, e) = match r.values.get(&p.node) {
Some(Value::Points { base, end }) => (*base, *end),
_ => (*base, *end),
};
let u = (e - b).xy();
if shown(p.node, grip(0)) && u.len() > 1e-12 {
let (at, dir) = (world(b), toward(b, u.perp().to3(0.0)));
out.push(DynGrip {
node: p.node,
part: GripPart::Base,
shape: GripShape::Alignment,
at,
dir,
property: String::new(),
choices: Vec::new(),
});
}
}
ParameterKind::Visibility { at, label, .. } | ParameterKind::Lookup { at, label, .. } => {
let Some(list) = choices.get(&label.to_ascii_uppercase()).filter(|c| !c.is_empty()) else { continue };
if shown(p.node, grip(0)) {
Expand Down
Loading
Loading