-
-
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
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.
Test Results23 701 tests 23 699 ✅ 46s ⏱️ Results for commit be0671c. ♻️ This comment has been updated with latest results. |
@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. |
- Remove the travel move -> type probably - Remove the second F in 3 out of 8 wipe moves
Ok, so adding a helper function would generate twice the amount of code since we need 2 coordinates for the first move and 2 for the second one, I could not make it pretty or more understandable than the current format. So instead I made the wipe moves for the rectangular build plates more consistent. I also fixed some indentation bits. |
I think I know how I deleted the 'start_x' 'start_y' lines. I originally added the "border distance" below the start_x and start_y in that INIT section. When I deleted it to go another way I think I inadvertently deleted those two lines as well. It may have been a Senior Moment. Sorry about that. The wipe function was really the only one I figured could be split off per Erwan's comment. Looking at it I figured there wouldn't be much saving (if any). This has turned out to be more work than the Cooling Fan script was. It's only 80 lines shorter as well. |
I pad the setting names with spaces to make it obvious to the user that they are child settings.
When the user looks at it they can tell it belongs to something else. |
I was a checker for a long time in machine design studios. I would give any 'new kids' projects that I had previously checked as references so they would know how I liked things laid out. It saved a lot of rework down the road. |
Could also be "Number of lines pairs" so that the final number would always be even 🙂 So I have a strange way of working, I usually have a skirt but in order to remove it properly, I don't really want it to be used as a prime and I end up manually insert the filament. But maybe I would also do the same with the purge lines because they would not be easy to remove either 😅
Yes sorry, I know I am a bit fanatical about code duplication, I have been traumatized in the past by people copy-pasting the same piece of ~20 lines of code over and over, and sometimes they slightly changed it to fix something, but not in all places 🙂 but I also know how easy it is to make this mistake of changing a line of code, and forgetting (or not knowing) that there is a similar one somewhere else. The purpose is not really to make the file smaller, but to make sure that whoever will changes it in the future is less likely to create mistakes/inconsistencies.
I am indeed 😄 |
My printer came with a light duty 25mm wide putty knife. It's good at removing purge lines and skirts. I ended up putting an override for "Skirt Height" into my printer definition file. I never understood how one person (obviously a fingernail biter) got to have the default skirt height set to "3". When I design these things (all things really) I go for what I call the "Solid Gold Edition". That means all the bells and whistles I can think of. It generally adds flexibility but at the cost of making things complicated. That would have the advantage that users would not damage their fingernail polish when removing the blob as seems to be the case when removing purge lines and skirts. Just sayin'. |
results in:
It's just like adding more purge lines only different. @HellAholic should we do this? |
I have a build plate that is quite soft, so I tried that once and made a scratch in it 😅 Adhesion is very good though, and also removal is very easy, so I do like it, but it is just annoying for prime lines 🙂
Maybe that is just me doing weird things, indeed ! I could also try the prime blob... We do have this feature in the engine btw, but I think it is only for printers that have a firmware implementation of it. In this case we should just make it work on all printers instead. |
Added purge blob option. Required changes in some settings to 'self'. Fixed 'quick_purge_speed' to adjust for 2.85 filament.
Gotta be getting close here. |
Indents for child settings
With the new Prime Blob addition the prime is being performed right after homing, which is right above the centre of the bed on my S1 pro and is the usual print position so I wouldn't want the prime material potentially getting deposited on the build plate in that position,. Would it not be better if the prime took place after the print head had moved to the purge line start position? |
Anything would be better than blobbing into the middle of a print. When you enable the prime blob "Blob Location X" and "Blob Location Y" will now be available. I'll do the commit here in a minute. |
b1e4661
to
f8b424d
Compare
Update PurgeLinesAndUnload.py Added 2 settings so the user can dictate where the prime blob will be. "Blob Location X" and "Blob Location Y". Delete PurgeLinesAndUnload_old.py I'm not sure how I do these things.
b588ad0
to
436e3e8
Compare
This last commit (after three tries) adds two settings so the user can dictate where the prime blob will occur. |
@GregValiant That seems to do the trick in the simulator, Well done for the quick turnaround. I'd done an amateur fix by moving the call to the blob procedure to after the start move in the sections that generate the purge code for the Front & Left Purge lines, which seemed to work, but like you stated this also runs the risk of the purge line starting in the prime blob. When using purge lines on the front of the plate the purge start is X10 Y0 so I thought I'd try with the purge blob at X0 Y0 & see how/if that works |
I looked at simply moving the insertion point but right away I saw the potential interference with the purge lines. The user still has to be careful, but a working combination of settings should quickly become apparent. |
Just thinking about this... I've written it in and it's sitting here. |
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: