"""Headless build of Tender_Mako.blend: from factory settings (a new file) or on the saved file (rebuilds only the Mako'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_Mako.blend --python build/run_build_headless.py (rebuild)""" import bpy, os, sys, traceback HERE = r"D:\HADAL - The Descent\models\tender-mako\build" PATH = os.path.join(os.path.dirname(HERE), "Tender_Mako.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__": "mako"} exec(open(os.path.join(HERE, "build_mako.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", "boundary_loops", "pruned_faces", "custom_normal_corners", "dimensions", "bounds_min", "bounds_max", "build_seconds", "arm_tip_y")}) for a in rep.get("audit", []): print("AUDIT", a)