Adding metarigs via python (and scaling)

Looking for a few caviat things.

  1. add any of the metarigs via script.

  2. scale a full armature by arbitrary value and apply loc/rot/scale (via code)

  3. understanding how to create a matrix off the deconstruct() values from an edit_bone matrix.
    Loc, rot, scale.
    Simply loc * rot * scale errors out

  4. understanding how edit_bone.translate should work. So far it doesn’t seem like it does what I think it should do…
    Is it head, tail, or center based?

  5. bonus question. Is there a way to autokeyframe every layer/pose bone of every armor following the already present keyframes (which can some times not be at full frame distances) ?

Very american-socratic today, giving my self some of my own answers…

bpy.ops.object.armature_add(view_align=False, enter_editmode=False, location=(0, 0, 0), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))
bpy.ops.object.editmode_toggle()
bpy.ops.object.armature_human_metarig_add()

bpy.ops.transform.resize(value=(91, 91, 91), constraint_axis=(False, False, False), constraint_orientation=‘GLOBAL’, mirror=False, proportional=‘DISABLED’, proportional_edit_falloff=‘SMOOTH’, proportional_size=54.7637)
bpy.ops.object.transform_apply(location=True, rotation=True, scale=True)

I wish I had though of looking that up before - however I also wish the window was more extensive - it would allow to better understand how to work 3, 4 if I could see the commands being issues on the snap_selected for instance without having to go and look up the function…

In case someone wants the same result but is getting errors and what not, this works on .79

import bpy
import mathutils
from mathutils import Vector,Quaternion
import math
bpy.ops.object.armature_add(view_align=False, enter_editmode=False, location=(0, 0, 0), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))
bpy.ops.object.editmode_toggle()
bpy.ops.object.editmode_toggle()
bpy.ops.object.armature_human_metarig_add()
bpy.ops.transform.resize(value=(91, 91, 91), constraint_axis=(False, False, False), constraint_orientation="GLOBAL", mirror=False, proportional="DISABLED", proportional_edit_falloff="SMOOTH", proportional_size=54.7637)
bpy.ops.object.transform_apply(location=True, rotation=True, scale=True)

Going a little further I figured out that translation is additive - and that’s probably why it doesn’t work for me. It takes the current position into account when moving things.
I had to resort to head/tail math with ± length on the axis I’m interested.
Can’t believe there isn’t an easier way to just offset a bone by its center point though…