Files
OpenNest/docs/geometry/fix-spacing.md
T
ajandClaude Opus 5.5 6867ae2ee4 feat(arrange): let Fix Spacing clear overlaps on packed plates and tilt as a last resort
On a plate packed edge to edge, an overlap left by hand-placing extra
parts could not be fixed: straight push chains ran into the edge and
the relaxation gave up on pairs that share material, which have no
contact normal. The relaxation now pushes such a pair along its
shortest straight way out and lets the rest settle, which cleared a
0.92 sq in overlap on a 38-part plate with every part kept square.

When moves alone still cannot settle, the relaxation runs again as a
rigid one: an off-center push also turns a part, up to 3 degrees, if
its drawing is free to rotate. Moves stay first because a tilt turns
every part the push reaches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 14:45:54 -05:00

3.6 KiB

Fix Spacing

Plate > Fix Spacing clears the pairs the overlap check flags (parts sharing material, and parts closer than the plate's PartSpacing, or than their kerf for common-line partners) with the smallest moves it can find. It moves parts by translation, tilts them slightly only as a last resort (below), and never changes PartSpacing or EdgeSpacing. Unlike Expand Spacing it needs no selection and does not open up the rest of the layout: parts nothing crowds stay where they are. With parts selected, only flagged pairs that include a selected part are fixed. The engine entry point is SpacingFixer.Fix.

How a pair is opened

Pairs are fixed in turn, overlaps first, then the tightest gaps. Gaps are measured on the same native contours the overlap check confirms with (NativeContours), flattened a little coarser for speed; that understates gaps, so a push errs slightly long.

  1. Straight chains. One part of the pair is pushed straight away from the other, in each of 16 directions, by just enough to reach the spacing plus the check's slack. Any part that push brings closer than its floor is pushed the same way by its own shortfall, and so on down the chain, so a fix can ripple through rows already locked in at the spacing. A chain fails when it would push the pair's other part, a common-line member, or a part past the work-area edge or into a clamp. The chain with the least total travel wins.
  2. Relaxation. When no straight chain has room (a plate packed edge to edge), each crowded pair is pushed apart along the normal between its closest points, the shortfall shared between its two parts; a part held by the work-area edge or locked passes its share to the other. Passes repeat until every gap holds, so the moves can differ in direction (one part right and up, its partner down and left). Parts that share material have no contact normal; they are pushed along their shortest straight way out (16 directions) instead. A move under 0.0001 that the layout does not need is undone.
  3. Tilt. When moves alone cannot settle, the relaxation runs again as a rigid one: a push at a contact off a part's center also turns it about that center, by up to SpacingFixer.DefaultMaxTilt (3 degrees) from where it started. Only parts whose drawing is free to rotate tilt (no rotation constraints, or a full turn allowed); the rest only move. A tilted part's lead-ins turn with it. The status bar names how many parts tilted and by how much. Moves are always tried first: tilting turns every part the push reaches.

A pair's floor is its required gap, or its gap before the fix when that is already smaller (another flagged pair never gets worse), less 0.00001 of rounding allowance.

Validation

The plan for every pair is checked once with the overlap check. The result is applied only when it has fewer findings than before and nothing new: no new pair, edge, clamp or unreadable finding. Otherwise the pairs are redone one at a time, each fix kept only when the overlap check rates the plate better. A pair with no room is left as it was and counted in the status bar ("Fixed 3 of 4 flagged pairs ... - 1 flagged pair left").

Cut-offs are not obstacles: they are regenerated around the moved parts. Irregular sheet outlines are honored through the final overlap check, which reports parts outside them.

Desktop

The command runs on a worker behind the same Cancel window as Expand Spacing, and refuses while Auto Nest or a fill is still running on the nest. A canceled run moves nothing. It records one undo step, "Fix Spacing", and does not save.