compas_nest.pack¶
compas_nest.pack
¶
Pack elements into a simple grid (array) layout — a deterministic alternative to nesting.
Mirrors the OpenNest grasshopper "pack / array" behaviour: each part instance is dropped into a grid
cell sized by its bounding box, wrapping into rows, with gaps. The result is a
:class:compas_nest.nest_result, so it plugs into the same viewer / placed_polylines /
to_json / to_obj as a real nest.
pack(geo, columns=10, gap_x=10.0, gap_y=10.0, max_width=None)
¶
Lay parts out in a simple row-major grid (no nesting).
Each part instance (copies expanded) is placed left to right; the x-advance uses each part's
own width and the row height is the tallest part in that row. Two wrapping modes:
- array (default) — start a new row every
columnsitems. - distance — pass
max_widthand a row wraps once the next part would exceed that width (columnsis ignored). A part wider thanmax_widthstill gets its own row.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geo
|
:class:`compas_nest.nest_geo`
|
The parts to arrange (holes and attributes are carried along). |
required |
columns
|
int
|
Number of cells per row before wrapping (array mode). |
10
|
gap_x
|
float
|
Gaps between cells horizontally and vertically. |
10.0
|
gap_y
|
float
|
Gaps between cells horizontally and vertically. |
10.0
|
max_width
|
float
|
If set, wrap by row width instead of by |
None
|
Returns:
| Type | Description |
|---|---|
class:`compas_nest.nest_result`
|
All instances placed on a single sheet with rotation 0; use |
Source code in compas_nest/pack.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |