Files
workinf_Blender_Wasm/tools/web/generated/M16-GAP-00274.py
mes123456 5c8cfd1a8c
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled
Complete M16 asset operator parity chain
2026-08-23 18:10:00 -04:00

38 lines
1.4 KiB
Python

#!/usr/bin/env python3
import pathlib
import sys
import bpy
LIBRARY_NAME = "WebGapCatalogsSave.blend"
OBJECT_NAME = "WebGapCatalogsSaveObject"
def main():
arguments = sys.argv[sys.argv.index("--") + 1 :]
if len(arguments) != 1:
raise SystemExit("usage: blender -b --factory-startup --python M16-GAP-00274.py -- OUTPUT")
output = pathlib.Path(arguments[0]).resolve()
source = output.with_name(LIBRARY_NAME)
bpy.ops.wm.read_factory_settings(use_empty=True)
mesh = bpy.data.meshes.new("WebGapCatalogsSaveMesh")
mesh.from_pydata([(-1.0, 0.0, 0.0), (1.0, 0.0, 0.0), (0.0, 1.0, 0.0)], [], [(0, 1, 2)])
obj = bpy.data.objects.new(OBJECT_NAME, mesh)
bpy.context.scene.collection.objects.link(obj)
bpy.ops.wm.save_as_mainfile(filepath=str(source), check_existing=False, compress=True)
bpy.ops.wm.read_factory_settings(use_empty=True)
with bpy.data.libraries.load(str(source), link=True) as (data_from, data_to):
if OBJECT_NAME not in data_from.objects:
raise RuntimeError("catalogs-save source object is missing")
data_to.objects = [OBJECT_NAME]
linked = data_to.objects[0]
if linked is None:
raise RuntimeError("catalogs-save linked object is missing")
bpy.context.scene.collection.objects.link(linked)
bpy.ops.wm.save_as_mainfile(filepath=str(output), check_existing=False, compress=True)
if __name__ == "__main__":
main()