Created
December 3, 2018 16:25
-
-
Save machinekoder/541e0f3819ea6c516aa6a90f520543c6 to your computer and use it in GitHub Desktop.
Cura PostProcessingPlugin for my 3D printer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ..Script import Script | |
class SimpleTweak(Script): | |
def __init__(self): | |
super().__init__() | |
def getSettingDataString(self): | |
return """{ | |
"name":"SimpleTweak (for Alex Uni-Print-3D)", | |
"key": "SimpleTweak", | |
"metadata":{}, | |
"version": 2, | |
"settings": | |
{ | |
"pause_height": | |
{ | |
"label": "Tweak at height", | |
"description": "At what height should we tweak", | |
"unit": "mm", | |
"type": "float", | |
"default_value": 0.5 | |
} | |
} | |
}""" | |
def execute(self, data): | |
current_z = 0.0 | |
is_prefix = True | |
pause_z = self.getSettingValueByKey("pause_height") | |
for layer in data: | |
lines = layer.split("\n") | |
for line in lines: | |
if not is_prefix or ";LAYER_COUNT:" in line: | |
is_prefix = False | |
else: | |
continue | |
g = self.getValue(line, 'G') | |
if g == 1 or g == 0: | |
current_z = self.getValue(line, 'Z') | |
if current_z is not None: | |
if current_z >= pause_z: | |
custom_gcode = ";TYPE:CUSTOM\n" | |
custom_gcode += "; -- Execute custom GCode at height (%.2f mm) --\n" % pause_z | |
# Insert custom gcode | |
custom_gcode += "M64 P16 ; Turn on the auxillary fan\n" | |
index = data.index(layer) | |
layer = custom_gcode + layer | |
data[index] = layer # Override the data of this layer with the modified data | |
return data | |
break | |
return data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Copy to
<Cura Plugin Folder>/PostProcessingPlugin/scripts
and enable via the menu.