"""Headless build of Tender_Grouper.blend: from factory settings (a new file) or on the saved file (rebuilds only the Grouper's collections), then saves. The surfaces pass must run after it (a rebuild replaces the meshes and their UVs). blender.exe -b --factory-startup --python build/run_build_headless.py (new file) blender.exe -b Tender_Grouper.blend --python build/run_build_headless.py (rebuild) add "-- --nosave" to test without saving""" import bpy, os, sys, traceback HERE = r"D:\HADAL - The Descent\models\tender-grouper\build" # (round 3) GROUPER_OUT: save somewhere else (development builds; the user may have Tender_Grouper.blend open) PATH = os.environ.get("GROUPER_OUT") or os.path.join(os.path.dirname(HERE), "Tender_Grouper.blend") if not bpy.data.filepath: for o in list(bpy.data.objects): # the factory scene's cube, light and camera bpy.data.objects.remove(o) bpy.context.scene.unit_settings.system = 'METRIC' try: g = {"__name__": "grouper"} exec(open(os.path.join(HERE, "build_grouper.py")).read(), g) except Exception: traceback.print_exc() print("BUILD FAILED") sys.exit(1) if "--nosave" not in sys.argv: bpy.ops.wm.save_as_mainfile(filepath=PATH) print("HEADLESS BUILD SAVED", PATH) rep = g.get("REPORT", {}) print("REPORT", {k: rep.get(k) for k in ("hull_stations", "hull_columns", "pruned_faces", "custom_normal_corners", "dimensions", "bounds_min", "bounds_max", "build_seconds", "stage_seconds")}) for a in rep.get("audit", []): print("AUDIT", a)