Skip to content

Commit

Permalink
Update MultiExtColorMix.py
Browse files Browse the repository at this point in the history
Update2
  • Loading branch information
GregValiant committed Oct 3, 2023
1 parent be008c6 commit f3a183e
Showing 1 changed file with 103 additions and 0 deletions.
103 changes: 103 additions & 0 deletions plugins/PostProcessingPlugin/scripts/MultiExtColorMix.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def initialize(self) -> None:
ext3_default_str = ""
ext4_default_str = ""
if extruder_count >= 2:
<<<<<<< HEAD
ext1_default_str += "Ext 1 Nozzle Switch Retraction Distance.............. " + str(switch_retraction_list[0]) + "\n"
ext1_default_str += "...Ext 1 Shared Extruder Initial Retraction Amt... " + str(shared_retraction_list[0]) + "\n"
ext2_default_str += "Ext 2 Nozzle Switch Retraction Distance.............. " + str(switch_retraction_list[1]) + "\n"
Expand All @@ -83,6 +84,18 @@ def initialize(self) -> None:
if extruder_count == 4:
ext4_default_str += "Ext 4 Nozzle Switch Retraction Distance.............. " + str(switch_retraction_list[3]) + "\n"
ext4_default_str += "...Ext 4 Shared Extruder Initial Retraction Amt... " + str(shared_retraction_list[3]) + "\n"
=======
ext1_default_str += "Ext 1 Nozzle Switch Retraction Distance = " + str(switch_retraction_list[0]) + "\n"
ext1_default_str += "Ext 1 Shared Extruder Initial Retraction Amount = " + str(shared_retraction_list[0]) + "\n"
ext2_default_str += "Ext 2 Nozzle Switch Retraction Distance = " + str(switch_retraction_list[1]) + "\n"
ext2_default_str += "Ext 2 Shared Extruder Initial Retraction Amount = " + str(shared_retraction_list[1]) + "\n"
if extruder_count >= 3:
ext3_default_str += "Ext 3 Nozzle Switch Retraction Distance = " + str(switch_retraction_list[2]) + "\n"
ext3_default_str += "Ext 3 Shared Extruder Initial Retraction Amount = " + str(shared_retraction_list[2]) + "\n"
if extruder_count == 4:
ext3_default_str += "Ext 4 Nozzle Switch Retraction Distance = " + str(switch_retraction_list[3]) + "\n"
ext3_default_str += "Ext 4 Shared Extruder Initial Retraction Amount = " + str(shared_retraction_list[3]) + "\n"
>>>>>>> parent of f5c873a0fb (Revert "Update MultiExtColorMix.py")

if multi_present == 1:
Message(title = "Multi-Extruder Color Mixer:", text = "You must have a Blending Hot End and 'Extruders Share Heater' and 'Extruders Share Nozzle' must be enabled in the 'Printer Settings' in Cura." + "\n" + "The 'Printer Settings / Shared Nozzle Initial Retraction Amount' will be set to '0.0' for all extruders." + "\n" + "The 'Dual Extrusion / Nozzle Switch Retraction Distance' will be set to '0.0' for all extruders." + "\n" + "Prime Tower is not allowed and will be turned off." + "\n\n" + "Note Your Default Settings:" + "\n" + ext1_default_str + ext2_default_str + ext3_default_str + ext4_default_str).show()
Expand Down Expand Up @@ -146,8 +159,14 @@ def getSettingDataString(self):
"type": "int",
"unit": "%",
"default_value": 100,
<<<<<<< HEAD
"minimum_value": 0,
"maximum_value": 100,
=======
"minimum_value": "0",
"minimum_value": "0",
"maximum_value": "100",
>>>>>>> parent of f5c873a0fb (Revert "Update MultiExtColorMix.py")
"enabled": "t0_include"
},
"t0_mix_end":
Expand All @@ -157,8 +176,13 @@ def getSettingDataString(self):
"type": "int",
"unit": "%",
"default_value": 0,
<<<<<<< HEAD
"minimum_value": 0,
"maximum_value": 100,
=======
"minimum_value": "0",
"maximum_value": "100",
>>>>>>> parent of f5c873a0fb (Revert "Update MultiExtColorMix.py")
"enabled": "t0_include and mix_style == 'gradient'"
},
"t1_include":
Expand All @@ -176,7 +200,11 @@ def getSettingDataString(self):
"type": "int",
"unit": "%",
"default_value": 0,
<<<<<<< HEAD
"minimum_value": "0",
=======
"minimum_value": "0
>>>>>>> parent of f5c873a0fb (Revert "Update MultiExtColorMix.py")
"maximum_value": "100",
"enabled": "t1_include"
},
Expand Down Expand Up @@ -383,6 +411,7 @@ def execute(self, data):

# Calculate the 'Gradient' Indexing Factor for extruders included in the mixing------------
if t0_include:
<<<<<<< HEAD
t0_mix_start = int(self.getSettingValueByKey("t0_mix_start")); t0_mix_end = int(self.getSettingValueByKey("t0_mix_end")); t0_ext_incr = (t0_mix_start - t0_mix_end) / (layer_span - 1)
else:
t0_mix_start = 0; t0_mix_end = 0; t0_ext_incr = 0
Expand All @@ -398,6 +427,39 @@ def execute(self, data):
t3_mix_start = int(self.getSettingValueByKey("t3_mix_start")); t3_mix_end = int(self.getSettingValueByKey("t3_mix_end")); t3_ext_incr = (t3_mix_start - t3_mix_end) / (layer_span - 1)
else:
t3_mix_start = 0; t3_mix_end = 0; t3_ext_incr = 0
=======
t0_mix_start = int(self.getSettingValueByKey("t0_mix_start"))
t0_mix_end = int(self.getSettingValueByKey("t0_mix_end"))
t0_ext_incr = (t0_mix_start - t0_mix_end) / (layer_span - 1)
else:
t0_mix_start = 0
t0_mix_end = 0
t0_ext_incr = 0
if t1_include:
t1_mix_start = int(self.getSettingValueByKey("t1_mix_start"))
t1_mix_end = int(self.getSettingValueByKey("t1_mix_end"))
t1_ext_incr = (t1_mix_start - t1_mix_end) / (layer_span - 1)
else:
t1_mix_start = 0
t1_mix_end = 0
t1_ext_incr = 0
if t2_include:
t2_mix_start = int(self.getSettingValueByKey("t2_mix_start"))
t2_mix_end = int(self.getSettingValueByKey("t2_mix_end"))
t2_ext_incr = (t2_mix_start - t2_mix_end) / (layer_span - 1)
else:
t2_mix_start = 0
t2_mix_end = 0
t2_ext_incr = 0
if t3_include:
t3_mix_start = int(self.getSettingValueByKey("t3_mix_start"))
t3_mix_end = int(self.getSettingValueByKey("t3_mix_end"))
t3_ext_incr = (t3_mix_start - t3_mix_end) / (layer_span - 1)
else:
t3_mix_start = 0
t3_mix_end = 0
t3_ext_incr = 0
>>>>>>> parent of f5c873a0fb (Revert "Update MultiExtColorMix.py")

# Check that the Start Percentages and the End Percentages add up to 100. If not then Exit with a message----
total_start_percent = 0
Expand Down Expand Up @@ -434,6 +496,7 @@ def execute(self, data):
# Put together the Reset String-----------------------------------------------------------
m163_reset = ""
if extruder_count == 2:
<<<<<<< HEAD
m163_reset = "M163 P0.50 S0\nM163 P0.50 S1\n"
if extruder_count == 3:
m163_reset = "M163 P0.33 S0\nM163 P0.34 S1\nM163 P0.33 S2\n"
Expand All @@ -456,6 +519,30 @@ def execute(self, data):
m163_t2 = ""
if t3_include:
m163_t3 = f"\nM163 P{t3_mix_start/100} S3"
=======
m163_reset = "M163 P0.50 S0" + "\nM163 P0.50 S1\n"
if extruder_count == 3:
m163_reset = "M163 P0.33 S0" + "\nM163 P0.34 S1\n" + "M163 P0.33 S2\n"
if extruder_count == 4:
m163_reset = "M163 P0.25 S0" + "\nM163 P0.25 S1\n" + "M163 P0.25 S2\n" + "M163 P0.25 S3\n"
m163_reset += "M164 S" + str(m164_ext_nr) + "\n"

# Put together the Initial Mix String-----------------------------------
if t0_include:
m163_t0 = "\nM163 P" + str(t0_mix_start/100) + " S0"
else:
m163_t0 = ""
if t1_include:
m163_t1 = "\nM163 P" + str(t1_mix_start/100) + " S1"
else:
m163_t1 = ""
if t2_include:
m163_t2 = "\nM163 P" + str(t2_mix_start/100) + " S2"
else:
m163_t2 = ""
if t3_include:
m163_t3 = "\nM163 P" + str(t3_mix_start/100) + " S3"
>>>>>>> parent of f5c873a0fb (Revert "Update MultiExtColorMix.py")
else:
m163_t3 = ""
m164str = m163_t0 + m163_t1 + m163_t2 + m163_t3 + "\nM164 S" + str(m164_ext_nr) + "\nT" + str(m164_ext_nr)
Expand Down Expand Up @@ -685,28 +772,44 @@ def processGradient(self,
t0_mix_start -= t0_ext_incr
if t0_mix_start > 100: t0_mix_start = 100
if t0_mix_start < 0: t0_mix_start = 0
<<<<<<< HEAD
m163_t0 = f"\nM163 P{round(t0_mix_start/100, 2)} S0"
=======
m163_t0 = "\nM163 P" + str(round(t0_mix_start/100, 2)) + " S0"
>>>>>>> parent of f5c873a0fb (Revert "Update MultiExtColorMix.py")
else:
m163_t0 = ""
if t1_include:
t1_mix_start -= t1_ext_incr
if t1_mix_start > 100: t1_mix_start = 100
if t1_mix_start < 0: t1_mix_start = 0
<<<<<<< HEAD
m163_t1 = f"\nM163 P{round(t1_mix_start/100, 2)} S1"
=======
m163_t1 = "\nM163 P" + str(round(t1_mix_start/100, 2)) + " S1"
>>>>>>> parent of f5c873a0fb (Revert "Update MultiExtColorMix.py")
else:
m163_t1 = ""
if t2_include:
t2_mix_start -= t2_ext_incr
if t2_mix_start > 100: t2_mix_start = 100
if t2_mix_start < 0: t2_mix_start = 0
<<<<<<< HEAD
m163_t2 = f"\nM163 P{round(t2_mix_start/100, 2)} S2"
=======
m163_t2 = "\nM163 P" + str(round(t2_mix_start/100, 2)) + " S2"
>>>>>>> parent of f5c873a0fb (Revert "Update MultiExtColorMix.py")
else:
m163_t2 = ""
if t3_include:
t3_mix_start -= t3_ext_incr
if t3_mix_start > 100: t3_mix_start = 100
if t3_mix_start < 0: t3_mix_start = 0
<<<<<<< HEAD
m163_t3 = f"\nM163 P{round(t3_mix_start/100, 2)} S3"
=======
m163_t3 = "\nM163 P" + str(round(t3_mix_start/100, 2)) + " S3"
>>>>>>> parent of f5c873a0fb (Revert "Update MultiExtColorMix.py")
else:
m163_t3 = ""
m164str = m163_t0 + m163_t1 + m163_t2 + m163_t3 + "\nM164 S" + str(m164_ext_nr) + "\nT" + str(m164_ext_nr) + "\n"
Expand Down

0 comments on commit f3a183e

Please sign in to comment.