#!/usr/bin/env python3 import pathlib import sys import bpy def triangle(name): mesh = bpy.data.meshes.new(name) mesh.from_pydata([(-1, 0, 0), (1, 0, 0), (0, 1, 0)], [], [(0, 1, 2)]) mesh.update() return mesh def main(output): bpy.ops.wm.read_factory_settings(use_empty=True) scene = bpy.context.scene scene.name = "WBV2P2002Scene" root = scene.collection source = bpy.data.collections.new("WBV2P2002Source") target = bpy.data.collections.new("WBV2P2002Target") root.children.link(source) root.children.link(target) parent = bpy.data.objects.new("WBV2P2002Parent", triangle("WBV2P2002ParentMesh")) source.objects.link(parent) parent.location = (1.0, 0.0, 0.0) child = bpy.data.objects.new("WBV2P2002Child", triangle("WBV2P2002ChildMesh")) source.objects.link(child) child.parent = parent child.location = (0.0, 2.0, 0.0) bpy.context.view_layer.objects.active = parent parent.select_set(True) child.select_set(False) bpy.ops.wm.save_as_mainfile(filepath=str(output.resolve()), check_existing=False, compress=True) if __name__ == "__main__": arguments = sys.argv[sys.argv.index("--") + 1 :] if len(arguments) != 1: raise SystemExit("usage: blender -b --factory-startup --python WBV2-P2-002.py -- OUTPUT") main(pathlib.Path(arguments[0]))