53 lines
1.6 KiB
Python
53 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
import pathlib
|
|
import sys
|
|
|
|
import bpy
|
|
|
|
|
|
ARMATURE_NAME = "WebGapArmatureFillArmature"
|
|
OBJECT_NAME = "WebGapArmatureFillObject"
|
|
SOURCE_BONE = "WebGapArmatureFillSource"
|
|
TARGET_BONE = "WebGapArmatureFillTarget"
|
|
OTHER_BONE = "WebGapArmatureFillOther"
|
|
|
|
|
|
def main():
|
|
arguments = sys.argv[sys.argv.index("--") + 1 :]
|
|
if len(arguments) != 1:
|
|
raise SystemExit("usage: blender -b --factory-startup --python M16-GAP-00242.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")
|
|
source = armature.edit_bones.new(SOURCE_BONE)
|
|
source.head = (0.0, 0.0, 0.0)
|
|
source.tail = (0.0, 1.0, 0.0)
|
|
target = armature.edit_bones.new(TARGET_BONE)
|
|
target.head = (0.0, 2.0, 0.0)
|
|
target.tail = (0.0, 3.0, 0.0)
|
|
other = armature.edit_bones.new(OTHER_BONE)
|
|
other.head = (2.0, 0.0, 0.0)
|
|
other.tail = (2.0, 1.0, 0.0)
|
|
source.select = False
|
|
source.select_head = False
|
|
source.select_tail = True
|
|
target.select = False
|
|
target.select_head = True
|
|
target.select_tail = False
|
|
other.select = False
|
|
other.select_head = False
|
|
other.select_tail = False
|
|
armature.edit_bones.active = target
|
|
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()
|