mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-06 22:47:32 -06:00
Update default filaments for printers (#8655)
* update M1 * update Voron * update Positron * update Biqu * update Eryone * update Folgetech * update Geeetech * update Kingroon * update MagicMaker * update Raise3D * update Rolohaun * update Tronxy * update Kingroon and Tronxy * update Voxelab * update Wanhao * more fix
This commit is contained in:
parent
118266f721
commit
5e5542d02f
178 changed files with 281 additions and 180 deletions
|
@ -49,10 +49,102 @@ def check_filament_compatible_printers(vendor_folder):
|
|||
error += 1
|
||||
return error
|
||||
|
||||
def load_available_filament_profiles(profiles_dir, vendor_name):
|
||||
"""
|
||||
Load all available filament profiles from a vendor's directory.
|
||||
|
||||
Parameters:
|
||||
profiles_dir (Path): The directory containing vendor profile directories
|
||||
vendor_name (str): The name of the vendor directory
|
||||
|
||||
Returns:
|
||||
set: A set of filament profile names
|
||||
"""
|
||||
profiles = set()
|
||||
vendor_path = profiles_dir / vendor_name / "filament"
|
||||
|
||||
if not vendor_path.exists():
|
||||
return profiles
|
||||
|
||||
for file_path in vendor_path.rglob("*.json"):
|
||||
try:
|
||||
with open(file_path, 'r') as fp:
|
||||
data = json.load(fp)
|
||||
if "name" in data:
|
||||
profiles.add(data["name"])
|
||||
except Exception as e:
|
||||
print(f"Error loading filament profile {file_path}: {e}")
|
||||
|
||||
return profiles
|
||||
|
||||
def check_machine_default_materials(profiles_dir, vendor_name):
|
||||
"""
|
||||
Checks if default materials referenced in machine profiles exist in
|
||||
the vendor's filament library or in the global OrcaFilamentLibrary.
|
||||
|
||||
Parameters:
|
||||
profiles_dir (Path): The base profiles directory
|
||||
vendor_name (str): The vendor name to check
|
||||
|
||||
Returns:
|
||||
int: Number of missing filament references found
|
||||
"""
|
||||
error_count = 0
|
||||
machine_dir = profiles_dir / vendor_name / "machine"
|
||||
|
||||
if not machine_dir.exists():
|
||||
print(f"No machine profiles found for vendor: {vendor_name}")
|
||||
return 0
|
||||
|
||||
# Load available filament profiles
|
||||
vendor_filaments = load_available_filament_profiles(profiles_dir, vendor_name)
|
||||
global_filaments = load_available_filament_profiles(profiles_dir, "OrcaFilamentLibrary")
|
||||
all_available_filaments = vendor_filaments.union(global_filaments)
|
||||
|
||||
# Check each machine profile
|
||||
for file_path in machine_dir.rglob("*.json"):
|
||||
try:
|
||||
with open(file_path, 'r') as fp:
|
||||
data = json.load(fp)
|
||||
|
||||
default_materials = None
|
||||
if "default_materials" in data:
|
||||
default_materials = data["default_materials"]
|
||||
elif "default_filament_profile" in data:
|
||||
default_materials = data["default_filament_profile"]
|
||||
|
||||
if default_materials:
|
||||
if isinstance(default_materials, list):
|
||||
for material in default_materials:
|
||||
if material not in all_available_filaments:
|
||||
print(f"Missing filament profile: '{material}' referenced in {file_path.relative_to(profiles_dir)}")
|
||||
error_count += 1
|
||||
else:
|
||||
# Handle semicolon-separated list of materials in a string
|
||||
if ";" in default_materials:
|
||||
for material in default_materials.split(";"):
|
||||
material = material.strip()
|
||||
if material and material not in all_available_filaments:
|
||||
print(f"Missing filament profile: '{material}' referenced in {file_path.relative_to(profiles_dir)}")
|
||||
error_count += 1
|
||||
else:
|
||||
# Single material in a string
|
||||
if default_materials not in all_available_filaments:
|
||||
print(f"Missing filament profile: '{default_materials}' referenced in {file_path.relative_to(profiles_dir)}")
|
||||
error_count += 1
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error processing machine profile {file_path}: {e}")
|
||||
error_count += 1
|
||||
|
||||
return error_count
|
||||
|
||||
def main():
|
||||
print("Checking compatible_printers ...")
|
||||
parser = argparse.ArgumentParser(description="Check compatible_printers")
|
||||
parser = argparse.ArgumentParser(description="Check profiles for issues")
|
||||
parser.add_argument("--vendor", type=str, required=False, help="Vendor name")
|
||||
parser.add_argument("--check-filaments", default=True, action="store_true", help="Check compatible_printers in filament profiles")
|
||||
parser.add_argument("--check-materials", action="store_true", help="Check default materials in machine profiles")
|
||||
args = parser.parse_args()
|
||||
|
||||
script_dir = Path(__file__).resolve().parent
|
||||
|
@ -61,7 +153,10 @@ def main():
|
|||
errors_found = 0
|
||||
|
||||
if args.vendor:
|
||||
errors_found += check_filament_compatible_printers(profiles_dir / args.vendor / "filament")
|
||||
if args.check_filaments or not (args.check_materials and not args.check_filaments):
|
||||
errors_found += check_filament_compatible_printers(profiles_dir / args.vendor / "filament")
|
||||
if args.check_materials:
|
||||
errors_found += check_machine_default_materials(profiles_dir, args.vendor)
|
||||
checked_vendor_count += 1
|
||||
else:
|
||||
for vendor_dir in profiles_dir.iterdir():
|
||||
|
@ -69,7 +164,10 @@ def main():
|
|||
if vendor_dir.name == "OrcaFilamentLibrary":
|
||||
continue
|
||||
if vendor_dir.is_dir():
|
||||
errors_found += check_filament_compatible_printers(vendor_dir / "filament")
|
||||
if args.check_filaments or not (args.check_materials and not args.check_filaments):
|
||||
errors_found += check_filament_compatible_printers(vendor_dir / "filament")
|
||||
if args.check_materials:
|
||||
errors_found += check_machine_default_materials(profiles_dir, vendor_dir.name)
|
||||
checked_vendor_count += 1
|
||||
|
||||
if errors_found > 0:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue