def getLabelDxf(self, for_prime_center=True): x = self.getPosition()[0] - self.getWidth()/2 y = self.getPosition()[1] - self.getHeight()/2 width = self.getWidth() height = self.getHeight() # if self.isCoupage() and (height > width) and height <= self.getGridWidth(): # # rotate when more optimal # width = self.getHeight() # height = self.getWidth() if for_prime_center == True: x = Helper.toMillimeters(x) y = Helper.toMillimeters(y) width = Helper.toMillimeters(width) height = Helper.toMillimeters(width) text = dxf.text(str(self.getClientName()), (y, x + width), 100.0, rotation=0) text['layer'] = 'TEXT' text['color'] = '7' else: text = dxf.text(str(self.getClientName()), (x, y + height), 10.0, rotation=0) text['layer'] = 'TEXT' text['color'] = '7' return text
def getRectangleDxf(self, for_prime_center=True): x = self.getPosition()[0] - self.getWidth()/2 y = self.getPosition()[1] - self.getHeight()/2 width = self.getWidth() height = self.getHeight() # if self.isCoupage() and (height > width) and height <= self.getGridWidth(): # # rotate when more optimal # width = self.getHeight() # height = self.getWidth() if for_prime_center == True: x = Helper.toMillimeters(x) y = Helper.toMillimeters(y) width = Helper.toMillimeters(width) height = Helper.toMillimeters(height) bgcolor = random.randint(1,255) return dxf.rectangle((y,x), height, width, bgcolor=bgcolor) else: bgcolor = random.randint(1,255) return dxf.rectangle((x, y), width, height, bgcolor=bgcolor)
def addLargeHorizontalLineAtTop(self): y_start = Helper.toMillimeters(self.getHighestVerticalPoint()) x_start = 0 y_end = Helper.toMillimeters(self.getHighestVerticalPoint()) x_end = Helper.toMillimeters(self.getWidth() + 20) line = dxf.line((y_start, x_start), (y_end, x_end)) self.dxf_drawing.add(line)
def removeOverlappingVerticalLines(self, for_prime_center): for x in self.x_unique: vertical_lines = self.getVerticalLinesPerXValue(x) i = 0 j = 1 while self.thereAreOverlappingLines(vertical_lines): l1 = vertical_lines[i] l2 = vertical_lines[j] if i != j: if l1.overlaps(l2): if l2.end_point[1] > l1.end_point[1]: l1.setEndPoint(l2.end_point) if l2.start_point[1] < l1.start_point[1]: l1.setStartPoint(l2.start_point) del vertical_lines[j] i = 0 j = 1 else: if (j + 1 >= len(vertical_lines)): if (i + 1 >= len(vertical_lines)): break else: i += 1 j = 0 else: j += 1 else: if (j + 1 >= len(vertical_lines)): if (i + 1 >= len(vertical_lines)): break else: i += 1 j = 0 else: j += 1 if for_prime_center == True: for line in vertical_lines: new_line = Line() new_line.setStartPoint([Helper.toMillimeters(line.start_point[1]), Helper.toMillimeters(line.start_point[0])]) new_line.setEndPoint([Helper.toMillimeters(line.end_point[1]), Helper.toMillimeters(line.end_point[0])]) x = Helper.toMillimeters(x) self.lines_without_overlap.append(new_line) self.dxf_lines_without_overlap.append(dxf.line((new_line.start_point[1], x), (new_line.end_point[1], x))) else: for line in vertical_lines: dxf_line = dxf.line((x, line.start_point[1]), (x, line.end_point[1]), color=random.randint(0, 255), thickness=100.0) self.lines_without_overlap.append(line) self.dxf_lines_without_overlap.append(dxf_line)
def fillXmlWithLargeHorizontalLineAtTop(self, grid): y_start = Helper.toMillimeters(grid.getHighestVerticalPoint()) x_start = 0 y_end = Helper.toMillimeters(grid.getHighestVerticalPoint()) x_end = Helper.toMillimeters(grid.getWidth() + 20) # x/y swapped for prime center self.fillXmlWithMoveTo(y_start, x_start) self.fillXmlWithLineTo(y_end, x_end) self.addThruCutLayer()
def toPrimeCenterFormat(self): self.rotate() x = Helper.toMillimeters(self.getPosition()[0]) y = Helper.toMillimeters(self.getPosition()[1]) width = Helper.toMillimeters(self.getWidth()) height = Helper.toMillimeters(self.getHeight()) self.setPosition([x, y]) self.setWidth(width) self.setHeight(height)
def addCreation(self): self.creation = ET.SubElement( self.meta, "Creation", { "Name": "Cut Editor", "Version": "3.2.6.9", "Date": Helper.getDateTimeZcc() })
def initExcel(self): desktop = Helper.getDesktopPath() path = desktop + "/paklijsten/" file_name = "paklijst.xlsx" self.excel_parser = ExcelParser( data_logger=self.stacker.getDataLogger(), path=path, file_name=file_name, sheet_name='Paklijst') self.stacker.setExcelParser(path=path, file_name=file_name)
def loadOrders(self): file_name = self.excel_file_line_edit.text() desktop = Helper.getDesktopPath() path = desktop + "/paklijsten/" self.excel_parser.setFileName(file_name) self.stacker.setExcelParser(path=path, file_name=file_name) unstacked_rectangles = self.excel_parser.getUnstackedRectangles() self.db_manager.addRectangles(unstacked_rectangles) self.refreshNewOrders()
def rotateCoupageToLargestSideUpwards(self): _width = self.coupage.getWidth() _height = self.coupage.getHeight() if _width > _height: print("Coupage width is larger than height") width, height = Helper.swap(_width, _height) print("Width before swap = " + str(self.coupage.getWidth())) self.coupage.setWidth(width) self.coupage.setHeight(height) print("Width after swap = " + str(self.coupage.getWidth())) self.db_manager.updateRectangle(self.coupage)
def initEmptyDxfDrawing(self): dxf_file_name = self.getDxfFileName() dxf_file_path = Helper.createAndGetDxfFolder() + "/" + self.getDxfFileName() self.dxf_drawing = dxf.drawing(dxf_file_path)
def removeOverlappingHorizontalLines(self, for_prime_center): for y in self.y_unique: horizontal_lines = self.getHorizontalLinesPerYValue(y) i = 0 j = 1 while self.thereAreOverlappingLines(horizontal_lines): l1 = horizontal_lines[i] l2 = horizontal_lines[j] if i != j: if l1.overlaps(l2): if l2.end_point[0] > l1.end_point[0]: l1.setEndPoint(l2.end_point) if l2.start_point[0] < l1.start_point[0]: l1.setStartPoint(l2.start_point) del horizontal_lines[j] i = 0 j = 1 else: if (j + 1 >= len(horizontal_lines)): if (i + 1 >= len(horizontal_lines)): break else: i += 1 j = 0 else: j += 1 else: if (j + 1 >= len(horizontal_lines)): if (i + 1 >= len(horizontal_lines)): break else: i += 1 j = 0 else: j += 1 if for_prime_center == True: for line in horizontal_lines: if self.isHeighestLine(line): continue new_line = Line() new_line.setStartPoint([Helper.toMillimeters(line.start_point[1]), Helper.toMillimeters(line.start_point[0])]) new_line.setEndPoint([Helper.toMillimeters(line.end_point[1]), Helper.toMillimeters(line.end_point[0])]) y = Helper.toMillimeters(y) self.lines_without_overlap.append(new_line) self.dxf_lines_without_overlap.append(dxf.line((y, new_line.start_point[0]), (y, new_line.end_point[0]))) else: for line in horizontal_lines: self.lines_without_overlap.append(line) dxf_line = dxf.line((line.start_point[0], y), (line.end_point[0], y), color=random.randint(0, 255), thickness=100.0) # self.drawing.add(dxf_line) self.dxf_lines_without_overlap.append(dxf_line)
def getZccPath(self): return Helper.createAndGetFolderOnDesktop('zcc')
def getDxfFileName(self): hour = Helper.getCurrentHour() return str(hour) + "h" + "_" + str(self.getArticleName()) + "_" + str(self.getClientName()) + "_" + str(self.getName()) + "_" + str(self.getCoupageBatch()) + ".dxf"
def getDxfFileName(self): hour = Helper.getCurrentHour() return str(hour) + "h" + "_" + str(self.getArticleName()) + "_" + str(self.getWidth()) + "cm" + "_batch_" + str(self.getName()) + ".dxf"
def __init__(self): self.setStoragePath(Helper.createAndGetFolderOnDesktop("log")) self.error_data = []
def storeData(self): file_name = str(Helper.getCurrentHour()) + 'h_log.txt' with open(self.getStoragePath() + file_name, 'w+') as f: f.write(self.dataToString())
def createDxfFilePath(self): dxf_path = Helper.createAndGetDxfFolder() hour = Helper.getCurrentHour() print("Article name for export dxf = " + str(self.getArticleName())) # self.dxf_file_path = dxf_path + "/" + str(hour) + "h" + "_" + self.getBrand() + "_" + self.getColor() + "_" + str(self.getWidth()) + "cm" + ".dxf" self.dxf_file_path = dxf_path + "/" + str(hour) + "h" + "_" + self.getArticleName() + "_" + str(self.getWidth()) + "cm" + "_batch_" + str(self.getName()) + ".dxf"
def __init__(self, material, file_name): self.zcc_path = Helper.createAndGetFolderOnDesktop('zcc') self.setMaterial(material) self.setFileName(file_name) self.createInitialTemplate()