Width, spacing, and shape checks¶
Distance checks¶
Methods apply to Regions and Edges unless noted. Minimum checks report values
below the threshold; equality passes. Zero thresholds do not by themselves make
touching a violation. All distance methods accept a literal or measured length,
except Region.min_enclosure(), which requires a literal.
| Call | Returns / requirement | What it does and why |
|---|---|---|
a.min_width(minimum) |
EdgePairs; material narrower than minimum |
Finds facing edges where material is thinner than the minimum. Use it to catch narrow lines and necks. |
a.min_space(minimum, between="all") |
EdgePairs; spacing below minimum; scope also "same_polygon", "different_polygons" |
Finds gaps smaller than the minimum. Use between to check gaps within one polygon, between different polygons, or both. |
a.min_separation(b, minimum) |
EdgePairs; separation between operands |
Finds edges of a and b that are too close. Use it for clearance between different materials or layers. |
a.enclosed_edges(b, minimum) |
EdgePairs; boundary margin of a inside b |
Treats a as the inner material and checks its edge margin inside b. Use it when only edge-pair markers are wanted. |
a.min_overlap(b, minimum) |
EdgePairs; overlap below minimum |
Finds places where two materials overlap by less than the minimum distance. Use it to require enough overlap at a joint. |
a.min_notch(minimum) |
EdgePairs; narrow gaps within a polygon |
Checks gaps between parts of the same polygon. Use it for narrow cuts or slots without also checking gaps between separate shapes. |
a.enclosing_edges(b, minimum) |
EdgePairs; enclosing-boundary relation |
Treats a as the enclosing material and b as the inner material. Use it to check the surrounding margin from the outer side. |
a.not_covered_by(b) |
Region; uncovered material; Regions only |
Returns the parts of a that b does not cover. Use it to catch missing cover, including shapes completely separate from b. |
a.min_enclosure(b, minimum) |
Uncovered Region + margin EdgePairs; report both |
Combines missing-cover polygons with edge pairs for a margin that is too small. Use both outputs so disjoint shapes are not missed. |
min_enclosure() returns uncovered polygons and insufficient-margin pairs.
Report both to catch disjoint material.
Shared distance settings¶
Pass keywords directly or use options=DistanceOptions(...). Explicit keywords
override shared options, which override library defaults. projection_min=None
clears a shared bound.
| Keyword | Default / choices | What it does and why |
|---|---|---|
metric |
"euclidean"; also "square", "projection" |
Chooses how distance is measured: straight-line distance, a square search area, or edge projection. Match it to the rule being written. |
angle_limit |
90 degrees |
Ignores edge pairs at or above this angle. Use it to keep the check from treating unsuitable corner angles as width or spacing errors. |
projection_min, projection_max |
None; nonnegative projection bounds |
Limits how much of one edge projects along the other. Use these bounds to include or exclude short facing sections. |
whole_edges |
False |
Reports the full source edges instead of just the failing parts. Use it when later steps need each complete edge. |
shielded |
True |
Ignores pairs blocked by other geometry when true. Use it to check exposed facing edges rather than measuring through intervening material. |
zero_distance |
"touching"; also "never", "collinear_touching", "overlapping", "always" |
Chooses which zero-gap contacts can produce pairs. Use it to state whether touching or overlapping edges count under the check. |
negative |
False; relation restrictions are validated |
Returns the negative output from the first Region in an enclosed-edge check: boundary parts not flagged by the normal check. Use it for inverse enclosure rules; it does not allow a negative minimum. |
nets, net_relation |
Separate arguments on min_space / min_separation; relation "any", "same", "different" |
nets supplies the connection model; net_relation keeps any, same-net, or different-net pairs. Use them when allowed spacing depends on electrical connection. |
between, nets, and net_relation stay outside DistanceOptions.
Legacy Distance is accepted only when its threshold, relation, and scope match
the call; measured thresholds require DistanceOptions.
Shape and area checks¶
| Call | Returns / behavior | What it does and why |
|---|---|---|
a.rectangles(any_angle=False, inverse=False) |
Region; rectangle selection |
Keeps rectangular polygons; inverse=True keeps the rest. Use it to separate rectangles from other shapes before applying a size rule. |
a.squares(any_angle=False, inverse=False) |
Region; square selection |
Keeps square polygons; inverse=True keeps the rest. Use it when a feature must have equal sides rather than merely be rectangular. |
a.rectilinear(inverse=False) |
Region; rectilinear shape selector |
Keeps polygons with only horizontal and vertical sides; inverse=True keeps the rest. Use it to find slanted edges when only right-angle geometry is allowed. |
a.area_check(minimum=..., maximum=...) |
Region; polygons outside inclusive area requirements |
Reports whole polygons whose area is below the minimum or above the maximum. Use it for small islands or oversized shapes; equal limits pass. |
a.opening_area(minimum=..., maximum=...) |
Region; hole-area requirement |
Finds holes whose area is outside the allowed limits. Use it to check openings inside material rather than the material itself. |
a.size_check(allowed=((0.2, 0.2), (0.2, 0.4)), ...) |
Failing polygons; allowed rectangle sizes | Reports polygons that are not one of the allowed rectangle sizes. Use it for contacts with a fixed list of permitted dimensions. |
a.self_overlap(point_touch=None) |
Area covered by two or more stored polygons; duplicates count | Returns positive-area overlap shared by at least two stored shapes. Use raw input to catch duplicate or overlapping drawn objects; touching alone does not count. |
Use shapes="raw" for source-overlap checks. Boundary-only contacts do not
count as self-overlap; positive-area duplicates do. The overlap result is merged,
so triple coverage is reported once. Holes remove covered area.
Size checks and rectangle fitting
size_check() keeps original failing polygons and duplicates. Candidates must
be hole-free, axis-aligned rectangles matching an allowed (width, height) pair.
A matching bounding box alone is insufficient. Dimensions must be positive.
Defaults: rotations=(0, 90), tolerance=0. Only 0, 90, 180, and 270 degrees
are accepted. Each side passes when abs(actual - allowed) <= tolerance.
Tolerance must be smaller than every allowed side.
Dimensions and tolerance are converted separately to the input grid using the deck's rounding policy. Off-grid parameters fail unless rounding was selected. A rounded zero side, or tolerance reaching a side, is an execution error even for empty input. Empty input otherwise has no size violations.