#!/usr/bin/env python3 import pathlib import sys import bpy ARMATURE_NAME = "WebGapArmatureDissolveArmature" OBJECT_NAME = "WebGapArmatureDissolveObject" ROOT_BONE = "WebGapArmatureDissolveRoot" MIDDLE_BONE = "WebGapArmatureDissolveMiddle" TIP_BONE = "WebGapArmatureDissolveTip" OTHER_BONE = "WebGapArmatureDissolveOther" def main(): arguments = sys.argv[sys.argv.index("--") + 1 :] if len(arguments) != 1: raise SystemExit("usage: blender -b --factory-startup --python M16-GAP-00235.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.0, 0.0) root.tail = (0.0, 1.0, 0.0) middle = armature.edit_bones.new(MIDDLE_BONE) middle.head = (0.0, 1.0, 0.0) middle.tail = (0.0, 2.0, 0.0) middle.parent = root middle.use_connect = True tip = armature.edit_bones.new(TIP_BONE) tip.head = (0.0, 2.0, 0.0) tip.tail = (0.0, 3.0, 0.0) tip.parent = middle tip.use_connect = True other = armature.edit_bones.new(OTHER_BONE) other.head = (2.0, 0.0, 0.0) other.tail = (2.0, 1.0, 0.0) root.select = False middle.select = True tip.select = True other.select = False armature.edit_bones.active = middle bpy.ops.object.mode_set(mode="OBJECT") bpy.ops.wm.save_as_mainfile( filepath=str(pathlib.Path(arguments[0]).resolve()), check_existing=False, compress=True ) if __name__ == "__main__": main()