52 lines
1.8 KiB
Python
52 lines
1.8 KiB
Python
#!/usr/bin/env python3
|
|
import pathlib
|
|
import sys
|
|
|
|
import bpy
|
|
|
|
|
|
ARMATURE_NAME = "WebGapArmatureCollectionDeselectArmature"
|
|
OBJECT_NAME = "WebGapArmatureCollectionDeselectObject"
|
|
ACTIVE_COLLECTION = "WebGapArmatureCollectionDeselectActive"
|
|
OTHER_COLLECTION = "WebGapArmatureCollectionDeselectOther"
|
|
ACTIVE_BONE = "WebGapArmatureCollectionDeselectActiveBone"
|
|
OTHER_BONE = "WebGapArmatureCollectionDeselectOtherBone"
|
|
|
|
|
|
def main():
|
|
arguments = sys.argv[sys.argv.index("--") + 1 :]
|
|
if len(arguments) != 1:
|
|
raise SystemExit("usage: blender -b --factory-startup --python M16-GAP-00224.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)
|
|
active = armature.collections.new(ACTIVE_COLLECTION)
|
|
armature.collections.new(OTHER_COLLECTION)
|
|
bpy.context.view_layer.objects.active = obj
|
|
obj.select_set(True)
|
|
bpy.ops.object.mode_set(mode="EDIT")
|
|
active_bone = armature.edit_bones.new(ACTIVE_BONE)
|
|
active_bone.head = (0.0, 0.0, 0.0)
|
|
active_bone.tail = (0.0, 1.0, 0.0)
|
|
other_bone = armature.edit_bones.new(OTHER_BONE)
|
|
other_bone.head = (1.0, 0.0, 0.0)
|
|
other_bone.tail = (1.0, 1.0, 0.0)
|
|
active_bone.select = True
|
|
active_bone.select_head = True
|
|
active_bone.select_tail = True
|
|
other_bone.select = True
|
|
other_bone.select_head = True
|
|
other_bone.select_tail = True
|
|
bpy.ops.object.mode_set(mode="OBJECT")
|
|
active.assign(armature.bones[ACTIVE_BONE])
|
|
armature.collections[OTHER_COLLECTION].assign(armature.bones[OTHER_BONE])
|
|
armature.collections.active_index = 0
|
|
bpy.ops.wm.save_as_mainfile(
|
|
filepath=str(pathlib.Path(arguments[0]).resolve()), check_existing=False, compress=True
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|