Continue Blender Web parity task handoff
This commit is contained in:
52
tools/web/generated/M16-GAP-00228.py
Normal file
52
tools/web/generated/M16-GAP-00228.py
Normal file
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env python3
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
import bpy
|
||||
|
||||
|
||||
ARMATURE_NAME = "WebGapArmatureCollectionSelectArmature"
|
||||
OBJECT_NAME = "WebGapArmatureCollectionSelectObject"
|
||||
FIRST_COLLECTION = "WebGapArmatureCollectionSelectFirst"
|
||||
ACTIVE_COLLECTION = "WebGapArmatureCollectionSelectActive"
|
||||
LAST_COLLECTION = "WebGapArmatureCollectionSelectLast"
|
||||
FIRST_BONE = "WebGapArmatureCollectionSelectFirstBone"
|
||||
ACTIVE_BONE = "WebGapArmatureCollectionSelectActiveBone"
|
||||
LAST_BONE = "WebGapArmatureCollectionSelectLastBone"
|
||||
|
||||
|
||||
def main():
|
||||
arguments = sys.argv[sys.argv.index("--") + 1 :]
|
||||
if len(arguments) != 1:
|
||||
raise SystemExit("usage: blender -b --factory-startup --python M16-GAP-00228.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)
|
||||
first = armature.collections.new(FIRST_COLLECTION)
|
||||
active = armature.collections.new(ACTIVE_COLLECTION)
|
||||
last = armature.collections.new(LAST_COLLECTION)
|
||||
bpy.context.view_layer.objects.active = obj
|
||||
obj.select_set(True)
|
||||
bpy.ops.object.mode_set(mode="EDIT")
|
||||
edit_bones = {}
|
||||
for name, x in ((FIRST_BONE, 0.0), (ACTIVE_BONE, 1.0), (LAST_BONE, 2.0)):
|
||||
bone = armature.edit_bones.new(name)
|
||||
bone.head = (x, 0.0, 0.0)
|
||||
bone.tail = (x, 1.0, 0.0)
|
||||
edit_bones[name] = bone
|
||||
edit_bones[FIRST_BONE].select = True
|
||||
edit_bones[ACTIVE_BONE].select = False
|
||||
edit_bones[LAST_BONE].select = False
|
||||
bpy.ops.object.mode_set(mode="OBJECT")
|
||||
first.assign(armature.bones[FIRST_BONE])
|
||||
active.assign(armature.bones[ACTIVE_BONE])
|
||||
last.assign(armature.bones[LAST_BONE])
|
||||
armature.collections.active_index = 1
|
||||
bpy.ops.wm.save_as_mainfile(
|
||||
filepath=str(pathlib.Path(arguments[0]).resolve()), check_existing=False, compress=True
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user