diff --git a/cura/Settings/ExtruderManager.py b/cura/Settings/ExtruderManager.py index 4d4f66652e..a0db1bbf83 100644 --- a/cura/Settings/ExtruderManager.py +++ b/cura/Settings/ExtruderManager.py @@ -351,8 +351,11 @@ class ExtruderManager(QObject): #The platform adhesion extruder. Not used if using none. if global_stack.getProperty("adhesion_type", "value") != "none": used_extruder_stack_ids.add(self.extruderIds[str(global_stack.getProperty("adhesion_extruder_nr", "value"))]) - - return [container_registry.findContainerStacks(id = stack_id)[0] for stack_id in used_extruder_stack_ids] + try: + return [container_registry.findContainerStacks(id = stack_id)[0] for stack_id in used_extruder_stack_ids] + except IndexError: # One or more of the extruders was not found. + UM.Logger.log("e", "Unable to find one or more of the extruders in %s", used_extruder_stack_ids) + return [] ## Removes the container stack and user profile for the extruders for a specific machine. # diff --git a/plugins/SolidView/SolidView.py b/plugins/SolidView/SolidView.py index 33c21acb08..8277813c92 100644 --- a/plugins/SolidView/SolidView.py +++ b/plugins/SolidView/SolidView.py @@ -86,8 +86,10 @@ class SolidView(View): extruder_id = node.callDecoration("getActiveExtruder") if extruder_id: extruder_index = max(0, self._extruders_model.find("id", extruder_id)) - - material_color = self._extruders_model.getItem(extruder_index)["color"] + try: + material_color = self._extruders_model.getItem(extruder_index)["color"] + except KeyError: + material_color = self._extruders_model.defaultColors[0] if extruder_index != ExtruderManager.getInstance().activeExtruderIndex: # Shade objects that are printed with the non-active extruder 25% darker diff --git a/plugins/VersionUpgrade/VersionUpgrade22to24/VersionUpgrade.py b/plugins/VersionUpgrade/VersionUpgrade22to24/VersionUpgrade.py index 04267f45f1..1dd6a504ee 100644 --- a/plugins/VersionUpgrade/VersionUpgrade22to24/VersionUpgrade.py +++ b/plugins/VersionUpgrade/VersionUpgrade22to24/VersionUpgrade.py @@ -8,6 +8,7 @@ import io from UM import Resources from UM.VersionUpgrade import VersionUpgrade # Superclass of the plugin. +import UM.VersionUpgrade class VersionUpgrade22to24(VersionUpgrade): @@ -48,9 +49,11 @@ class VersionUpgrade22to24(VersionUpgrade): # Change the name of variant and insert empty_variant into the stack. new_container_list = [] for item in container_list: + if not item: # the last item may be an empty string + continue if item == variant_name: - new_container_list.append(config_name) new_container_list.append("empty_variant") + new_container_list.append(config_name) else: new_container_list.append(item) @@ -62,7 +65,7 @@ class VersionUpgrade22to24(VersionUpgrade): config.remove_option("general", "containers") for index in range(len(container_list)): - config.set("containers", index, container_list[index]) + config.set("containers", str(index), container_list[index]) output = io.StringIO() config.write(output) @@ -118,6 +121,26 @@ class VersionUpgrade22to24(VersionUpgrade): config.write(output) return [filename], [output.getvalue()] + def upgradePreferences(self, serialised, filename): + config = configparser.ConfigParser(interpolation = None) + config.read_string(serialised) + + if not config.has_section("general"): + raise UM.VersionUpgrade.FormatException("No \"general\" section.") + + # Make z_seam_x and z_seam_y options visible. In a clean 2.4 they are visible by default. + if config.has_option("general", "visible_settings"): + visible_settings = config.get("general", "visible_settings") + visible_set = set(visible_settings.split(";")) + visible_set.add("z_seam_x") + visible_set.add("z_seam_y") + config.set("general", "visible_settings", ";".join(visible_set)) + config.set("general", "version", value="4") + + output = io.StringIO() + config.write(output) + return [filename], [output.getvalue()] + def getCfgVersion(self, serialised): parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialised) diff --git a/plugins/VersionUpgrade/VersionUpgrade22to24/__init__.py b/plugins/VersionUpgrade/VersionUpgrade22to24/__init__.py index 85d53199e4..e1114922d6 100644 --- a/plugins/VersionUpgrade/VersionUpgrade22to24/__init__.py +++ b/plugins/VersionUpgrade/VersionUpgrade22to24/__init__.py @@ -20,8 +20,10 @@ def getMetaData(): "version_upgrade": { # From To Upgrade function ("machine_instance", 2): ("machine_stack", 3, upgrade.upgradeMachineInstance), - ("extruder_train", 2): ("extruder_train", 3, upgrade.upgradeExtruderTrain) - }, + ("extruder_train", 2): ("extruder_train", 3, upgrade.upgradeExtruderTrain), + ("preferences", 3): ("preferences", 4, upgrade.upgradePreferences) + + }, "sources": { "machine_stack": { "get_version": upgrade.getCfgVersion, diff --git a/plugins/XmlMaterialProfile/XmlMaterialProfile.py b/plugins/XmlMaterialProfile/XmlMaterialProfile.py index fa0d3d2b8c..a0e80df436 100644 --- a/plugins/XmlMaterialProfile/XmlMaterialProfile.py +++ b/plugins/XmlMaterialProfile/XmlMaterialProfile.py @@ -594,6 +594,8 @@ class XmlMaterialProfile(UM.Settings.InstanceContainer): # Map XML file product names to internal ids # TODO: Move this to definition's metadata __product_id_map = { + "Ultimaker 3": "ultimaker3", + "Ultimaker 3 Extended": "ultimaker3_extended", "Ultimaker 2": "ultimaker2", "Ultimaker 2+": "ultimaker2_plus", "Ultimaker 2 Go": "ultimaker2_go", diff --git a/resources/definitions/fdmprinter.def.json b/resources/definitions/fdmprinter.def.json index 8dec4a307e..7725940553 100644 --- a/resources/definitions/fdmprinter.def.json +++ b/resources/definitions/fdmprinter.def.json @@ -1190,7 +1190,7 @@ "type": "int", "minimum_value": "0", "maximum_value_warning": "4", - "maximum_value": "20 - math.log(infill_line_distance) / math.log(2)", + "maximum_value": "(20 - math.log(infill_line_distance) / math.log(2)) if infill_line_distance > 0 else 0", "enabled": "infill_sparse_density > 0 and infill_pattern != 'cubicsubdiv'", "settable_per_mesh": true }, diff --git a/resources/qml/AddMachineDialog.qml b/resources/qml/AddMachineDialog.qml index 80ac1213a8..8506074b0d 100644 --- a/resources/qml/AddMachineDialog.qml +++ b/resources/qml/AddMachineDialog.qml @@ -46,7 +46,8 @@ UM.Dialog left: parent.left; top: parent.top; right: parent.right; - bottom: parent.bottom; + bottom: machineNameRow.top; + bottomMargin: UM.Theme.getSize("default_margin").height } ListView @@ -65,6 +66,7 @@ UM.Dialog section.delegate: Button { text: section + width: machineList.width style: ButtonStyle { background: Rectangle @@ -102,8 +104,8 @@ UM.Dialog base.activeCategory = section; if (machineList.model.getItem(machineList.currentIndex).section != section) { // Find the first machine from this section - for(var i = 0; i < sortedMachineDefinitionsModel.count; i++) { - var item = sortedMachineDefinitionsModel.getItem(i); + for(var i = 0; i < machineList.model.rowCount(); i++) { + var item = machineList.model.getItem(i); if (item.section == section) { machineList.currentIndex = i; break; @@ -169,21 +171,33 @@ UM.Dialog } } - TextField + Row { - id: machineName; - text: getMachineName() - implicitWidth: UM.Theme.getSize("standard_list_input").width - maximumLength: 40 - //validator: Cura.MachineNameValidator { } //TODO: Gives a segfault in PyQt5.6. For now, we must use a signal on text changed. - validator: RegExpValidator - { - regExp: { - machineName.machine_name_validator.machineNameRegex - } - } - property var machine_name_validator: Cura.MachineNameValidator { } + id: machineNameRow anchors.bottom:parent.bottom + spacing: UM.Theme.getSize("default_margin").width + + Label + { + text: catalog.i18nc("@label", "Printer Name:") + anchors.verticalCenter: machineName.verticalCenter + } + + TextField + { + id: machineName + text: getMachineName() + implicitWidth: UM.Theme.getSize("standard_list_input").width + maximumLength: 40 + //validator: Cura.MachineNameValidator { } //TODO: Gives a segfault in PyQt5.6. For now, we must use a signal on text changed. + validator: RegExpValidator + { + regExp: { + machineName.machine_name_validator.machineNameRegex + } + } + property var machine_name_validator: Cura.MachineNameValidator { } + } } Button