Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- python3 - <<'EOF'
- import json, glob, os
- root = os.path.expanduser("~/Library/Application Support/BambuStudio/system/BBL")
- idx = os.path.join(root + ".json")
- d = json.load(open(idx))
- have = {e["name"] for e in d["filament_list"]}
- # base must come before its children
- files = sorted(glob.glob(root + "/filament/Bambu PETG Matte @*.json"), key=lambda p: "@base" not in p)
- for f in files:
- name = json.load(open(f))["name"]
- if name not in have:
- d["filament_list"].append({"name": name, "sub_path": "filament/" + os.path.basename(f)})
- print("added", name)
- json.dump(d, open(idx, "w"), indent=4)
- EOF
Advertisement
Add Comment
Please, Sign In to add comment