Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create startHeatingAtPercentage.py #19494

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions plugins/PostProcessingPlugin/scripts/startHeatingAtPercentage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#------------------------------------------------------------------------------------------------------------------------------------
#
# Cura PostProcessing Script
# Author: Ricardo Ortega Magaña
# Date: August 06, 2024
#
# Description: Modify M190 line
#
#
#------------------------------------------------------------------------------------------------------------------------------------
#
# Version 1.2 08/06/2024 Continue heating bed after waiting.
# Version 1.1 08/03/2024 Default percentage is now 80%
# Version 1.0 01/03/2024 Change the M190 temperature to a percentage to start heating the nozzle
#
#------------------------------------------------------------------------------------------------------------------------------------

from ..Script import Script
from UM.Logger import Logger
from UM.Application import Application

from enum import Enum

__version__ = '1.2'

class startHeatingAtPercentage(Script):
def __init__(self):
super().__init__()

def getSettingDataString(self):
return """{
"name": "startHeatingAtPercentage",
"key": "startHeatingAtPercentage",
"metadata": {},
"version": 2,
"settings":
{
"bedTempPercentage":
{
"label": "Bed temperature percentage to start heating the nozzle",
"description": "What is the percentage of bed heating to start heating the nozzle.",
"type": "float",
"unit": "%",
"default_value": 80,
"minimum_value": "50",
"maximum_value": "100"
}
}
}"""

def execute(self, data):

bedTempPercentage = float(self.getSettingValueByKey("bedTempPercentage"))
OnlyFirst=True
for layer in data:
layer_index = data.index(layer)
lines = layer.split("\n")
resLines=[]
for line in lines:

if ("M190" in line) and OnlyFirst:
temp=line.split("S")
if(len(temp)==2):
percTemp=int((float(temp[1])*bedTempPercentage)/100)
resLines.append(f"M190 S{percTemp}")
resLines.append(f"M140 S{temp[1]}")
OnlyFirst=False
else:
resLines.append(line)
result = "\n".join(resLines)
data[layer_index] = result

return data
Loading