From c3d846440d6bf9c3ef1b0eba33d74bc797bdff4c Mon Sep 17 00:00:00 2001 From: ChrisTerBeke Date: Tue, 1 Oct 2019 19:31:35 +0200 Subject: [PATCH 1/6] Set some meta data before switching active stacks, fix manual added device pairing --- .../src/Cloud/CloudOutputDevice.py | 4 ++-- .../src/Cloud/CloudOutputDeviceManager.py | 15 +++++++-------- .../Network/LocalClusterOutputDeviceManager.py | 14 ++++++++------ 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py index 75e2b30ff1..bfe5a5728a 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py @@ -127,8 +127,8 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice): if network_key.startswith(self.clusterData.host_name): return True # However, for manually added printers, the local IP address is used in lieu of a proper - # network key, so check for that as well - if self.clusterData.host_internal_ip is not None and network_key in self.clusterData.host_internal_ip: + # network key, so check for that as well. It is in the format "manual:10.1.10.1". + if network_key.endswith(self.clusterData.host_internal_ip): return True return False diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py index 8d35b41fa2..fcf29c018a 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py @@ -9,6 +9,7 @@ from UM.Logger import Logger # To log errors talking to the API. from UM.Signal import Signal from cura.API import Account from cura.CuraApplication import CuraApplication +from cura.Settings.CuraStackBuilder import CuraStackBuilder from cura.Settings.GlobalStack import GlobalStack from .CloudApiClient import CloudApiClient @@ -140,14 +141,12 @@ class CloudOutputDeviceManager: if not device: return - # The newly added machine is automatically activated. - machine_manager = CuraApplication.getInstance().getMachineManager() - machine_manager.addMachine(device.printerType, device.clusterData.friendly_name) - active_machine = CuraApplication.getInstance().getGlobalContainerStack() - if not active_machine: - return - active_machine.setMetaDataEntry(self.META_CLUSTER_ID, device.key) - self._connectToOutputDevice(device, active_machine) + # Create a new machine and activate it. + # We do not use use MachineManager.addMachine here because we need to set the cluster ID before activating it. + new_machine = CuraStackBuilder.createMachine(device.name, device.printerType) + new_machine.setMetaDataEntry(self.META_CLUSTER_ID, device.key) + CuraApplication.getInstance().getMachineManager().setActiveMachine(new_machine.getId()) + self._connectToOutputDevice(device, new_machine) ## Callback for when the active machine was changed by the user or a new remote cluster was found. def _connectToActiveMachine(self) -> None: diff --git a/plugins/UM3NetworkPrinting/src/Network/LocalClusterOutputDeviceManager.py b/plugins/UM3NetworkPrinting/src/Network/LocalClusterOutputDeviceManager.py index 557de4ec80..c4c4779a3c 100644 --- a/plugins/UM3NetworkPrinting/src/Network/LocalClusterOutputDeviceManager.py +++ b/plugins/UM3NetworkPrinting/src/Network/LocalClusterOutputDeviceManager.py @@ -9,6 +9,7 @@ from UM.Signal import Signal from UM.Version import Version from cura.CuraApplication import CuraApplication +from cura.Settings.CuraStackBuilder import CuraStackBuilder from cura.Settings.GlobalStack import GlobalStack from .ZeroConfClient import ZeroConfClient @@ -203,12 +204,13 @@ class LocalClusterOutputDeviceManager: if device is None: return - # The newly added machine is automatically activated. - CuraApplication.getInstance().getMachineManager().addMachine(device.printerType, device.name) - active_machine = CuraApplication.getInstance().getGlobalContainerStack() - if not active_machine: - return - self._connectToOutputDevice(device, active_machine) + # Create a new machine and activate it. + # We do not use use MachineManager.addMachine here because we need to set the network key before activating it. + # If we do not do this the auto-pairing with the cloud-equivalent device will not work. + new_machine = CuraStackBuilder.createMachine(device.name, device.printerType) + new_machine.setMetaDataEntry(self.META_NETWORK_KEY, device.key) + CuraApplication.getInstance().getMachineManager().setActiveMachine(new_machine.getId()) + self._connectToOutputDevice(device, new_machine) self._showCloudFlowMessage(device) ## Add an address to the stored preferences. From 5f3155118404c1a2dae510e107e825b951dda3bf Mon Sep 17 00:00:00 2001 From: ChrisTerBeke Date: Tue, 1 Oct 2019 19:41:02 +0200 Subject: [PATCH 2/6] Fix checking for cases where machine creation failed --- .../UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py | 3 +++ .../src/Network/LocalClusterOutputDeviceManager.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py index fcf29c018a..c4929fc2d1 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py @@ -144,6 +144,9 @@ class CloudOutputDeviceManager: # Create a new machine and activate it. # We do not use use MachineManager.addMachine here because we need to set the cluster ID before activating it. new_machine = CuraStackBuilder.createMachine(device.name, device.printerType) + if not new_machine: + Logger.log("e", "Failed creating a new machine") + return new_machine.setMetaDataEntry(self.META_CLUSTER_ID, device.key) CuraApplication.getInstance().getMachineManager().setActiveMachine(new_machine.getId()) self._connectToOutputDevice(device, new_machine) diff --git a/plugins/UM3NetworkPrinting/src/Network/LocalClusterOutputDeviceManager.py b/plugins/UM3NetworkPrinting/src/Network/LocalClusterOutputDeviceManager.py index c4c4779a3c..273c64ef4d 100644 --- a/plugins/UM3NetworkPrinting/src/Network/LocalClusterOutputDeviceManager.py +++ b/plugins/UM3NetworkPrinting/src/Network/LocalClusterOutputDeviceManager.py @@ -208,6 +208,9 @@ class LocalClusterOutputDeviceManager: # We do not use use MachineManager.addMachine here because we need to set the network key before activating it. # If we do not do this the auto-pairing with the cloud-equivalent device will not work. new_machine = CuraStackBuilder.createMachine(device.name, device.printerType) + if not new_machine: + Logger.log("e", "Failed creating a new machine") + return new_machine.setMetaDataEntry(self.META_NETWORK_KEY, device.key) CuraApplication.getInstance().getMachineManager().setActiveMachine(new_machine.getId()) self._connectToOutputDevice(device, new_machine) From 76536fe715d21cd7b577c54143a964f8311a562e Mon Sep 17 00:00:00 2001 From: ChrisTerBeke Date: Tue, 1 Oct 2019 19:52:40 +0200 Subject: [PATCH 3/6] Ensure string matching is done with strings --- plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py index bfe5a5728a..4db68560a4 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py @@ -124,11 +124,11 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice): def matchesNetworkKey(self, network_key: str) -> bool: # Typically, a network key looks like "ultimakersystem-aabbccdd0011._ultimaker._tcp.local." # the host name should then be "ultimakersystem-aabbccdd0011" - if network_key.startswith(self.clusterData.host_name): + if network_key.startswith(str(self.clusterData.host_name)): return True # However, for manually added printers, the local IP address is used in lieu of a proper # network key, so check for that as well. It is in the format "manual:10.1.10.1". - if network_key.endswith(self.clusterData.host_internal_ip): + if network_key.endswith(str(self.clusterData.host_internal_ip)): return True return False From 445743ab75e9f70ef3809882c426c489b47c7565 Mon Sep 17 00:00:00 2001 From: ChrisTerBeke Date: Tue, 1 Oct 2019 19:53:40 +0200 Subject: [PATCH 4/6] Use empty string as fallback value --- plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py index 4db68560a4..b544490cfb 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py @@ -124,11 +124,11 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice): def matchesNetworkKey(self, network_key: str) -> bool: # Typically, a network key looks like "ultimakersystem-aabbccdd0011._ultimaker._tcp.local." # the host name should then be "ultimakersystem-aabbccdd0011" - if network_key.startswith(str(self.clusterData.host_name)): + if network_key.startswith(str(self.clusterData.host_name or "")): return True # However, for manually added printers, the local IP address is used in lieu of a proper # network key, so check for that as well. It is in the format "manual:10.1.10.1". - if network_key.endswith(str(self.clusterData.host_internal_ip)): + if network_key.endswith(str(self.clusterData.host_internal_ip or "")): return True return False From 2a4c387067bbd9c25190cbe557a96bb391687048 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 2 Oct 2019 11:44:24 +0200 Subject: [PATCH 5/6] Add sideways move to not squash the primed amount onto the nozzle Provided by Psychonno and tested by MetalRobo in #6424. --- resources/definitions/anycubic_i3_mega.def.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/definitions/anycubic_i3_mega.def.json b/resources/definitions/anycubic_i3_mega.def.json index cc9832cf09..18005f0e12 100644 --- a/resources/definitions/anycubic_i3_mega.def.json +++ b/resources/definitions/anycubic_i3_mega.def.json @@ -54,7 +54,7 @@ }, "machine_start_gcode": { - "default_value": "G21 ;metric values\nG90 ;absolute positioning\nM82 ;set extruder to absolute mode\nM107 ;start with the fan off\nG28 X0 Y0 ;move X/Y to min endstops\nG28 Z0 ;move Z to min endstops\nG1 Z15.0 F{speed_travel} ;move the platform down 15mm\nG92 E0 ;zero the extruded length\nG1 F200 E3 ;extrude 3mm of feed stock\nG92 E0 ;zero the extruded length again\nG1 F{speed_travel}\nM117 Printing...\nG5" + "default_value": "G21 ;metric values\nG90 ;absolute positioning\nM82 ;set extruder to absolute mode\nM107 ;start with the fan off\nG28 X0 Y0 ;move X/Y to min endstops\nG28 Z0 ;move Z to min endstops\nG1 Z15.0 F{speed_travel} ;move the platform down 15mm\nG92 E0 ;zero the extruded length\nG1 F200 E3 ;extrude 3mm of feed stock\nG92 E0 ;zero the extruded length again\nG1 F{speed_travel}\nG0 Y20 F{speed_travel}\nM117 Printing...\nG5" }, "machine_end_gcode": { From 672fc58930052749c497862242f7871c888ac223 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 2 Oct 2019 12:59:30 +0200 Subject: [PATCH 6/6] Allow down to half the layer height for infill layer thickness This is possible because CuraEngine rounds these to the nearest layer thickness. So if it's more than half the layer height it gets rounded up and it's still properly one layer. Contributes to issue #6465. --- resources/definitions/fdmprinter.def.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/definitions/fdmprinter.def.json b/resources/definitions/fdmprinter.def.json index 3dbada96f5..122d0e3f5e 100644 --- a/resources/definitions/fdmprinter.def.json +++ b/resources/definitions/fdmprinter.def.json @@ -1886,7 +1886,7 @@ "unit": "mm", "type": "float", "default_value": 0.1, - "minimum_value": "resolveOrValue('layer_height') if infill_line_distance > 0 else -999999", + "minimum_value": "resolveOrValue('layer_height') / 2 if infill_line_distance > 0 else -999999", "maximum_value_warning": "0.75 * machine_nozzle_size", "maximum_value": "resolveOrValue('layer_height') * (1.45 if spaghetti_infill_enabled else 8) if infill_line_distance > 0 else 999999", "value": "resolveOrValue('layer_height')",