We're 2022 and this bug is still in the latest cura. I made a script that detects the last extruder switch and removes the prime tower from all higher layers. You'll need to switch on relative extrusion (under Special Modes) for it to work. Hope this helps anyone running into this issue.
from ..Script import Script
from UM.Application import Application #To get the current printer's settings.
from UM.Logger import Logger
from typing import List, Tuple
class FixPrimeTower(Script):
def __init__(self) -> None:
super().__init__()
def getSettingDataString(self) -> str:
return """{
"name": "Fix Prime Tower",
"key": "FixPrimeTower",
"metadata": {},
"version": 2,
"settings":
{
}
}"""
def initialize(self) -> None:
super().initialize()
def execute(self, data: List[str]) -> List[str]:
lastTlayer = 0;
for index, layer in reversed(list(enumerate(data))):
lines = layer.split("\n")
hasT = False
for line in lines:
hasT |= line.startswith("T")
if hasT:
lastTlayer = index
break
for index, layer in enumerate(data):
if index <= lastTlayer:
continue;
lines = layer.split("\n")
cnt = 0
nlst = []
inPrimeTower = False
# Scroll each line of instruction for each layer in the G-code
for line in lines:
if not inPrimeTower:
if ";TYPE:PRIME-TOWER" in line:
inPrimeTower = True
nlst.pop()
nlst.pop()
else:
nlst.append(line)
else:
if self.getValue(line, "E") is not None and float(self.getValue(line, "E")) < 0:
inPrimeTower = False
newLayer = ""
for line in nlst:
newLayer += line + "\n"
data[index] = newLayer
return data