38 lines
1.6 KiB
Python
38 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
import pathlib
|
|
import sys
|
|
|
|
import bpy
|
|
|
|
|
|
ARMATURE_NAME = "WebGapArmatureSelectMirrorArmature"
|
|
OBJECT_NAME = "WebGapArmatureSelectMirrorObject"
|
|
LEFT_BONE = "WebGapSelectMirror.L"
|
|
RIGHT_BONE = "WebGapSelectMirror.R"
|
|
CENTER_BONE = "WebGapSelectMirrorCenter"
|
|
|
|
|
|
def main():
|
|
arguments = sys.argv[sys.argv.index("--") + 1 :]
|
|
if len(arguments) != 1:
|
|
raise SystemExit("usage: blender -b --factory-startup --python M16-GAP-00255.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")
|
|
left = armature.edit_bones.new(LEFT_BONE); left.head = (-2.0, 0.0, 0.0); left.tail = (-2.0, 1.0, 0.0)
|
|
right = armature.edit_bones.new(RIGHT_BONE); right.head = (2.0, 0.0, 0.0); right.tail = (2.0, 1.0, 0.0)
|
|
center = armature.edit_bones.new(CENTER_BONE); center.head = (0.0, 0.0, 0.0); center.tail = (0.0, 1.0, 0.0)
|
|
left.select = True; left.select_head = True; left.select_tail = True
|
|
right.select = False; right.select_head = False; right.select_tail = False
|
|
center.select = False; center.select_head = False; center.select_tail = False
|
|
armature.edit_bones.active = left
|
|
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()
|