Jump to content

raferde

New member
  • Posts

    1
  • Joined

  • Last visited

Personal Information

  • 3D printer
    Other 3D printer

raferde's Achievements

0

Reputation

  1. I have updated the ColorMix 2-1 Post Processing script to mix 3 colors. I have found that to make it work I need to show the Start and End Mix ratios for all of the extruders. The total for all of the extruders start and end ration has to add up to 100%. It works to show all values since setting the first two extruders will default the third to the remaining amount. The problem shows up if you edit either value for the third extruder since changing the value overrides the "value" setting. Is there a way to make a setting show on the screen but be view only? # ColorMix script - 3-1 extruder color mix and blending # This script is specific for the Geeetech A30T dual extruder but should work with other Marlin printers. # It runs with the PostProcessingPlugin which is released under the terms of the AGPLv3 or higher. # This script is licensed under the Creative Commons - Attribution - Share Alike (CC BY-SA) terms #Authors of the ColorMix for A30T plug-in / script: # Written by Jay Holweger - jay.holweger@gmail.com #history / change-log: #V1.0.0 - Initial Copy of ColorMix 2-1 import re #To perform the search and replace. from ..Script import Script class ColorMixA30T(Script😞 def __init__(self😞 super().__init__() def getSettingDataString(self😞 return """{ "name":"ColorMix A30T V1.0.0", "key":"ColorMix A30T", "metadata": {}, "version": 2, "settings": { "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", "description": "Value to start at (mm or layer)", "type": "float", "default_value": 0, "minimum_value": "0" }, "behavior": { "label": "Fixed or blend", "description": "Select Fixed (set new mixture) or Blend mode (dynamic mix)", "type": "enum", "options": {"fixed_value":"Fixed","blend_value":"Blend"}, "default_value": "fixed_value" }, "finish_height": { "label": "Finish Height", "description": "Value to stop at (mm or layer)", "type": "float", "default_value": 0, "minimum_value": "0", "minimum_value_warning": "start_height", "enabled": "behavior == 'blend_value'" }, "mix0_start": { "label": "Extruder 1 Start mix ratio", "description": "First extruder percentage 0-100", "type": "float", "default_value": 100, "minimum_value": "0", "minimum_value_warning": "0", "maximum_value_warning": "100" }, "mix0_finish": { "label": "Extruder 1 End mix ratio", "description": "First extruder percentage 0-100 to finish blend", "type": "float", "default_value": 0, "minimum_value": "0", "minimum_value_warning": "0", "maximum_value_warning": "100", "enabled": "behavior == 'blend_value'" }, "mix1_start": { "label": "Extruder 2 Start mix ratio", "description": "Second extruder percentage 0-100", "type": "float", "default_value": 0, "minimum_value": "0", "minimum_value_warning": "0", "maximum_value_warning": "100" }, "mix1_finish": { "label": "Extruder 2 End mix ratio", "description": "Second extruder percentage 0-100 to finish blend", "type": "float", "default_value": 100, "minimum_value": "0", "minimum_value_warning": "0", "maximum_value_warning": "100", "enabled": "behavior == 'blend_value'" }, "virtual_tool": { "label": "Virtual Tool", "description": "Number of the virtual tool to set", "type": "int", "default_value": 12, "minimum_value": "0", "minimum_value_warning": "0", "maximum_value_warning": "16" }, "dont_touch": { "label": "Do not change Extruder 3", "description": "Do not change the values below this box. Extruder 3 is calculated from the other extruder values", "type": "str", "default_value": "It's calculated for you" }, "mix2_start": { "label": "Extruder 3 Start mix ratio", "description": "Third extruder percentage 0-100", "type": "float", "value": "(100 - mix0_start - mix1_start)", "minimum_value": "0", "minimum_value_warning": "0", "maximum_value_warning": "100" }, "mix2_finish": { "label": "Extruder 3 End mix ratio", "description": "Third extruder percentage 0-100 to finish blend", "type": "float", "value": "(100 - mix0_finish - mix1_finish)", "minimum_value": "0", "minimum_value_warning": "0", "maximum_value_warning": "100", "enabled": "behavior == 'blend_value'" } } }""" def getValue(self, line, key, default = None😞 #replace default getvalue due to comment-reading feature if not key in line or (";" in line and line.find(key) > line.find(";") and not ";ChangeAtZ" in key and not ";LAYER:" in key😞 return default subPart = line[line.find(key) + len(key):] #allows for string lengths larger than 1 if ";ChangeAtZ" in key: m = re.search("^[0-4]", subPart) elif ";LAYER:" in key: m = re.search("^[+-]?[0-9]*", subPart) else: #the minus at the beginning allows for negative values, e.g. for delta printers m = re.search("^[-]?[0-9]*\.?[0-9]*", subPart) if m == None: return default try: return float(m.group(0)) except: return default def execute(self, data😞 firstHeight = self.getSettingValueByKey("start_height") secondHeight = self.getSettingValueByKey("finish_height") firstMix0 = self.getSettingValueByKey("mix0_start") secondMix0 = self.getSettingValueByKey("mix0_finish") firstMix1 = self.getSettingValueByKey("mix1_start") secondMix1 = self.getSettingValueByKey("mix1_finish") firstMix2 = 100 - self.getSettingValueByKey("mix0_start") - self.getSettingValueByKey("mix1_start") secondMix2 = 100 - self.getSettingValueByKey("mix0_finish") - self.getSettingValueByKey("mix1_finish") vTool= self.getSettingValueByKey("virtual_tool") modelOfInterest = self.getSettingValueByKey("object_number") #get layer height 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("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 secondExtruderIncrements = 0 thirdExtruderIncrements = 0 else: #blend firstExtruderIncrements = (secondMix0 - firstMix0) / (endLayer - startLayer) secondExtruderIncrements = (secondMix1 - firstMix1) / (endLayer - startLayer) thirdExtruderIncrements = (secondMix2 - firstMix2) / (endLayer - startLayer) firstExtruderValue = 0 secondExtruderValue = 0 thirdExtruderValue = 0 index = 0 #start scanning layer = -1 modelNumber = 0 for active_layer in data: modified_gcode = "" lineIndex = 0 lines = active_layer.split("\n") for line in lines: #dont leave blanks if line != "": modified_gcode += line + "\n" # find current layer if ";LAYER:" in line: layer = self.getValue(line, ";LAYER:", layer) #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] == "T12": del lines[(lineIndex + 1):(lineIndex + 5)] #add mixing commands firstExtruderValue = int(((layer - startLayer) * firstExtruderIncrements) + firstMix0) secondExtruderValue = int(((layer - startLayer) * secondExtruderIncrements) + firstMix1) thirdExtruderValue = int(((layer - startLayer) * thirdExtruderIncrements) + firstMix2) if firstExtruderValue == 100: modified_gcode += "M163 S0 P1\n" else: modified_gcode += "M163 S0 P0.{:02d}\n".format(firstExtruderValue) if secondExtruderValue == 100: modified_gcode += "M163 S1 P1\n" else: modified_gcode += "M163 S1 P0.{:02d}\n".format(secondExtruderValue) if thirdExtruderValue == 100: modified_gcode += "M163 S2 P1\n" else: modified_gcode += "M163 S2 P0.{:02d}\n".format(100 - firstExtruderValue - secondExtruderValue) modified_gcode += "M164 S{:02d}\n".format(vTool) modified_gcode += "T{:02d}\n".format(vTool) lineIndex += 1 #for deleting index data[index] = modified_gcode index += 1 return data
×
×
  • Create New...