Esempio n. 1
0
def gcode_process_toolchange(new_tool, location):
    # some commands are generated at the end to unload filament,
    # they appear as a reload of current filament - messing up things
    if new_tool == v.currentTool:
        return

    location += v.splice_offset

    if new_tool == -1:
        location += v.extraRunoutFilament
    else:
        v.paletteInputsUsed[new_tool] = True

    length = location - v.previousToolChangeLocation

    if v.currentTool != -1:
        v.spliceExtruderPosition.append(location)
        v.spliceLength.append(length)
        v.spliceUsedTool.append(v.currentTool)

        if len(v.spliceExtruderPosition) == 1:
            if v.spliceLength[0] < v.minimalStartSpliceLength:
                log_warning(
                    "Warning : Short first splice (<{}mm) Length:{:-3.2f}".
                    format(length, v.minimalStartSpliceLength))
        else:
            if v.spliceLength[-1] < v.minimalSpliceLength:
                log_warning(
                    "Warning: Short splice (<{}mm) Length:{:-3.2f} Layer:{} Input:{}"
                    .format(v.minimalSpliceLength, length, v.current_layer,
                            v.currentTool))

    v.previousToolChangeLocation = location
    v.currentTool = new_tool
Esempio n. 2
0
def algorithm_create_table():
    splice_list = []
    for i in range(4):
        for j in range(4):

            if i == j:
                continue
            try:
                algo_key = "{}{}".format(
                    v.usedFilamentTypes.index(v.filamentType[i]) + 1,
                    v.usedFilamentTypes.index(v.filamentType[j]) + 1)
                if algo_key in splice_list:
                    continue
            except:
                continue

            if not algorithm_transition_used(i, j):
                continue

            splice_list.append(algo_key)

            try:
                algo = v.spliceAlgorithmDictionary["{}-{}".format(
                    v.filamentType[i], v.filamentType[j])]
            except KeyError:
                log_warning("WARNING: No Algorithm defined for transitioning" +
                            " {} to {}. Using Default".format(
                                v.filamentType[i], v.filamentType[j]))
                algo = v.defaultSpliceAlgorithm

            v.spliceAlgorithmTable.append("D{} {}".format(algo_key, algo))
Esempio n. 3
0
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}
Esempio n. 4
0
def check_config_parameters(gcode_line):
    # BASIC SETUP  (material setup handled in mcf.py)

    if gcode_line.startswith(
            ";P2PP PRINTERPROFILE="
    ) and v.printerProfileString == '':  # -p takes precedence over printer defined in file
        v.printerProfileString = gcode_line[21:]

    if gcode_line.startswith(";P2PP SPLICEOFFSET="):
        v.splice_offset = float(gcode_line[19:])

    if gcode_line.startswith(";P2PP EXTRAENDFILAMENT="):
        v.extraRunoutFilament = float(gcode_line[23:])

    if gcode_line.startswith(";P2PP BEFORESIDEWIPEGCODE"):
        v.before_sidewipe_gcode.append(gcode_line[25:].strip())

    if gcode_line.startswith(";P2PP AFTERSIDEWIPEGCODE"):
        v.after_sidewipe_gcode.append(gcode_line[24:].strip())

    if gcode_line.startswith(";P2PP MINSTARTSPLICE="):
        v.minimalStartSpliceLength = float(gcode_line[21:])
        if v.minimalStartSpliceLength < 100:
            v.minimalStartSpliceLength = 100
            log_warning("Minimal first slice length adjusted to 100mm")

    if gcode_line.startswith(";P2PP BEDSIZEX="):
        v.bed_size_x = float(gcode_line[15:])
    if gcode_line.startswith(";P2PP BEDSIZEY="):
        v.bed_size_y = float(gcode_line[15:])
    if gcode_line.startswith(";P2PP BEDORIGINX="):
        v.bed_origin_x = float(gcode_line[17:])
    if gcode_line.startswith(";P2PP BEDORIGINY="):
        v.bed_origin_y = float(gcode_line[17:])

    if gcode_line.startswith(";P2PP MINSPLICE="):
        v.minimalSpliceLength = float(gcode_line[16:])
        if v.minimalSpliceLength < 70:
            v.minimalSpliceLength = 70
            log_warning("Minimal slice length adjusted to 70mm")

    # LINEAR PING
    if gcode_line.startswith(";P2PP LINEARPING"):
        v.pingLengthMultiplier = 1.0

    if gcode_line.startswith(";P2PP LINEARPINGLENGTH="):
        v.pingIntervalLength = float(gcode_line[23:])
        if (v.pingIntervalLength < 350):
            v.pingIntervalLength = 300
            log_warning(
                "Minimal Linear Ping distance is 300mm!  Your config statet: {}"
                .format(gcode_line))

    # SIDE TRANSITIONING
    if gcode_line.startswith(";P2PP SIDEWIPELOC="):
        v.side_wipe_loc = gcode_line[18:].strip()

    if gcode_line.startswith(";P2PP WIPEFEEDRATE="):
        v.wipeFeedRate = float(gcode_line[19:].strip())

    if gcode_line.startswith(";P2PP SIDEWIPEMINY="):
        v.sideWipeMinY = float(gcode_line[19:])

    if gcode_line.startswith(";P2PP SIDEWIPEMAXY="):
        v.sideWipeMaxY = float(gcode_line[19:])

    if gcode_line.startswith(";P2PP SIDEWIPECORRECTION="):
        v.sidewipecorrection = float(gcode_line[26:])
        if v.sidewipecorrection < 0.9 or v.sidewipecorrection > 1.10:
            v.sidewipecorrection = 1.0

    # REPRAP COMPATIBILITY
    if gcode_line.startswith(";P2PP REPRAPCOMPATIBLE"):
        v.reprap_compatible = True