I'm trying to programmatically create an armature and I've run into an issue. While creating a new armature is straight-forward enough (bpy.ops.object.armature_add()
), there's no option in that function call to assign a custom name and the function itself doesn't return anything helpful in this regard. While getting the armature instance isn't too bad (albeit a bit fragile) thanks to new armatures being appended to the end of the bpy.data.armatures
list, the same doesn't quite seem to be the case for the armature's object. Without a known name to access it by, I'm not sure how to programmatically get access to it in a reliable manner.
The only solution I've been able to dig up so far involved looping over all objects in the scene, checking their type to see if they're armatures and then checking their names to see if it's the desired armature. I feel like this might run into performance issues with a large scene with many objects...
Is there an efficient way for me to get an armature's object?
Is there a direct access method like bpy.data.armatures[<armature name>].parent_object
or something of that nature?
bpy.ops.object.armature_add() ;ob = bpy.context.object ;arm = ob.data ;print(ob, arm)
$\endgroup$bpy.ops
) are designed to be called from UI, so they do not return anything besides the final status of the operator $\endgroup$