Files
workinf_Blender_Wasm/tools/web/generated/M16-GAP-00234.py
mes123456 9f43244982
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled
Continue Blender Web parity task handoff
2026-08-23 05:47:21 -04:00

44 lines
1.4 KiB
Python

#!/usr/bin/env python3
import pathlib
import sys
import bpy
ARMATURE_NAME = "WebGapArmatureDeleteArmature"
OBJECT_NAME = "WebGapArmatureDeleteObject"
KEEP_BONE = "WebGapArmatureDeleteKeep"
DELETE_BONE = "WebGapArmatureDeleteSelected"
RETAIN_BONE = "WebGapArmatureDeleteRetain"
def main():
arguments = sys.argv[sys.argv.index("--") + 1 :]
if len(arguments) != 1:
raise SystemExit("usage: blender -b --factory-startup --python M16-GAP-00234.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")
bones = {}
for name, x in ((KEEP_BONE, 0.0), (DELETE_BONE, 1.0), (RETAIN_BONE, 2.0)):
bone = armature.edit_bones.new(name)
bone.head = (x, 0.0, 0.0)
bone.tail = (x, 1.0, 0.0)
bones[name] = bone
for bone in bones.values():
bone.select = False
bones[DELETE_BONE].select = True
armature.edit_bones.active = bones[DELETE_BONE]
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()