compas_nest.collision¶
compas_nest.collision
¶
opennest_collision — the physics / overlap-relaxation nesting engine.
collision_solve
¶
Handle to a collision solve running on a background thread.
Returned by :meth:opennest_collision.start. Poll :meth:snapshot for the current best layout
(e.g. from a viewer animation callback), check :meth:is_running, and call :meth:wait for the
final result.
Source code in compas_nest/collision.py
12 13 14 15 16 17 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 | |
progress()
¶
int : Relaxation rounds completed so far.
Source code in compas_nest/collision.py
28 29 30 | |
is_running()
¶
bool : Whether the solve thread is still running.
Source code in compas_nest/collision.py
32 33 34 | |
cancel()
¶
Ask the solve to stop at the next round and return its best layout so far.
Source code in compas_nest/collision.py
36 37 38 | |
snapshot()
¶
Build a :class:compas_nest.nest_result from the current mid-solve layout.
Source code in compas_nest/collision.py
47 48 49 50 | |
wait()
¶
Block until the solve finishes and return the final :class:compas_nest.nest_result.
Source code in compas_nest/collision.py
52 53 54 55 56 | |
opennest_collision
¶
Nest polylines (with holes) into sheets (with holes) using the collision/relaxation engine.
Replicates the OpenNest OpenNestCollision Grasshopper component. The solve runs on a background
thread while the calling thread prints live progress (relaxation rounds); Ctrl-C cancels and
returns the best layout found so far.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iterations
|
int
|
Relaxation-round budget (deterministic). ~4000 packs tight on one sheet; ~1 is a rough preview. |
4000
|
num_rotations
|
int
|
Discrete orientations sampled per part (more = tighter, slower). |
3600
|
spacing
|
float
|
Minimum gap kept between parts and from holes. |
0.0
|
seed
|
int
|
Base RNG seed. |
100
|
n_starts
|
int
|
Multi-start: run this many seeds and keep the densest. |
1
|
part_holes_mode
|
int
|
0 = ignore part holes, 1 = nest smaller parts into larger parts' holes. |
1
|
pole_max
|
int
|
Inscribed circles per part for collision tests (more = accurate, fewer = faster). |
16
|
final_compact
|
int
|
0 = off, 1 = bottom-left post-pack slide, 2 = multi-direction. |
2
|
fit_mode
|
int
|
0 = place all parts on fewest sheets, 1 = single sheet, max fill. |
1
|
max_sheets
|
int
|
Cap on sheets used (0 = engine default of 6). |
0
|
time_budget_secs
|
float
|
If > 0, use a wall-clock budget instead of |
0.0
|
simplify_tolerance
|
float
|
Geometry simplification tolerance (<= 0 keeps the lean default). |
0.0
|
verbose
|
bool
|
Print progress to the terminal. |
True
|
Source code in compas_nest/collision.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | |
start(geo, sheets)
¶
Launch the solve on a background thread and return immediately.
Use this for live/animated UIs: poll :meth:collision_solve.snapshot while
:meth:collision_solve.is_running is true, then call :meth:collision_solve.wait.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geo
|
:class:`compas_nest.nest_geo`
|
Parts to nest. |
required |
sheets
|
:class:`compas_nest.nest_sheets`
|
Sheets to nest into. |
required |
Returns:
| Type | Description |
|---|---|
class:`collision_solve`
|
|
Source code in compas_nest/collision.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | |
solve(geo, sheets)
¶
Run the nest, blocking until done (prints progress when verbose).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geo
|
:class:`compas_nest.nest_geo`
|
Parts to nest. |
required |
sheets
|
:class:`compas_nest.nest_sheets`
|
Sheets to nest into. |
required |
Returns:
| Type | Description |
|---|---|
class:`compas_nest.nest_result`
|
|
Source code in compas_nest/collision.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | |