#!/usr/bin/env python3 import pathlib import sys import bpy ARMATURE_NAME = "WebGapArmatureSelectMoreArmature" OBJECT_NAME = "WebGapArmatureSelectMoreObject" ROOT_BONE = "WebGapArmatureSelectMoreRoot" CHILD_BONE = "WebGapArmatureSelectMoreChild" GRANDCHILD_BONE = "WebGapArmatureSelectMoreGrandchild" OTHER_BONE = "WebGapArmatureSelectMoreOther" def main(): args = sys.argv[sys.argv.index("--") + 1:] if len(args) != 1: raise SystemExit("usage: blender -b --factory-startup --python M16-GAP-00256.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) bpy.context.view_layer.objects.active = obj obj.select_set(True) bpy.ops.object.mode_set(mode="EDIT") root = armature.edit_bones.new(ROOT_BONE); root.head = (0, 0, 0); root.tail = (0, 1, 0) child = armature.edit_bones.new(CHILD_BONE); child.head = (0, 1, 0); child.tail = (0, 2, 0); child.parent = root; child.use_connect = True grandchild = armature.edit_bones.new(GRANDCHILD_BONE); grandchild.head = (0, 2, 0); grandchild.tail = (0, 3, 0); grandchild.parent = child; grandchild.use_connect = True other = armature.edit_bones.new(OTHER_BONE); other.head = (2, 0, 0); other.tail = (2, 1, 0) root.select = True; root.select_head = True; root.select_tail = True for bone in (child, grandchild, other): bone.select = False; bone.select_head = False; bone.select_tail = False armature.edit_bones.active = root bpy.ops.object.mode_set(mode="OBJECT") bpy.ops.wm.save_as_mainfile(filepath=str(pathlib.Path(args[0]).resolve()), check_existing=False, compress=True) if __name__ == "__main__": main()