tests/CATCH2.md says to run the suites with `--order rand --warn
NoAssertions`. On main that fails in fff_print (8 test cases), libslic3r
(15), sla_print (1) and slic3rutils (4), even when each case runs alone.
ctest never passed the flag, so nothing stopped new ones. Most of these
tests have SECTIONs that only set up state, with the assertions after
them, or generated cases that return early for combinations that don't
apply. Catch2 counts assertions per section, so each of those reads as
an empty test.
Where only a value or a short setup changes, use GENERATE or a table and
generate only the combinations that apply. Elsewhere, end each section
with a call to a local check. ctest now passes `--warn NoAssertions`, so
CI fails a case or section that asserts nothing, and tests/AGENTS.md
says so. ctest also passes the CATCH_EXTRA_ARGS cache variable, which
nothing read before, split like a command line, so setting it now takes
effect.
Three tests only wrote a debug mesh or diagram and asserted nothing.
They now check that the Voronoi diagram of the six points is complete,
that hollowing with hfRemoveInsideTriangles removes at least half of the
roughly 400 mm² of the two spheres that lies deeper than the wall, and
that the half cone is closed. The legacy 3MF scenario checked for a
volume map on every plate of a file that has none, so it now also saves
and loads a project with a plate, and its name says so.
`is_all_objects_are_short()` and both "No sparse layers" compacted tower clearance checks now measure an object by its top above the bed, with the raft, Z offset and Z shrinkage included. Before, a short object on a raft still counted as short in a by-object print, and the raft was left out of an object's rise above the compacted tower. These checks and the by-object check now read the new `PrintObject::print_z_max()`. Belt printers use the model's own top.
The comment was written from TimeMachine::prepare_time, which only
accumulates the blocks inside the start G-code's ;TYPE:Custom region, so
it reported the start G-code duration. With a start G-code that just
calls a PRINT_START macro that is close to zero.
The comment is a port of PrusaSlicer 2.6's identical one, which prints
the first layer time, and OrcaSlicer already writes the first layer time
into the .3mf plate metadata as first_layer_time, so G-code and .3mf
disagreed.
Write TimeMachine::first_layer_time instead, for both the normal and the
silent mode line and for every vendor. prepare_time is unchanged: the
preview still shows it as "Prepare time" and the Bambu-only
"; model printing time: ..." line still subtracts it.
The new test slices a cube with a slow start-G-code move and checks that
the comment carries the first layer time, which fails without the change.
The by-object ordering, the too-tall check and the rod check now measure an object by its top above the bed, raft and Z shrinkage included. Before, a raised object was never moved to print last, and a raft could lift objects into the rod without a warning. Belt printers keep the model's own top, as the printable-height check does.
`is_print_object_the_same` now also compares `center_offset()`. Two objects with the same transform can have different offsets, because the offset comes from each object's first instance. Before, the object that took over the other's layers printed shifted.
A plate whose parts use one filament, with only the support on another, was refused for prime tower rules before slicing even when no part needed support and no tower would be printed.
- The layering checks run before slicing only when a tower is certain: the parts use more than one filament, custom G-code changes the tool, or wrapping detection or a smooth timelapse forces one. Otherwise they run in _make_wipe_tower() once the tool changes are known, and only if a tower is generated.
- The "No sparse layers" check before slicing still refuses objects next to the tower. Objects away from it are judged after slicing against the real tower height, and the drag preview draws the height limit plane only on objects the check before slicing refuses.
- The fake tower is reset at each slicing, and the conflict check only uses it when a tower is generated. It was read uninitialized on plates with no tool change.
Fixes#16936
Copies of an object with the same mesh, transform and settings reuse one set of sliced layers. The check ignored height range modifiers, so when only one copy had a range, that range was either dropped from the copy or applied to both.
The check now compares the ranges and their settings too, so objects whose ranges differ slice on their own.
* By object: order rotated copies of an object by their list position
Copies of one object that differ in rotation get one PrintObject each, and
print.objects() lists those groups by transformation. sequential_print_
clearance_valid() keyed the instances by their object's index, which all
copies share, so std::stable_sort kept the transformation grouping and every
second copy on a rotated plate printed out of place.
Key each instance by its position in the model's object and instance lists
instead. No key repeats, so the sort no longer depends on being stable, and
arrange_order is then the list order the G-code export and the sequence
labels already print in.
Fixes#17260.
* Keep the sequential printed-copy tests in step with the list order
The new by-object test rotated a cube centred on its corner, which moved the
footprint by half the cube and closed the 12 mm grid gap under the 2 mm
clearance distance, so validation rejected the plate. Centre the mesh on the
object origin so the rotation turns the footprint in place.
Sequential clearance warned the copy that print.objects() listed first, which
for a plate of rotated copies was the rotated one. Copies now print in object
list order, so print validation warns the first copy in the list; expect that
copy from the preview as well, and drop the now incorrect header comment.
By layer: order As object list copies by their list position
sort_object_instances_by_model_order() keyed every instance on its object's
index when it initialized the order, so all copies of an object tied.
print.objects() does not list the copies in list order either: copies with a
different rotation live in separate PrintObjects, ordered by transformation,
so the ties were broken by that grouping and the copies printed as 2, 4, 6,
1, 3, 5. std::sort reordering the ties made it worse from 17 instances up.
Number the instances by their position in the model's object and instance
lists instead. No order key repeats, so a plain sort is enough; the renumber
after it compacts this print's instances to 1..n. The other intra-layer orders
and the by-object path are unaffected.
The new test rotates every second copy, which fails on every platform before
this change, MSVC included.
Print::m_extruder_filament_info feeds filament grouping, but it was a plain
member with no change detection and no invalidation entry point. Changing only
the device-side AMS material inventory, such as a spool colour, therefore left
a finished slice valid: Print::apply() reported UNCHANGED, the grouping steps
stayed done, and export re-emitted the previous G-code with a stale
filament_map.
Compare the inventory in Print::apply() and invalidate the grouping steps when
it changed:
- set_extruder_filament_info() now only stashes the payload, so apply() can
compare it against the installed one and act on the change under the state
lock.
- The comparison projects both payloads exactly as grouping does: colour, type,
tray name, support flag and filament id per tray. Volatile AMS keys such as
remaining amount, temperatures and filament_changed therefore do not count.
- A changed inventory invalidates psWipeTower and psSkirtBrim, matching what
extruder_ams_count already does, and escalates to APPLY_STATUS_INVALIDATED
only when a step was actually taken back.
- A payload carrying no tray configs at all is treated as "not known yet"
rather than "no filaments", so an AMS reconnect does not invalidate a
finished slice, while clearing the last spool still does.
- The Plater hands the inventory to apply() before applying, so the change
rides the same pass.
Adds comparator tests for the inventory projection and an integration test that
drives process() and apply() over a two-extruder auto-match print.
The by-object "too tall" check used each object's whole footprint to decide whether the rod can hit it. An object that reaches above extruder_clearance_height_to_rod now uses only the Y range of its geometry above the rod. That range is widened by how far the rod reaches past half the radius (extruder_clearance_dist_to_rod) and kept inside the footprint. It is used for both the print order and the too-tall check.
Objects below the rod keep the footprint, so on profiles with the lid below the rod they still get the rod height when they share a Y band with a later object. Objects with a draft shield or a skirt tall enough to reach the rod also keep the footprint. The mesh walk accounts for a raft.
Tests cover fins facing away, facing each other and one of each (print order), raised objects, a draft shield and a tall skirt, the A1 mini Distance to rod, two boxes closer than Distance to rod, a raft, the lid below the rod with and without a raft, and a rotated instance.
Most stock profiles leave Distance to rod at the default 40, which can be less than the printer's real reach. Until those values are measured, a narrow top closer to a neighbor than the real reach can still pass.
The by-object ordering from #14987 broke ties in its ready queue by object_index, which every copy of an object shares. std::sort isn't stable, so on a plate with enough copies it could shuffle them. The copies then printed out of list order, and validation warned that one was printed later than its place in the list to avoid a collision, even though nothing had been held back.
Ties now use each instance's place in the object list, the same order the fallback uses. The test validates 200 copies on a grid and checks there's no reorder warning and the copies keep their list order.
The height ranges are uncompensated print heights. The layer height profile
clipped them against the compensated object height, and the region ranges
were compared with the compensated slices and volume boxes without scaling,
so the range's layer height and its settings ended up at different heights.
The region ranges are now scaled by the Z compensation (not on belt printers,
whose slices are taken in the rotated frame), and the cached regions are only
reused while their ranges are unchanged.
Co-authored-by: SoftFever <softfeverever@gmail.com>
On a belt the brim and the part's outer wall didn't land at the same
height above the belt, so no single endstop or Y offset setting worked
for both (#16705). Brim lines sat at a fixed 0.75 layer height above
the belt. The outer wall where it rests on the belt sits half a layer
up, because the layer is sliced at mid-height, plus half its width
times tan(tilt), because it is inset half a width from the slice edge.
At 45 degrees with 0.32 mm layers and a 0.4 mm wall that is 0.24
against 0.36 mm. Brim lines now sit at the clearance of the outer wall
that rests on the belt in their own band's layer, with XY contour
compensation included. Each line's bead is built from its spacing and
clearance, so it fills its cell however small the clearance gets.
Flow::with_cross_section(), used before, delivers only a quarter of the
area once it falls back to a round bead.
The first-layer test measured from the nozzle, so a wall resting on
the belt never counted as first layer and printed at full speed with
the fan on, and the raised brim would have dropped out too. It now
measures from the belt under the edge of the bead. Travels use the
width of the path they lead to. Brim lines are as wide as the bands
are far apart, not as a bead, so they always count as resting on the
belt.
Speed, flow ratio and acceleration are chosen once per path, and a
wall loop runs from the belt up the part, so the whole loop took
whatever its seam point got. Belt paths are now cut where they cross
the edge of the first-layer band or a step of the slow_down_layers
ramp. Each piece is judged by the heights of all its points. Small-area
flow compensation keeps using the original line lengths.
Non-belt printers are unaffected.
Claude-Session: https://claude.ai/code/session_01Ux9BwdWCA7N8UG7ftaNkWg
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
On a belt printer the slicing height comes from the box of the mesh under
trafo_centered(), which already carries the shrinkage compensation, and
SlicingParameters::create_from_config() scaled it by the Z compensation again.
With a Z shrinkage above 100 % the top of the part was not sliced.
The belt build height check now also compares the compensated height when the
object is too tall, so an object that only fits after the compensation is no
longer refused.
Co-authored-by: SoftFever <softfeverever@gmail.com>
* Test the layer height limits taken for an object, and that they don't keep objects from sharing a prime tower
* Take the layer height limits from an object's own extruder, and don't let them refuse a prime tower
* Test the prime tower check through Print::validate(), and shorten the equal_layering comment
The test runs Print::validate() on two cubes, on filaments 1 and 3 of a printer whose first extruder allows thicker layers than the others. Without this PR, and with only the index fix, it fails with the refusal from #16938. It uses filament 3 because filament 2 read extruder 1's limits before the index fix.
---------
Co-authored-by: raistlin7447 <kris.austin@gmail.com>
Adds the printing_filament_types placeholder. It lists the filament types that are actually printed on the plate, with duplicates removed, in filament order, joined with "_" (for example ABS_PLA). It works in the file name template and in custom G-code. Before slicing, the file name shows the placeholder unfilled, the same way print_time does.
Nothing changes for templates that don't use it.
When the object list order fails the height-to-rod check, look for an order that passes. Each object taller than the rod height prints after every object it overlaps in Y, keeping the list order where possible. A list order that already passes is kept as it is.
When an object has to print later than its place in the object list, a warning names it and links to it. If no order works, the "too tall" error is still reported.
Adds tests in test_print.cpp for both cases.
Renaming a plate now creates an undo snapshot, so a rename is its own undo step and marks the project as modified. All four rename paths use the new `Plater::rename_plate()`.
When a G-code template uses `{plate_name}`, renaming a sliced plate invalidates only the G-code export step, so the next slice only re-exports the G-code. `filename_format` is excluded because the file name is built from the current plate name at export time.
The "Rename Plate" undo snapshot is from #16141.
Co-authored-by: cook0001 <79376116+cook0001@users.noreply.github.com>
A used filament with a flow ratio of 0 sliced in the GUI and wrote
E-92233720368547.758 on every extrusion move: GCode::_extrude multiplied
the flow by the ratio and divided by it again, giving 0 * 0 / 0 = NaN.
The CLI already rejected the value through the config check, but
Print::validate never looked at it.
Print::validate now stops the slice with an error naming the filament
when a used filament's flow ratio is 0 or nil, and _extrude converts the
flow to extrusion length with the bare filament cross-section, so the
ratio is applied once without a divide.
# Description
This PR adds opt-in, height-aware exclusion volumes to OrcaSlicer,
including multi-nozzle handling, object and generated-geometry
validation, final G-code collision checking, and travel rerouting.
It grew from the original object-placement prototype into a
collision-aware slicing pipeline with documented limitations. The
central compatibility decision is that Orca's existing
`bed_exclude_area` keeps its historical meaning, while the new
`bed_exclude_volumes` setting explicitly enables the stronger
collision-aware behavior.
<img width="935" height="707" alt="Travel paths routed around exclusion
volumes"
src="https://github.com/user-attachments/assets/22925e5c-a3b1-4c26-be1a-8a89d9970cb5"
/>
Related issues: #5922, #10579, #10638 and #12774.
## Why this is useful
The existing 2D exclusion area prevents object placement in areas such
as the filament-cutter corner on Bambu printers. It cannot describe low
bed clips, raised tool docks, camera arms, flying-gantry hardware, or
other obstacles that occupy only part of the printer's Z range.
Treating every existing area as a physical motion obstacle would also be
unsafe for compatibility: some printers deliberately move into their
excluded material area. This PR therefore separates the two concepts
rather than changing the meaning of existing profiles.
| Setting | Purpose | Existing motion affected? |
| --- | --- | --- |
| `bed_exclude_area` | Existing bed-fixed material/placement keep-out |
No G-code checking or travel rerouting |
| `bed_exclude_volumes` | Shared 3D collision volumes |
Object/generated-material checks, G-code validation and travel rerouting
|
| `extruder_bed_exclude_volumes` | Per-extruder 3D collision volumes |
Same collision behavior, resolved for the active physical nozzle |
Bed areas and collision volumes are additive. A printer can retain an
existing cutter/material keep-out while adding separate physical
collision volumes. Belt printers retain the existing projection of bed
areas onto the tilted belt surface; collision volumes remain in model
coordinates.
## Configuration and syntax
`bed_exclude_volumes` accepts one or more polygonal prisms:
```text
XxY,XxY,...
```
defines a full-height collision volume.
```text
REGION|REGION|REGION
```
defines multiple independent volumes.
```text
ZMIN..ZMAX;XxY,XxY,...
```
defines a volume active only across that Z range. Either Z bound may be
omitted:
```text
..10;20x20,40x20,40x40,20x40
30..;20x20,40x20,40x40,20x40
```
For example:
```text
20x0,45x0,45x18,20x18|8..22;115x20,145x20,145x48,115x48
```
defines one full-height volume and one volume active from Z=8 mm to Z=22
mm. Z ranges are validated and clamped against the configured printable
height, and decimal parsing is locale-independent.
The CLI exposes the same distinction:
```text
--bed-exclude-area
--bed-exclude-volumes
```
Existing scripts using `--bed-exclude-area` retain the original polygon
format and behavior.
## Backward compatibility and migration
- Existing profiles and projects using only `bed_exclude_area` keep its
material/placement keep-out meaning; they do not implicitly enable
collision-volume checking or travel rerouting.
- Stock printer motion is not checked or rerouted against bed areas.
This is important for machines that deliberately enter an excluded
material area during cutting or loading.
- The new syntax is stored under separate config keys, so an older Orca
build does not try to deserialize a volumetric string as the existing
point-list option.
- In **Printer settings → Basic information → Printable space**,
**Excluded bed area** remains a normal editable field with Orca's
standard reset controls. **Toolhead collision volumes** is a separate
field directly below it. There is no Convert/Copy button and neither
setting clears the other.
- A bed-area polygon can be manually copied into the collision-volume
field to describe a full-height physical obstacle. Pasting volume syntax
into the bed-area field instead prompts for confirmation before adding
it to the appropriate volume definitions. The saved bed area, existing
volumes and selected nozzle mode are preserved; cancelling leaves them
unchanged.
- If a user does not configure the new volume keys, the new G-code
checker, rerouter, support trimming and nozzle-specific brim behavior
remain inactive.
This gives existing profiles a stable compatibility boundary while
allowing users and maintainers to migrate deliberately to full collision
checking over time.
## Multi-nozzle behavior
For multi-nozzle printers, the collision-volume mode selects one of
three behaviours. In individual mode, each extruder's definition is
edited on its own Extruder settings page. These modes apply only to
collision volumes; the excluded bed area stays shared and bed-fixed.
Collision volumes support three modes:
<img width="549" height="441" alt="Exclusion volume behavior selector"
src="https://github.com/user-attachments/assets/6ca8c2e2-d00e-4b32-9b12-bfbff0928966"
/>
### Shared
Every physical nozzle uses the same collision-volume definition.
<img width="2353" height="1633" alt="Shared exclusion volumes"
src="https://github.com/user-attachments/assets/96fe938b-07b4-4cd9-b587-e31f2ebba5f8"
/>
### Toolhead-relative (nozzle offsets)
The shared definition is treated as relative to the toolhead. Orca
derives the other nozzles' collision regions using their configured XY
offset from the reference nozzle. This is useful where the same physical
carriage must avoid an obstacle but its position changes when a
different offset nozzle prints at the same model coordinate.
<img width="1084" height="803" alt="Toolhead-relative exclusion volumes"
src="https://github.com/user-attachments/assets/e0790ee4-68b5-444f-90ac-22a5eba05eec"
/>
### Individual per extruder
Each physical extruder/nozzle has its own independent volume definition.
This supports machines whose valid region differs by tool and cannot be
derived from a simple nozzle offset.
<img width="1123" height="761" alt="Independent exclusion volumes for
three extruders"
src="https://github.com/user-attachments/assets/c6404ceb-9958-4df8-93ed-5ff2ac7dc658"
/>
Object validation resolves logical filament assignments to the physical
nozzle or nozzles that may print the object, including automatic Bambu
mapping. If an object may use several nozzles through painting,
feature-level assignments, modifiers, support or interface material, the
complete object is conservatively checked against every relevant
nozzle's volumes.
## Object validation and 3D preview
Object collision detection uses a cheap XY/Z broad phase followed by an
exact mesh-versus-prism test. The exact test:
- Avoids rejecting an object whose XY shadow overlaps a raised volume
while its real mesh remains clear.
- Detects normal surface crossings.
- Detects a volume completely enclosed inside a solid model.
- Respects object-instance and model-volume transforms.
- Separates the collision decision from optional preview-mesh
generation.
When a collision is found, Orca reports the relevant extruder where
possible and renders the intersecting model surface in red. The bed
preview shows a neutral grey footprint, a thin nozzle-colored ownership
border where appropriate, and a translucent 3D prism when a nearby
object makes the volume relevant. Raised volumes keep their ownership
outline on the bed rather than floating at their starting Z.
<img width="578" height="534" alt="Red model and exclusion-volume
intersection preview"
src="https://github.com/user-attachments/assets/d409f574-1790-48e5-b4a3-703273439954"
/>
Single-nozzle/shared geometry remains visually neutral; nozzle colors
are used when they convey distinct tool ownership.
The default automatic preview limits the translucent 3D geometry to
nearby object height to avoid obscuring the workspace. **View → Show all
collision volumes** displays the complete configured Z ranges, including
on an empty bed. Its default shortcut is **Ctrl+Shift+V**
(**Command+Shift+V** on macOS), and it can be changed in the shortcut
settings. Orca remembers this application-level display preference
independently of printer presets; it does not change collision checks or
slicing.
## Arrange and Fill Bed
Arrange and Fill Bed receive Z-aware, nozzle-aware obstacles, so an
object may occupy a footprint belonging only to another nozzle or pass
below a raised volume when its height permits it.
- Existing objects remain obstacles when Fill Bed creates new copies.
- Convex volume footprints are passed through accurately.
- Orca's current libnest2d path supports convex NFP obstacles only, so
non-convex volumes use a documented conservative bounding box until
convex decomposition is implemented.
- Orca's existing final alignment and normal unplaced-item behavior are
retained.
<img width="1097" height="846" alt="Fill Bed with multiple tools and
exclusion volumes"
src="https://github.com/user-attachments/assets/8c0ee5cf-624b-42a6-b57a-13c73400ac5c"
/>
## Brim and support generation
When collision volumes are enabled, object and support brims are clipped
against the relevant first-layer volume footprints before their final
extrusion paths are generated. Brim ownership is retained so touching
object and support brims cannot be merged and silently reassigned to a
nozzle whose volume they intersect. Established bed-edge and bed-area
brim clipping remains unchanged when collision volumes are not
configured.
<img width="1139" height="770" alt="Object and support brims clipped
around nozzle-specific volumes"
src="https://github.com/user-attachments/assets/2913ff31-53e4-4e43-8b27-1afba7e3bafb"
/>
Normal support and raft polygon categories are trimmed against the
relevant volumes over each support layer's actual vertical slab.
Support-material resolution accounts for explicit support/interface
tools, “current filament” behavior, alternating material layers,
automatic physical-nozzle mapping, support brims, and shared support
geometry.
TreeSupport3D receives active exclusion geometry during branch planning
so its existing avoidance machinery can steer branches around obstacles
rather than merely cutting finished paths.
## Final G-code collision validation
The final emitted G-code is checked as a safety backstop after slicing.
The checker tracks:
- The active physical nozzle and its XY offset.
- Absolute and relative XY/Z motion.
- Travel, extrusion and other parsed motion types.
- Tool selection and physical/nozzle mapping.
- Explicit motion in start, filament-change and tool-change G-code.
- Coordinate resets and common `G28` forms, including bare, spaced,
compact and parameterized axis selections.
Material keep-outs from `bed_exclude_area` are deliberately ignored by
the motion checker. Only explicit collision volumes constrain motion.
If Z is genuinely unknown, the check is conservative across all relevant
heights and the warning identifies that fact and includes the relevant
G-code line. The artificial first segment that the preview draws from
`(0,0)` is not treated as a real machine move.
## Travel rerouting
Generated travel moves are rerouted around active collision volumes when
a valid route exists.
Routing is:
- Aware of the travel's actual Z slab and planned lift/Z-hop.
- Resolved for the active physical nozzle.
- Constrained so any detour vertices added by Orca remain inside the
printable bed.
- Able to accept firmware-established start/end points on or beyond the
nominal bed edge.
- Revalidated before the replacement path is emitted.
The implementation covers ordinary generated travels, the first
generated move after start G-code, and moves following physical or
same-nozzle filament changes. Explicit movement commands in custom
start/tool-change G-code update the tracked position so the next
generated travel begins from the correct point without defeating Orca's
post-toolchange Z restoration.
Obstacle geometry is cached by extruder and active Z-region set, with
bounding-box rejection before expensive polygon work. Clear travels
therefore avoid repeatedly unioning and offsetting the same obstacles.
If no safe route can be found, Orca leaves the original move for the
final checker to report rather than emitting an assumed-safe detour.
Extrusion paths are validated but never rerouted.
<img width="1286" height="706" alt="Travel rerouting from start G-code
across multiple Z-aware volumes"
src="https://github.com/user-attachments/assets/a68cd98f-5576-4f78-af43-697e9f687a9b"
/>
And here is an example of independent nozzle travel rerouting:
<img width="2532" height="876" alt="image"
src="https://github.com/user-attachments/assets/28b0c26e-59d6-42b9-a64f-4c2205c4ea3f"
/>
## Testing and review status
Targeted Catch2 coverage now includes:
- Bed-area/volume parsing, validation, confirmed paste handling,
additive behavior and CLI options.
- Belt-surface projection of bed areas through both static and dynamic
region resolution, including the reported cube positions, with collision
volumes left unprojected.
- Shared, toolhead-relative and individual per-extruder resolution.
- Physical-nozzle and filament mapping.
- Exact object intersection, including fully enclosed prisms and
transformed instances.
- 3MF persistence.
- Arrange behavior for convex and non-convex obstacles.
- Brim bed-boundary and volume clipping regressions.
- Support and interface-material masks across support polygon
categories.
- G-code motion classification, coordinate tracking, homing forms and
tool selection.
- Safe travel rerouting, Z-aware activation, nozzle selection, off-bed
firmware endpoints and failure cases.
The reviewed `929beaee15` revision passed the CI checks, and review
testing confirmed that the unit tests and earlier arrange, tool-change Z
restoration, support, brim and brim-ownership regressions still pass.
Stock-output comparisons covered 12 printers × 3 jobs plus 17 project
files and produced G-code identical to `main` when the new feature was
not configured.
The belt projection correction and its regression coverage are included
in the latest update. Please use the checks below for the current head's
build and test status; earlier successful runs do not substitute for
validation of a new revision.
Review also compared CLI output against `main` across stock printers and
multi-filament projects. The compatibility regressions found during that
review—including stock Bambu cutter motion, preset dirty state,
unintended bed-area brim/support changes, tool-change Z restoration,
stale post-change origins, arrange rejection, router cost, locale
parsing and bed-edge brim clipping—have been addressed.
## Known limitations and follow-up work
The implementation deliberately favors conservative safety. A false
positive or some unused build volume is preferable to emitting a
movement that may collide with the machine. Collision warnings are not
an automatic repair or a guarantee of safe output.
- Skirts and draft shields are not regenerated or detoured around
collision volumes. The final checker can report an intersection, but
producing a valid closed loop around internal obstacles while remaining
inside the bed needs a dedicated solution.
- Extrusion paths are checked but not rerouted.
- Spiral Z-hop's circular XY sweep is generated after the primary travel
route has been planned. That sweep is not currently rerouted; the final
G-code checker can report a collision, but does not repair it.
- Orca cannot infer movement hidden inside an opaque firmware macro. A
deterministic macro endpoint should be exposed with explicit `G90`/`G91`
and `G0`/`G1` motion in Orca's custom G-code so the following travel can
be routed from a known position. Movements inside custom G-code are
checked, but only the generated travel after them is rerouted.
- Negative model parts are not applied to the raw object-intersection
mesh, so geometry removed only by a negative part can produce a
conservative false positive.
- Multi-nozzle object validation applies every relevant nozzle's volume
to the complete object rather than only its visibly painted surface.
- Support shared by several instances uses a conservative union of
relevant plate-space exclusions.
- Support avoidance trims or steers generated geometry but does not
perform structural support re-planning. Support above a raised volume
may resume over a void; native tree-support paths not using
TreeSupport3D are not yet volume-aware.
- Raised-only collision volumes are not yet fully represented in
prime/wipe-tower placement validation; the final G-code checker remains
the safety backstop.
- Existing cross-object support-to-support overlap behavior is outside
this PR.
- “No tool selected” carriage-only exclusions are not represented by
Orca's current backend and remain a possible future extension.
## Origin
This work began with the [Muon3D
M1](https://www.youtube.com/watch?v=jBatFQpTM6g), whose notched glass
bed leaves usable print volume above a low obstruction. Upstreaming the
capability lets other printers describe low clips, raised docks,
toolchanger hardware and per-tool clearance limits without requiring a
permanent fork.
Thank you to everyone who tested the implementation, reviewed the
architecture, identified regressions and helped improve the test
coverage—especially the multi-tool and macOS testers. Further
real-hardware feedback remains welcome, but the current implementation
and compatibility behavior are ready to merge.
Harry Loud
Muon3D
Some calls of the same script set fewer placeholders than the others,
so a placeholder the editor offers could stop the slice with "Variable
does not exist" on one path only:
- layer_change_gcode set max_layer_z after processing the template.
- Belt brim layers ran layer_change_gcode without
most_used_physical_extruder_id or the mass values. Both layer change
paths now share one helper.
- Printers that aren't bed slingers ran time_lapse_gcode with only
layer_num, layer_z and max_layer_z. Both timelapse paths now share
one helper for the snapshot placeholders, which picks the snapshot
position only when the template uses it.
- The Type 1 wipe tower ran filament_start_gcode without layer_num,
layer_z and max_layer_z, and filament_end_gcode without
filament_extruder_id and max_layer_z. filament_extruder_id is the
filament being unloaded, as in the Type 1 filament start G-code and
the end-of-print filament end G-code.
- The first filament start G-code on Bambu Lab printers had no layer_z
or max_layer_z.
The editor looks up a script's placeholder list by its option key, but
the timelapse list was keyed timelapse_gcode while the option is
time_lapse_gcode, so the editor showed no timelapse placeholders. The
list and the name passed to placeholder_parser_process, which the
placeholder validator looks up by, are now both time_lapse_gcode.
previous_extruder and next_extruder hold filament indexes, and
previous_extruder is -1 before any filament is loaded.
filament_extruder_id is the extruder index in filament end G-code at a
tool change outside the Type 1 wipe tower, and machine end G-code gets
the value from the last end-of-print filament end G-code. layer_num is
-1 before the first layer. total_wipe_tower_filament is a length in mm.
Placeholders that GCodeProcessor fills in after the G-code is generated
(print_time_total_sec and the other print_time_* parts,
used_filament_length, and the print statistics such as total_weight)
hold a tag such as @TOTAL_WEIGHT@ while the template is evaluated.
Multiplying one already failed with a type error. Adding a number
joined the tag as text, so {total_weight + 5} printed 123.455 for a
123.45 g print, and a comparison compared the tag as text, so
{if total_weight > 100} was always true. Neither gave an error.
PlaceholderParser::set_deferred() now registers such a value. Printing
it and joining it to text work as before. A calculation, a comparison,
a regex or a condition on it fails with an error that says the value is
known only after the G-code is generated, also after it was copied to a
variable or through regex_replace(). Adding a number or another
deferred value to one is treated as a sum and fails too. Text that
already contains one joins a number as text, like any other string.
filament_change() inside an {if} branch that is not taken now does
nothing. It used to set the current extruder from an uninitialized
value.
The G-code editor lists the Print Statistics placeholders for every
custom G-code field, but total_weight, used_filament, total_cost,
print_time, normal_print_time, silent_print_time,
total_wipe_tower_cost and total_wipe_tower_filament were only defined
for filename_format. Using one in custom G-code, including the File
header G-code, stopped slicing with "Not a variable name".
They are known only once the whole G-code is generated, so they use the
reserved-tag mechanism of print_time_sec and used_filament_length: the
placeholder parser gets a tag such as @TOTAL_WEIGHT@ and
GCodeProcessor::run_post_process() replaces it with the same value
filename_format gets, with numbers written to two decimals. The
per-tag replacement loops are folded into one helper. The running
extruded_* totals are unchanged.
Fixes#15320Fixes#7870
Print::apply() decided the shrinkage compensation from the existing PrintObjects and their regions. On the first apply() they do not exist yet, so the first slice was not scaled. The CLI calls apply() only once, so filament_shrink and filament_shrinkage_compensation_z had no effect there.
The compensation is now decided before the PrintObjects are built, from the filaments the model uses, and stored in Print. When the filaments have different shrinkage values, every filament assigned to a feature, height range, modifier, support, tool change or the wipe tower counts, even if it does not end up printing. If they disagree, compensation stays off with the existing warning.
The build height check in Print::validate() compared object layers that already include the Z shrinkage compensation against printable_height divided by that compensation. That counted the compensation twice, so objects that fit were rejected. The check also left out the raft, so an object whose top plus the raft is above printable_height passed validation.
The check now adds object_print_z_min to the top layer and applies the compensation once. The shrinkage message is shown only when the object fits without the compensation. Belt printers apply the compensation to the raw model height, since their height does not come from the layers.
Guard the layer count and the per-object layer collection against an
object that is left without a layer to print on a belt (the counting
loop stepped before begin() and front() was taken of an empty vector).
Check the belt temperature tower's embossed model before the current
project is replaced, not after. Only invalidate the support step of
objects that own a belt brim when an object is added or removed. The
empty-layers test now counts an extrusion only where material is laid
down along a move. The BeltBrim.cpp SEQUENCING note says exactly which
layers are read, and the machine-frame scale is 1/|sin|.
Remove more code that nothing calls: the kinematics inverse
(to_logical, apply_axis_remap_inverse, to_build_volume and the state
kept for them), the world_coordinates(), is_active() and
belt_brim_areas_by_layer() accessors, the PrintConfig overload of
physical_tilt() and the DynamicPrintConfig overload of
compute_belt_height_and_floor(). Comments in GCode.hpp,
BeltSliceStrategy.hpp/.cpp and PrintObjectSlice.cpp that described the
retired pre-slice remap and plane-evaluator still did; the purge-tower
width tooltip named the wrong switch.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
collect_layers_to_print() drops the belt layers that print nothing (an
object's empty lead-in), but m_layer_count still counted every object
and support layer, so "total layers count", the total_layer_count
placeholder and the M73 progress disagreed with the layer changes in the
file. Count with the same predicate, shared through
belt_object_layer_prints_something(). The by-object overload of
collect_layers_to_print() now drops those layers as well, so both print
sequences write the same layer changes.
Dropping the empty entries per object has one more effect on multi-
filament belt prints: a layer no longer selects a filament that it then
prints nothing with. On belt_project.3mf (two filaments, belt purge
tower) the T commands go from 472 to 106 while the extruded length per
filament is unchanged; each of the removed tool changes was followed by
no extrusion.
The empty-layers test now runs for both print sequences and also checks
"total layers count" against the layer changes.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
dda58b07cd stripped debug instrumentation from TreeSupport3D.cpp with a
script, and that script also deleted the loop in organic_draw_branches()
that trims every branch slice against the collision volume, the bed and,
on a belt, the belt plane. This is the generator every printer uses, not
a belt code path, and it is the one place where raistlin7447's export
fixtures differed from main with belt printing off. Restore the loop as
it was on main, with the belt-floor clip.
The new test prints a cube carrying a 60 mm plate with organic supports
on a flat-bed printer and checks on every support layer that no support
extrusion comes within 0.2 mm of the part's slice. It guards that
invariant; on this fixture the loop's own effect is a sub-millimetre
reshaping of one branch (verified by slicing the fixture with and
without the loop), below the asserted gap, so the test does not by
itself fail without the loop.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Windows headers declare a global Polyline, so the unqualified name in
test_print.cpp is ambiguous there (both Windows builds of belt-printer
fail at tests/fff_print/test_print.cpp:1336), as Polygon was in #16196.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Since the slicing frame of a belt object starts at the belt below its
leading end, its first layers are empty. On a single part they carry
the brim bands; with several parts along the belt the later parts'
empty layers fall between the earlier parts' printing layers and were
written to the G-code as layer changes with no moves at all. The
preview numbers its layers (libvgcode::Layers) from the vertices it is
given and expects consecutive ids, so at the first such gap it stopped
creating layers and folded everything after it into the last one: the
top slider layer held nearly the whole print, the slider jumped every
other layer through the single-colour stretch before a second part on
another filament, and with the belt purge tower the whole print greyed
out while dragging.
Drop the belt layers that print nothing (no object, support or brim
content) in GCode::collect_layers_to_print, and renumber the layers
consecutively over the moves that exist when converting a result for
libvgcode, so a file with empty layers from any source still previews
correctly. The layer slider labels a belt layer with its print Z (the
slicer's layer Z, which increases along the belt) instead of libvgcode's
toolpath height, which on a tilted layer is wherever its last extrusion
ended; the slider assumes that list increases and showed "0 / max" on
alternate layers. The processor reads that print Z from the ";Z:" tag
non-BBL printers write (it only knew "; Z_HEIGHT:"), on belt printers
only, so nothing changes elsewhere. Regression test: two cubes 60 mm apart along the
belt produce no layer without an extrusion and the header's layer count
matches.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The belt object height is estimated from a bounding box swept through
the tilt rotation. raw_bounding_box() has the instance's Z offset
removed, which did not matter while the estimate was the box's rotated
Z extent (a Z shift moves every corner alike), but the frame now starts
at the lowest belt-floor point under the footprint, and a point's
rotated z and the floor under it move in opposite directions under a Z
shift: the offset box under-estimated the height by twice the object's
height above the bed, so the layers stopped at the part's diagonal and
every part came out as a wedge (GUI and CLI alike; the unit tests never
checked the top). Use the box of the mesh in the frame it is sliced in
(trafo_centered(), Z as placed on the bed), and have the leading
overhang test check that the whole part is sliced.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The slicing frame of a belt object started at its lowest vertex, but the
belt under the leading end of an overhang lies below that, by the
overhang's length times the tilt's shear. Every support generator works
in layers at z >= 0, so none of them could reach it: normal supports
stopped at the object's own lowest layer, and the two tree generators
each carried a stack of hacks to extend themselves below it (a post-hoc
copy of the lowest base area in TreeSupport, "virtual belt raft layers"
in TreeSupport3D/TreeModelVolumes), sized from the pre-rotation bbox
and capped at global z = 0, which is only right for the trailing half
of the belt.
Start the frame at the lowest belt-floor point under the footprint
instead, less a 10 mm margin along the belt for the base of a support
column (BeltSliceStrategy::apply_preslice_transforms and
BeltTransformPipeline::compute_belt_height_and_floor agree on it). The
layers between it and the first vertex come out empty, which belt
slicing already tolerates, and the generators need no extension at all:
- normal supports: the generator anchors its layer grid at the frame
origin, so run it in the object frame and shift the global belt Z
offset onto the result afterwards, as organic supports already did.
With the offset on the object layers a top contact at negative z
turned the intermediate-layer count negative and the generator
allocated layers until the kernel killed it (any overhang in the
leading half of the belt). Drop the first-layer flange expansion on a
belt: the first support layer is the leading tip of the support, not
a flange, and inflating it put lines in the air ahead of the belt.
- classic tree: a node now keeps dropping until its whole circle is in
the belt, so the branch tapers to a tip on the belt instead of
stopping, a radius above it, when its centre crosses.
- organic: the belt is no longer a support blocker. A blocker is a
collision, and a branch descending onto one slides off it, down the
tilted belt and ahead of the part; the belt is where branches end,
which the per-layer m_belt_floor clipping already does.
The belt brim is generated after the parallel support step instead of
inside it: belt_brim_obstacles() reads every object's layers and support
layers, which another object's support step rebuilds (and, now, shifts)
at the same time. This is the race behind the Windows arm64 segfault
in "Belt brim of each object precedes its perimeters on its own
filament".
Also: the belt tilt axis moves to Developer mode as its own row (a
shared line is shown by its first option's mode), first_layer_plane
band thickness, belt_support_floor_mode, belt_preslice_global and
gcode_back_transform are retired and presumed on, the gravity arrow is
a plain line along the up direction, and the "Show raw G-code (belt
only)" preview toggle is gone.
Regression test: "Belt supports reach the belt under a leading
overhang" slices a cube with a fin whose underside is parallel to the
layers, 20 mm ahead of the cube and up to 41 mm of slicing Z above the
belt, for normal, organic and classic tree supports, and checks that
the lowest support layer sits on the belt beneath its own lines.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Removed, with the keys added to handle_legacy()'s ignore list so saved
profiles and 3MFs keep loading:
- belt_slice_rotation_global and preslice_remap_global. Both were only
consulted when belt_preslice_global ("Global mesh transforms") was off,
which no profile does; belt_preslice_global is now the single global
mode and is presumed on everywhere the old flags were ORed in
(PrintObjectSlice, BeltBackTransform, BeltGCode, Print::process,
PrintApply). The Belt tilt row is axis + angle only.
- preslice_remap_x/y/z. No profile used the pre-slice axis remap; the belt
tilt axis plus the G-code axis remap cover the machines that exist, and
its implementation only agreed with itself for a plain swap (matrix
columns vs remap_bbox rows). BeltTransformPipeline::build_preslice_remap,
remap_bbox and has_preslice_remap are gone, the forward transform is the
rotation, and the G-code header no longer carries the remap.
- belt_support_z_offset_mode. Saved and invalidated steps, but no support
generator read it.
- first_layer_plane and first_layer_plane_offset, with FirstLayerPlane.cpp.
On every shipped configuration the band is measured from the belt
surface (GCode::belt_height_above_floor) and the evaluator was only
reached for an explicit XY/YZ/XZ choice or a non-zero offset, which
nobody set. first_layer_plane_thickness stays as the band unit,
relabelled "First layer band thickness".
UI: the Machine frame transforms group is five single-option rows (G-code
remap X / Y / Z, Decouple machine-frame tilt, Machine-frame tilt angle;
the angle row is shown only when decoupled) instead of two multi-column
lines, and the remap fields carry full labels.
Also carries the phong.fs struct fix from #16226 so the worktree build
links its shaders.
libslic3r_tests and fff_print_tests pass; clang-tidy diff check clean;
orca_profile_tool.py check clean.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
tests/fff_print/test_print.cpp includes <Windows.h>, so an unqualified Polygon
in the new TreeModelVolumes test is ambiguous with GDI's Polygon() and fails
the Windows x64 and arm64 builds on belt-printer.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Code review items (raistlin7447):
1. PrintObject::slice() zeroes m_belt_min_z, m_belt_global_z_offset and
m_belt_global_xy_correction before slicing. They were only written in belt
mode, so a project switched to a normal printer, or whose tilt axis was set
to None, kept the old offsets and shifted the adaptive infill octree and the
organic support layers by them.
2. TreeModelVolumes shifts the support blockers into the raft-offset index
space; a test now pins the index the blocker lands on.
3. The final-alignment clamp in libnest2d is opt-in (NfpPConfig::clamp_to_bin)
and arrange sets it for belt printers only. Printers with an off-centre
best_object_pos keep their alignment; a flat-bed test pins that.
4. The preview's belt view follows the loaded G-code, not the selected printer:
GCodeProcessor carries the file's belt keys (and, for a belt file, its bed)
into export_config_for_render(), and GCodeViewer enables the belt view from
the header tilt.
5. belt_shift_layer_grid() also shifts the cached belt floor and the global Z
offset, so a support-only or brim-only change after the purge-prism snap
matches a fresh slice.
6. update_print_fff_config() resets raft_layers and draft_shield on a belt
printer instead of only greying out the fields Print::validate() rejects.
7. GCodeWriter takes a first-layer point test instead of the FirstLayerPlane;
GCode installs one that measures from the belt surface, like its
extrusions, so the first-layer travel speed and the second-layer
temperature change no longer depend on the gcode_remap_* convention.
8. belt_brim_clip_leading_edge() is exported and called by both the generator
and the test.
9. Both phong.vs shaders use slope.up_direction for the overhang highlight.
The pre-slice and G-code axis remaps are gated on belt_printer through
BeltTransformPipeline::axis_remap_enabled(), so belt keys left in a profile
cannot change a non-belt print.
Tests requested in the review: belt-only keys at non-default values leave
non-belt G-code unchanged; switching a sliced project from belt to non-belt
(and tilt axis None) matches a fresh slice; a support-only change on a belt
purge print matches a fresh slice; non-belt start G-code moves keep the
first-layer Z in the processor; the belt brim's segment count catches a band
emitted twice.
The belt-to-non-belt test exposed an unrelated gap: invalidate_step(posSlice)
re-invalidated posSupportMaterial but not posSimplifySupportPath, so after
any re-slice the regenerated support paths were exported unsimplified.
posSimplifySupportPath is now in that list.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Remove Unused Project Includes and Forward-Declare Where a Type Is Only Referenced
Generated with include-what-you-use and applied conservatively. Only OrcaSlicer's own headers, the ones under src/ and tests/, are removed or forward-declared; standard-library and third-party includes are left alone. An include is removed only when both the Release and the Debug configuration leave it unused, never from inside a conditional block, and never from a file with platform-specific blocks, which only gain includes. Files whose only use of a header sits behind a feature or debug macro (libvgcode's OpenGL ES and marker code, the ARACHNE/TESTS_EXPORT_SVGS debug output) keep their includes.
clonable_ptr.hpp gains #pragma once; it had no include guard and was only safe while Config.hpp was its sole includer.
* Remove Unused Project Includes From Files With Platform-Specific Code
A Linux include-what-you-use run cannot see the code inside _WIN32, __APPLE__ or __linux__ blocks, so its verdict is only taken where nothing the removed header declares, directly or through what it includes, is named inside those blocks. Removals also have to hold in both the Release and Debug configuration and never touch a line inside a conditional block.
* Restore the libslic3r Precompiled Header and Direct Includes Lost in the Platform Pass
The platform-file pass treated pchheader.hpp as an ordinary header and
emptied it, and left GUI_Preview.hpp and 14 other files relying on
headers they no longer reached directly.
* Restore MainFrame.hpp in ParamsDialog.cpp for the Windows-Only Reparent Call
* Include Headers That Files Reached Through Ones the Cleanup Removed
* Drop Includes Duplicated by the Cleanup or by Main's Own Additions
* Leave PreciseSeam.cpp as Main Has It After the Precise Seam Rework
Brings belt-printer up to main 4b4a261787. Resolutions:
- G-code header (#15897, #15915): main moved the header, config and
thumbnail block later in _do_export; write_belt_header() moves with it,
still after the thumbnails and outside the BTT_TFT gate.
- _extrude: first-layer acceleration keeps the per-path first-layer plane
test with main's cached nozzle index (#16028); main's set_speed out-param
form (#16108) everywhere else.
- GCodeWriter (#16108): the arc-to-polyline fallback for machine mappings
that cannot express G2/G3 now runs in the out-param extrude_arc_to_xy,
which is the overload GCode calls, and appends to the caller's string.
- GCodeProcessorResult: the belt fields join main's forwarding assign.
- Clipper2 (#15969): belt arrange helpers take Slic3r::Point; the tree
support join types lose their ClipperLib qualifier.
- CLI arrange (#15837): belt printers still reserve no wipe tower.
- Wipe tower options (#15841): the two new sparse-layer toggles are hidden
for belt printers like the rest of the tower options.
- Keyboard shortcuts (#15706): main's registry replaces the old key switch;
the belt view toggle is re-registered in the next commit.
- Print::process: the belt purge-plan undo runs before main's SliceStarted
event.
- scripts/filament_id_snapshot.json: deleted on main (a77209af8f).
- Includes and appended tests: union of both sides.
* Ignore Clipper, libpng, mcut and Boost.Polygon Internals in clang-tidy
Each only works through a wrapper or umbrella header: libslic3r/clipper.hpp or clipper_z.hpp configure Clipper before including it, png.h pulls in libpng's config headers, and Boost.Polygon's headers only compile through polygon.hpp or voronoi.hpp.
* Ignore minilzo's Config Headers in clang-tidy
lzoconf.h and lzodefs.h are internal to minilzo.h, which is what the code includes.
* Add Missing Includes Across the Remaining Sources and Tests
Covers src/slic3r/Utils, src/slic3r/plugin, src/slic3r/Config, src/libvgcode, src/dev-utils, src/OrcaSlicer.cpp and tests/, the directories left after src/slic3r/GUI and src/libslic3r. Generated with clang-tidy misc-include-cleaner. libvgcode's own headers are included by relative path as in the rest of that library, and Catch2 and pybind11 with angle brackets as elsewhere in the repo.
* Make the GUI and Test Headers Compile on Their Own
Each now includes, or forward-declares, what it uses instead of relying on what its includers happened to include first. Headers that only compile on one platform, or that nothing built includes, are left alone.
* Keep Windows and nanosvg Setup Ahead of the Added Includes
OrcaSlicer.cpp and several tests set _WIN32_WINNT, WIN32_LEAN_AND_MEAN or NOMINMAX before including Windows.h, and the profile validator defines NANOSVG_IMPLEMENTATION before any libslic3r header. The added includes had landed above those blocks, which broke the Windows build.
* Add the GUI Includes the First Pass Missed
Covers headers that only became editable once they compiled on their own, and wx symbols whose suggested header changed as the clang-tidy ignore list grew after the src/slic3r/GUI pass.
* Keep the Added Test Includes Below the NOMINMAX Guard
test_marchingsquares.cpp and test_texture_displacement.cpp had includes inside #ifndef NOMINMAX, which the tests inherit as defined on Windows from libslic3r, so those were skipped there. .clang-tidy also ignores the MSVC STL and UCRT internals, Boost.Multiprecision's fwd.hpp and CPython's Windows include directory, as in #16068.
The band was a second pass over the finished layer that fought the fan commands
the layer pass had already written (overhang, bridge and resume requests). The
generator now marks where each segment enters and leaves the band and the layer
pass treats the band as the strongest fan request, so there is one place that
decides the fan.