-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Create ZHopOnTravel.py #20489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Create ZHopOnTravel.py #20489
Conversation
New script to customize Z-hops in a gcode file.
Test Results23 928 tests 23 926 ✅ 47s ⏱️ Results for commit 64a1512. ♻️ This comment has been updated with latest results. |
This is a good idea, we actually have some internal discussions to customize the z-hop depending on layer type (e.g. not on top layers), so in the meantime this provides a good solution. |
My original thought was to alter the Z-hops that Cura puts in. If the user was to set the "New Hop Height" to 0.00 over a certain layer range then that would negate the Cura hops for those layers. They could enter layers "13,25,66" and on those specific layers the Z-hop height would be their new value which could be 0.00 as easy as anything else. That idea goes back awhile to a script I called "AlterZHops". Then a feature request here mentioned only hopping across Infill. I can't do that in post process (no model) but I could add hopping when printing the infill. That was easier to do when controlling all the hops, rather than simply altering the existing hops. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I usually don't do these anymore, but as Erwan is busy-ish, I made some review-comments to hopefully help this along.
What is "Resolve Conversation"? I'm going to do some more debugging on this just to make sure there are no "unexpected consequences" or a fat finger caused an inadvertent delete. |
Update per RBurema requested changes.
I haven't been able to break it so I've made a new commit with the changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.
Changed the inserted "G0 F Z" lines to "G1 F Z" so they match the existing Cura syntax.
@HellAholic I made a commit based on feedback on the UM forum. The inserted Z-hop lines used "G0 F Z" and I have changed those to "G1 F Z" to match the Cura syntax. |
Bug fix in line 505 that resulted in the first hop being the wrong Z.
I found a bug in line 505. It resulted in the first Z hop-up being wrong and effected the entire layer. |
I found and fixed a bug that occurred when the "End Layer" was greater than the "Total Layer Count" of the print. |
Bug fix for End_Layer when the entered layer > total layer count. Update ZHopOnTravel.py I'm not sure why git desktop did this. Update ZHopOnTravel.py I'm not sure why git desktop did this. Bug fix Bug fix for End_Layer when the entered layer > total layer count. Bug fix for 'index_list' when using a layer list. It now tracks the Z through the file rather than just the layers of interest.
Commit 7 is a bug fix of an initial design error. |
Removed the Stashed Changes beginning and ends. Update ZHopOnTravel.py Add comments.
@HellAholic has there been any internal discussion regarding including or dropping this? There have been questions on a couple of forums. |
@GregValiant Nothing in terms of dropping. We do have a ticket for this to include it: CURA-12523 |
I've always found Z-hops as a necessary evil, but rarely for an entire file.
This script allows the user to customize Z-hops in the Gcode for either particular layers, or a range of layers. The user can add hops to get over feather edges that might curl up, or infill that the nozzle might strike.
The main options are:
Other options are as you see here:

The script is compatible with:
Cura travel settings:
The setting "Add Z-hops to Infill Only" is limited as the script can only tell when the nozzle is printing infill. If the nozzle is traveling from a "Wall over there" to a "Wall over here" and crosses infill during the travel there would not be a Z-hop added.
The script is NOT compatible with:
Example gcode for an added retraction and Z-hop (Extra prime amt = 0.5mm³ and absolute extrusion, z-hop = 0.50)
I don't know how many people use Cura for pellet feeders, but they can't retract and so this could be used to add Z-hops when required.
Type of change
Test Configuration:
Various versions of Cura
Windows 10 Pro
Checklist: