-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathstartHeatingAtPercentage.py
More file actions
88 lines (70 loc) · 2.65 KB
/
startHeatingAtPercentage.py
File metadata and controls
88 lines (70 loc) · 2.65 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#------------------------------------------------------------------------------------------------------------------------------------
#
# Cura PostProcessing Script
# Author: Ricardo Ortega
# Date: March 01, 2024
#
# Description: Modify M190 line
#
#
#------------------------------------------------------------------------------------------------------------------------------------
#
# 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.0'
class Section(Enum):
"""Enum for section type."""
NOTHING = 0
SKIRT = 1
INNER_WALL = 2
OUTER_WALL = 3
INFILL = 4
SKIN = 5
SKIN2 = 6
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": 100,
"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}")
OnlyFirst=False
else:
resLines.append(line)
result = "\n".join(resLines)
data[layer_index] = result
return data