Skip to content

fix: fix nested block reference osnap transforms and insertion points#229

Merged
mlightcad merged 1 commit intomainfrom
feat/osnap
Apr 21, 2026
Merged

fix: fix nested block reference osnap transforms and insertion points#229
mlightcad merged 1 commit intomainfrom
feat/osnap

Conversation

@mlightcad
Copy link
Copy Markdown
Owner

PR Description

Summary

  • Correct object snap resolution in AcDbBlockReference by propagating cumulative insertion transforms through nested block references.
  • Transform pick/last points into block-local space before querying sub-entity osnap points.
  • Return insertion snap points in world space using block base point + full insertion transform.
  • Add regression tests for transformed pick-point snapping and nested block-reference osnap traversal.

Why

  • Osnap queries against sub-entities in transformed/nested block references could return incorrect coordinates because world/local transforms were not consistently applied.
  • Insertion osnap behavior needed to honor parent insertion context and block origin in nested scenarios.

What Changed

  • Extended subGetOsnapPoints(...) with an optional cumulative insertionMat parameter.
  • Reworked subEntityGetOsnapPoints(...) to:
  • Track visited block references to prevent recursion loops.
  • Build cumulative transforms per nesting level.
  • Query sub-entities in local space and map results back to world space correctly.
  • Added helpers for insertion-point and full insertion-transform computation.
  • Updated base AcDbEntity.subGetOsnapPoints(...) signature/docs to include the optional insertion matrix.
  • Added tests in AcDbBlockReference.spec.ts for:
  • Pick-point transformation before nearest osnap query.
  • End-point osnap resolution through nested block references.

Testing

  • Added/updated unit tests in packages/data-model/__tests__/AcDbBlockReference.spec.ts
  • Not run (drafted from git diff context only)

Risks / Notes

  • Method signature change (subGetOsnapPoints adds optional parameter) is backward-compatible at call sites but may require attention for custom overrides/implementations.
  • Nested traversal now depends on recursion with visited-set guards; edge cases with unusual reference graphs should continue to be monitored.

@mlightcad mlightcad self-assigned this Apr 21, 2026
@mlightcad mlightcad added bug Something isn't working enhancement New feature or request labels Apr 21, 2026
@mlightcad mlightcad merged commit 3534653 into main Apr 21, 2026
2 checks passed
@mlightcad mlightcad deleted the feat/osnap branch April 22, 2026 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant