Treat extruder_clearance_max_radius as extruder_clearance_radius, and raise error if both options are present

This commit is contained in:
Noisyfox 2025-10-11 16:17:14 +08:00
parent 6ea106f754
commit 2fa386cbdb
31 changed files with 77 additions and 29 deletions

View file

@ -21,7 +21,6 @@
"default_print_profile": "0.10mm Standard 0.2mm nozzle @Anker",
"extruder_clearance_height_to_lid": "250",
"extruder_clearance_height_to_rod": "30",
"extruder_clearance_max_radius": "45",
"extruder_clearance_radius": "45",
"printer_structure": "i3",
"nozzle_type": "brass",

View file

@ -21,7 +21,6 @@
"default_print_profile": "0.10mm Standard 0.25mm nozzle @Anker",
"extruder_clearance_height_to_lid": "250",
"extruder_clearance_height_to_rod": "30",
"extruder_clearance_max_radius": "45",
"extruder_clearance_radius": "45",
"printer_structure": "i3",
"nozzle_type": "brass",

View file

@ -18,7 +18,6 @@
"default_print_profile": "0.20mm Standard @Anker",
"extruder_clearance_height_to_lid": "250",
"extruder_clearance_height_to_rod": "30",
"extruder_clearance_max_radius": "45",
"extruder_clearance_radius": "45",
"printer_structure": "i3",
"nozzle_type": "brass",

View file

@ -24,7 +24,6 @@
"default_print_profile": "0.30mm Standard 0.6 nozzle @Anker",
"extruder_clearance_height_to_lid": "250",
"extruder_clearance_height_to_rod": "30",
"extruder_clearance_max_radius": "45",
"extruder_clearance_radius": "45",
"printer_structure": "i3",
"nozzle_type": "brass",

View file

@ -21,7 +21,6 @@
"default_print_profile": "0.10mm Standard 0.2mm nozzle @Anker",
"extruder_clearance_height_to_lid": "250",
"extruder_clearance_height_to_rod": "30",
"extruder_clearance_max_radius": "45",
"extruder_clearance_radius": "45",
"printer_structure": "i3",
"nozzle_type": "brass",

View file

@ -21,7 +21,6 @@
"default_print_profile": "0.10mm Standard 0.25mm nozzle @Anker",
"extruder_clearance_height_to_lid": "250",
"extruder_clearance_height_to_rod": "30",
"extruder_clearance_max_radius": "45",
"extruder_clearance_radius": "45",
"printer_structure": "i3",
"nozzle_type": "brass",

View file

@ -18,7 +18,6 @@
"default_print_profile": "0.20mm Standard @Anker",
"extruder_clearance_height_to_lid": "250",
"extruder_clearance_height_to_rod": "30",
"extruder_clearance_max_radius": "45",
"extruder_clearance_radius": "45",
"printer_structure": "i3",
"nozzle_type": "brass",

View file

@ -24,7 +24,6 @@
"default_print_profile": "0.30mm Standard 0.6 nozzle @Anker",
"extruder_clearance_height_to_lid": "250",
"extruder_clearance_height_to_rod": "30",
"extruder_clearance_max_radius": "45",
"extruder_clearance_radius": "45",
"printer_structure": "i3",
"nozzle_type": "brass",

View file

@ -21,7 +21,6 @@
"default_print_profile": "0.10mm Standard 0.2mm nozzle @Anker",
"extruder_clearance_height_to_lid": "250",
"extruder_clearance_height_to_rod": "30",
"extruder_clearance_max_radius": "45",
"extruder_clearance_radius": "45",
"printer_structure": "i3",
"nozzle_type": "brass",

View file

@ -21,7 +21,6 @@
"default_print_profile": "0.10mm Standard 0.25mm nozzle @Anker",
"extruder_clearance_height_to_lid": "250",
"extruder_clearance_height_to_rod": "30",
"extruder_clearance_max_radius": "45",
"extruder_clearance_radius": "45",
"printer_structure": "i3",
"nozzle_type": "brass",

View file

@ -18,7 +18,6 @@
"default_print_profile": "0.20mm Standard @Anker",
"extruder_clearance_height_to_lid": "250",
"extruder_clearance_height_to_rod": "30",
"extruder_clearance_max_radius": "45",
"extruder_clearance_radius": "45",
"printer_structure": "i3",
"nozzle_type": "brass",

View file

@ -24,7 +24,6 @@
"default_print_profile": "0.30mm Standard 0.6 nozzle @Anker",
"extruder_clearance_height_to_lid": "250",
"extruder_clearance_height_to_rod": "30",
"extruder_clearance_max_radius": "45",
"extruder_clearance_radius": "45",
"printer_structure": "i3",
"nozzle_type": "brass",

View file

@ -19,7 +19,6 @@
"extruder_clearance_height_to_lid": "201",
"extruder_clearance_height_to_rod": "47.4",
"extruder_clearance_max_radius": "96",
"extruder_clearance_radius": "49",
"extruder_printable_area": [
"0x0,325x0,325x320,0x320",
"25x0,350x0,350x320,25x320"

View file

@ -23,7 +23,6 @@
"extruder_clearance_height_to_lid": "201",
"extruder_clearance_height_to_rod": "47.4",
"extruder_clearance_max_radius": "96",
"extruder_clearance_radius": "49",
"extruder_printable_area": [
"0x0,325x0,325x320,0x320",
"25x0,350x0,350x320,25x320"

View file

@ -27,7 +27,6 @@
"extruder_clearance_height_to_lid": "187",
"extruder_clearance_height_to_rod": "33",
"extruder_clearance_max_radius": "81",
"extruder_clearance_radius": "30",
"fan_direction": "left",
"hotend_cooling_rate": [
"2",

View file

@ -33,7 +33,6 @@
],
"extruder_clearance_height_to_lid": "90",
"extruder_clearance_max_radius": "68",
"extruder_clearance_radius": "57",
"extruder_colour": [
"#018001"
],

View file

@ -32,7 +32,6 @@
"extruder_clearance_height_to_lid": "90",
"extruder_clearance_height_to_rod": "38.70",
"extruder_clearance_max_radius": "92",
"extruder_clearance_radius": "13",
"extruder_colour": [
"#018001",
"#018001"

View file

@ -17,7 +17,7 @@
],
"extruder_clearance_height_to_lid": "140",
"extruder_clearance_height_to_rod": "34",
"extruder_clearance_radius": "65",
"extruder_clearance_max_radius": "65",
"extruder_clearance_dist_to_rod": "33",
"extruder_colour": [
"#FCE94F"

View file

@ -11,7 +11,6 @@
"printer_structure": "i3",
"default_print_profile": "0.20mm Standard @Creality Ender3V3KE",
"extruder_clearance_height_to_rod": "47",
"extruder_clearance_max_radius": "90",
"extruder_clearance_radius": "90",
"machine_load_filament_time": "11",
"nozzle_diameter": [

View file

@ -11,7 +11,6 @@
"printer_structure": "i3",
"default_print_profile": "0.20mm Standard @Creality Ender3V3KE",
"extruder_clearance_height_to_rod": "47",
"extruder_clearance_max_radius": "90",
"extruder_clearance_radius": "90",
"machine_load_filament_time": "11",
"nozzle_diameter": [

View file

@ -11,7 +11,6 @@
"printer_structure": "i3",
"default_print_profile": "0.20mm Standard @Creality Ender3V3KE",
"extruder_clearance_height_to_rod": "47",
"extruder_clearance_max_radius": "90",
"extruder_clearance_radius": "90",
"machine_load_filament_time": "11",
"nozzle_diameter": [

View file

@ -11,7 +11,6 @@
"printer_structure": "i3",
"default_print_profile": "0.20mm Standard @Creality Ender3V3KE",
"extruder_clearance_height_to_rod": "47",
"extruder_clearance_max_radius": "90",
"extruder_clearance_radius": "90",
"machine_load_filament_time": "11",
"nozzle_diameter": [

View file

@ -12,7 +12,6 @@
"printer_structure": "i3",
"default_print_profile": "0.20mm Standard @Creality Ender3V3SE 0.2",
"extruder_clearance_height_to_rod": "47",
"extruder_clearance_max_radius": "90",
"extruder_clearance_radius": "90",
"machine_load_filament_time": "11",
"nozzle_diameter": [

View file

@ -12,7 +12,6 @@
"printer_structure": "i3",
"default_print_profile": "0.20mm Standard @Creality Ender3V3SE 0.4",
"extruder_clearance_height_to_rod": "47",
"extruder_clearance_max_radius": "90",
"extruder_clearance_radius": "90",
"machine_load_filament_time": "11",
"nozzle_diameter": [

View file

@ -12,7 +12,6 @@
"printer_structure": "i3",
"default_print_profile": "0.20mm Standard @Creality Ender3V3SE 0.6",
"extruder_clearance_height_to_rod": "47",
"extruder_clearance_max_radius": "90",
"extruder_clearance_radius": "90",
"machine_load_filament_time": "11",
"nozzle_diameter": [

View file

@ -12,7 +12,6 @@
"printer_structure": "i3",
"default_print_profile": "0.20mm Standard @Creality Ender3V3SE 0.8",
"extruder_clearance_height_to_rod": "47",
"extruder_clearance_max_radius": "90",
"extruder_clearance_radius": "90",
"machine_load_filament_time": "11",
"nozzle_diameter": [

View file

@ -96,7 +96,6 @@
"retract_lift_below": [
"249"
],
"extruder_clearance_radius": "57",
"extruder_clearance_max_radius": "68",
"extruder_clearance_height_to_lid": "90",
"nozzle_volume": "107",

View file

@ -95,7 +95,6 @@
"retract_lift_below": [
"249"
],
"extruder_clearance_radius": "57",
"extruder_clearance_max_radius": "68",
"extruder_clearance_height_to_lid": "90",
"nozzle_volume": "107",

View file

@ -355,6 +355,57 @@ def check_obsolete_keys(profiles_dir, vendor_name):
return error_count
CONFLICT_KEYS = [
['extruder_clearance_radius', 'extruder_clearance_max_radius'],
]
def check_conflict_keys(profiles_dir, vendor_name):
"""
Check for keys that could not be specified at the same time,
due to option renaming & backward compatibility reasons.
For example, `extruder_clearance_max_radius` and `extruder_clearance_radius` cannot co-exist
otherwise slicer won't know which one to use.
Parameters:
profiles_dir (Path): Base profiles directory
vendor_name (str): Vendor name
Returns:
int: Number of errors found
int: Number of warnings found
"""
error_count = 0
warn_count = 0
vendor_path = profiles_dir / vendor_name
if not vendor_path.exists():
print_warning(f"No machine profiles found for vendor: {vendor_name}")
return 0, 1
for file_path in vendor_path.rglob("*.json"):
try:
with open(file_path, 'r', encoding='UTF-8') as fp:
# Use custom hook to detect duplicates.
data = json.load(fp, object_pairs_hook=no_duplicates_object_pairs_hook)
except ValueError as ve:
print_error(f"Duplicate key error in {file_path.relative_to(profiles_dir)}: {ve}")
error_count += 1
continue
except Exception as e:
print_error(f"Error processing {file_path.relative_to(profiles_dir)}: {e}")
error_count += 1
continue
for key_sets in CONFLICT_KEYS:
if sum([1 if k in data else 0 for k in key_sets]) > 1:
print_error(f"Conflict keys {key_sets} co-exist in {file_path.relative_to(profiles_dir)}")
error_count += 1
return error_count, warn_count
def main():
parser = argparse.ArgumentParser(
description="Check 3D printer profiles for common issues",
@ -393,6 +444,10 @@ def main():
errors_found += new_errors
warnings_found += new_warnings
new_errors, new_warnings = check_conflict_keys(profiles_dir, vendor_name)
errors_found += new_errors
warnings_found += new_warnings
errors_found += check_filament_id(vendor_name, vendor_path / "filament")
checked_vendor_count += 1
@ -416,6 +471,8 @@ def main():
else:
print_success("Files with warnings : 0")
print("=================================================")
if errors_found > 0 or warnings_found > 0 :
print_warning('Issue(s) found, try `orca_filament_lib.py --fix` to fix common issues automatically')
exit(-1 if errors_found > 0 else 0)

View file

@ -160,6 +160,9 @@ def clean_up_profile(vendor="", profile_type="", force=False):
for root, dirs, files in os.walk(profile_dir):
for file in files:
if file.lower().endswith('.json'):
if file == 'filaments_color_codes.json': # Ignore non-profile file
continue
full_path = os.path.join(root, file)
# Get relative path from base directory
@ -190,6 +193,19 @@ def clean_up_profile(vendor="", profile_type="", force=False):
print(f"Removed {field} field from {file}")
need_update = True
# Handle `extruder_clearance_radius`.
if 'extruder_clearance_radius' in _profile and 'extruder_clearance_max_radius' in _profile:
# BBS renamed `extruder_clearance_radius` to `extruder_clearance_max_radius`
# however some of their profiles have both options exists with different value, which
# could cause very bad consequence such as toolhead collision.
# Here we make sure only one of these options exist, and if both present, we keep
# the one with greater value.
need_update = True
if float(_profile['extruder_clearance_max_radius']) > float(_profile['extruder_clearance_radius']):
del _profile['extruder_clearance_radius']
else:
del _profile['extruder_clearance_max_radius']
if need_update or force:
# write back to file
f.seek(0)

View file

@ -7373,6 +7373,8 @@ void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &va
opt_key = "wipe_tower_rib_width";
} else if (opt_key == "prime_tower_fillet_wall") {
opt_key = "wipe_tower_fillet_wall";
} else if (opt_key == "extruder_clearance_max_radius") {
opt_key = "extruder_clearance_radius";
}
// Ignore the following obsolete configuration keys:
@ -7389,7 +7391,7 @@ void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &va
"can_switch_nozzle_type", "can_add_auxiliary_fan", "extra_flush_volume", "spaghetti_detector", "adaptive_layer_height",
"z_hop_type", "z_lift_type", "bed_temperature_difference","long_retraction_when_cut",
"retraction_distance_when_cut",
"internal_bridge_support_thickness","extruder_clearance_max_radius", "top_area_threshold", "reduce_wall_solid_infill","filament_load_time","filament_unload_time",
"internal_bridge_support_thickness", "top_area_threshold", "reduce_wall_solid_infill","filament_load_time","filament_unload_time",
"smooth_coefficient", "overhang_totally_speed", "silent_mode",
"overhang_speed_classic", "filament_prime_volume",
};