4

Could i use blender to export model to .fbx format via console?

something like: blender.exe myModel.blend --output model.fbx

2 Answers2

6

For Blender 2.90 and up this script will export a scene as an FBX file for you.

export_fbx.py:

import bpy
import sys

print("Blender export scene in FBX Format in file "+sys.argv[-1])

# Doc can be found here: https://docs.blender.org/api/current/bpy.ops.export_scene.html
bpy.ops.export_scene.fbx(filepath=sys.argv[-1])

To invoke it with blender you can use the following command:

blender <your_scene>.blend --background --python export_fbx.py -- <your_scene>.fbx

The python script is the minimum you can get away with for exporting your scene. There are a lot of parameters you can pass to the export_scene.fbx() function and it does not handle mutliple input and output files.

OutOfBound
  • 1,914
  • 14
  • 31
1

The answer is yes, you could, but in non-trivial way. What i mean by that, is, as it says here in Python Options, you can execute python script (as file, or as passed string) from a command line. Example:

blender --background --python myscript.py

Your script will be executed in --background mode - that means without even opening Blender GUI. So you can use Blender as import-export module. Basically you can use anything that is in bpy module in such a way. Have a nice time!


EDIT

something like: blender.exe myModel.blend --output model.fbx

Link, that i have provided, also contains all other command line options for Blender. At least i haven't found direct import-export option here. So i think you will anyway need to write python script.

Nicolas Iceberg
  • 665
  • 1
  • 6
  • 17
  • 1
    What script should i use to export to fbx? Is it already in blender? How could I run it? – Yaroslav Aloshyn May 17 '20 at 13:21
  • For controlling blender in python script, use `bpy`. It's blender python library, that allows you to communicate with blender within code. To run python script, using blender, type this into your cmd: ` --background --python myscript.py`. you need to pass path where yor blender exe is instead of , and myscript.py is the path where your script is. – Nicolas Iceberg May 17 '20 at 13:38
  • I understand what you want to do, but i'm afraid that there is no really "quick'n'easy" way to do this. For your purposes, https://docs.blender.org/api/current/bpy.ops.export_scene.html and https://docs.blender.org/api/current/bpy.ops.import_scene.html is good to read. Let me know if you have any problems or questions. – Nicolas Iceberg May 17 '20 at 13:40