Beispiel #1
0
def generate(input_file, output_file, printer_profile, splice_offset, silent):
    starttime = time.time()
    v.printer_profile_string = printer_profile
    basename = os.path.basename(input_file)
    _taskName = os.path.splitext(basename)[0].replace(" ", "_")
    _taskName = _taskName.replace(".mcf", "")

    v.splice_offset = splice_offset

    try:
        # python 3.x
        opf = open(input_file, encoding='utf-8')
    except TypeError:
        try:
            # python 2.x
            opf = open(input_file)
        except IOError:
            if v.gui:
                gui.user_error(
                    "P2PP - Error Occurred",
                    "Could not read input file\n'{}'".format(input_file))
            else:
                print("Could not read input file\n'{}".format(input_file))
            return
    except IOError:
        if v.gui:
            gui.user_error(
                "P2PP - Error Occurred",
                "Could not read input file\n'{}'".format(input_file))
        else:
            print("Could not read input file\n'{}".format(input_file))
        return

    gui.setfilename(input_file)
    gui.set_printer_id(v.printer_profile_string)
    gui.create_logitem("Reading File " + input_file)
    gui.progress_string(1)

    v.input_gcode = opf.readlines()
    opf.close()

    v.input_gcode = [item.strip() for item in v.input_gcode]

    gui.create_logitem("Analyzing slicer parameters")
    gui.progress_string(2)
    parse_slic3r_config()

    gui.create_logitem("Pre-parsing GCode")
    gui.progress_string(4)
    parse_gcode()
    if v.palette_plus:
        if v.palette_plus_ppm == -9:
            gui.log_warning(
                "P+ parameter P+PPM not set correctly in startup GCODE")
        if v.palette_plus_loading_offset == -9:
            gui.log_warning(
                "P+ parameter P+LOADINGOFFSET not set correctly in startup GCODE"
            )

    v.side_wipe = not coordinate_on_bed(v.wipetower_posx, v.wipetower_posy)
    v.tower_delta = v.max_tower_z_delta > 0

    if v.side_wipe:
        gui.create_logitem("Side wipe activated", "blue")
        if v.full_purge_reduction:
            gui.log_warning(
                "Full Purge Reduction is not compatible with Side Wipe, performing Side Wipe"
            )
            v.full_purge_reduction = False

    if v.full_purge_reduction:
        v.side_wipe = False
        gui.create_logitem("Full Tower Reduction activated", "blue")
        if v.tower_delta:
            gui.log_warning(
                "Full Purge Reduction is not compatible with Tower Delta, performing Full Purge Reduction"
            )
            v.tower_delta = False

    v.pathprocessing = (v.tower_delta or v.full_purge_reduction or v.side_wipe)

    if v.tower_delta:
        optimize_tower_skip(v.max_tower_z_delta, v.layer_height)

    if v.side_wipe:
        optimize_tower_skip(999, v.layer_height)

    gui.create_logitem("Generate processed GCode")

    total_line_count = len(v.input_gcode)
    v.retraction = 0
    for process_line_count in range(total_line_count):
        gcode_parseline(process_line_count)
        gui.progress_string(50 + 50 * process_line_count // total_line_count)

    v.processtime = time.time() - starttime

    gcode_process_toolchange(-1, v.total_material_extruded, 0)
    omega_result = header_generate_omega(_taskName)
    header = omega_result['header'] + omega_result['summary'] + omega_result[
        'warnings']

    if v.absolute_extruder and v.gcode_has_relative_e:
        gui.create_logitem("Converting to absolute extrusion")
        convert_to_absolute()

    # write the output file
    ######################

    if not output_file:
        output_file = input_file
    gui.create_logitem("Generating GCODE file: " + output_file)
    opf = open(output_file, "w")
    if not v.accessory_mode:
        opf.writelines(header)
        opf.write("\n\n;--------- START PROCESSED GCODE ----------\n\n")
    if v.accessory_mode:
        opf.write("M0\n")
        opf.write("T0\n")

    if v.splice_offset == 0:
        gui.log_warning("SPLICE_OFFSET not defined")
    opf.writelines(v.processed_gcode)
    opf.close()

    if v.accessory_mode:

        pre, ext = os.path.splitext(output_file)
        if v.palette_plus:
            maffile = pre + ".msf"
        else:
            maffile = pre + ".maf"
        gui.create_logitem("Generating PALETTE MAF/MSF file: " + maffile)
        opf = open(maffile, "w")
        for i in range(len(header)):
            if not header[i].startswith(";"):
                opf.write(header[i])

    gui.print_summary(omega_result['summary'])

    gui.progress_string(100)
    if (len(v.process_warnings) > 0
            and not v.ignore_warnings) or v.consolewait:
        gui.close_button_enable()
Beispiel #2
0
def p2pp_command(command, parameter):
    command = command.upper()

    if command == "LINEARPINGLENGTH":
        v.pinglength = float(parameter)
        v.pingincrease = 1

    if command == "WIPESPEED":
        v.wipe_feedrate = int(parameter)

    if command == "LAYERONEWIPESPEED":
        v.wipe_feedrate1 = int(parameter)

    if command == "TOWERDELTA":
        v.towerdelta = float(parameter)

    if command == "PRINTERPROFILE":
        v.printerid = parameter
        gui.set_printer_id(v.printerid)

    if command == "AUTOTOWER":
        v.autotower = True

    if command == "MAXTOWERDELTA":
        v.towerdelta = float(parameter)

    if command == "EXTRAENDFILAMENT":
        v.extra_extrusion_at_end = float(parameter)

    if command == "SPLICEOFFSET":
        unit = "mm"
        if parameter.endswith("%"):
            parameter = parameter.replace("%", "")
            v.splice_procent = True
            unit = "% of purge length"
        v.spliceoffset = float(parameter)

        comment("Splice offset is {}{}.".format(v.spliceoffset, unit))

    if command == "AUTOEXPANDTOWER":
        v.expand_tower = True

    if command in ["TOOL_0", "TOOL_1", "TOOL_2", "TOOL_3"]:
        m = v.regex_purge_info.match(parameter)
        if m:
            tool = int(command[-1])
            v.filament_type[tool] = m.group(1).upper()
            v.loadinfo[tool] = int(m.group(2))
            v.unloadinfo[tool] = int(m.group(3))

    if command.startswith("MATERIAL"):
        _deflt = "MATERIAL_DEFAULT_(\d+)_(\d+)_(\d+)"
        _algo = "MATERIAL_(\w+_\w+)_(\d+)_(\d+)_(\d+)"

        m = re.search(_algo, command)
        if m:
            v.algorithm["{}".format(m.group(1))] = (int(m.group(2)), int(m.group(3)), int(m.group(4)))
        else:
            m = re.search(_deflt, command)
            if m:
                v.algorithm["DEFAULT"] = (int(m.group(1)), int(m.group(2)), int(m.group(3)))
Beispiel #3
0
def check_config_parameters(line):
    # BASIC SETUP  (material setup handled in mcf.py

    # -p takes precedence over printer defined in file
    if "PRINTERPROFILE" in line:
        tmp_string = stringparameter(line)
        if len(tmp_string) != 16:
            gui.log_warning(
                "Invalid Printer profile!  - Has invalid length (expect 16) - [{}]"
                .format(tmp_string))
            tmp_string = ""
        if not all(char in set("0123456789ABCDEFabcdef")
                   for char in tmp_string):
            gui.log_warning(
                "Invalid Printer profile!  - Invalid characters  (expect 0123456789abcdef) - [{}]"
                .format(tmp_string))
            tmp_string = ""

        if len(tmp_string) == 16:
            v.printer_profile_string = tmp_string
            gui.set_printer_id(v.printer_profile_string)
        return

    if "ACCESSORYMODE_MAF" in line:
        v.accessory_mode = True
        gui.create_logitem("Config: Palette2 Accessory Mode Selected")

    if "ACCESSORYMODE_MSF" in line:
        v.accessory_mode = True
        v.palette_plus = True
        gui.create_logitem("Config: Palette+ Accessory Mode Selected")

    if "P+LOADINGOFFSET" in line:
        v.palette_plus_loading_offset = int(floatparameter(line))

    if "P+PPM" in line:
        v.palette_plus_ppm = int(floatparameter(line))

    if "SPLICEOFFSET" in line:
        v.splice_offset = floatparameter(line)
        gui.create_logitem("Splice Offset set to {:-5.2f}mm".format(
            v.splice_offset))
        return

    if "PROFILETYPEOVERRIDE" in line:
        v.filament_type[v.current_tool] = stringparameter(line)
        v.used_filament_types.append(v.filament_type[v.current_tool])
        v.used_filament_types = list(dict.fromkeys(v.used_filament_types))
        return

    if "EXTRUSIONMULTIPLIERCORRECTION" in line:
        v.filament_type[v.current_tool] = floatparameter(line)
        return

    if "EXTRAENDFILAMENT" in line:
        v.extra_runout_filament = floatparameter(line)
        gui.create_logitem("Extra filament at end of print {:-8.2f}mm".format(
            v.extra_runout_filament))
        return

    if "BEFORESIDEWIPEGCODE" in line:
        v.before_sidewipe_gcode.append(stringparameter(line))
        return

    if "AFTERSIDEWIPEGCODE" in line:
        v.after_sidewipe_gcode.append(stringparameter(line))
        return

    if "MINSTARTSPLICE" in line:
        v.min_start_splice_length = floatparameter(line)
        if v.min_start_splice_length < 100:
            v.min_start_splice_length = 100
            gui.log_warning("Minimal first slice length adjusted to 100mm")
        return

    if "BEDSIZEX" in line:
        v.bed_size_x = floatparameter(line)
        return
    if "BEDSIZEY" in line:
        v.bed_size_y = floatparameter(line)
        return
    if "BEDORIGINX" in line:
        v.bed_origin_x = floatparameter(line)
        return
    if "BEDORIGINY" in line:
        v.bed_origin_y = floatparameter(line)
        return

    if "BIGBRAIN3D_BLOBSIZE" in line:
        v.bigbrain3d_blob_size = int(floatparameter(line))

    if "BIGBRAIN3D_COOLINGTIME" in line:
        v.bigbrain3d_blob_cooling_time = int(floatparameter(line))

    if "BIGBRAIN3D_PURGEPOSITION" in line:
        v.bigbrain3d_x_position = floatparameter(line)

    if "BIGBRAIN3D_MOTORPOWER_HIGH" in line:
        v.bigbrain3d_motorpower_high = int(floatparameter(line))

    if "BIGBRAIN3D_MOTORPOWER_NORMAL" in line:
        v.bigbrain3d_motorpower_normal = int(floatparameter(line))

    if "BIGBRAIN3D_ENABLE" in line:
        v.bigbrain3d_purge_enabled = True
        gui.log_warning(
            "BIGBRAIN3D Will only work with installed hardware on a Prusa Printer"
        )

    if "BIGBRAIN3D_SMARTFAN" in line:
        v.bigbrain3d_smartfan = True

    if "MINSPLICE" in line:
        v.min_splice_length = floatparameter(line)
        if v.min_splice_length < 70:
            v.min_splice_length = 70
            gui.log_warning("Minimal slice length adjusted to 70mm")
        return

    # LINEAR PING removed

    if "LINEARPINGLENGTH" in line:
        v.ping_interval = floatparameter(line)
        v.ping_length_multiplier = 1.0
        if v.ping_interval < 300:
            v.ping_interval = 300
            gui.log_warning(
                "Minimal Linear Ping distance is 300mm!  Your config stated: {}"
                .format(line))
        gui.create_logitem("Linear Ping interval of  {:-6.2f}mm".format(
            v.ping_interval))
        return

    if line.endswith("LINEARPING"):
        gui.log_warning(
            "LINEARPING deprecated, use LINEARPINGLENGTH  parameter instead")
        return

    # SIDE TRANSITIONING
    if "SIDEWIPELOC" in line:
        v.side_wipe_loc = stringparameter(line)
        return

    if "WIPEFEEDRATE" in line:
        v.wipe_feedrate = floatparameter(line)
        return

    if "SIDEWIPEMINY" in line:
        v.sidewipe_miny = floatparameter(line)
        return

    if "SIDEWIPEMAXY" in line:
        v.sidewipe_maxy = floatparameter(line)
        return

    if "SIDEWIPECORRECTION" in line:
        v.sidewipe_correction = floatparameter(line)
        if v.sidewipe_correction < 0.9 or v.sidewipe_correction > 1.10:
            v.sidewipe_correction = 1.0
        return

    if "PURGETOWERDELTA" in line:
        if abs(floatparameter(line)) != abs(float(0)):
            v.max_tower_z_delta = abs(floatparameter(line))
            gui.create_logitem(
                "Max Purge Tower Delta set to {:-2.2f}mm".format(
                    v.max_tower_z_delta))
        return
    if "FULLPURGEREDUCTION" in line:
        gui.create_logitem("Full purge reduction configured")
        v.full_purge_reduction = True

    if line.endswith("CHECKVERSION"):
        import p2pp.checkversion as cv
        import version
        latest = cv.get_version(cv.MASTER)
        if latest > version.Version:
            gui.create_logitem(
                "New development version of P2PP available ({})".format(
                    latest), "red", False, "2.0")
        else:
            if (latest < version.Version):
                latest = cv.get_version(cv.DEV)
                if (latest > version.Version):
                    gui.create_logitem(
                        "New development version of P2PP available ({})".
                        format(latest), "red", False, "2.0")

    # REPRAP COMPATIBILITY
    if "REPRAPCOMPATIBLE" in line:
        v.reprap_compatible = True
        return

    # Program parameters
    if "NOGUI" in line:
        v.gui = False
        return

    if "CONSOLEWAIT" in line:
        v.consolewait = True

    if "IGNOREWARNINGS" in line:
        v.ignore_warnings = True

    if "ABSOLUTEEXTRUDER" in line:
        v.absolute_extruder = True
        gui.create_logitem("Convert to absolute extrusion parameters")
Beispiel #4
0
def check_config_parameters(keyword, value):
    keyword = keyword.upper()
    if value is None:
        value = ""

    if keyword == "TEMPERATURECONTROL":
        v.process_temp = True

    if keyword == "PRINTERPROFILE":

        if len(value) != 16:
            gui.log_warning("Invalid Printer profile!  - Has invalid length (expect 16) - [{}]"
                            .format(value))
            value = ""
        if not all(char in set("0123456789ABCDEFabcdef") for char in value):
            gui.log_warning("Invalid Printer profile!  - Invalid characters  (expect 0123456789abcdef) - [{}]"
                            .format(value))
            value = ""

        if len(value) == 16:
            v.printer_profile_string = value
            gui.set_printer_id(v.printer_profile_string)
        return

    if keyword == "ACCESSORYMODE_MAF":
        v.accessory_mode = True
        gui.create_logitem("Config: Palette2 Accessory Mode Selected")
        return

    if keyword == "ACCESSORYMODE_MSF":
        v.accessory_mode = True
        v.palette_plus = True
        gui.create_logitem("Config: Palette+ Accessory Mode Selected")
        return

    if keyword == "P+LOADINGOFFSET":
        v.palette_plus_loading_offset = int(value)
        return

    if keyword == "P+PPM":
        v.palette_plus_ppm = intparameter(value)
        return

    if keyword == "SPLICEOFFSET":
        v.splice_offset = floatparameter(value)
        gui.create_logitem("Splice Offset set tofiloverride {:-5.2f}mm".format(v.splice_offset))
        return

    if keyword == "PROFILETYPEOVERRIDE":
        v.filament_type[v.set_tool] = value
        v.used_filament_types.append(v.filament_type[v.set_tool])
        v.used_filament_types = list(dict.fromkeys(v.used_filament_types))
        return

    if keyword == "EXTRUSIONMULTIPLIERCORRECTION":
        v.filament_type[v.current_tool] = floatparameter(value)
        return

    if keyword == "EXTRAENDFILAMENT":
        v.extra_runout_filament = floatparameter(value)
        gui.create_logitem("Extra filament at end of print {:-8.2f}mm".format(v.extra_runout_filament))
        return

    if keyword == "BEFORESIDEWIPEGCODE":
        v.before_sidewipe_gcode.append(value)
        return

    if keyword == "AFTERSIDEWIPEGCODE":
        v.after_sidewipe_gcode.append(value)
        return

    if keyword == "AUTOLOADINGOFFSET":
        v.autoloadingoffset = floatparameter(value)
        return

    if keyword == "AUTOADDPURGE":
        v.autoaddsplice = True
        return

    if keyword == "MINSTARTSPLICE":
        v.min_start_splice_length = floatparameter(value)
        if v.min_start_splice_length < 100:
            v.min_start_splice_length = 100
            gui.log_warning("Minimal first slice length adjusted to 100mm")
        return

    if keyword == "BEDSIZEX":
        v.bed_size_x = floatparameter(value)
        return

    if keyword == "BEDSIZEY":
        v.bed_size_y = floatparameter(value)
        return

    if keyword == "BEDORIGINX":
        v.bed_origin_x = floatparameter(value)
        return

    if keyword == "BEDORIGINY":
        v.bed_origin_y = floatparameter(value)
        return

    if keyword == "BIGBRAIN3D_BLOBSIZE":
        v.bigbrain3d_blob_size = intparameter(value)
        return

    if keyword == "BIGBRAIN3D_BLOBSPEED":
        v.bigbrain3d_blob_speed = intparameter(value)
        return

    if keyword == "BIGBRAIN3D_COOLINGTIME":
        v.bigbrain3d_blob_cooling_time = intparameter(value)
        return

    if keyword == "BIGBRAIN3D_PURGEPOSITION":
        v.bigbrain3d_x_position = floatparameter(value)
        return

    if keyword == "BIGBRAIN3D_PURGEYPOSITION":
        v.bigbrain3d_y_position = floatparameter(value)
        return

    if keyword == "BIGBRAIN3D_MOTORPOWER_HIGH":
        v.bigbrain3d_motorpower_high = intparameter(value)
        return

    if keyword == "BIGBRAIN3D_MOTORPOWER_NORMAL":
        v.bigbrain3d_motorpower_normal = intparameter(value)
        return

    if keyword == "BIGBRAIN3D_NUMBER_OF_WHACKS":
        v.bigbrain3d_whacks = intparameter(value)
        return

    if keyword == "BIGBRAIN3D_PRIME_BLOBS":
        v.bigbrain3d_prime = intparameter(value)
        return

    if keyword == "BIGBRAIN3D_FAN_OFF_PAUSE":
        v.bigbrain3d_fanoffdelay = intparameter(value)
        return

    if keyword == "BIGBRAIN3D_LEFT_SIDE":
        v.bigbrain3d_left = -1
        return

    if keyword == "BIGBRAIN3D_ENABLE":
        if not v.wipe_remove_sparse_layers:
            v.bigbrain3d_purge_enabled = True
            gui.log_warning("BIGBRAIN3D Will only work with installed hardware on a Prusa Printer")
        else:
            gui.log_warning("BIGBRAIN3D mode not compatible with sparse wipe tower in PS")
        return

    if keyword == "BIGBRAIN3D_SMARTFAN":
        v.bigbrain3d_smartfan = True
        return

    if keyword == "MINSPLICE":
        v.min_splice_length = floatparameter(value)
        if v.min_splice_length < 70:
            v.min_splice_length = 70
            gui.log_warning("Minimal slice length adjusted to 70mm")
        return

    # LINEAR PING removed

    if keyword == "LINEARPINGLENGTH":
        v.ping_interval = floatparameter(value)
        v.ping_length_multiplier = 1.0
        if v.ping_interval < 300:
            v.ping_interval = 300
            gui.log_warning("Minimal Linear Ping distance is 300mm!  Your config stated: {}".format(line))
        gui.create_logitem("Linear Ping interval of  {:-6.2f}mm".format(v.ping_interval))
        return

    # SIDE TRANSITIONING
    if keyword == "SIDEWIPELOC":
        v.side_wipe_loc = value
        return

    if keyword == "PURGETOPSPEED":
        v.purgetopspeed = int(floatparameter(value))
        gui.create_logitem("Purge Max speed set to {:.0f}mm/min ({}mm/s)".format(v.purgetopspeed, v.purgetopspeed / 60))
        return

    if keyword == "WIPEFEEDRATE":
        v.wipe_feedrate = floatparameter(value)
        return

    if keyword == "SIDEWIPEMINY":
        v.sidewipe_miny = floatparameter(value)
        return

    if keyword == "SIDEWIPEMAXY":
        v.sidewipe_maxy = floatparameter(value)
        return

    if keyword == "SIDEWIPECORRECTION":
        v.sidewipe_correction = floatparameter(value)
        if v.sidewipe_correction < 0.9 or v.sidewipe_correction > 1.10:
            v.sidewipe_correction = 1.0
        return

    if keyword == "PURGETOWERDELTA":
        parm = abs(floatparameter(value))
        if parm > 0.001 and v.wipe_remove_sparse_layers:
            gui.log_warning("TOWER DELTA feature mode not compatible with sparse wipe tower in PS")
            v.max_tower_delta = 0.0
        else:
            if parm != float(0):
                v.max_tower_z_delta = abs(floatparameter(value))
                gui.create_logitem("Max Purge Tower Delta set to {:-2.2f}mm".format(v.max_tower_z_delta))


        return

    if keyword == "FULLPURGEREDUCTION":
        if not v.wipe_remove_sparse_layers:
            gui.create_logitem("Full purge reduction configured")
            v.full_purge_reduction = True
        else:
            gui.log_warning("FULL PURGE TOWER REDUCTION feature mode not compatible with sparse wipe tower in PS")
            v.full_purge_reduction = False
        return

    if keyword == "CHECKVERSION":
        import p2pp.checkversion as cv
        import version
        latest = cv.get_version(cv.MASTER)
        if latest > version.Version:
            gui.create_logitem("New development version of P2PP available ({})".format(latest), "red", False, "2.0")
        else:
            if (latest < version.Version):
                latest = cv.get_version(cv.DEV)
                if (latest > version.Version):
                    gui.create_logitem("New development version of P2PP available ({})".format(latest), "red", False,
                                       "2.0")

    # Program parameters
    if keyword == "NOGUI":
        v.gui = False
        return

    if keyword == "CONSOLEWAIT":
        v.consolewait = True
        return

    if keyword == "IGNOREWARNINGS":
        v.ignore_warnings = True
        return

    if keyword == "ABSOLUTEEXTRUDER":
        v.absolute_extruder = True
        gui.create_logitem("Convert to absolute extrusion parameters")
        return

    if keyword == "DEBUGTCOMMAND":
        v.debug_leaveToolCommands = True
        gui.log_warning("DEBUGTCOMMAND ACTIVE - File will not print correctly!!")
        return
Beispiel #5
0
def generate(input_file, output_file, printer_profile, splice_offset, silent):
    starttime = time.time()
    v.printer_profile_string = printer_profile
    basename = os.path.basename(input_file)
    _taskName = os.path.splitext(basename)[0].replace(" ", "_")
    _taskName = _taskName.replace(".mcf", "")

    v.splice_offset = splice_offset

    try:
        # python 3.x
        opf = open(input_file, encoding='utf-8')
    except TypeError:
        try:
            # python 2.x
            opf = open(input_file)
        except IOError:
            if v.gui:
                gui.user_error("P2PP - Error Occurred", "Could not read input file\n'{}'".format(input_file))
            else:
                print ("Could not read input file\n'{}".format(input_file))
            return
    except IOError:
        if v.gui:
            gui.user_error("P2PP - Error Occurred", "Could not read input file\n'{}'".format(input_file))
        else:
            print ("Could not read input file\n'{}".format(input_file))
        return

    gui.setfilename(input_file)
    gui.set_printer_id(v.printer_profile_string)
    gui.create_logitem("Reading File " + input_file)
    gui.progress_string(1)

    v.input_gcode = opf.readlines()
    opf.close()

    v.input_gcode = [item.strip() for item in v.input_gcode]

    gui.create_logitem("Analyzing slicer parameters")
    gui.progress_string(2)
    parse_slic3r_config()

    gui.create_logitem("Pre-parsing GCode")
    gui.progress_string(4)
    parse_gcode()

    if v.tower_delta or v.full_purge_reduction:
        if v.variable_layer:
            gui.log_warning("Variable layers are not compatible with fullpruge/tower delta")

    if v.process_temp and v.side_wipe:
        gui.log_warning("TEMPERATURECONTROL and Side Wipe / BigBrain3D are not compatible")

    if v.palette_plus:
        if v.palette_plus_ppm == -9:
            gui.log_warning("P+ parameter P+PPM not set correctly in startup GCODE")
        if v.palette_plus_loading_offset == -9:
            gui.log_warning("P+ parameter P+LOADINGOFFSET not set correctly in startup GCODE")

    v.side_wipe = not coordinate_on_bed(v.wipetower_posx, v.wipetower_posy)
    v.tower_delta = v.max_tower_z_delta > 0

    gui.create_logitem("Creating tool usage information")
    m4c.calculate_loadscheme()


    if v.side_wipe:

        if v.skirts and v.ps_version > "2.2":
            gui.log_warning("SIDEWIPE and SKIRTS are NOT compatible in PS2.2 or later")
            gui.log_warning("THIS FILE WILL NOT PRINT CORRECTLY")

        if v.wipe_remove_sparse_layers:
            gui.log_warning("SIDE WIPE mode not compatible with sparse wipe tower in PS")
            gui.log_warning("THIS FILE WILL NOT PRINT CORRECTLY")

        gui.create_logitem("Side wipe activated", "blue")
        if v.full_purge_reduction:
            gui.log_warning("Full Purge Reduction is not compatible with Side Wipe, performing Side Wipe")
            v.full_purge_reduction = False



    if v.full_purge_reduction:
        v.side_wipe = False
        gui.create_logitem("Full Tower Reduction activated", "blue")
        if v.tower_delta:
            gui.log_warning("Full Purge Reduction is not compatible with Tower Delta, performing Full Purge Reduction")
            v.tower_delta = False

    v.pathprocessing = (v.tower_delta or v.full_purge_reduction or v.side_wipe)

    if v.autoaddsplice and not v.full_purge_reduction and not v.side_wipe:
        gui.log_warning("AUTOEDDPURGE only works with side wipe and fullpurgereduction at this moment")

    if (len(v.skippable_layer) == 0) and v.pathprocessing:
        gui.log_warning("LAYER configuration is missing. NO OUTPUT FILE GENERATED.")
        gui.log_warning("Check the P2PP documentation for furhter info.")
    else:

        if v.tower_delta:
            optimize_tower_skip(v.max_tower_z_delta, v.layer_height)

        if v.side_wipe:
            optimize_tower_skip(999, v.layer_height)

        gui.create_logitem("Generate processed GCode")

        total_line_count = len(v.input_gcode)
        v.retraction = 0
        for process_line_count in range(total_line_count):
            gcode_parseline(process_line_count)
            gui.progress_string(50 + 50 * process_line_count // total_line_count)

        v.processtime = time.time() - starttime

        gcode_process_toolchange(-1, v.total_material_extruded, 0)
        omega_result = header_generate_omega(_taskName)
        header = omega_result['header'] + omega_result['summary'] + omega_result['warnings']

        if v.absolute_extruder and v.gcode_has_relative_e:
            gui.create_logitem("Converting to absolute extrusion")
            convert_to_absolute()

        # write the output file
        ######################

        if not output_file:
            output_file = input_file
        gui.create_logitem("Generating GCODE file: " + output_file)
        opf = open(output_file, "w")
        if not v.accessory_mode:
            opf.writelines(header)
            opf.write("\n\n;--------- START PROCESSED GCODE ----------\n\n")
        if v.accessory_mode:
            opf.write("M0\n")
            opf.write("T0\n")

        if v.splice_offset == 0:
            gui.log_warning("SPLICE_OFFSET not defined")
        opf.writelines(v.processed_gcode)
        opf.close()

        if v.accessory_mode:

            pre, ext = os.path.splitext(output_file)
            if v.palette_plus:
                maffile = pre + ".msf"
            else:
                maffile = pre + ".maf"
            gui.create_logitem("Generating PALETTE MAF/MSF file: " + maffile)


            maf = open(maffile, 'w')

            for h in header:
                h = h.strip('\r\n')
                maf.write(unicode(h))
                maf.write('\r\n')
            maf.close()
            #
            # with io.open(maffile, 'w', newline='\r\n') as maf:
            #
            #     for i in range(len(header)):
            #         h = header[i].strip('\n\r') + "\n"
            #         if not h.startswith(";"):
            #             try:
            #                 maf.write(unicode(h))
            #             except:
            #                 maf.write(h)


        gui.print_summary(omega_result['summary'])

    gui.progress_string(100)
    if (len(v.process_warnings) > 0 and not v.ignore_warnings) or v.consolewait:
        gui.close_button_enable()