From a1b4e0ce55f31f4095268f8fbc4ab47439c97a25 Mon Sep 17 00:00:00 2001 From: anselor Date: Sun, 26 May 2024 01:30:51 -0400 Subject: [PATCH] Added additional filament vendors. (#5461) Added Anker printers to filament presets dialog. Added helper to generate formatted strings for dialog from profile JSON files. --- scripts/generate_presets_vendors.py | 150 +++++++++++++++++++++++++ src/slic3r/GUI/CreatePresetsDialog.cpp | 56 ++++++--- 2 files changed, 190 insertions(+), 16 deletions(-) create mode 100644 scripts/generate_presets_vendors.py diff --git a/scripts/generate_presets_vendors.py b/scripts/generate_presets_vendors.py new file mode 100644 index 00000000000..c70177632af --- /dev/null +++ b/scripts/generate_presets_vendors.py @@ -0,0 +1,150 @@ +# helps manage the static list of vendor names in src/slic3r/GUI/CreatePresetsDialog.cpp + +import json +from pathlib import Path +from typing import Dict, List + + +scripts_dir = Path(__file__).resolve().parent +print(f'Scripts dir: {scripts_dir}') +root_dir = scripts_dir.parent +profiles_dir = root_dir / 'resources' / 'profiles' + +printers: Dict[str, List[str]] = {} + +# generates the printer vendor list +print(f'Looking in {profiles_dir.resolve()}') +for entry in profiles_dir.glob('*.json'): + if entry.is_file(): + entry_info = json.loads(entry.read_text()) + vendor_name = entry_info.get('name', None) + if vendor_name: + models = [machine.get('name', None) for machine in entry_info.get('machine_model_list', []) if machine.get('name', None)] + printers[vendor_name] = models + +vendor_names = [f'"{vendor_name}",' for vendor_name in sorted(printers.keys(), key=str.casefold)] +vend_col_width = len(max(vendor_names, key=len)) +vendors_formatted = ' {' + '\n '.join(' '.join(f"{vendor_name:{vend_col_width}}" for vendor_name in vendor_names[i:i+5]) for i in range(0, len(vendor_names), 5)).rstrip()[:-1] + '}' +print(vendors_formatted) + +# generates the printer model map +models_formatted = ' {' +models_indent = len(models_formatted) + vend_col_width + 2 +for vendor_name in sorted(printers.keys(), key=str.casefold): + vendor_formatted = f'"{vendor_name}",' + models_formatted += f'{{{vendor_formatted:{vend_col_width}}{{' + + model_names = printers[vendor_name] + model_names_formatted = [f'"{model_name}",' for model_name in model_names] + model_col_width = len(max(model_names_formatted, key=len)) + model_names_str = ('\n' + ' ' * models_indent).join(' '.join(f"{model_name:{model_col_width}}" for model_name in model_names_formatted[i:i+5]) for i in range(0, len(model_names), 5)).rstrip()[:-1] + '}' + + models_formatted += model_names_str + + models_formatted += '},\n ' + +models_formatted = models_formatted.rstrip()[:-1] +print(models_formatted) + + +# Generate Filament Vendors +filament_vendors = [ + '3Dgenius', + '3DJake', + '3DXTECH', + '3D BEST-Q', + '3D Hero', + '3D-Fuel', + 'Aceaddity', + 'AddNorth', + 'Amazon Basics', + 'AMOLEN', + 'Ankermake', + 'Anycubic', + 'Atomic', + 'AzureFilm', + 'BASF', + 'Bblife', + 'BCN3D', + 'Beyond Plastic', + 'California Filament', + 'Capricorn', + 'CC3D', + 'colorFabb', + 'Comgrow', + 'Cookiecad', + 'Creality', + 'Das Filament', + 'DO3D', + 'DOW', + 'DSM', + 'Duramic', + 'ELEGOO', + 'Eryone', + 'Essentium', + 'eSUN', + 'Extrudr', + 'Fiberforce', + 'Fiberlogy', + 'FilaCube', + 'Filamentive', + 'Fillamentum', + 'FLASHFORGE', + 'Formfortura', + 'Francofil', + 'GEEETECH', + 'Giantarm', + 'Gizmo Dorks', + 'GreenGate3D', + 'HATCHBOX', + 'Hello3D', + 'IC3D', + 'IEMAI', + 'IIID Max', + 'INLAND', + 'iProspect', + 'iSANMATE', + 'Justmaker', + 'Keene Village Plastics', + 'Kexcelled', + 'MakerBot', + 'MatterHackers', + 'MIKA3D', + 'NinjaTek', + 'Nobufil', + 'Novamaker', + 'OVERTURE', + 'OVVNYXE', + 'Polymaker', + 'Priline', + 'Printed Solid', + 'Protopasta', + 'Prusament', + 'Push Plastic', + 'R3D', + 'Re-pet3D', + 'Recreus', + 'Regen', + 'Sain SMART', + 'SliceWorx', + 'Snapmaker', + 'SnoLabs', + 'Spectrum', + 'SUNLU', + 'TTYT3D', + 'UltiMaker', + 'Verbatim', + 'VO3D', + 'Voxelab', + 'YOOPAI', + 'Yousu', + 'Ziro', + 'Zyltech', + ] + +filament_vendors_formatted = [f'"{vendor_name}",' for vendor_name in filament_vendors] +fil_col_width = len(max(filament_vendors_formatted, key=len)) +filaments_formatted = ' {' +filament_indent = len(filaments_formatted) +filaments_formatted += ('\n' + ' ' * filament_indent).join(' '.join(f'{vendor_name:{fil_col_width}}' for vendor_name in filament_vendors_formatted[i:i+5]) for i in range(0, len(filament_vendors), 5)).rstrip()[:-1] + '};' +print(filaments_formatted) \ No newline at end of file diff --git a/src/slic3r/GUI/CreatePresetsDialog.cpp b/src/slic3r/GUI/CreatePresetsDialog.cpp index 5e6b863217f..d1ef2d911ca 100644 --- a/src/slic3r/GUI/CreatePresetsDialog.cpp +++ b/src/slic3r/GUI/CreatePresetsDialog.cpp @@ -37,22 +37,44 @@ namespace Slic3r { namespace GUI { -static const std::vector filament_vendors = {"Polymaker", "OVERTURE", "Kexcelled", "HATCHBOX", "eSUN", "SUNLU", "Prusament", "Creality", "Protopasta", - "Anycubic", "Basf", "ELEGOO", "INLAND", "FLASHFORGE", "AMOLEN", "MIKA3D", "3DXTECH", "Duramic", - "Priline", "Eryone", "3Dgunius", "Novamaker", "Justmaker", "Giantarm", "iProspect"}; - -static const std::vector filament_types = {"PLA", "PLA+", "PLA Tough", "PETG", "ABS", "ASA", "FLEX", "HIPS", "PA", "PACF", - "NYLON", "PVA", "PC", "PCABS", "PCTG", "PCCF", "PP", "PEI", "PET", "PETG", - "PETGCF", "PTBA", "PTBA90A", "PEEK", "TPU93A", "TPU75D", "TPU", "TPU92A", "TPU98A", "Misc", +static const std::vector filament_vendors = + {"3Dgenius", "3DJake", "3DXTECH", "3D BEST-Q", "3D Hero", + "3D-Fuel", "Aceaddity", "AddNorth", "Amazon Basics", "AMOLEN", + "Ankermake", "Anycubic", "Atomic", "AzureFilm", "BASF", + "Bblife", "BCN3D", "Beyond Plastic", "California Filament", "Capricorn", + "CC3D", "colorFabb", "Comgrow", "Cookiecad", "Creality", + "Das Filament", "DO3D", "DOW", "DSM", "Duramic", + "ELEGOO", "Eryone", "Essentium", "eSUN", "Extrudr", + "Fiberforce", "Fiberlogy", "FilaCube", "Filamentive", "Fillamentum", + "FLASHFORGE", "Formfortura", "Francofil", "GEEETECH", "Giantarm", + "Gizmo Dorks", "GreenGate3D", "HATCHBOX", "Hello3D", "IC3D", + "IEMAI", "IIID Max", "INLAND", "iProspect", "iSANMATE", + "Justmaker", "Keene Village Plastics", "Kexcelled", "MakerBot", "MatterHackers", + "MIKA3D", "NinjaTek", "Nobufil", "Novamaker", "OVERTURE", + "OVVNYXE", "Polymaker", "Priline", "Printed Solid", "Protopasta", + "Prusament", "Push Plastic", "R3D", "Re-pet3D", "Recreus", + "Regen", "Sain SMART", "SliceWorx", "Snapmaker", "SnoLabs", + "Spectrum", "SUNLU", "TTYT3D", "UltiMaker", "Verbatim", + "VO3D", "Voxelab", "YOOPAI", "Yousu", "Ziro", + "Zyltech"}; + +static const std::vector filament_types = {"PLA", "PLA+", "PLA Tough", "PETG", "ABS", "ASA", "FLEX", "HIPS", "PA", "PACF", + "NYLON", "PVA", "PC", "PCABS", "PCTG", "PCCF", "PHA", "PP", "PEI", "PET", "PETG", + "PETGCF", "PTBA", "PTBA90A", "PEEK", "TPU93A", "TPU75D", "TPU", "TPU92A", "TPU98A", "Misc", "TPE", "GLAZE", "Nylon", "CPE", "METAL", "ABST", "Carbon Fiber"}; -static const std::vector printer_vendors = {"Anycubic", "Artillery", "BIBO", "BIQU", "Creality ENDER", "Creality CR", "Creality SERMOON", - "FLSun", "gCreate", "Geeetech", "INAT", "Infinity3D", "Jubilee", "LNL3D", - "LulzBot", "MakerGear", "Original Prusa", "Papapiu", "Print4Taste", "RatRig", "Rigid3D", - "Snapmaker", "Sovol", "TriLAB", "Trimaker", "Ultimaker", "Voron", "Zonestar"}; +static const std::vector printer_vendors = + {"Anker", "Anycubic", "Artillery", "Bambulab", "BIQU", + "Comgrow", "Creality", "Custom Printer", "Elegoo", "Flashforge", + "FLSun", "FlyingBear", "Folgertech", "InfiMech", "Kingroon", + "Orca Arena Printer", "Peopoly", "Prusa", "Qidi", "Raise3D", + "RatRig", "SecKit", "Snapmaker", "Sovol", "Tronxy", + "TwoTrees", "UltiMaker", "Vivedino", "Voron", "Voxelab", + "Vzbot", "Wanhao"}; static const std::unordered_map> printer_model_map = - {{"Anycubic", {"Kossel Linear Plus", "Kossel Pulley(Linear)", "Mega Zero", "i3 Mega", "Predator"}}, + {{"Anker", {"Anker M5", "Anker M5 All-Metal Hot End", "Anker M5C"}}, + {"Anycubic", {"Kossel Linear Plus", "Kossel Pulley(Linear)", "Mega Zero", "i3 Mega", "Predator"}}, {"Artillery", {"sidewinder X1", "Genius", "Hornet"}}, {"BIBO", {"BIBO2 Touch"}}, {"BIQU", {"BX"}}, @@ -93,10 +115,10 @@ static const std::unordered_map> printer_m "Zero 120mm3", "Switchwire"}}, {"Zonestar", {"Z5", "Z6", "Z5x", "Z8", "Z9"}}}; -static std::vector nozzle_diameter_vec = {"0.4", "0.2", "0.25", "0.3", "0.35", "0.5", "0.6", "0.75", "0.8", "1.0", "1.2"}; -static std::unordered_map nozzle_diameter_map = {{"0.2", 0.2}, {"0.25", 0.25}, {"0.3", 0.3}, {"0.35", 0.35}, - {"0.4", 0.4}, {"0.5", 0.5}, {"0.6", 0.6}, {"0.75", 0.75}, - {"0.8", 0.8}, {"1.0", 1.0}, {"1.2", 1.2}}; +static std::vector nozzle_diameter_vec = {"0.4", "0.15", "0.2", "0.25", "0.3", "0.35", "0.5", "0.6", "0.75", "0.8", "1.0", "1.2"}; +static std::unordered_map nozzle_diameter_map = {{"0.15", 0.15}, {"0.2", 0.2}, {"0.25", 0.25}, {"0.3", 0.3}, + {"0.35", 0.35}, {"0.4", 0.4}, {"0.5", 0.5}, {"0.6", 0.6}, + {"0.75", 0.75}, {"0.8", 0.8}, {"1.0", 1.0}, {"1.2", 1.2}}; static std::set cannot_input_key = {9, 10, 13, 33, 35, 36, 37, 38, 40, 41, 42, 44, 46, 47, 59, 60, 62, 63, 64, 92, 94, 95, 124, 126}; @@ -673,6 +695,7 @@ wxBoxSizer *CreateFilamentPresetDialog::create_vendor_item() for (const wxString &vendor : filament_vendors) { choices.push_back(vendor); } + choices.Sort(); wxBoxSizer *vendor_sizer = new wxBoxSizer(wxHORIZONTAL); m_filament_vendor_combobox = new ComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, NAME_OPTION_COMBOBOX_SIZE, 0, nullptr, wxCB_READONLY); @@ -754,6 +777,7 @@ wxBoxSizer *CreateFilamentPresetDialog::create_type_item() for (const wxString &filament : m_system_filament_types_set) { filament_type.Add(filament); } + filament_type.Sort(); wxBoxSizer *comboBoxSizer = new wxBoxSizer(wxVERTICAL); m_filament_type_combobox = new ComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, NAME_OPTION_COMBOBOX_SIZE, 0, nullptr, wxCB_READONLY);