Skip to content

Commit

Permalink
Merge pull request #24 from Knifa/fix-cura-retract
Browse files Browse the repository at this point in the history
Fix retractions for Cura
  • Loading branch information
Knifa authored Aug 21, 2020
2 parents 9d0e452 + a810638 commit 6b1feff
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 14 deletions.
55 changes: 45 additions & 10 deletions src/Intro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const Intro: FunctionComponent = () => {
return (
<div className="Intro">
<Header />

<h2>Hello!</h2>
<p>
This tool can generate sweet <strong>calibration towers</strong> for
Expand All @@ -32,9 +31,7 @@ export const Intro: FunctionComponent = () => {
</p>
<h2>Slicer Setup</h2>
<p>
We need to be able to figure out when a new layer starts and when the
print is over. You'll need to make a couple of changes to your slicer to
get going.
You'll need to make a couple of changes to your slicer to get going.
</p>
<h3>Layer Change</h3>
<p>
Expand All @@ -47,9 +44,8 @@ export const Intro: FunctionComponent = () => {
</p>
<CopyCode>;LAYER:[layer_num]</CopyCode>
<p>
Using <strong>something else</strong>? Something like the line above
needs to appear after every layer change with the new layer number,
starting from zero.
Using <strong>something else</strong>? The line above needs to appear
after every layer change with the new layer number, starting from zero.
</p>
<h3>Print End</h3>
<p>
Expand All @@ -68,9 +64,48 @@ export const Intro: FunctionComponent = () => {
</p>
<CopyCode>;PRINT_END</CopyCode>
<p>
Using <strong>something else</strong>? Something like the line above
needs to appear just as the print is about to end, before any actions
like homing or turning off fans.
Using <strong>something else</strong>? The line above needs to appear
just as the print is about to end, before any actions like homing or
turning off fans.
</p>
<h3>Retraction</h3>
<p>
Using <strong>Cura?</strong>
<ul>
<li>
Uncheck <strong>Relative Extrusion</strong>.
</li>
<li>
Uncheck <strong>Enable Coasting</strong>.
</li>
<li>
Set <strong>Outer Wall Wipe Distance</strong> to 0.
</li>
<li>
Set <strong>Infill Wipe Distance</strong> to 0.
</li>
</ul>
</p>
<p>
Using <strong>PrusaSlicer or Slic3r?</strong>
<ul>
<li>
Enable <strong>Expert</strong> settings mode.
</li>
<li>
Under <em>Printer Settings ➤ General</em>, check{" "}
<strong>use relative E distances</strong>.
</li>
<li>
Under <em>Printer Settings ➤ Extruder 1</em>, uncheck{" "}
<strong>Wipe while retracting</strong>.
</li>
</ul>
</p>
<p>
Using <strong>something else?</strong> You must enable{" "}
<strong>relative extrusion</strong> and disable any{" "}
<strong>coasting</strong> or <strong>wiping</strong> moves.
</p>
</div>
);
Expand Down
1 change: 0 additions & 1 deletion src/gcode/__tests__/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ describe("GCodeProcessor", () => {
);

const lines = processor.process(mockFile);
console.log(lines);
expect(lines).toEqual([
";LAYER:0",
";LAYER:1",
Expand Down
4 changes: 2 additions & 2 deletions src/gcode/transformers/__tests__/retract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe("retract distance", () => {
expect(transformer.onLayer(location)).toBeInstanceOf(TransformerActionNoOp);
});

it("replaces retraction", () => {
it("replaces retraction in either order", () => {
const transformer = new RetractTransformer({
distanceRange: { start: 1, step: 0.25, stop: 5 },
});
Expand All @@ -37,7 +37,7 @@ describe("retract distance", () => {

transformer.onLine("M82", location);
const actionBack = transformer.onLine("G1 E-69.69 F420", location);
const actionForward = transformer.onLine("G1 E69.69 F420", location);
const actionForward = transformer.onLine("G1 F420 E69.69", location);

expect(actionBack).toBeInstanceOf(TransformerActionReplace);
expect((actionBack as TransformerActionReplace).lines).toMatchObject([
Expand Down
2 changes: 1 addition & 1 deletion src/gcode/transformers/retract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class RetractTransformer extends GCodeTransformer {
this.speedRange = opts.speedRange;
this.retractRegex = opts.retractRegex
? opts.retractRegex
: /G(0|1) E(?<distance>(-|\d|\.)+) F(?<speed>(\d|.)+)/;
: /G(0|1)((?=.*\bE(?<distance>(-|\d|\.)+)\b)(?=.*\bF(?<speed>(\d|\.)+)\b))(?!.*(X|Y|Z))/;

this.retractMode = RetractMode.Absolute;

Expand Down

0 comments on commit 6b1feff

Please sign in to comment.