0
$\begingroup$

If I use the outliner, I can select a skeleton and include it in an FBX export by hand. How would I do this programmatically?

The goal is to be able to export multiple meshes with the same armature to separate FBX files. Right now my script looks like the below, but it doesn't export the armature correctly.

import bpy


def export_clothing_items_to_assets_directory(assets_directory):
    objects = bpy.data.objects
    for object in objects:
        if ("_shoes" in object.name or "_top" in object.name or "_bottom" in object.name):
            bpy.ops.object.select_all(action='DESELECT')
            object.select = True
            for bone in bpy.data.objects[0].find_armature().data.bones:
                print("Selecting", bone.name)
                bone.select = True   
            export_path = assets_directory + object.name + '.fbx'
            bpy.ops.export_scene.fbx(filepath=export_path, check_existing=True, axis_up='Y', axis_forward='-Z', filter_glob="*.fbx", version='BIN7400', use_selection=True, global_scale=1.0, bake_space_transform=False, object_types={'MESH', 'ARMATURE'}, use_mesh_modifiers=False, mesh_smooth_type='OFF', use_mesh_edges=False, use_tspace=False, use_custom_props=False, add_leaf_bones=False, primary_bone_axis='Y', secondary_bone_axis='X', use_armature_deform_only=False, bake_anim=True, bake_anim_use_all_bones=True, bake_anim_use_nla_strips=True, bake_anim_use_all_actions=True, bake_anim_step=1.0, bake_anim_simplify_factor=1.0, use_anim=True, use_anim_action_all=True, use_default_take=True, use_anim_optimize=True, anim_optimize_precision=6.0, path_mode='AUTO', embed_textures=False, batch_mode='OFF', use_batch_own_dir=True, use_metadata=True)

export_clothing_items_to_assets_directory("D:/tmp/")

I would like to select the highlighted object in this image: enter image description here

When I try to select from the armature object, an error is thrown that Armature type cannot select.

>>> bpy.data.armatures[3].select = True
Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
AttributeError: 'Armature' object has no attribute 'select'
$\endgroup$
0
$\begingroup$

Selecting the MBlab_sk3213u120r3289hyf38u9ghqf object will grab the data.

$\endgroup$
  • $\begingroup$ This is not an answer to the question. An answer will contain a script which does what the question asks for. $\endgroup$ – Amir Oct 27 '18 at 12:55
  • 1
    $\begingroup$ This kind of sounds like this should be added to your question as additional information, not as an answer to your question. If however this is the answer to your question please expand on it because as it is now it will not be helpful to anyone except you. $\endgroup$ – David Oct 27 '18 at 22:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.