mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-06 22:47:32 -06:00
Fix selected filament not shown up (#9371)
* Add `renamed_from` so existing user won't break (cherry picked from commit f8f3b5c2c9b0b15c209d8307a6eaba24e393ddda) * Add check for profile name consistency (cherry picked from commit 7343aa5b55cab9a9f7cbdcdddd4e7650f1577598) * Update filament name checking script (cherry picked from commit 7c4c1bf191de1fd6b86a07bf62c1ab634faa9f55) * Fix filament name inconsistency (cherry picked from commit 36225fc3dbd88babbc5a227fcc6247528d0de6a4)
This commit is contained in:
commit
bae3a1e6b8
11 changed files with 78 additions and 8 deletions
|
@ -3,6 +3,7 @@
|
||||||
"filament_id": "GFL99",
|
"filament_id": "GFL99",
|
||||||
"setting_id": "GFSA04",
|
"setting_id": "GFSA04",
|
||||||
"name": "Generic ASA @Flashforge AD4",
|
"name": "Generic ASA @Flashforge AD4",
|
||||||
|
"renamed_from": "Generic ASA @AD4",
|
||||||
"from": "system",
|
"from": "system",
|
||||||
"instantiation": "true",
|
"instantiation": "true",
|
||||||
"inherits": "Flashforge Generic ASA",
|
"inherits": "Flashforge Generic ASA",
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
"type": "filament",
|
"type": "filament",
|
||||||
"filament_id": "GFL99",
|
"filament_id": "GFL99",
|
||||||
"setting_id": "GFSA04",
|
"setting_id": "GFSA04",
|
||||||
"name": "PLA Silk @Flashforge AD4",
|
"name": "Generic PLA Silk @Flashforge AD4",
|
||||||
|
"renamed_from": "PLA Silk @Flashforge AD4",
|
||||||
"from": "system",
|
"from": "system",
|
||||||
"instantiation": "true",
|
"instantiation": "true",
|
||||||
"inherits": "Flashforge Generic PLA-Silk",
|
"inherits": "Flashforge Generic PLA-Silk",
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"type": "filament",
|
"type": "filament",
|
||||||
"name": "SUNLU PETG @FF AD5M 0.25 Nozzle",
|
"name": "SUNLU PETG @FF AD5M 0.25 Nozzle",
|
||||||
|
"renamed_from": "SUNLU PETG @FF AD5M 0.25 nozzle",
|
||||||
"inherits": "SUNLU PETG @base",
|
"inherits": "SUNLU PETG @base",
|
||||||
"from": "system",
|
"from": "system",
|
||||||
"setting_id": "GFSNLS08_00",
|
"setting_id": "GFSNLS08_00",
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"type": "filament",
|
"type": "filament",
|
||||||
"name": "SUNLU PETG @FF AD5M 0.8 Nozzle",
|
"name": "SUNLU PETG @FF AD5M 0.8 Nozzle",
|
||||||
|
"renamed_from": "SUNLU PETG @FF AD5M 0.8 nozzle",
|
||||||
"inherits": "SUNLU PETG @base",
|
"inherits": "SUNLU PETG @base",
|
||||||
"from": "system",
|
"from": "system",
|
||||||
"setting_id": "GFSNLS08_01",
|
"setting_id": "GFSNLS08_01",
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"type": "filament",
|
"type": "filament",
|
||||||
"name": "SUNLU PLA Marble @base",
|
"name": "SUNLU PLA Marble @base",
|
||||||
|
"renamed_from": "SUNLU Marble PLA @base",
|
||||||
"inherits": "fdm_filament_pla",
|
"inherits": "fdm_filament_pla",
|
||||||
"from": "system",
|
"from": "system",
|
||||||
"filament_id": "GFSNL06",
|
"filament_id": "GFSNL06",
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"type": "filament",
|
"type": "filament",
|
||||||
"name": "SUNLU PLA Matte @FF AD5M 0.25 Nozzle",
|
"name": "SUNLU PLA Matte @FF AD5M 0.25 Nozzle",
|
||||||
|
"renamed_from": "SUNLU PLA Matte @FF AD5M 0.25 nozzle",
|
||||||
"inherits": "SUNLU PLA Matte @base",
|
"inherits": "SUNLU PLA Matte @base",
|
||||||
"from": "system",
|
"from": "system",
|
||||||
"setting_id": "GFSNLS02_00",
|
"setting_id": "GFSNLS02_00",
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"type": "filament",
|
"type": "filament",
|
||||||
"name": "SUNLU PLA+ 2.0 @FF AD5M 0.25 Nozzle",
|
"name": "SUNLU PLA+ 2.0 @FF AD5M 0.25 Nozzle",
|
||||||
|
"renamed_from": "SUNLU PLA+ 2.0 @FF AD5M 0.25 nozzle",
|
||||||
"inherits": "SUNLU PLA+ 2.0 @base",
|
"inherits": "SUNLU PLA+ 2.0 @base",
|
||||||
"from": "system",
|
"from": "system",
|
||||||
"setting_id": "GFSNLS04_01",
|
"setting_id": "GFSNLS04_01",
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"type": "filament",
|
"type": "filament",
|
||||||
"name": "SUNLU PLA+ @FF AD5M 0.25 Nozzle",
|
"name": "SUNLU PLA+ @FF AD5M 0.25 Nozzle",
|
||||||
|
"renamed_from": "SUNLU PLA+ @FF AD5M 0.25 nozzle",
|
||||||
"inherits": "SUNLU PLA+ @base",
|
"inherits": "SUNLU PLA+ @base",
|
||||||
"from": "system",
|
"from": "system",
|
||||||
"setting_id": "GFSNLS03_01",
|
"setting_id": "GFSNLS03_01",
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"type": "filament",
|
"type": "filament",
|
||||||
"name": "SUNLU Silk PLA+ @FF AD5M 0.25 Nozzle",
|
"name": "SUNLU Silk PLA+ @FF AD5M 0.25 Nozzle",
|
||||||
|
"renamed_from": "SUNLU Silk PLA+ @FF AD5M 0.25 nozzle",
|
||||||
"inherits": "SUNLU Silk PLA+ @base",
|
"inherits": "SUNLU Silk PLA+ @base",
|
||||||
"from": "system",
|
"from": "system",
|
||||||
"setting_id": "GFSNLS05_01",
|
"setting_id": "GFSNLS05_01",
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"type": "filament",
|
"type": "filament",
|
||||||
"name": "Z-Bolt ABS HT@0.4 nozzle",
|
"name": "Z-Bolt ABS HT @0.4 nozzle",
|
||||||
|
"renamed_from": "Z-Bolt ABS HT@0.4 nozzle",
|
||||||
"inherits": "Z-Bolt ABS HT @base",
|
"inherits": "Z-Bolt ABS HT @base",
|
||||||
"from": "system",
|
"from": "system",
|
||||||
"instantiation": "true",
|
"instantiation": "true",
|
||||||
|
|
|
@ -139,8 +139,65 @@ def check_machine_default_materials(profiles_dir, vendor_name):
|
||||||
|
|
||||||
return error_count
|
return error_count
|
||||||
|
|
||||||
|
def check_filament_name_consistency(profiles_dir, vendor_name):
|
||||||
|
"""
|
||||||
|
Make sure filament profile names match in both vendor json and subpath files.
|
||||||
|
Filament profiles work only if the name in <vendor>.json matches the name in sub_path file,
|
||||||
|
or if it's one of the sub_path file's `renamed_from`.
|
||||||
|
"""
|
||||||
|
error_count = 0
|
||||||
|
vendor_dir = profiles_dir / vendor_name
|
||||||
|
vendor_file = profiles_dir / (vendor_name + ".json")
|
||||||
|
|
||||||
|
if not vendor_file.exists():
|
||||||
|
print(f"No profiles found for vendor: {vendor_name} at {vendor_file}")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open(vendor_file, 'r', encoding='UTF-8') as fp:
|
||||||
|
data = json.load(fp)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error loading vendor profile {vendor_file}: {e}")
|
||||||
|
return 1
|
||||||
|
|
||||||
|
if 'filament_list' not in data:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
for child in data['filament_list']:
|
||||||
|
name_in_vendor = child['name']
|
||||||
|
sub_path = child['sub_path']
|
||||||
|
sub_file = vendor_dir / sub_path
|
||||||
|
|
||||||
|
if not sub_file.exists():
|
||||||
|
print(f"Missing sub profile: '{sub_path}' declared in {vendor_file.relative_to(profiles_dir)}")
|
||||||
|
error_count += 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open(sub_file, 'r', encoding='UTF-8') as fp:
|
||||||
|
sub_data = json.load(fp)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error loading profile {sub_file}: {e}")
|
||||||
|
error_count += 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
name_in_sub = sub_data['name']
|
||||||
|
|
||||||
|
if name_in_sub == name_in_vendor:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if 'renamed_from' in sub_data:
|
||||||
|
renamed_from = [n.strip() for n in sub_data['renamed_from'].split(';')]
|
||||||
|
if name_in_vendor in renamed_from:
|
||||||
|
continue
|
||||||
|
|
||||||
|
print(f"Filament name mismatch: required '{name_in_vendor}' in {vendor_file.relative_to(profiles_dir)} but found '{name_in_sub}' in {sub_file.relative_to(profiles_dir)}, and none of its `renamed_from` matches the required name either")
|
||||||
|
error_count += 1
|
||||||
|
|
||||||
|
return error_count
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
print("Checking compatible_printers ...")
|
print("Checking profiles ...")
|
||||||
parser = argparse.ArgumentParser(description="Check profiles for issues")
|
parser = argparse.ArgumentParser(description="Check profiles for issues")
|
||||||
parser.add_argument("--vendor", type=str, required=False, help="Vendor name")
|
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-filaments", default=True, action="store_true", help="Check compatible_printers in filament profiles")
|
||||||
|
@ -157,17 +214,20 @@ def main():
|
||||||
errors_found += check_filament_compatible_printers(profiles_dir / args.vendor / "filament")
|
errors_found += check_filament_compatible_printers(profiles_dir / args.vendor / "filament")
|
||||||
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)
|
||||||
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():
|
||||||
|
continue
|
||||||
|
errors_found += check_filament_name_consistency(profiles_dir, vendor_dir.name)
|
||||||
# skip "OrcaFilamentLibrary" folder
|
# skip "OrcaFilamentLibrary" folder
|
||||||
if vendor_dir.name == "OrcaFilamentLibrary":
|
if vendor_dir.name == "OrcaFilamentLibrary":
|
||||||
continue
|
continue
|
||||||
if vendor_dir.is_dir():
|
if args.check_filaments or not (args.check_materials and not args.check_filaments):
|
||||||
if args.check_filaments or not (args.check_materials and not args.check_filaments):
|
errors_found += check_filament_compatible_printers(vendor_dir / "filament")
|
||||||
errors_found += check_filament_compatible_printers(vendor_dir / "filament")
|
if args.check_materials:
|
||||||
if args.check_materials:
|
errors_found += check_machine_default_materials(profiles_dir, vendor_dir.name)
|
||||||
errors_found += check_machine_default_materials(profiles_dir, vendor_dir.name)
|
|
||||||
checked_vendor_count += 1
|
checked_vendor_count += 1
|
||||||
|
|
||||||
if errors_found > 0:
|
if errors_found > 0:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue