Selecting a scene object by type and wildcard

I’m using a Python script to run Blender’s FBX exporter, but I only want to export certain objects.

The FBX exporter has an option to only export selected objects, so I want to have only the Armature and one mesh selected when I call bpy.ops.export_scene.fbx().

I’m invoking my script from the command line like so: blender model.blend --python animation-export.py

But whatever I try, I get errors like “context is incorrect”, or that there is no bpy.context.scene or bpy.context.active.
Can anyone give me an example of how to select 1) the first Armature in my scene and 2) a mesh by name from Python?

I’ve uploaded my current, incomplete, Python script to PasteBin: animation-export.py

Solved it myself.

Here’s the completed script: animation-export.py

All documentation is at the top of the script.

1 Like

One more iteration. All issues solved.

Instead of requiring a dummy mesh to be exported by convention, the script now creates a skinned dummy mesh itself.

animation-export.py