diff --git a/plugins/MachineSettingsAction/MachineSettingsAction.py b/plugins/MachineSettingsAction/MachineSettingsAction.py index 8e6ff57b81..9b52a18af2 100644 --- a/plugins/MachineSettingsAction/MachineSettingsAction.py +++ b/plugins/MachineSettingsAction/MachineSettingsAction.py @@ -32,18 +32,19 @@ class MachineSettingsAction(MachineAction): # First check if there is a variant previously generated by this machine machine_settings_variant = global_container_stack.findContainer({"type": "variant", "subtype": "machine_settings"}) if not machine_settings_variant: - # There may be a variant created by the UMOUpgradeSelection machine action - machine_settings_variant = global_container_stack.findContainer({"type": "variant", "id": global_container_stack.getName() + "_variant"}) + variant = global_container_stack.findContainer({"type": "variant"}) + if variant: + if variant.getId() == global_container_stack.getName() + "_variant": + # There is a variant created by the UMOUpgradeSelection machine action + machine_settings_variant = variant + if variant.getId() == "empty_variant": + # There is an empty variant that we can replace to store the machine settings + container_index = global_container_stack.getContainerIndex(variant) + machine_settings_variant = self._createMachineSettingsVariant(global_container_stack, container_index) if not machine_settings_variant: - variant = global_container_stack.findContainer({"type": "variant"}) - if variant and variant.getId() == "empty_variant": - # There is an empty variant that we can use to store the machine settings - container_index = global_container_stack.getContainerIndex(variant) - machine_settings_variant = self._createMachineSettingsVariant(global_container_stack, container_index) - else: - # Add a second variant before the current variant to store the machine settings - machine_settings_variant = self._createMachineSettingsVariant(global_container_stack) + # Add a new variant to store the machine settings + machine_settings_variant = self._createMachineSettingsVariant(global_container_stack) # Notify the UI in which container to store the machine settings data container_index = global_container_stack.getContainerIndex(machine_settings_variant)