def generatesummary(): summary = [ ";---------------------\n", "; - SPLICE INFORMATION-\n", ";---------------------\n", "; Splice Offset = {:-8.2f}mm\n\n".format(v.splice_offset) ] for i in range(len(v.splice_extruder_position)): if i == 0: pos = 0 else: pos = v.splice_extruder_position[i - 1] summary.append( ";{:04} Tool: {} Location: {:-8.2f}mm length {:-8.2f}mm ({})\n" .format(i + 1, v.splice_used_tool[i], pos, v.splice_length[i], hexify_float(pos))) summary.append("\n") summary.append(";-------------------\n") summary.append("; - PING INFORMATION-\n") summary.append(";-------------------\n") for i in range(len(v.ping_extruder_position)): pingtext = ";Ping {:04} at {:-8.2f}mm ({})\n".format( i + 1, v.ping_extruder_position[i], hexify_float(v.ping_extruder_position[i])) summary.append(pingtext) if v.side_wipe and v.side_wipe_loc == "": gui.log_warning("Using sidewipe with undefined SIDEWIPELOC!!!") return summary
def generatesummary(): summary = [] summary.append(";---------------------\n") summary.append("; - COLORS DEFINED -\n") summary.append(";---------------------\n") summary.append(";Number of extruders defined in PrusaSlicer: {}\n".format( v.m4c_numberoffilaments)) summary.append(";Number of color swaps in this print: {}\n".format( len(v.m4c_late_warning))) summary.append(";Filament defined for this print:\n") for i in range(v.m4c_numberoffilaments): try: id = v.filament_ids[i] except IndexError: id = "" summary.append(";. Filament {} - Color Code {} - {:20} {}\n".format( i + 1, v.filament_color_code[i], find_nearest_colour(v.filament_color_code[i].strip("\n")), id)) summary.append("\n") summary.append(";---------------------\n") summary.append("; - SPLICE INFORMATION-\n") summary.append(";---------------------\n") summary.append("; Splice Offset = {:-8.2f}mm\n".format( v.splice_offset)) summary.append("; Autoloading Offset = {:-8.2f}mm\n\n".format( v.autoloadingoffset)) for i in range(len(v.splice_extruder_position)): if i == 0: pos = 0 else: pos = v.splice_extruder_position[i - 1] summary.append( ";{:04} Input: {} Location: {:-8.2f}mm length {:-8.2f}mm ({})\n" .format(i + 1, v.splice_used_tool[i] + 1, pos, v.splice_length[i], hexify_float(pos))) summary.append("\n") summary.append(";-------------------\n") summary.append("; - PING INFORMATION-\n") summary.append(";-------------------\n") for i in range(len(v.ping_extruder_position)): pingtext = ";Ping {:04} at {:-8.2f}mm ({})\n".format( i + 1, v.ping_extruder_position[i], hexify_float(v.ping_extruder_position[i])) summary.append(pingtext) if v.side_wipe and v.side_wipe_loc == "" and not v.bigbrain3d_purge_enabled: gui.log_warning("Using sidewipe with undefined SIDEWIPELOC!!!") return summary
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 check_connected_ping(): if not v.accessory_mode and check_first_ping_condition(): v.ping_interval = v.ping_interval * v.ping_length_multiplier v.ping_interval = min(v.max_ping_interval, v.ping_interval) v.last_ping_extruder_position = v.total_material_extruded v.ping_extruder_position.append(v.last_ping_extruder_position) gcode.issue_code( "; --- P2PP - Added Sequence - INITIATE PING - START COMMAND after {:-10.4f}mm of extrusion \n".format( v.last_ping_extruder_position)) gcode.issue_code("G4 S0 \n") gcode.issue_code("O31 {}\n".format(hexify_float(v.last_ping_extruder_position + v.autoloadingoffset))) gcode.issue_code("; --- P2PP - Added Sequence - INITIATE PING - END\n")
def issue_command(self): v.output_code.append(self.__str__()) if self.E and self.is_movement_command(): # perform ping checks v.total_extrusion += self.E * v.extrusion_multiplier if v.total_extrusion - v.lastping >= v.pinglength: v.pingpositions.append(v.total_extrusion) v.output_code.append(";----------------------------------\n") v.output_code.append( "; P2 PING {} COMMAND AT {:.3f}mm\n".format(len(v.pingpositions), v.total_extrusion)) v.output_code.append("O31 {}\n".format(hexify_float(v.total_extrusion))) v.output_code.append(";----------------------------------\n") v.lastping = v.total_extrusion v.pinglength *= v.pingincrease
def check_connected_ping(): if not v.accessory_mode and check_first_ping_condition(): v.ping_interval = v.ping_interval * v.ping_length_multiplier v.ping_interval = min(v.max_ping_interval, v.ping_interval) v.last_ping_extruder_position = v.total_material_extruded v.ping_extruder_position.append(v.last_ping_extruder_position) gcode.issue_code( "; --- P2PP - INSERT PING CODE {} after {:-10.4f}mm of extrusion".format(len(v.ping_extruder_position), v.last_ping_extruder_position)) # wait for the planning buffer to clear gcode.issue_code(v.finish_moves) # insert O31 commands format depending on device if v.palette3: gcode.issue_code("O31 L{:.2f} mm".format(v.last_ping_extruder_position + v.autoloadingoffset)) else: gcode.issue_code("O31 {}".format(hexify_float(v.last_ping_extruder_position + v.autoloadingoffset))) gcode.issue_code("; --- P2PP - END PING CODE", True)
def gcode_parseline(gcode_full_line): __tower_remove = False if not gcode_full_line[0] == ";": gcode_full_line = gcode_full_line.split(';')[0] gcode_full_line = gcode_full_line.rstrip('\n') if gcode_full_line == "": v.processedGCode.append("\n") return if gcode_full_line.startswith('T'): new_tool = int(gcode_full_line[1]) gcode_process_toolchange(new_tool, v.totalMaterialExtruded) v.allowFilamentInformationUpdate = True v.processedGCode.append(';--- P2PP removed ' + gcode_full_line + "\n") return if v.side_wipe: sidewipe.collect_wipetower_info(gcode_full_line) if v.side_wipe_skip: v.processedGCode.append(";--- P2PP sremoved " + gcode_full_line + "\n") return if moved_in_tower() and v.side_wipe and not v.side_wipe_skip: if not gcode_full_line[0] == ";": v.processedGCode.append(";--- P2PP - Purge Tower - " + gcode_full_line + "\n") gcode_full_line = gcode_remove_params(gcode_full_line, ["X", "Y"]) __tower_remove = True # Processing of extrusion speed commands # ############################################ if gcode_full_line.startswith("M220"): new_feedrate = get_gcode_parameter(gcode_full_line, "S") if new_feedrate != "": v.currentprintFeedrate = new_feedrate / 100 # Processing of extrusion multiplier commands # ############################################ if gcode_full_line.startswith("M221"): new_multiplier = get_gcode_parameter(gcode_full_line, "S") if new_multiplier != "": v.extrusionMultiplier = new_multiplier / 100 # Processing of print head movements ############################################# if v.emptyGrid and (v.wipeFeedRate != 2000): gcode_full_line = gcode_remove_params(gcode_full_line, ["F"]) if gcode_full_line.startswith( "G") and not gcode_full_line.startswith("G28"): to_x = get_gcode_parameter(gcode_full_line, "X") to_y = get_gcode_parameter(gcode_full_line, "Y") prev_x = v.currentPositionX prev_y = v.currentPositionY if to_x != "": v.currentPositionX = float(to_x) if to_y != "": v.currentPositionY = float(to_y) if not coordinate_on_bed(v.currentPositionX, v.currentPositionY) and coordinate_on_bed( prev_x, prev_y): gcode_full_line = ";" + gcode_full_line if gcode_full_line.startswith("G1"): extruder_movement = get_gcode_parameter(gcode_full_line, "E") if extruder_movement != "": extruder_movement = extruder_movement * v.extrusionMultiplier if v.within_tool_change_block and v.side_wipe: v.side_wipe_length += extruder_movement v.totalMaterialExtruded += extruder_movement if (v.totalMaterialExtruded - v.lastPingExtruderPosition) > v.pingIntervalLength and\ v.side_wipe_length == 0: v.pingIntervalLength = v.pingIntervalLength * v.pingLengthMultiplier v.pingIntervalLength = min(v.maxPingIntervalLength, v.pingIntervalLength) v.lastPingExtruderPosition = v.totalMaterialExtruded v.pingExtruderPosition.append(v.lastPingExtruderPosition) v.processedGCode.append(";Palette 2 - PING\n") v.processedGCode.append("G4 S0\n") v.processedGCode.append("O31 {}\n".format( hexify_float(v.lastPingExtruderPosition))) if v.within_tool_change_block and v.side_wipe: if not __tower_remove: v.processedGCode.append(';--- P2PP removed ' + gcode_full_line + "\n") return if not v.within_tool_change_block and v.wipeRetracted: sidewipe.unretract() # Other configuration information # this information should be defined in your Slic3r printer settings, startup GCode ################################################################################### if gcode_full_line.startswith(";P2PP"): parameters.check_config_parameters(gcode_full_line) v.side_wipe = not coordinate_on_bed(v.wipetower_posx, v.wipetower_posy) if gcode_full_line.startswith(";P2PP MATERIAL_"): algorithm_process_material_configuration(gcode_full_line[15:]) if gcode_full_line.startswith("M900"): k_factor = get_gcode_parameter(gcode_full_line, "K") if int(k_factor) > 0: sidewipe.create_side_wipe() v.within_tool_change_block = False v.mmu_unload_remove = False if v.reprap_compatible: v.processedGCode.append(';--- P2PP removed ' + gcode_full_line + "\n") return if gcode_full_line.startswith(";P2PP ENDPURGETOWER"): sidewipe.create_side_wipe() v.within_tool_change_block = False v.mmu_unload_remove = False # Next section(s) clean up the GCode generated for the MMU # specially the rather violent unload/reload required for the MMU2 # special processing for side wipes is required in this section ################################################################# if "CP EMPTY GRID START" in gcode_full_line and v.current_layer > "0": v.emptyGrid = True v.current_print_feed = v.wipeFeedRate / 60 v.processedGCode.append(";P2PP Set wipe speed to {}mm/s\n".format( v.current_print_feed)) v.processedGCode.append("G1 F{}\n".format(v.wipeFeedRate)) if "CP EMPTY GRID END" in gcode_full_line: v.emptyGrid = False if "TOOLCHANGE START" in gcode_full_line: v.allowFilamentInformationUpdate = False v.within_tool_change_block = True sidewipe.sidewipe_toolchange_start() if ("TOOLCHANGE END" in gcode_full_line) and not v.side_wipe: v.within_tool_change_block = False v.mmu_unload_remove = False if "TOOLCHANGE UNLOAD" in gcode_full_line and not v.side_wipe: v.current_print_feed = v.wipeFeedRate / 60 v.mmu_unload_remove = True if v.current_layer != "0": v.processedGCode.append(";P2PP Set wipe speed to {}mm/s\n".format( v.current_print_feed)) v.processedGCode.append("G1 F{}\n".format(v.wipeFeedRate)) else: v.processedGCode.append(";P2PP Set wipe speed to 33.3mm/s\n") v.processedGCode.append("G1 F2000\n") if "TOOLCHANGE WIPE" in gcode_full_line: v.mmu_unload_remove = False if coordinate_on_bed(v.currentPositionX, v.currentPositionY): v.processedGCode.append("G0 X{} Y{}\n".format( v.currentPositionX, v.currentPositionY)) # Layer Information if gcode_full_line.startswith(";LAYER "): v.current_layer = gcode_full_line[7:] if v.mmu_unload_remove: v.processedGCode.append( gcode_filter_toolchange_block(gcode_full_line) + "\n") return if v.within_tool_change_block: v.processedGCode.append( gcode_filter_toolchange_block(gcode_full_line) + "\n") return # Catch All v.processedGCode.append(gcode_full_line + "\n")
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 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 gcode_parseline(splice_offset, gcode_fullline): if not gcode_fullline[0] == ";": gcode_fullline = gcode_fullline.split(';')[0] gcode_fullline = gcode_fullline.rstrip('\n') if len(gcode_fullline) < 2: return {'gcode': gcode_fullline, 'splice_offset': splice_offset} gcode_command2 = gcode_fullline[0:2] gcode_command4 = gcode_fullline[0:4] # Processing of extrusion speed commands # ############################################ if gcode_command4 == "M220": new_feedrate = get_gcode_parameter(gcode_fullline, "S") if new_feedrate != "": v.currentprintFeedrate = new_feedrate / 100 # Processing of extrusion multiplier commands # ############################################ if gcode_command4 == "M221": new_multiplier = get_gcode_parameter(gcode_fullline, "S") if new_multiplier != "": v.extrusionMultiplier = new_multiplier / 100 # Processing of Extruder Movement commands # and generating ping at threshold intervals # ############################################ if gcode_command2 == "G1": extruder_movement = get_gcode_parameter(gcode_fullline, "E") if extruder_movement != "": actual_extrusion_length = extruder_movement * v.extrusionMultiplier v.totalMaterialExtruded += actual_extrusion_length if (v.totalMaterialExtruded - v.lastPingExtruderPosition) > v.pingIntervalLength: v.pingIntervalLength = v.pingIntervalLength * v.pingLengthMultiplier v.pingIntervalLength = min(v.maxPingIntervalLength, v.pingIntervalLength) v.lastPingExtruderPosition = v.totalMaterialExtruded v.pingExtruderPosition.append(v.lastPingExtruderPosition) v.processedGCode.append(";Palette 2 - PING\n") v.processedGCode.append("G4 S0\n") v.processedGCode.append("O31 {}\n".format( hexify_float(v.lastPingExtruderPosition))) # processedGCode.append("M117 PING {:03} {:-8.2f}mm]\n".format(len(pingExtruderPosition), lastPingExtruderPosition)) # Process Toolchanges. Build up the O30 table with Splice info ############################################################## if gcode_fullline[0] == 'T': new_tool = int(gcode_fullline[1]) gcode_processtoolchange(new_tool, v.totalMaterialExtruded, splice_offset) v.allowFilamentInformationUpdate = True return { 'gcode': ';P2PP removed ' + gcode_fullline, 'splice_offset': splice_offset } # Build up the O32 table with Algo info ####################################### if gcode_fullline.startswith( ";P2PP FT=" ) and v.allowFilamentInformationUpdate: # filament type information v.filamentType[v.currentTool] = gcode_fullline[9:].strip("\n") if gcode_fullline.startswith( ";P2PP FN=" ) and v.allowFilamentInformationUpdate: # filament color information p2ppinfo = gcode_fullline[9:].strip( "\n-+!@#$%^&*(){}[];:\"\',.<>/?").replace(" ", "_") v.filemantDescription[v.currentTool] = p2ppinfo if gcode_fullline.startswith( ";P2PP FC=#" ) and v.allowFilamentInformationUpdate: # filament color information p2ppinfo = gcode_fullline[10:] v.filamentColorCode[v.currentTool] = p2ppinfo # Other configuration information # this information should be defined in your Slic3r printer settings, startup GCode ################################################################################### if gcode_fullline.startswith( ";P2PP PRINTERPROFILE=" ) and v.printerProfileString == '': # -p takes precedence over printer defined in file v.printerProfileString = gcode_fullline[21:] if gcode_fullline.startswith(";P2PP SPLICEOFFSET="): splice_offset = float(gcode_fullline[19:]) if gcode_fullline.startswith(";P2PP MINSTARTSPLICE="): v.minimalStartSpliceLength = float(gcode_fullline[21:]) if v.minimalStartSpliceLength < 100: v.minimalStartSpliceLength = 100 if gcode_fullline.startswith(";P2PP MINSPLICE="): v.minimalSpliceLength = float(gcode_fullline[16:]) if v.minimalSpliceLength < 40: v.minimalSpliceLength = 40 if gcode_fullline.startswith(";P2PP MATERIAL_"): algorithm_processmaterialconfiguration(gcode_fullline[15:]) # Next section(s) clean up the GCode generated for the MMU # specially the rather violent unload/reload required for the MMU2 ################################################################### if "TOOLCHANGE START" in gcode_fullline: v.allowFilamentInformationUpdate = False v.withinToolchangeBlock = True if "TOOLCHANGE END" in gcode_fullline: v.withinToolchangeBlock = False if "TOOLCHANGE UNLOAD" in gcode_fullline: v.processedGCode.append(";P2PP Set Wipe Speed\n") v.processedGCode.append("G1 F2000\n") v.currentprintFeed = 2000.0 / 60.0 # Layer Information if gcode_fullline.startswith(";LAYER "): v.currentLayer = gcode_fullline[7:] return {'gcode': gcode_fullline, 'splice_offset': splice_offset} if v.withinToolchangeBlock: return { 'gcode': gcode_filtertoolchangeblock(gcode_fullline, gcode_command2, gcode_command4), 'splice_offset': splice_offset } # Catch All return {'gcode': gcode_fullline, 'splice_offset': splice_offset}
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