#!/usr/bin/env python3 import pathlib import sys import bpy ARMATURE_NAME = "WebGapArmatureSelectSimilarArmature" OBJECT_NAME = "WebGapArmatureSelectSimilarObject" ACTIVE_BONE = "WebGapArmatureSelectSimilarActive" SIMILAR_BONE = "WebGapArmatureSelectSimilarSameLength" DIFFERENT_BONE = "WebGapArmatureSelectSimilarDifferentLength" def main(): arguments = sys.argv[sys.argv.index("--") + 1 :] if len(arguments) != 1: raise SystemExit("usage: blender -b --factory-startup --python M16-GAP-00257.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") active = armature.edit_bones.new(ACTIVE_BONE) active.head = (0.0, 0.0, 0.0) active.tail = (0.0, 1.0, 0.0) similar = armature.edit_bones.new(SIMILAR_BONE) similar.head = (2.0, 0.0, 0.0) similar.tail = (2.0, 1.0, 0.0) different = armature.edit_bones.new(DIFFERENT_BONE) different.head = (4.0, 0.0, 0.0) different.tail = (4.0, 2.0, 0.0) active.select = True active.select_head = True active.select_tail = True for bone in (similar, different): bone.select = False bone.select_head = False bone.select_tail = False armature.edit_bones.active = active 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()