Esempio n. 1
0
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
Esempio n. 2
0
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
Esempio n. 3
0
def create_colordefinition(input, filament_type, color_code, filamentused):
    global color_count
    color_count += 1
    tagname = "color" + str(color_count)
    color_count += 1
    tagname2 = "color" + str(color_count)
    loglist.tag_configure(tagname, foreground='black')
    loglist.tag_configure(tagname2, foreground="#" + color_code)
    loglist.insert(
        tkinter.END,
        "  \tInput  {} {:-8.2f}mm - {} ".format(input, filamentused,
                                                filament_type), tagname)
    loglist.insert(tkinter.END, "  \t[####]\t", tagname2)
    loglist.insert(
        tkinter.END,
        "  \t{}\n".format(colornames.find_nearest_colour(color_code)), tagname)
Esempio n. 4
0
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}
Esempio n. 5
0
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}
Esempio n. 6
0
def create_colordefinition(reporttype, p2_input, filament_type, color_code, filamentused):

    name = "----"
    if reporttype == 0:
        name = "Input"
    if reporttype == 1:
        name = "Filament"

    try:
        filament_id = v.filament_ids[p2_input - 1]
    except IndexError:
        filament_id = ""

    word = ''
    if reporttype == 0:
        word = "  \t{}  {} {:-8.2f}mm - {} <span style=\" color: #{};\">[######]</span>   \t{:15} {} ".format(name, p2_input, filamentused, filament_type, color_code, colornames.find_nearest_colour(color_code), filament_id)

    if reporttype == 1:
        word = "  \t{}  {}  - {} <span style=\" color: #{};\">[######]]</span>   \t{:15} {}".format(name, p2_input, filament_type, color_code, colornames.find_nearest_colour(color_code), filament_id)

    form.textBrowser.append(word)
Esempio n. 7
0
def generate_meta():
    fila = []
    lena = {}
    vola = {}
    inputsused = 0

    if v.palette3 and len(v.splice_extruder_position) < 2:
        try:
            drive_used = v.splice_used_tool[0] + 1
        except IndexError:
            drive_used = 1
        v.palette_inputs_used[drive_used - 1] = True

    for i in range(v.colors):
        if v.palette_inputs_used[i]:
            inputsused += 1
            fila.append({
                "materialId":
                v.used_filament_types.index(v.filament_type[i]) + 1,
                "filamentId":
                i + 1,
                "type":
                v.filament_type[i],
                "name":
                find_nearest_colour(v.filament_color_code[i]),
                "color":
                "#" + v.filament_color_code[i].strip("\n")
            })
            try:
                if i == v.splice_used_tool[0]:
                    add = v.splice_offset
                else:
                    add = 0
            except IndexError:
                add = 0

            if v.palette3 and len(v.splice_extruder_position) < 2:
                lena[str(i + 1)] = int(v.total_material_extruded + 0.5 +
                                       v.autoloadingoffset)
                vola[str(i + 1)] = int(
                    purgetower.volfromlength(v.total_material_extruded + 0.5 +
                                             v.autoloadingoffset))
            else:
                lena[str(i + 1)] = int(v.material_extruded_per_color[i] + add)
                vola[str(i + 1)] = int(
                    purgetower.volfromlength(v.material_extruded_per_color[i] +
                                             add))

    bounding_box = {
        "min": [v.bb_minx, v.bb_miny, v.bb_minz],
        "max": [v.bb_maxx, v.bb_maxy, v.bb_maxz]
    }

    splice_count = len(v.splice_extruder_position)

    if v.palette3 and splice_count == 0:
        splice_count = 1

    metafile = {
        "version":
        "3.2",
        "setupId":
        "null",
        "printerProfile": {
            "id": v.printer_profile_string,
            "name": v.p3_printername
        },
        "preheatTemperature": {
            "nozzle": [0],
            "bed": 0
        },
        "paletteNozzle":
        0,
        "time":
        v.printing_time,
        "length":
        lena,
        "totalLength":
        int(v.total_material_extruded + 0.5 + v.autoloadingoffset),
        "volume":
        vola,
        "totalVolume":
        int(
            purgetower.volfromlength(v.total_material_extruded + 0.5 +
                                     v.autoloadingoffset)),
        "inputsUsed":
        inputsused,
        "splices":
        splice_count,
        "pings":
        len(v.ping_extruder_position),
        "boundingBox":
        bounding_box,
        "filaments":
        fila
    }

    if v.p3_process_preheat:
        try:
            if v.palette3 and len(v.splice_extruder_position) < 2:
                first_filament = drive_used - 1
            else:
                first_filament = v.splice_used_tool[0]

            metafile["preheatTemperature"]["nozzle"] = [
                v.p3_printtemp[first_filament]
            ]
            metafile["preheatTemperature"]["bed"] = v.p3_bedtemp[
                first_filament]
        except (IndexError, KeyError):
            pass

    return json.dumps(metafile, indent=2)