Skip to main content

Via built-ins

max_via_array​

max_via_array(size: Float, space: Float, bot_enc: (Float, Float), top_enc: (Float, Float), bot: Rect, top: Rect, bot_ext_dir: Int, top_ext_dir: Int, longer: Bool, later_wins_ties: Bool) -> (Int, Int, Float, Float, Float, Float, Int, Float)

Chooses the via array with the most cuts that fits where two shapes overlap.

ArgumentTypeRequirementDescription
sizeFloatRequired, positionalWidth of a square cut.
spaceFloatRequired, positionalSpacing between cuts.
bot_enc(Float, Float)Required, positionalEnclosure of the cuts by the bottom shape, as (short side, long side).
top_enc(Float, Float)Required, positionalEnclosure of the cuts by the top shape, as (short side, long side).
botRectRequired, positionalThe bottom shape.
topRectRequired, positionalThe top shape.
bot_ext_dirIntRequired, positionalDirection of the bottom enclosure's long side: 0 for either, 1 for horizontal, 2 for vertical.
top_ext_dirIntRequired, positionalDirection of the top enclosure's long side, as for bot_ext_dir.
longerBoolRequired, positionalWhen a shape is too narrow for a cut, still place a row of cuts along its length rather than a single cut.
later_wins_tiesBoolRequired, positionalPrefer the later enclosure orientation when two leave the same area outside the shapes.

Returns (Int, Int, Float, Float, Float, Float, Int, Float). Cuts in x and y; the bottom enclosure in x and y; the top enclosure in x and y; the total number of cuts; and the enclosure area that falls outside the shapes.

It tries the four orientations of the two enclosures and keeps the one with the most cuts, then the least enclosure area outside the shapes. The array is centered on the shapes' overlap, or on bot if they do not overlap. Like a comparison, it waits until the solver has fixed both shapes and compares values snapped to the manufacturing grid.

let choice = max_via_array(170., 170., (0., 80.,), (30., 60.,), active, li, 0, 0, false, false);
let cuts = choice.6;