-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathFastGyroidInfill.py
49 lines (42 loc) · 1.67 KB
/
FastGyroidInfill.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#
# Cura PostProcessingPlugin
# Author: Jérôme Wiedemann
# Date: November 24 2021
# Modified: November 24 2021 Initial Version
#
# Description: This script modifies the Square Corner Velocity only for the Sparse Infill.
# It will massively accelerate the gyroid infill print speed.
# It only works with Klipper with specific macro configured
#
from ..Script import Script
from UM.Application import Application
GCODE_NORMAL_SQV = "_USE_NORMAL_SQV"
GCODE_INFILL_SQV = "_USE_INFILL_SQV"
class FastGyroidInfill(Script):
def __init__(self):
super().__init__()
def getSettingDataString(self):
return """{
"name": "Faster Gyroid Infill with Klipper",
"key": "FastGyroidInfill",
"metadata": {},
"version": 2,
"settings": {}
}"""
def execute(self, data):
inInfill = False
init = False
for layerIndex, layer in enumerate(data):
if layerIndex == 0 and not init:
layer += "; Ensure Macros are setup in Klipper\n" + GCODE_INFILL_SQV + "\n" + GCODE_NORMAL_SQV + "\n"
init = True
lines = layer.split("\n")
for lineIndex, line in enumerate(lines):
if line.startswith(";TYPE:FILL"):
lines.insert(lineIndex + 1, GCODE_INFILL_SQV)
inInfill = True
elif (line.startswith(";TYPE") or line.startswith(";MESH:") or line.startswith(";LAYER:")) and inInfill:
lines.insert(lineIndex + 1, GCODE_NORMAL_SQV)
inInfill = False
data[layerIndex] = "\n".join(lines)
return data