def generate_warninglist(): template = "O500 {} {} {} {} {} {}" result = [] hotswapID = 256 for tmp_value in v.m4c_late_warning: if len(tmp_value) > 0: source = "D{}{}{}".format( v.filament_color_code[tmp_value[1]].strip("\n"), find_nearest_colour( v.filament_color_code[tmp_value[1]].strip("\n")), v.filament_type[0].strip("\n")) target = "D{}{}{}".format( v.filament_color_code[tmp_value[2]].strip("\n"), find_nearest_colour( v.filament_color_code[tmp_value[2]].strip("\n")), v.filament_type[0].strip("\n")) result.append( template.format(fn.hexify_short(hotswapID), fn.hexify_byte(tmp_value[0]), source, target, fn.hexify_short(tmp_value[3]), fn.hexify_short(tmp_value[4]))) hotswapID += 1 return result
def algorithm_create_process_string(heating, compression, cooling): if v.palette_plus: if int(cooling ) != 0: # cooling parameter functions as a forward/reverse cooling = 1 return "{},{},{}".format( hexify_float(float(heating))[1:].zfill(8), hexify_float(float(compression))[1:].zfill(8), cooling) else: return "{} {} {}".format(hexify_short(int(heating)), hexify_short(int(compression)), hexify_short(int(cooling)))
def header_generate_omega_paletteplus(): header = ["MSF1.4\n"] cu = "cu:" for i in range(4): if v.palette_inputs_used[i]: cu = cu + "{}{};".format( v.used_filament_types.index(v.filament_type[i]) + 1, find_nearest_colour(v.filament_color_code[i].strip("\n"))) else: cu = cu + "0;" header.append(cu + "\n") header.append("ppm:{}\n".format((hexify_float(v.palette_plus_ppm))[1:])) header.append("lo:{}\n".format( (hexify_short(v.palette_plus_loading_offset))[1:])) header.append("ns:{}\n".format( hexify_short(len(v.splice_extruder_position))[1:])) header.append("np:{}\n".format( hexify_short(len(v.ping_extruder_position))[1:])) header.append("nh:0000\n") header.append("na:{}\n".format( hexify_short(len(v.splice_algorithm_table))[1:])) for i in range(len(v.splice_extruder_position)): header.append("({},{})\n".format( hexify_byte(v.splice_used_tool[i])[1:], (hexify_float(v.splice_extruder_position[i])[1:]))) # make ping list for i in range(len(v.ping_extruder_position)): header.append("(64,{})\n".format( (hexify_float(v.ping_extruder_position[i])[1:]))) # insert algos for i in range(len(v.splice_algorithm_table)): header.append("{}\n".format(v.splice_algorithm_table[i])) summary = generatesummary() warnings = generatewarnings() return {'header': header, 'summary': summary, 'warnings': warnings}
def header_generate_omega_palette2(job_name): header = [] summary = [] warnings = [] header.append('O21 ' + hexify_short(20) + "\n") # MSF2.0 if v.printer_profile_string == '': v.printer_profile_string = v.default_printerprofile gui.log_warning( "No or Invalid Printer profile ID specified\nusing default P2PP printer profile ID {}" .format(v.default_printerprofile)) header.append('O22 D' + v.printer_profile_string.strip("\n") + "\n") # PRINTERPROFILE used in Palette2 header.append('O23 D0001' + "\n") # unused header.append('O24 D0000' + "\n") # unused str = "O25" initools = v.m4c_loadedinputs[0] if len(initools) < 4: if v.m4c_numberoffilaments == 4: initools = [0, 1, 2, 3] for i in range(4): if not v.palette_inputs_used[i]: initools[i] = -1 else: while len(initools) < 4: initools.append(-1) for i in initools: if i != -1: str += " D{}{}{}{}".format( v.used_filament_types.index(v.filament_type[i]) + 1, v.filament_color_code[i].strip("\n"), find_nearest_colour(v.filament_color_code[i].strip("\n")), v.filament_type[i].strip("\n")) else: str += (" D0") header.append(str + "\n") header.append('O26 ' + hexify_short(len(v.splice_extruder_position)) + "\n") header.append('O27 ' + hexify_short(len(v.ping_extruder_position)) + "\n") if len(v.splice_algorithm_table) > 9: header.append("O28 D{:0>4d}\n".format(len(v.splice_algorithm_table))) else: header.append('O28 ' + hexify_short(len(v.splice_algorithm_table)) + "\n") header.append('O29 ' + hexify_short(v.hotswap_count) + "\n") for i in range(len(v.splice_extruder_position)): if v.accessory_mode: header.append("O30 D{:0>1d} {}\n".format( v.splice_used_tool[i], hexify_float(v.splice_extruder_position[i]))) else: header.append("O30 D{:0>1d} {}\n".format( v.splice_used_tool[i], hexify_float(v.splice_extruder_position[i] + v.autoloadingoffset))) if v.accessory_mode: for i in range(len(v.ping_extruder_position)): header.append("O31 {} {}\n".format( hexify_float(v.ping_extruder_position[i]), hexify_float(v.ping_extrusion_between_pause[i]))) for i in range(len(v.splice_algorithm_table)): header.append("O32 {}\n".format(v.splice_algorithm_table[i])) if v.m4c_numberoffilaments > 4: v.m4c_headerinfo = m4c.generate_warninglist() for i in v.m4c_headerinfo: header.append(i + "\n") if v.autoloadingoffset > 0: header.append("O40 D{}".format(v.autoloadingoffset)) else: v.autoloadingoffset = 0 if not v.accessory_mode: if len(v.splice_extruder_position) > 0: header.append("O1 D{} {}\n".format( job_name, hexify_long( int(v.splice_extruder_position[-1] + 0.5 + v.autoloadingoffset)))) else: header.append("O1 D{} {}\n".format( job_name, hexify_long( int(v.total_material_extruded + 0.5 + v.autoloadingoffset)))) header.append("M0\n") header.append("T0\n") summary = generatesummary() warnings = generatewarnings() return {'header': header, 'summary': summary, 'warnings': warnings}
def header_generate_omega(job_name): if v.printerProfileString == '': log_warning("The PRINTERPROFILE identifier is missing, Please add:\n" + ";P2PP PRINTERPROFILE=<your printer profile ID>\n" + "to your Printers Start GCODE.\n") if len(v.spliceExtruderPosition) == 0: log_warning( "This does not look lie a multi color file.. Skip P2PP Processing?\n" ) # TODO: Implement Y/N Box algorithm_create_table() header = [] summary = [] warnings = [] header.append('O21 ' + hexify_short(20) + "\n") # MSF2.0 header.append('O22 D' + v.printerProfileString.strip("\n") + "\n") # PRINTERPROFILE used in Palette2 header.append('O23 D0001' + "\n") # unused header.append('O24 D0000' + "\n") # unused header.append("O25 ") for i in range(4): if v.paletteInputsUsed[i]: if v.filamentType[i] == "": log_warning( "Filament #{} is missing Material Type, make sure to add" + " ;P2PP FT=[filament_type] to filament GCode".format(i)) if v.filamentColorCode[i] == "-": log_warning( "Filament #{} is missing Color info, make sure to add" + ";P2PP FC=[extruder_colour] to filament GCode".format(i)) v.filamentColorCode[i] = '000000' header.append("D{}{}{}_{} ".format( v.usedFilamentTypes.index(v.filamentType[i]) + 1, v.filamentColorCode[i].strip("\n"), findNearestColor(v.filamentColorCode[i].strip("\n")), v.filamentType[i].strip("\n"))) else: header.append("D0 ") header.append("\n") header.append('O26 ' + hexify_short(len(v.spliceExtruderPosition)) + "\n") header.append('O27 ' + hexify_short(len(v.pingExtruderPosition)) + "\n") if len(v.spliceAlgorithmTable) > 9: log_warning( "ATTENTION: THIS FILE WILL NOT POTENTIALLY NOT WORK CORRECTLY DUE TO A BUG IN PALETTE2 PLUGIN" ) header.append("O28 D{:0>4d}\n".format(len(v.spliceAlgorithmTable))) else: header.append('O28 ' + hexify_short(len(v.spliceAlgorithmTable)) + "\n") header.append('O29 ' + hexify_short(v.hotSwapCount) + "\n") for i in range(len(v.spliceExtruderPosition)): header.append("O30 D{:0>1d} {}\n".format( v.spliceUsedTool[i], hexify_float(v.spliceExtruderPosition[i]))) for i in range(len(v.spliceAlgorithmTable)): header.append("O32 {}\n".format(v.spliceAlgorithmTable[i])) if len(v.spliceExtruderPosition) > 0: header.append("O1 D{} {}\n".format( job_name, hexify_long(int(v.spliceExtruderPosition[-1] + 0.5)))) else: header.append("O1 D{} {}\n".format( job_name, hexify_long(int(v.totalMaterialExtruded + v.splice_offset + 0.5)))) header.append("M0\n") header.append("T0\n") summary.append(";---------------------:\n") summary.append("; - SPLICE INFORMATION:\n") summary.append(";---------------------:\n") summary.append("; Splice Offset = {:-8.2f}mm\n\n".format( v.splice_offset)) for i in range(len(v.spliceExtruderPosition)): summary.append( ";{:04} Tool: {} Location: {:-8.2f}mm length {:-8.2f}mm \n". format( i + 1, v.spliceUsedTool[i], v.spliceExtruderPosition[i], v.spliceLength[i], )) summary.append("\n") summary.append(";-------------------:\n") summary.append("; - PING INFORMATION:\n") summary.append(";-------------------:\n") for i in range(len(v.pingExtruderPosition)): summary.append(";Ping {:04} at {:-8.2f}mm\n".format( i + 1, v.pingExtruderPosition[i])) if v.side_wipe and v.side_wipe_loc == "": log_warning("Using sidewipe with undefined SIDEWIPELOC!!!") warnings.append("\n") warnings.append(";-------------------:\n") warnings.append("; - PROCESS WARNINGS:\n") warnings.append(";-------------------:\n") warnings.append(";Generated with P2PP version {}\n".format(v.version)) if len(v.processWarnings) == 0: warnings.append(";None\n") else: for i in range(len(v.processWarnings)): warnings.append("{}\n".format(v.processWarnings[i])) gui.show_warnings(warnings) return {'header': header, 'summary': summary, 'warnings': warnings}
def algorithm_create_process_string(heating, compression, cooling): return "{} {} {}".format(hexify_short(int(heating)), hexify_short(int(compression)), hexify_short(int(cooling)))
def header_generateomegaheader(job_name, splice_offset): if v.printerProfileString == '': log_warning( "Printerprofile identifier is missing, add \n;P2PP PRINTERPROFILE=<your printer profile ID> to the Printer Start GCode block\n" ) if len(v.spliceExtruderPosition) == 0: log_warning("This does not look lie a multi color file......\n") algorithm_createtable() header = [] summary = [] warnings = [] header.append('O21 ' + hexify_short(20) + "\n") # MSF2.0 header.append('O22 D' + v.printerProfileString.strip("\n") + "\n") # printerprofile used in Palette2 header.append('O23 D0001' + "\n") # unused header.append('O24 D0000' + "\n") # unused header.append("O25 ") for i in range(4): if v.paletteInputsUsed[i]: if v.filamentType[i] == "": log_warning( "Filament #{} is missing Material Type, make sure to add ;P2PP FT=[filament_type] to filament GCode" .format(i)) if v.filemantDescription[i] == "Unnamed": log_warning( "Filament #{} is missing job_name, make sure to add ;P2PP FN=[filament_preset] to filament GCode" .format(i)) if v.filemantDescription[i] == "-": log_warning( "Filament #{} is missing Color info, make sure to add ;P2PP FC=[extruder_colour] to filament GCode" .format(i)) v.filemantDescription[i] = '000000' header.append("D{}{}{} ".format( i + 1, v.filamentColorCode[i].strip("\n"), v.filemantDescription[i].strip("\n"))) else: header.append("D0 ") header.append("\n") header.append('O26 ' + hexify_short(len(v.spliceExtruderPosition)) + "\n") header.append('O27 ' + hexify_short(len(v.pingExtruderPosition)) + "\n") header.append('O28 ' + hexify_short(len(v.spliceAlgorithmTable)) + "\n") header.append('O29 ' + hexify_short(v.hotSwapCount) + "\n") for i in range(len(v.spliceExtruderPosition)): header.append("O30 D{:0>1d} {}\n".format( v.spliceUsedTool[i], hexify_float(v.spliceExtruderPosition[i]))) for i in range(len(v.spliceAlgorithmTable)): header.append("O32 {}\n".format(v.spliceAlgorithmTable[i])) if len(v.spliceExtruderPosition) > 0: header.append("O1 D{} {}\n".format( job_name, hexify_float(v.spliceExtruderPosition[-1]))) else: header.append("O1 D{} {}\n".format( job_name, hexify_float(v.totalMaterialExtruded + splice_offset))) header.append("M0\n") header.append("T0\n") summary.append(";------------------:\n") summary.append(";SPLICE INFORMATION:\n") summary.append(";------------------:\n") summary.append( "; Splice Offset = {:-8.2f}mm\n\n".format(splice_offset)) for i in range(len(v.spliceExtruderPosition)): summary.append( ";{:04} Tool: {} Location: {:-8.2f}mm length {:-8.2f}mm \n". format( i + 1, v.spliceUsedTool[i], v.spliceExtruderPosition[i], v.spliceLength[i], )) summary.append("\n") summary.append(";------------------:\n") summary.append(";PING INFORMATION:\n") summary.append(";------------------:\n") for i in range(len(v.pingExtruderPosition)): summary.append(";Ping {:04} at {:-8.2f}mm\n".format( i + 1, v.pingExtruderPosition[i])) warnings.append("\n") warnings.append(";------------------:\n") warnings.append(";PROCESS WARNINGS:\n") warnings.append(";------------------:\n") if len(v.processWarnings) == 0: warnings.append(";None\n") else: for i in range(len(v.processWarnings)): warnings.append("{}\n".format(v.processWarnings[i])) gui.show_warnings(warnings) return {'header': header, 'summary': summary, 'warnings': warnings}
def omegaheader(): header = [] header.append('O21 ' + hexify_short(20) + "\n") if v.printerid: header.append('O22 D' + v.printerid.strip("\n") + "\n") else: error(";P2PP PRINTERPROFILE command is missing from configuration") header.append('O23 D0001' + "\n") # unused header.append('O24 D0000' + "\n") # unused toolinfo = ["D0", "D0", "D0", "D0" ] materials = {} for i in range(4): if v.toolsused[i] and v.filament_type[i] not in materials.keys(): materials[v.filament_type[i]] = len(materials.keys())+1 for i in range(4): if v.toolsused[i]: toolinfo[i] = "D{}000000input{}_{}".format(materials[v.filament_type[i]], i,v.filament_type[i]) header.append('O25 {} {} {} {}'.format(toolinfo[0],toolinfo[1],toolinfo[2],toolinfo[3]) + "\n") header.append('O26 ' + hexify_short(len(v.toolchangeinfo)) + "\n") header.append('O27 ' + hexify_short(len(v.pingpositions)) + "\n") header.append('O28 ' + hexify_short(len(v.algooverview)) + "\n") previous_change = 0 header.append('O29 ' + hexify_short(0) + "\n") v.processcomments.append("\n") v.processcomments.append(";------------------------------------\n") v.processcomments.append(";SPLICE INFORMATION - {} SPLICES\n".format(len(v.toolchangeinfo))) v.processcomments.append(";------------------------------------\n") previoussplice = 0 for i in range(len(v.toolchangeinfo)): nextpos = v.toolchangeinfo[i]["E"] if previous_change==0 and nextpos < 100: error("First splice is {:.1f}mm too short. Try adding brim or skirt".format(100-nextpos)) else: splicelength = nextpos - previous_change if splicelength < 70: error("Short splice {} is {:.1f}mm too short. Try increasing purge".format(i+1, 70-splicelength)) previous_change = nextpos header.append("O30 D{:0>1d} {}\n".format(v.toolchangeinfo[i]["Tool"], hexify_float(nextpos))) v.processcomments.append(";Tool {} Length {:.2f}mm\n".format(v.toolchangeinfo[i]["Tool"], nextpos-previoussplice)) previoussplice = nextpos v.processcomments.append("\n") v.processcomments.append("\n") v.processcomments.append(";------------------------------------\n") v.processcomments.append(";PING INFORMATION - {} PINGS\n".format(len(v.pingpositions))) v.processcomments.append(";------------------------------------\n") for i in range( len(v.pingpositions)): v.processcomments.append(";PING {:>4} at {:8.2f}mm\n".format(i,v.pingpositions[i])) v.processcomments.append("\n") if not "DEFAULT" in v.algorithm.keys(): v.algorithm['DEFAULT'] = (0,0,0) if check_tooldefs(): for algo in v.algooverview: fils = algo.split("_") if algo in v.algorithm.keys(): info = v.algorithm[algo] else: info = v.algorithm["DEFAULT"] process = "{} {} {}".format(hexify_short(int(info[0])), hexify_short(int(info[1])), hexify_short(int(info[2])) ) header.append("O32 D{}{} {}\n".format(materials[fils[0]],materials[fils[1]],process)) header.append("O1 D{} {}\n" .format("_S3D_P2PP_PRINT_", hexify_long(int(v.total_extrusion + v.extra_extrusion_at_end)))) header.append("M0\nT0\n\n") header = header + v.processcomments header.append(";--- END OF P2 HEADER ---\n") header.append("\n") return header