37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
import pathlib
|
|
import sys
|
|
|
|
import bpy
|
|
|
|
|
|
OBJECT_NAME = "WebGapAssetMarkObject"
|
|
MESH_NAME = "WebGapAssetMarkMesh"
|
|
|
|
|
|
def main():
|
|
arguments = sys.argv[sys.argv.index("--") + 1 :]
|
|
if len(arguments) != 1:
|
|
raise SystemExit(
|
|
"usage: blender -b --factory-startup --python M16-GAP-00279.py -- OUTPUT"
|
|
)
|
|
output = pathlib.Path(arguments[0]).resolve()
|
|
bpy.ops.wm.read_factory_settings(use_empty=True)
|
|
mesh = bpy.data.meshes.new(MESH_NAME)
|
|
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)
|
|
|
|
# Background mode has no editor ID context for the operator. Seed the persisted asset record
|
|
# with the same data API used by Blender's asset system.
|
|
obj.asset_mark()
|
|
obj.asset_data.author = "M16 Fixture"
|
|
obj.asset_data.description = "Asset mark operator fixture"
|
|
obj.asset_data.tags.new("operator-mark")
|
|
|
|
bpy.ops.wm.save_as_mainfile(filepath=str(output), check_existing=False, compress=True)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|