mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 14:37:29 -06:00
Merge branch 'master' into ppscript_pre_secure
This commit is contained in:
commit
7f89c7e740
484 changed files with 98147 additions and 70366 deletions
|
@ -484,15 +484,53 @@ UM.Dialog
|
|||
onClicked: dialog.accept()
|
||||
}
|
||||
|
||||
Cura.SecondaryButton
|
||||
Item
|
||||
{
|
||||
objectName: "postProcessingSaveAreaButton"
|
||||
visible: activeScriptsList.count > 0
|
||||
height: UM.Theme.getSize("action_button").height
|
||||
width: height
|
||||
tooltip: catalog.i18nc("@info:tooltip", "Change active post-processing scripts")
|
||||
onClicked: dialog.show()
|
||||
iconSource: "postprocessing.svg"
|
||||
fixedWidthMode: true
|
||||
|
||||
Cura.SecondaryButton
|
||||
{
|
||||
height: UM.Theme.getSize("action_button").height
|
||||
tooltip:
|
||||
{
|
||||
var tipText = catalog.i18nc("@info:tooltip", "Change active post-processing scripts.");
|
||||
if (activeScriptsList.count > 0)
|
||||
{
|
||||
tipText += "<br><br>" + catalog.i18ncp("@info:tooltip",
|
||||
"The following script is active:",
|
||||
"The following scripts are active:",
|
||||
activeScriptsList.count
|
||||
) + "<ul>";
|
||||
for(var i = 0; i < activeScriptsList.count; i++)
|
||||
{
|
||||
tipText += "<li>" + manager.getScriptLabelByKey(manager.scriptList[i]) + "</li>";
|
||||
}
|
||||
tipText += "</ul>";
|
||||
}
|
||||
return tipText
|
||||
}
|
||||
toolTipContentAlignment: Cura.ToolTip.ContentAlignment.AlignLeft
|
||||
onClicked: dialog.show()
|
||||
iconSource: "postprocessing.svg"
|
||||
fixedWidthMode: false
|
||||
}
|
||||
|
||||
Cura.NotificationIcon
|
||||
{
|
||||
id: activeScriptCountIcon
|
||||
visible: activeScriptsList.count > 0
|
||||
anchors
|
||||
{
|
||||
top: parent.top
|
||||
right: parent.right
|
||||
rightMargin: (-0.5 * width) | 0
|
||||
topMargin: (-0.5 * height) | 0
|
||||
}
|
||||
|
||||
labelText: activeScriptsList.count
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
"name": "Post Processing",
|
||||
"author": "Ultimaker",
|
||||
"version": "2.2.1",
|
||||
"api": "7.0",
|
||||
"api": "7.1",
|
||||
"description": "Extension that allows for user created scripts for post processing",
|
||||
"catalog": "cura"
|
||||
}
|
|
@ -6,14 +6,22 @@
|
|||
#Authors of the 2-1 ColorMix plug-in / script:
|
||||
# Written by John Hryb - john.hryb.4@gmail.com
|
||||
|
||||
##history / change-log:
|
||||
##V1.0.0
|
||||
|
||||
## Uses -
|
||||
## M163 - Set Mix Factor
|
||||
## M164 - Save Mix - saves to T3 as a unique mix
|
||||
|
||||
import re #To perform the search and replace.
|
||||
#history / change-log:
|
||||
#V1.0.0 - Initial
|
||||
#V1.1.0 -
|
||||
# additions:
|
||||
#Object number - To select individual models or all when using "one at a time" print sequence
|
||||
#V1.2.0
|
||||
# fixed layer heights Cura starts at 1 while G-code starts at 0
|
||||
# removed notes
|
||||
# changed Units of measurement to Units
|
||||
#V1.2.1
|
||||
# Fixed mm bug when not in multiples of layer height
|
||||
# Uses -
|
||||
# M163 - Set Mix Factor
|
||||
# M164 - Save Mix - saves to T2 as a unique mix
|
||||
|
||||
import re #To perform the search and replace.
|
||||
from ..Script import Script
|
||||
|
||||
class ColorMix(Script):
|
||||
|
@ -22,20 +30,28 @@ class ColorMix(Script):
|
|||
|
||||
def getSettingDataString(self):
|
||||
return """{
|
||||
"name":"ColorMix 2-1",
|
||||
"name":"ColorMix 2-1 V1.2.1",
|
||||
"key":"ColorMix 2-1",
|
||||
"metadata": {},
|
||||
"version": 2,
|
||||
"settings":
|
||||
{
|
||||
"measurement_units":
|
||||
"units_of_measurement":
|
||||
{
|
||||
"label": "Units of measurement",
|
||||
"label": "Units",
|
||||
"description": "Input value as mm or layer number.",
|
||||
"type": "enum",
|
||||
"options": {"mm":"mm","layer":"Layer"},
|
||||
"default_value": "layer"
|
||||
},
|
||||
"object_number":
|
||||
{
|
||||
"label": "Object Number",
|
||||
"description": "Select model to apply to for print one at a time print sequence. 0 = everything",
|
||||
"type": "int",
|
||||
"default_value": 0,
|
||||
"minimum_value": "0"
|
||||
},
|
||||
"start_height":
|
||||
{
|
||||
"label": "Start Height",
|
||||
|
@ -59,10 +75,10 @@ class ColorMix(Script):
|
|||
"type": "float",
|
||||
"default_value": 0,
|
||||
"minimum_value": "0",
|
||||
"minimum_value_warning": "0.1",
|
||||
"enabled": "c_behavior == 'blend_value'"
|
||||
"minimum_value_warning": "start_height",
|
||||
"enabled": "behavior == 'blend_value'"
|
||||
},
|
||||
"mix_start_ratio":
|
||||
"mix_start":
|
||||
{
|
||||
"label": "Start mix ratio",
|
||||
"description": "First extruder percentage 0-100",
|
||||
|
@ -72,7 +88,7 @@ class ColorMix(Script):
|
|||
"minimum_value_warning": "0",
|
||||
"maximum_value_warning": "100"
|
||||
},
|
||||
"mix_finish_ratio":
|
||||
"mix_finish":
|
||||
{
|
||||
"label": "End mix ratio",
|
||||
"description": "First extruder percentage 0-100 to finish blend",
|
||||
|
@ -81,14 +97,7 @@ class ColorMix(Script):
|
|||
"minimum_value": "0",
|
||||
"minimum_value_warning": "0",
|
||||
"maximum_value_warning": "100",
|
||||
"enabled": "c_behavior == 'blend_value'"
|
||||
},
|
||||
"notes":
|
||||
{
|
||||
"label": "Notes",
|
||||
"description": "A spot to put a note",
|
||||
"type": "str",
|
||||
"default_value": ""
|
||||
"enabled": "behavior == 'blend_value'"
|
||||
}
|
||||
}
|
||||
}"""
|
||||
|
@ -112,52 +121,53 @@ class ColorMix(Script):
|
|||
return default
|
||||
|
||||
def execute(self, data):
|
||||
#get user variables
|
||||
firstHeight = 0.0
|
||||
secondHeight = 0.0
|
||||
firstMix = 0.0
|
||||
SecondMix = 0.0
|
||||
|
||||
firstHeight = self.getSettingValueByKey("start_height")
|
||||
secondHeight = self.getSettingValueByKey("finish_height")
|
||||
firstMix = self.getSettingValueByKey("mix_start_ratio")
|
||||
SecondMix = self.getSettingValueByKey("mix_finish_ratio")
|
||||
|
||||
#locals
|
||||
layer = 0
|
||||
|
||||
firstMix = self.getSettingValueByKey("mix_start")
|
||||
secondMix = self.getSettingValueByKey("mix_finish")
|
||||
modelOfInterest = self.getSettingValueByKey("object_number")
|
||||
|
||||
#get layer height
|
||||
layerHeight = .2
|
||||
layerHeight = 0
|
||||
for active_layer in data:
|
||||
lines = active_layer.split("\n")
|
||||
for line in lines:
|
||||
if ";Layer height: " in line:
|
||||
layerHeight = self.getValue(line, ";Layer height: ", layerHeight)
|
||||
break
|
||||
if layerHeight != 0:
|
||||
break
|
||||
|
||||
#default layerHeight if not found
|
||||
if layerHeight == 0:
|
||||
layerHeight = .2
|
||||
|
||||
#get layers to use
|
||||
startLayer = 0
|
||||
endLayer = 0
|
||||
if self.getSettingValueByKey("measurement_units") == "mm":
|
||||
if firstHeight == 0:
|
||||
startLayer = 0
|
||||
else:
|
||||
startLayer = firstHeight / layerHeight
|
||||
if secondHeight == 0:
|
||||
endLayer = 0
|
||||
else:
|
||||
endLayer = secondHeight / layerHeight
|
||||
else: #layer height
|
||||
startLayer = firstHeight
|
||||
endLayer = secondHeight
|
||||
if self.getSettingValueByKey("units_of_measurement") == "mm":
|
||||
startLayer = round(firstHeight / layerHeight)
|
||||
endLayer = round(secondHeight / layerHeight)
|
||||
else: #layer height shifts down by one for g-code
|
||||
if firstHeight <= 0:
|
||||
firstHeight = 1
|
||||
if secondHeight <= 0:
|
||||
secondHeight = 1
|
||||
startLayer = firstHeight - 1
|
||||
endLayer = secondHeight - 1
|
||||
#see if one-shot
|
||||
if self.getSettingValueByKey("behavior") == "fixed_value":
|
||||
endLayer = startLayer
|
||||
firstExtruderIncrements = 0
|
||||
else: #blend
|
||||
firstExtruderIncrements = (SecondMix - firstMix) / (endLayer - startLayer)
|
||||
firstExtruderIncrements = (secondMix - firstMix) / (endLayer - startLayer)
|
||||
firstExtruderValue = 0
|
||||
index = 0
|
||||
|
||||
#start scanning
|
||||
layer = -1
|
||||
modelNumber = 0
|
||||
for active_layer in data:
|
||||
modified_gcode = ""
|
||||
lineIndex = 0;
|
||||
|
@ -169,22 +179,30 @@ class ColorMix(Script):
|
|||
# find current layer
|
||||
if ";LAYER:" in line:
|
||||
layer = self.getValue(line, ";LAYER:", layer)
|
||||
if (layer >= startLayer) and (layer <= endLayer): #find layers of interest
|
||||
if lines[lineIndex + 4] == "T2": #check if needing to delete old data
|
||||
del lines[(lineIndex + 1):(lineIndex + 5)]
|
||||
firstExtruderValue = int(((layer - startLayer) * firstExtruderIncrements) + firstMix)
|
||||
if firstExtruderValue == 100:
|
||||
modified_gcode += "M163 S0 P1\n"
|
||||
modified_gcode += "M163 S1 P0\n"
|
||||
elif firstExtruderValue == 0:
|
||||
modified_gcode += "M163 S0 P0\n"
|
||||
modified_gcode += "M163 S1 P1\n"
|
||||
else:
|
||||
modified_gcode += "M163 S0 P0.{:02d}\n".format(firstExtruderValue)
|
||||
modified_gcode += "M163 S1 P0.{:02d}\n".format(100 - firstExtruderValue)
|
||||
modified_gcode += "M164 S2\n"
|
||||
modified_gcode += "T2\n"
|
||||
#get model number by layer 0 repeats
|
||||
if layer == 0:
|
||||
modelNumber = modelNumber + 1
|
||||
#search for layers to manipulate
|
||||
if (layer >= startLayer) and (layer <= endLayer):
|
||||
#make sure correct model is selected
|
||||
if (modelOfInterest == 0) or (modelOfInterest == modelNumber):
|
||||
#Delete old data if required
|
||||
if lines[lineIndex + 4] == "T2":
|
||||
del lines[(lineIndex + 1):(lineIndex + 5)]
|
||||
#add mixing commands
|
||||
firstExtruderValue = int(((layer - startLayer) * firstExtruderIncrements) + firstMix)
|
||||
if firstExtruderValue == 100:
|
||||
modified_gcode += "M163 S0 P1\n"
|
||||
modified_gcode += "M163 S1 P0\n"
|
||||
elif firstExtruderValue == 0:
|
||||
modified_gcode += "M163 S0 P0\n"
|
||||
modified_gcode += "M163 S1 P1\n"
|
||||
else:
|
||||
modified_gcode += "M163 S0 P0.{:02d}\n".format(firstExtruderValue)
|
||||
modified_gcode += "M163 S1 P0.{:02d}\n".format(100 - firstExtruderValue)
|
||||
modified_gcode += "M164 S2\n"
|
||||
modified_gcode += "T2\n"
|
||||
lineIndex += 1 #for deleting index
|
||||
data[index] = modified_gcode
|
||||
index += 1
|
||||
return data
|
||||
return data
|
|
@ -72,18 +72,25 @@ class DisplayFilenameAndLayerOnLCD(Script):
|
|||
lcd_text = "M117 Printing " + name + " - Layer "
|
||||
i = self.getSettingValueByKey("startNum")
|
||||
for layer in data:
|
||||
display_text = lcd_text + str(i) + " " + name
|
||||
display_text = lcd_text + str(i)
|
||||
layer_index = data.index(layer)
|
||||
lines = layer.split("\n")
|
||||
for line in lines:
|
||||
if line.startswith(";LAYER_COUNT:"):
|
||||
max_layer = line
|
||||
max_layer = max_layer.split(":")[1]
|
||||
if self.getSettingValueByKey("startNum") == 0:
|
||||
max_layer = str(int(max_layer) - 1)
|
||||
if line.startswith(";LAYER:"):
|
||||
if self.getSettingValueByKey("maxlayer"):
|
||||
display_text = display_text + " of " + max_layer
|
||||
if not self.getSettingValueByKey("scroll"):
|
||||
display_text = display_text + " " + name
|
||||
else:
|
||||
display_text = display_text + "!"
|
||||
if not self.getSettingValueByKey("scroll"):
|
||||
display_text = display_text + " " + name + "!"
|
||||
else:
|
||||
display_text = display_text + "!"
|
||||
line_index = lines.index(line)
|
||||
lines.insert(line_index + 1, display_text)
|
||||
i += 1
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
from ..Script import Script
|
||||
|
||||
|
||||
class TimeLapse(Script):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
@ -75,21 +76,29 @@ class TimeLapse(Script):
|
|||
trigger_command = self.getSettingValueByKey("trigger_command")
|
||||
pause_length = self.getSettingValueByKey("pause_length")
|
||||
gcode_to_append = ";TimeLapse Begin\n"
|
||||
last_x = 0
|
||||
last_y = 0
|
||||
|
||||
if park_print_head:
|
||||
gcode_to_append += self.putValue(G = 1, F = feed_rate, X = x_park, Y = y_park) + " ;Park print head\n"
|
||||
gcode_to_append += self.putValue(M = 400) + " ;Wait for moves to finish\n"
|
||||
gcode_to_append += self.putValue(G=1, F=feed_rate,
|
||||
X=x_park, Y=y_park) + " ;Park print head\n"
|
||||
gcode_to_append += self.putValue(M=400) + " ;Wait for moves to finish\n"
|
||||
gcode_to_append += trigger_command + " ;Snap Photo\n"
|
||||
gcode_to_append += self.putValue(G = 4, P = pause_length) + " ;Wait for camera\n"
|
||||
gcode_to_append += ";TimeLapse End\n"
|
||||
for layer in data:
|
||||
gcode_to_append += self.putValue(G=4, P=pause_length) + " ;Wait for camera\n"
|
||||
|
||||
for idx, layer in enumerate(data):
|
||||
for line in layer.split("\n"):
|
||||
if self.getValue(line, "G") in {0, 1}: # Track X,Y location.
|
||||
last_x = self.getValue(line, "X", last_x)
|
||||
last_y = self.getValue(line, "Y", last_y)
|
||||
# Check that a layer is being printed
|
||||
lines = layer.split("\n")
|
||||
for line in lines:
|
||||
if ";LAYER:" in line:
|
||||
index = data.index(layer)
|
||||
layer += gcode_to_append
|
||||
|
||||
data[index] = layer
|
||||
layer += "G0 X%s Y%s\n" % (last_x, last_y)
|
||||
|
||||
data[idx] = layer
|
||||
break
|
||||
return data
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue