Skip to content

Fix "Print by Object" collisions#453

Open
KuzuriAo wants to merge 1 commit into
Snapmaker:mainfrom
KuzuriAo:patch-1
Open

Fix "Print by Object" collisions#453
KuzuriAo wants to merge 1 commit into
Snapmaker:mainfrom
KuzuriAo:patch-1

Conversation

@KuzuriAo
Copy link
Copy Markdown

@KuzuriAo KuzuriAo commented Jun 6, 2026

Updated Snapmaker U1 0.4 nozzle.j change_filament_gcode and machine_end_gcode to fix the issue of collisions when using "Print by Object"

Description

This PR fixes the Snapmaker U1 collisions that can occur while printing using "Print by Object" with multiple colors or print heads. These collisions happen because the current configuration of the U1 seems to only track the current object's Z height and not the Z height of any other objects on the plate.

This will sometimes cause the print head to collide with previously printed objects on the plate when switching print heads or homing after a print finishes. All changes check that the print_sequence are by object, which improves on the current configuration in machine_end_gcode, that calls the logic regardless.

There is no logic in change_filament_gcode which is why collisions when swapping print heads is possible.

This PR fixes that by updating the following two settings:

change_filament_gcode

The changes to this setting add Z height tracking of all objects and not just the current object. It calculates the height of the tallest object and adds 2mm of clearance and lowers the build plate when switching print heads to avoid collisions. It then moves to the next object and raises the build plate and continues printing.

It also takes into consideration not to lower the plate lower than the maximum print height of the printer (270mm).

The current Snapmaker configuration only moves the build plate 1.5mm from the Z offset of the current object that was being printed. This is what causes the collisions when moving or swapping print heads.

machine_end_gcode

The changes to this setting are the same as change_filament_gcode and are called after the print finishes, before calling PRINT_END, so that the build plate is lowered the height of the tallest object + 2mm. This avoids collisions when homing during PRINT_END.

The current Snapmaker configuration only moves the build plate 1.5mm from the Z offset of the current object that was being printed at the end of the print. This is what causes the homing collisions.

Screenshots & Recordings

Here is the original video of the print head colliding with previously printed objects (the collision happens around 42s in the video):

https://photos.app.goo.gl/GVY4MQPvNVZfsnHH7

Tests

I have created a 3MF with two collision tests which with the current Snapmaker U1 settings and a 3MF with the settings in this PR.

U1 - Collision Test - Orca - Fail.3mf.zip

The only caveat is that in U1 - Collision Test 2, the circled object in front of print head 1 expects that filament/print head will handle that object. You could move it in front of whatever print head that will be handling that color (in this case black), but in this test case I chose print head 1.

U1 - Collision Test 1

This test will cause the print head to collide with the object circled in red when homing after the print:

U1 - Collision Test 1 - Orca

Here is a video of the U1 - Collision Test 1 being run with the current Snapmaker U1 settings, which cause a collision when homing at the end of the print:

https://photos.app.goo.gl/E8vryXHwuVoi7Aha9 (collision around 3:40)

Here is a video of the U1 - Collision Test 1 being run with the updated Snapmaker U1 settings in this PR, which avoids the collision. Notice the build plate moves to avoid collisions:

https://photos.app.goo.gl/YSVVB1MkFNak32of6

U1 - Collision Test 2

This test will cause the print head to collide with the object circled in red when switching print heads during the print:

U1 - Collision Test 2 - Orca

Here is a video of the U1 - Collision Test 2 being run with the current Snapmaker U1 settings, which causes a collision when swapping tool heads:

https://photos.app.goo.gl/TuPk1dou3NsKXyUu7 (collision around 5:40)

Here is a video of the U1 - Collision Test 2 being run with the updated Snapmaker U1 settings in this PR, which avoids the collision. Notice the build plate moves to avoid collisions:

https://photos.app.goo.gl/MiMJb2mreqgNTJkg8

How to create a Snapmaker U1 nozzle profile to test these settings

  1. Edit the current Snapmaker U1 printer profile
  2. Click the Machine G-code tab
  3. Replace the Machine end G-code with the following:
;===== date: 20260605 =====================
; layer [layer_num]
; max_layer_z [max_layer_z]
; print_sequence [print_sequence]

{if print_sequence == "by object"}
{
local move_z = max_print_height;

if max_layer_z < ((max_print_height - z_offset) - 2) then
    move_z = z_offset + min(((max_layer_z - z_offset) + 2), max_print_height);
endif
}

G91
G1 X2 Y2 Z1 F24000
G90
G1 Z{move_z} F600
{endif}

PRINT_END
TIMELAPSE_STOP
  1. Replace the Change filament G-code with:
;===== date: 20260605 =====================
; Change Tool[previous_extruder] -> Tool[next_extruder] (layer [layer_num])
; max_layer_z [max_layer_z]
; max_print_height [max_print_height]
; print_sequence [print_sequence]

{
local move_z = 1.5;
local max_speed_toolchange = 350.0;
local wait_for_extruder_temp = true;
position[2] = position[2] + 2.0;
local speed_toolchange = max_speed_toolchange;

if travel_speed < max_speed_toolchange then
      speed_toolchange = travel_speed;
endif

if print_sequence == "by object" then

    if max_layer_z < ((max_print_height - z_offset) - 2) then
        move_z = z_offset + min(((max_layer_z - z_offset) + 2), max_print_height);
    endif

endif

"G91
G90
G1 Z" + move_z + " F600
G90
";
"G1 F" + (speed_toolchange * 60) + "
";
if wait_for_extruder_temp and not((layer_num < 0) and (next_extruder == initial_tool)) then
      "
";
      "; " + layer_num + "
";
      if layer_num == 0 then
            "M109 S" + first_layer_temperature[next_extruder] + " T" + next_extruder + "
";
      else
            "M109 S" + temperature[next_extruder] + " T" + next_extruder + "
";
      endif
endif
"M400" + "
";
"T" + next_extruder + "
";
if filament_type[next_extruder] == "PVA" then
"SET_VELOCITY_LIMIT ACCEL=3000
";
else
endif
if previous_extruder != next_extruder and initial_extruder != next_extruder then
"SM_PRINT_PREEXTRUDE_FILAMENT INDEX=" + next_extruder + "
";
endif
"G90
";
}
  1. Save the profile with a new name Snapmaker U1 - Print By Object, etc.
  2. Run the two test prints again and no collisions should occur.

Made changes to machine_end_gcode and change_filament_gcode to fix collisions when printing by object.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant