compas_nest.nfp¶
compas_nest.nfp
¶
opennest — the NFP + genetic-algorithm nesting engine (the OpenNest component).
nfp_solve
¶
Handle to an NFP solve running on a background thread.
Returned by :meth:opennest.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/nfp.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 57 58 59 | |
progress()
¶
int : GA generation reached so far.
Source code in compas_nest/nfp.py
27 28 29 | |
fitness()
¶
float : Best fitness so far.
Source code in compas_nest/nfp.py
31 32 33 | |
is_running()
¶
bool : Whether the solve thread is still running.
Source code in compas_nest/nfp.py
35 36 37 | |
cancel()
¶
Ask the solve to stop and return its best layout so far.
Source code in compas_nest/nfp.py
39 40 41 | |
snapshot()
¶
Build a :class:compas_nest.nest_result from the current mid-solve layout.
Source code in compas_nest/nfp.py
50 51 52 53 | |
wait()
¶
Block until the solve finishes and return the final :class:compas_nest.nest_result.
Source code in compas_nest/nfp.py
55 56 57 58 59 | |
opennest
¶
Nest polylines (with holes) into sheets (with holes) using the NFP + genetic-algorithm engine.
Replicates the OpenNest grasshopper component, including carrying attributes
geometry through placement. The solve runs on a background thread while the calling thread prints
live progress (GA generation + fitness); Ctrl-C cancels and returns the best layout so far.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
generations
|
int
|
GA generations to evolve (the component "Iterations"). |
10
|
rotations
|
int
|
Discrete rotation count (360 / n orientations). |
8
|
placement_type
|
int
|
0 = box, 1 = gravity, 2 = squeeze. |
1
|
spacing
|
float
|
Gap between parts. |
0.0
|
seed
|
int
|
RNG seed (-1 = time-based, non-deterministic). |
30
|
mutation_rate
|
int
|
GA mutation rate (applied as 0.01 * rate). |
10
|
population_size
|
int
|
GA population size. |
10
|
use_holes
|
bool
|
Allow nesting into holes. |
True
|
try_all_rotations
|
bool
|
Evaluate every rotation per placement (slower, tighter). Defaults to .. warning::
The upstream NFP engine's |
False
|
exact_nfp
|
bool
|
Full-resolution exact NFP (no gap, slower). |
False
|
mode
|
int
|
0 = faithful (single-thread parity), 1 = default, 2 = turbo (multi-seed). |
1
|
num_seeds
|
int
|
Turbo: parallel independent seeds. |
4
|
use_parallel
|
bool
|
Parallel NFP / population evaluation. |
True
|
curve_tolerance
|
float
|
Simplification tolerance. |
0.3
|
clipper_scale
|
float
|
Clipper integer scale. |
10000000.0
|
time_budget_secs
|
float
|
If > 0, run until elapsed (overrides |
0.0
|
max_sheets
|
int
|
0 = use all provided sheets. |
0
|
verbose
|
bool
|
Print progress to the terminal. |
True
|
Source code in compas_nest/nfp.py
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 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | |
start(geo, sheets)
¶
Launch the solve on a background thread and return immediately.
Use this for live/animated UIs: poll :meth:nfp_solve.snapshot while
:meth:nfp_solve.is_running is true, then call :meth:nfp_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:`nfp_solve`
|
|
Source code in compas_nest/nfp.py
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 219 220 221 222 223 224 225 | |
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/nfp.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | |