mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 01:07:57 -06:00
Make sure filament_id
is not longer than 8 chars if the filament can be set in AMS (#9574)
Make sure `filament_id` is not longer than 8 chars if the filament is compatiable with AMS
This commit is contained in:
parent
00277ac4b0
commit
09d309ee9c
4 changed files with 43 additions and 3 deletions
|
@ -2,7 +2,7 @@
|
||||||
"type": "filament",
|
"type": "filament",
|
||||||
"name": "AliZ PETG-CF @base",
|
"name": "AliZ PETG-CF @base",
|
||||||
"inherits": "AliZ PETG @base",
|
"inherits": "AliZ PETG @base",
|
||||||
"filament_id": "AliZ001-1",
|
"filament_id": "AZ01-1",
|
||||||
"from": "system",
|
"from": "system",
|
||||||
"instantiation": "false",
|
"instantiation": "false",
|
||||||
"fan_cooling_layer_time": [
|
"fan_cooling_layer_time": [
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"type": "filament",
|
"type": "filament",
|
||||||
"name": "AliZ PETG-Metal @base",
|
"name": "AliZ PETG-Metal @base",
|
||||||
"inherits": "AliZ PETG @base",
|
"inherits": "AliZ PETG @base",
|
||||||
"filament_id": "AliZ001-2",
|
"filament_id": "AZ01-2",
|
||||||
"from": "system",
|
"from": "system",
|
||||||
"instantiation": "false",
|
"instantiation": "false",
|
||||||
"fan_cooling_layer_time": [
|
"fan_cooling_layer_time": [
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"inherits": "fdm_filament_common",
|
"inherits": "fdm_filament_common",
|
||||||
"from": "system",
|
"from": "system",
|
||||||
"instantiation": "false",
|
"instantiation": "false",
|
||||||
"filament_id": "OGFLSBS99",
|
"filament_id": "OFLSBS99",
|
||||||
"fan_cooling_layer_time": [
|
"fan_cooling_layer_time": [
|
||||||
"100"
|
"100"
|
||||||
],
|
],
|
||||||
|
|
|
@ -232,6 +232,44 @@ def check_filament_name_consistency(profiles_dir, vendor_name):
|
||||||
|
|
||||||
return error_count
|
return error_count
|
||||||
|
|
||||||
|
def check_filament_id(vendor, vendor_folder):
|
||||||
|
"""
|
||||||
|
Make sure filament_id is not longer than 8 characters, otherwise AMS won't work properly
|
||||||
|
"""
|
||||||
|
if vendor not in ('BBL', 'OrcaFilamentLibrary'):
|
||||||
|
return 0
|
||||||
|
|
||||||
|
error = 0
|
||||||
|
vendor_path = Path(vendor_folder)
|
||||||
|
if not vendor_path.exists():
|
||||||
|
return 0
|
||||||
|
|
||||||
|
# Use rglob to recursively find .json files.
|
||||||
|
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(f"Duplicate key error in {file_path}: {ve}")
|
||||||
|
error += 1
|
||||||
|
continue
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error processing {file_path}: {e}")
|
||||||
|
error += 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
if 'filament_id' not in data:
|
||||||
|
continue
|
||||||
|
|
||||||
|
filament_id = data['filament_id']
|
||||||
|
|
||||||
|
if len(filament_id) > 8:
|
||||||
|
error += 1
|
||||||
|
print(f"Filament id too long \"{filament_id}\": {file_path}")
|
||||||
|
|
||||||
|
return error
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
print("Checking profiles ...")
|
print("Checking profiles ...")
|
||||||
parser = argparse.ArgumentParser(description="Check profiles for issues")
|
parser = argparse.ArgumentParser(description="Check profiles for issues")
|
||||||
|
@ -251,12 +289,14 @@ def main():
|
||||||
if args.check_materials:
|
if args.check_materials:
|
||||||
errors_found += check_machine_default_materials(profiles_dir, args.vendor)
|
errors_found += check_machine_default_materials(profiles_dir, args.vendor)
|
||||||
errors_found += check_filament_name_consistency(profiles_dir, args.vendor)
|
errors_found += check_filament_name_consistency(profiles_dir, args.vendor)
|
||||||
|
errors_found += check_filament_id(args.vendor, profiles_dir / args.vendor / "filament")
|
||||||
checked_vendor_count += 1
|
checked_vendor_count += 1
|
||||||
else:
|
else:
|
||||||
for vendor_dir in profiles_dir.iterdir():
|
for vendor_dir in profiles_dir.iterdir():
|
||||||
if not vendor_dir.is_dir():
|
if not vendor_dir.is_dir():
|
||||||
continue
|
continue
|
||||||
errors_found += check_filament_name_consistency(profiles_dir, vendor_dir.name)
|
errors_found += check_filament_name_consistency(profiles_dir, vendor_dir.name)
|
||||||
|
errors_found += check_filament_id(vendor_dir.name, vendor_dir / "filament")
|
||||||
# skip "OrcaFilamentLibrary" folder
|
# skip "OrcaFilamentLibrary" folder
|
||||||
if vendor_dir.name == "OrcaFilamentLibrary":
|
if vendor_dir.name == "OrcaFilamentLibrary":
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue