diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index c2a08cadfc..d5f90f6846 100644 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -866,7 +866,7 @@ class CuraApplication(QtApplication): return # Compute the center of the objects when their origins are aligned. - object_centers = [node.getMeshData().getCenterPosition().scale(node.getScale()) for node in group_node.getChildren() if node.getMeshData()] + object_centers = [node.getBoundingBox().center for node in group_node.getChildren()] if object_centers and len(object_centers) > 0: middle_x = sum([v.x for v in object_centers]) / len(object_centers) middle_y = sum([v.y for v in object_centers]) / len(object_centers) @@ -874,11 +874,10 @@ class CuraApplication(QtApplication): offset = Vector(middle_x, middle_y, middle_z) else: offset = Vector(0, 0, 0) - # Move each node to the same position. for center, node in zip(object_centers, group_node.getChildren()): # Align the object and also apply the offset to center it inside the group. - node.setPosition(center - offset) + node.translate(-1 * (center - offset), SceneNode.TransformSpace.World) # Use the previously found center of the group bounding box as the new location of the group group_node.setPosition(group_node.getBoundingBox().center) diff --git a/plugins/3MFReader/ThreeMFReader.py b/plugins/3MFReader/ThreeMFReader.py index 633eb8bb02..a06c557276 100644 --- a/plugins/3MFReader/ThreeMFReader.py +++ b/plugins/3MFReader/ThreeMFReader.py @@ -17,6 +17,7 @@ import zipfile try: import xml.etree.cElementTree as ET except ImportError: + Logger.log("w", "Unable to load cElementTree, switching to slower version") import xml.etree.ElementTree as ET ## Base implementation for reading 3MF files. Has no support for textures. Only loads meshes! diff --git a/plugins/USBPrinting/USBPrinterOutputDevice.py b/plugins/USBPrinting/USBPrinterOutputDevice.py index 6147bfb53f..13dfe967b3 100644 --- a/plugins/USBPrinting/USBPrinterOutputDevice.py +++ b/plugins/USBPrinting/USBPrinterOutputDevice.py @@ -19,7 +19,6 @@ from PyQt5.QtCore import QUrl, pyqtSlot, pyqtSignal, pyqtProperty from UM.i18n import i18nCatalog catalog = i18nCatalog("cura") - class USBPrinterOutputDevice(PrinterOutputDevice): def __init__(self, serial_port): diff --git a/plugins/USBPrinting/avr_isp/intelHex.py b/plugins/USBPrinting/avr_isp/intelHex.py index 6e27595587..a51c798d8e 100644 --- a/plugins/USBPrinting/avr_isp/intelHex.py +++ b/plugins/USBPrinting/avr_isp/intelHex.py @@ -7,7 +7,6 @@ This is a python 3 conversion of the code created by David Braam for the Cura pr import io from UM.Logger import Logger - def readHex(filename): """ Read an verify an intel hex file. Return the data as an list of bytes. diff --git a/plugins/USBPrinting/avr_isp/stk500v2.py b/plugins/USBPrinting/avr_isp/stk500v2.py index 3bbecb06c2..ccbaa3de53 100644 --- a/plugins/USBPrinting/avr_isp/stk500v2.py +++ b/plugins/USBPrinting/avr_isp/stk500v2.py @@ -3,7 +3,6 @@ STK500v2 protocol implementation for programming AVR chips. The STK500v2 protocol is used by the ArduinoMega2560 and a few other Arduino platforms to load firmware. This is a python 3 conversion of the code created by David Braam for the Cura project. """ -import os import struct import sys import time @@ -28,7 +27,7 @@ class Stk500v2(ispBase.IspBase): self.close() try: self.serial = Serial(str(port), speed, timeout=1, writeTimeout=10000) - except SerialException as e: + except SerialException: raise ispBase.IspError("Failed to open serial port") except: raise ispBase.IspError("Unexpected error while connecting to serial port:" + port + ":" + str(sys.exc_info()[0])) @@ -92,7 +91,7 @@ class Stk500v2(ispBase.IspBase): self.sendMessage([0x06, 0x00, 0x00, 0x00, 0x00]) load_count = (len(flash_data) + page_size - 1) / page_size for i in range(0, int(load_count)): - recv = self.sendMessage([0x13, page_size >> 8, page_size & 0xFF, 0xc1, 0x0a, 0x40, 0x4c, 0x20, 0x00, 0x00] + flash_data[(i * page_size):(i * page_size + page_size)]) + self.sendMessage([0x13, page_size >> 8, page_size & 0xFF, 0xc1, 0x0a, 0x40, 0x4c, 0x20, 0x00, 0x00] + flash_data[(i * page_size):(i * page_size + page_size)]) if self.progress_callback is not None: if self._has_checksum: self.progress_callback(i + 1, load_count) @@ -183,11 +182,11 @@ class Stk500v2(ispBase.IspBase): def portList(): ret = [] import _winreg - key=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,"HARDWARE\\DEVICEMAP\\SERIALCOMM") + key=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,"HARDWARE\\DEVICEMAP\\SERIALCOMM") #@UndefinedVariable i=0 while True: try: - values = _winreg.EnumValue(key, i) + values = _winreg.EnumValue(key, i) #@UndefinedVariable except: return ret if "USBSER" in values[0]: @@ -206,7 +205,7 @@ def main(): """ Entry point to call the stk500v2 programmer from the commandline. """ import threading if sys.argv[1] == "AUTO": - Logger.log("d", portList()) + Logger.log("d", "portList(): ", repr(portList())) for port in portList(): threading.Thread(target=runProgrammer, args=(port,sys.argv[2])).start() time.sleep(5)