Various bug fixes and improvements - #78
Wasupmacuz wants to merge 4 commits into
Conversation
Fixed the stringing due to travel moves occurring right before a feature change. Fixed the stringing travel moves included in the Hilbert curve polygons.
Moves the `modify` and `gcodeWasModified` booleans to the bottom of the loop, ensuring that if the polygon is discarded, we keep the old geometry. Makes the checks for if GCODE was modified more robust.
Adds a comment explaining how to disable special cooling, 68. Fixes bug where wipe moves cause invalid polygons, 445-455. Increased specificity for faster runtime, 531. Increased readability of conditional, 551.
Corrects some mild spelling and grammatical errors in the script header. Removes trailing space characters from the file (to shrink file size)
Wasupmacuz
left a comment
There was a problem hiding this comment.
Comments describing my changes.
| self.deleteTheseInfills.append(idp) | ||
| break | ||
| if self.parameters.get("PrintDebugVerification"):print(f"Layer {self.layernumber}: Poly{idp} is not close enough to overhang perimeters") | ||
| if self.parameters.get("PrintDebugVerification"):print(f"Layer {self.layernumber}: Poly{idp} is not close enough to overhang perimeters") |
There was a problem hiding this comment.
Changed indentation to print for every failed ohp instead of once every time after the loop.
There was a problem hiding this comment.
Everything below this point is whitespace removal.
| "applyAboveFanSpeedToWholeLayer":True, | ||
| "CoolingSettingDetectionDistance":5, #if the gcode line is closer than this distance to an infill polygon the cooling settings will be applied. Unit:mm | ||
| "specialCoolingZdist":3, #use the special cooling XX mm above the arcs. | ||
| "specialCoolingZdist":3, #use the special cooling XX mm above the arcs. Set to a negative value to disable (not recommended). |
There was a problem hiding this comment.
Tells the user how to disable Hilbert curves. Could possibly stand to be more specific...
| if layer.validpolys: | ||
| modify=True | ||
| gcodeWasModified=True | ||
| numOverhangs += 1 |
There was a problem hiding this comment.
We track the number of overhangs for error printing if arc generation fails. Not required, but could be useful.
| #apply special cooling settings: | ||
| if len(layer.oldpolys)>0: | ||
| modify=True | ||
| gcodeWasModified=True |
There was a problem hiding this comment.
We moved these to the bottom of the loop so that they're only made true if arc generation was a success.
| if self.lines[start - 1].startswith("G1 E") or not "E" in self.lines[start - 1]: # if a travel move came right before this feature: | ||
| start -= 1 | ||
| while not "E" in self.lines[start - 1]: # include this travel move in the feature (excluding the first retraction step, if applicable) | ||
| start -= 1 |
There was a problem hiding this comment.
This is part of the fix for #56. Including the first retraction step also removes the stringing but gets rid of the retraction and de-retraction steps. Therefore, we leave out the first retraction step.
| lines=self.features[idf-1][1] | ||
| for line in reversed(lines): | ||
| if "G1" in line: | ||
| if line.startswith("G1 X"): |
There was a problem hiding this comment.
More clearly expresses our intent and runs marginally faster.
| linesWithStart=linesWithStart+lines | ||
| extPerimeterIsStarted=True | ||
| if (idf==len(self.features)-1 and extPerimeterIsStarted) or (extPerimeterIsStarted and not ("External" in ftype or "Overhang" in ftype)) :#finish the poly if end of featurelist or different feature | ||
| if extPerimeterIsStarted and (idf==len(self.features)-1 or not ("External" in ftype or "Overhang" in ftype)) :#finish the poly if end of featurelist or different feature |
| parts.append(pts) | ||
| pts=[]# update self.features... TODO | ||
| elif "E" in line: #maybe fix error of included travel moves? | ||
| pts=[]# update self.features... TODO |
There was a problem hiding this comment.
The other half of the fix for #56. This one removes the included travel moves in the Hilbert curves by always clearing single points when we travel.
| pts=[]# update self.features... TODO | ||
| elif "E" in line: #maybe fix error of included travel moves? | ||
| pts=[]# update self.features... TODO | ||
| elif "E" in line: #maybe fix error of included travel moves? |
There was a problem hiding this comment.
Do we get rid of this comment now?
jperry004
left a comment
There was a problem hiding this comment.
Works well for me, I've been using the patch for a few days and generated many files with it. Reduces failed generation of certain geometries and reduces stringing. No regressions noticed for me.
|
did you try fixing #59 yet, or did that get patched already? |
@Nathan22211 That must have been related to another issue because yes, this fixes #59. |
|
nice, I'll have to see if it's easy enough to bring the fixed-up code into lousassole and Keilish's orca slicer fork of the script because orca is my main slicer |
You may or may not want to wait for just a few minutes. I'm just about to finalize some changes to the script on my |
|
yeah, I have no clue where to begin here... I've been looking at the function between lousassole's orca script and this and I have no clue what needs to be move into the orca script to bring your changes to work in orca slicer |
|
@Nathan22211 I'll take a crack at it when I get a moment. I was looking at that fork and saw many changes to Nic's code that would make it not so straightforward to combine the two. |
|
yeah I actually can't get any Orca version script I find to work, they don't work for me it seems, also setuptools might need to be added to requirements because distutils was removed in 3.12 |
|
@Nathan22211 Check out the latest patch on my fork. The script is now blazing fast, supports OrcaSlicer AND PrusaSlicer, has the ability to easily support any other slicer, and includes MANY new features. |

This branch of my fork primarily fixes #56 and fixes #77.
specialCoolingZdistto explain how to disable Hilbert curves.