Files
OpenNest/docs/geometry/expand-spacing.md
T
ajandClaude Opus 5.5 4b61d249c0 fix(expand): let every selected part move and stop edges and clamps pinning parts
Expand Spacing kept the first selected part fixed and stalled on full plates.

- A pair of selected parts now shares each push (later part half, earlier
  part the rest, later part any remainder), so no selected part is an anchor.
  Both shares run to the full target, so a part between two short gaps no
  longer ping-pongs while its partners never move.
- Clamps act like the work-area edge: a part may close on the keep-out but
  never enter it, and the clamp gap neither chases the target spacing nor
  counts as the achieved spacing. Before, clamps held their full entry gap
  and a part resting just above one capped the whole search.
- A part flush on an edge can slide along it again. A push that leaned into
  the edge by rounding (parts turned a quarter or half) divided zero room by
  a tiny component and pinned every move.
- Faster search with identical layouts: per-part pair lists, clearances
  remembered at the positions measured, box-proven clamp pairs skipped,
  trial-move gaps measured only up to their threshold, the overlap clipping
  run only for outlines that touch, cross or nest, and ring distances
  measured at offsets without copying outlines. Clearance gains the bounded
  and offset distance used for this.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 08:45:31 -05:00

8.2 KiB

Expand Spacing

Plate > Expand Spacing moves selected parts by translation only. Any selected part may move: a pair of selected parts shares each push (the later part takes half, the earlier part the rest, and the later part whatever its partner has no room for), so the selection opens about its middle and a part on the edge leaves the push to its partner. A selected part pushes away from a nonselected part alone, and nonselected parts remain fixed. The search probes ever wider spacings (doubling, then bisecting between the last spacing that converged and the first that failed) and applies the widest one that converged. The plate retains its own EdgeSpacing floor; the command does not change PartSpacing or EdgeSpacing. To push apart only the parts the overlap check flags, use Fix Spacing.

Repeating patterns

A selection that repeats on a lattice, such as a fill, is stretched as one pattern instead of going through the pair search below. Parts of one drawing at one rotation form a motif group, and every group must sit on the same two lattice translations (one for a single row) to within 2% of a pitch. Each group needs at least two parts, and one group needs at least three for a row or four for a grid, because any two or three points fit some lattice. A single-drawing selection that fits no one lattice also counts when it forms rows along X (or Y): at least two rows of at least two parts, one of at least three, whose steps along the row are whole multiples of one shared pitch. Such rows may stack at any spacing and offset, as when staggered rows are topped by straight ones, and each part then stretches on its own. Cut-offs, overlapping selections and selections that start outside the work area always use the pair search.

The lattice is scaled along X, then along Y, about its center, and each part moves by the displacement of its motif copy's lattice point, so interlocked pairs and other multi-part motifs stay rigid. Along each axis the largest scale is used whose stretched selection fits the work area and keeps every floor: no selected gap closes below the smallest selected gap at entry, a gap to a nonselected part closes no further than that, cut-offs keep their entry gaps and no part enters a clamp keep-out. A part may not pass through a nonselected part, cut-off or clamp on its straight way from the entry layout. The stretched selection is tried centered on where it was, then held at its low edge, then at its high edge. An axis with no room keeps its pitch, so a fill whose rows run edge to edge along X only opens its rows along Y: the row gap stays and the diagonal gap grows. The status bar reads "Spread the repeating pattern" with the smallest gap, or says the pattern has no room to spread.

Every selected/selected and selected/nonselected pair has a clearance floor, measured against material with cutouts subtracted. A pair of parts may close to the spacing being tried but never below its own starting gap when that gap is already smaller, so a wide gap can be spent evenly across a layout and a tight one cannot shrink. A cut-off always keeps its full starting gap. A clamp is a hard edge, like the work-area edge: its keep-out (the zone grown by the clamp clearance) may be approached until a part touches it but never entered, and the gap to it neither has to reach the spacing being tried nor counts toward the reported spacing. A later move may reuse slack opened by an earlier move. Existing overlaps are accepted for attempted separation; a remaining overlap is reported as a violation, not a successful positive gap. Geometry whose material side is unresolved at sub-scale is conservatively reported as a violation when native extents intersect; that negative marker is not a measured penetration depth. An unchanged selected part already outside the work area also yields an edge violation and zero credited spacing. Temporarily blocked pairs are retried after another part moves, while a pass without positive movement stops the relaxation. An individual violation's BlockedByEdge flag is true only when the work-area edge is the first limiting cause; the desktop status currently displays a blocked-pair count, not those individual causes.

A part flush on a work-area edge still slides along that edge and away from it; only a move that would carry it past the edge is clipped. Each side of the work area is given the same 1e-9 allowance the inside-the-work-area check accepts, because a push between two parts can lean into the edge by a rounding-sized amount (parts turned a quarter or half carry rounding in their vertices), and zero room over that tiny component would otherwise pin every move.

Probes run on scratch poses. Each trial translation is clipped against blocking material along its entire straight path, including cutout walls and regenerated open cut-off paths; a remote cut-off does not pin an unrelated move. Entry floors for open cut-offs use nearest points on every native segment, not a program endpoint or a fictional closing chord. Open paths that strictly enter part material stay as violations even at zero target; boundary contact and paths wholly inside holes remain legal. An open path's broad box is not a blocker when its real segments miss the part. Initially overlapping convex line profiles and complete native disks can take a certified direct separating path, including a safe partial move when the plate edge prevents a full exit; unsupported or ambiguous overlap paths stay put and remain reported. Complete native disks use analytic clearance rather than interpreting a shallow arc overlap as a positive polygon gap. For other curved pairs, a polygon gap inside the combined 0.002-unit chord band is uncertain and conservatively reported as a violation rather than proof of clear material. When a part touches a cutout wall and the usual nearest-boundary direction makes no safe progress, the tool tries the opposite direction through the same checks. Tiny clamp keep-outs use tolerance-free material occupancy and a conservative native-bound motion limit when tolerant geometry cannot certify them. Cancellation before application leaves the live layout unchanged; Separate never changes it. A bounded search reports the spacing it found, not an optimum. See directional slides for directional contact behavior.

On a complex layout the search can run for minutes. The desktop command runs it on a worker thread; if it is still running after about 0.3 seconds, a small Expand Spacing window opens with an elapsed time and a Cancel button, and the rest of the application waits behind it. Cancel, Escape and the window's close box all request cancellation. The window then shows "Canceling..." and stays open until the search stops at its next pair check, which took under 0.3 seconds on the real jobs measured. A canceled search moves no part, and the status bar reads "Expand Spacing canceled - no parts were moved". A search that finishes before the cancellation takes effect applies its result normally. While Auto Nest or a fill is still running on the nest, the command refuses with "Finish or cancel the current nesting or fill before Expand Spacing." because those operations can still add parts to the plate the search reads. The command does not save automatically.

Search cost

The pair table is built once per run: every selected part with every other part and clamp, each with its starting gap as its floor, and with each part's own pairs listed so a trial move rechecks only the moved part's pairs. A measured clearance is remembered at the exact two positions it was measured at, so a pair is never measured again until one of its parts moves, including across the probes that each restart from the entry layout. Pairs whose bounding boxes are farther apart than the spacing being checked are skipped without measuring, and a clamp is skipped when the part's box clears its keep-out. A trial move only compares gaps with thresholds, so its gaps are measured just past the threshold and far outline segments are never visited; the overlap kernel's clipping runs only for outlines that touch, cross or nest. None of this changes a result: a skipped measurement is one whose answer is already known, and a measurement stopped short still answers its comparison exactly.