Skip to content

Instantly share code, notes, and snippets.

@ietz
Created November 17, 2021 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ietz/a63f883a944648413a681d8158981b9d to your computer and use it in GitHub Desktop.
Save ietz/a63f883a944648413a681d8158981b9d to your computer and use it in GitHub Desktop.
Cura Remove Bed Reheats Between “One at a Time” Prints
from typing import List, Optional
from ..Script import Script
class RemoveReheat(Script):
def getSettingDataString(self):
return """{
"name": "Remove Reheat",
"key": "RemoveReheat",
"metadata": {},
"version": 2,
"settings": {}
}"""
def execute(self, data: List[str]):
last_temp: Optional[int] = None
awaited_temp = False
result: List[str] = []
for layer_data in data:
layer_output = []
for line in layer_data.splitlines():
m_code = self.getValue(line, key='M', default=None)
s_value = self.getValue(line, key='S', default=None)
if m_code == 140:
# Set Bed Temperature
if last_temp != s_value:
last_temp = s_value
layer_output.append(line)
elif m_code == 190:
# Wait for Bed Temperature
assert s_value == last_temp
if not awaited_temp:
awaited_temp = True
layer_output.append(line)
else:
layer_output.append(line)
layer_output.append('') # to add a new line after the layer
result.append('\n'.join(layer_output))
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment