12 lines
1.2 KiB
Python
12 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
import pathlib,sys,bpy
|
|
ARMATURE_NAME="WebGapArmatureSwitchDirectionArmature"; OBJECT_NAME="WebGapArmatureSwitchDirectionObject"; ROOT_BONE="WebGapArmatureSwitchDirectionRoot"; CHILD_BONE="WebGapArmatureSwitchDirectionChild"; OTHER_BONE="WebGapArmatureSwitchDirectionOther"
|
|
def main():
|
|
a=sys.argv[sys.argv.index("--")+1:];
|
|
if len(a)!=1: raise SystemExit("usage")
|
|
bpy.ops.wm.read_factory_settings(use_empty=True);arm=bpy.data.armatures.new(ARMATURE_NAME);obj=bpy.data.objects.new(OBJECT_NAME,arm);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")
|
|
root=arm.edit_bones.new(ROOT_BONE);root.head=(0,0,0);root.tail=(0,1,0);child=arm.edit_bones.new(CHILD_BONE);child.head=(0,1,0);child.tail=(0,2,0);child.parent=root;child.use_connect=True;other=arm.edit_bones.new(OTHER_BONE);other.head=(2,0,0);other.tail=(2,1,0)
|
|
for b in (root,child):b.select=True;b.select_head=True;b.select_tail=True
|
|
other.select=False;other.select_head=False;other.select_tail=False;arm.edit_bones.active=root;bpy.ops.object.mode_set(mode="OBJECT");bpy.ops.wm.save_as_mainfile(filepath=str(pathlib.Path(a[0]).resolve()),check_existing=False,compress=True)
|
|
if __name__=="__main__":main()
|