-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Create PurgeLinesAndUnload.py #20013
base: main
Are you sure you want to change the base?
Conversation
This script has 4 options. Add Purge Lines will draw lines left, right, top, or bottom of the build plate and either fill length of half length. If a print takes up the entire width then the purge lines could be moved to the bottom.
@HellAholic the "Move around to the print start" function is something that came up in a post a while ago. I did account for cases where Cura adds the "Move to prime tower" line at the end of the startup. The script will add an orthogonal move to an edge before the actual move to the prime tower location. |
I'll take a look to see if I can update the code style. Will also try to play around with the current iteration to first get a grasp on how things work and what the output looks like. Might be a slow burner but it's on my todo list 👍 |
Changed 'Execute' procedure per suggestion. Add 'G10' firmware retraction support to 'Adjust Starting E'.
I went with the purge everything approach and it started working, something else I had in the background was interfering with the script. Update: |
Aloha, The slice result preview "should" in theory be simple enough, just have to figure out where I need to poke in the code to make it move. I think reloading the changed gcode is the doable part, but loading back to the original does not sound like a feasible option.
That should also be doable, but it requires some changes to the qml, adding a getter to the python with a pyqtsignal and such, and reading the description in a try/except to handle scripts without a description.
|
I hate unexpected bugs. The expected ones are much better. |
Wow. I have been integrating the "Disallowed Areas" into the code. There wasn't a lot of breakage, but there are more variable names to deal with (and there was already a lot). I'll go through your suggestions and make the changes and then push another commit. |
It might also be an idea to use enum strings, doesn't even need to be linked to the string value it can be an int, but to keep it as close to the current implementation as possible:
makes it easier to work with strings in the comparisons and also reduces the chance of making a typo, also helps with autocomplete xD You can also do the calculations for some values and store them in the self, since it's being passed along to the different functions, that will reduce the number of variables you need to pass with each function call. TLDR: |
Although it's a bit of a rare usecase to reload a gcode and run a post processing script on it, since the information regarding the post processing is already in at the end of header of the gcode file it should be possible to allow for running additional post processing without re-running the same scripts that already were executed on the gcode.
|
In the next week or two I'm going to tear this down and put it back together. It's working, but with the changes I've hacked in for the Prime Tower move and the Disallowed Areas it's turned into spaghetti code. It's pretty bad when even I can't stand it. So take a break. I'll add a new commit when I get done changing it. |
@HellAholic |
Hey Greg, |
Added a "quick purge" option before the actual unload to insure the filament is free to pull back. Made adjustments for "Machine Disallowed Areas". Added some comments. Re-ordered some of the code.
There it is. New and improved. One of the printers I used for the Disallowed Areas was a UM3. It has 6 areas defined and because I used a simple method of determining the "useable space" as a rectangle (rather than the actual shape), it ends up pushing the purge lines towards the print. There aren't many printers with the problem though, so the warning message I added should (hopefully) be sufficient. |
Adding a _v2 of the script to here mostly for safe-keeping, I'm just playing around with the code to see if I can simplify it a bit. Might break things so I'm doing it on a separate version to compare the output at the end. |
@GregValiant I'm a bit confused by the
we want to move to the start location, and if I understand the code, we're already there, but the moves are to right front. |
There are a couple of possible options for where the "Move to Start" will originate. Since it is the last alteration of the gcode, we know where it's going TO, but it might be starting out from the Right Rear if "Add Purge Lines" is selected, or it might be starting from the Prime Tower location if that move is in the Gcode. So we don't really know the start point until other things are decided. The design of the script was mostly done using 5.7 and 5.8. The "Layer start X" and "Layer start Y" seem to be different in 5.9.0. In earlier versions they would also dictate the start of the bed adhesion, but now the bed adhesion start seems to be related to the Z-seam location, or possibly the support Z seam location. I'll take another look at it this evening. I did remove one of the 'If "LF" ' sections because the nozzle was definitely going to be in the left front corner. Maybe the one you noted can be taken out as well. Since I brought up "going to..." I might have to abandon using the Layer Start X and Y in favor of reading the start of the first extrusion of the print. That way if something is affecting the skirt/brim starting point it will be taken into account. |
I got side-tracked by the Start X and Y thing. if self.start_location == "LF": Through the entire design stage I assumed (Hah!) that using the midpoint of the build plate to determine the "quadrant" would be correct. Last night I loaded a small model and put it in the left-front. It would seem that I should have used the model midpoint to determine the "starting quadrant". This is really making my head hurt. It appears that "_get_print_extents" was abandoned-in-place. I don't see it being used anywhere. The only reference is "max_print_size = self._get_build_plate_extents()" and then max_print_size isn't used. Merry Christmas by the way. |
Merry Christmas :) So in theory, the start of the bed adhesion / skirt / support on the first layer should be the closest point to the Start X / Y, but the main issue is the printer definitions are community contributed over 7-ish years and they do not all follow the best practice. So that's why you see references to prime tower on a single extruder printer that cannot even enable prime tower. That's another challenge to standardize the definitions, and a separate subject. For the move to start, if I boil it down until only the core remains we have this part:
I believe you're trying to over engineer things a bit too much. So if end of purge (start_location -> should rename to end_purge_location for clarity xD) and the Start of Layer are the same, we don't do anything. Otherwise regardless of where the print head is, we just simply tell it to go to that location and don't filter the extra X/Y moves, if the print head is at X or Y coordinates already then nothing should happen, if not, then it moves there. Also since you're calculating machine_left/right/top/bottom based on the shape of the build plate and origin, then you can reuse the same format (I double checked, should be fine). So it makes the code much simpler and boiled down. Of course you can add more to it, but if you have a generic base, you can add functions that trim the move based on the first extrusion location. Example of possible extensions:
Let me know if this makes sense. |
Description
This script has 4 options.
Add Purge Lines:
Will draw lines left, right, top, or bottom of the build plate and either full length of half length. If a print takes up the entire width then the purge lines could be moved to the bottom.
Circle Around To Layer Start:
Creates an orthogonal tool path that moves the nozzle around the periphery of the build plate before moving in to the Layer Start location. This keeps strings from dragging across the print location on the build plate.
Adjust Starting E Location:
Cura adds a retraction after the StartUp Gcode. If there is also a retraction within the StartUp Gcode (or when using Add Purge Lines) it causes a double retraction. This option will change that "G1 E-" line to a "G92 E" so the filament location within the nozzle can be adjusted to provide for an exact start to the skirt/brim/raft.
Unload FIlament at Print End:
Adds an unload sequence of G1 E commands to back the filament out of the hot end and out of the extruder. Works well with long-tube bowden printers.
The script supports:
Absolute and Relative extrusion
Rectangular and Elliptic beds
Origin-At-Center whether True or False.
Disallowed Areas
Settings
Type of change
How Has This Been Tested?
I've been using this script for a year.
Test Configuration:
Dell Laptop 16mb of RAM
Windows 10 Pro
Cura versions 4.13.1 and up.
Checklist: