fix: closing-segment markers on closed polylines; case-insensitive page-setup names

- resolve_point, set_polyline_vertex and the solver's point_for_marker
  treat the marker one past the last vertex of a closed polyline as
  vertex 0, the way line_segment already did. Equal (#1366), the axis
  pre-alignment (#1365) and the transform pin (#1361) address a picked
  segment's end that way, so on the closing segment they either refused
  the pick or pinned nothing.
- Page-setup dictionary keys compare case-insensitively: page_setup_save
  replaces "site" when "Site" exists instead of adding a second entry
  (PSETUPIN counted it as replaced, #1344), delete and rename match the
  same way, and a rename that only changes case is allowed.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Hakan SevenandClaude Fable 5.1 committed 2026-09-20 21:12:07 +03:00
1 parent 75e7f825cd
commit a1629fd073
3 files changed
+63 -11

No files matched your search

+24 -3
View File
@@ -244,6 +244,9 @@ pub(crate) fn set_polyline_vertex(
x: f64,
y: f64,
) -> bool {
let Some(index) = polyline_vertex_index(entity, index) else {
return false;
};
match entity {
acadrust::EntityType::LwPolyline(polyline) => polyline
.vertices
@@ -800,9 +803,27 @@ pub(crate) fn resolve_point(entity: &acadrust::EntityType, marker: i32) -> Optio
if marker < 0 {
return None;
}
super::dimension_assoc::source_points(entity)
.get(marker as usize)
.copied()
let points = super::dimension_assoc::source_points(entity);
// The closing segment of a closed polyline runs back to vertex 0, so its
// end marker (one past the last vertex) names that vertex — the same wrap
// the solver's `line_segment` applies.
let index = match polyline_vertex_index(entity, marker as usize) {
Some(index) => index,
None => marker as usize,
};
points.get(index).copied()
}
/// `marker` as a vertex index of a polyline, wrapping the closing segment's
/// end (one past the last vertex) onto vertex 0 when the polyline is closed.
/// `None` for anything that is not a 2D polyline.
pub(crate) fn polyline_vertex_index(entity: &acadrust::EntityType, marker: usize) -> Option<usize> {
let (count, closed) = match entity {
acadrust::EntityType::LwPolyline(polyline) => (polyline.vertices.len(), polyline.is_closed),
acadrust::EntityType::Polyline2D(polyline) => (polyline.vertices.len(), polyline.is_closed()),
_ => return None,
};
Some(if closed && marker == count && count > 0 { 0 } else { marker })
}
/// Below this squared distance (1e-6 world units), two points count as