#!/usr/bin/env python3 import pathlib import sys import bpy ARMATURE_NAME = "WebGapArmatureCollectionCreateAssignArmature" OBJECT_NAME = "WebGapArmatureCollectionCreateAssignObject" SOURCE_COLLECTION = "WebGapArmatureCollectionCreateAssignSource" BONE_NAME = "WebGapArmatureCollectionCreateAssignBone" def main(): arguments = sys.argv[sys.argv.index("--") + 1 :] if len(arguments) != 1: raise SystemExit("usage: blender -b --factory-startup --python M16-GAP-00223.py -- OUTPUT") bpy.ops.wm.read_factory_settings(use_empty=True) armature = bpy.data.armatures.new(ARMATURE_NAME) obj = bpy.data.objects.new(OBJECT_NAME, armature) bpy.context.scene.collection.objects.link(obj) source = armature.collections.new(SOURCE_COLLECTION) bpy.context.view_layer.objects.active = obj obj.select_set(True) bpy.ops.object.mode_set(mode="EDIT") bone = armature.edit_bones.new(BONE_NAME) bone.head = (0.0, 0.0, 0.0) bone.tail = (0.0, 1.0, 0.0) bone.select = True bpy.ops.object.mode_set(mode="OBJECT") source.assign(armature.bones[BONE_NAME]) armature.collections.active_index = 0 bpy.ops.wm.save_as_mainfile( filepath=str(pathlib.Path(arguments[0]).resolve()), check_existing=False, compress=True ) if __name__ == "__main__": main()