Skip to content

Latest commit

 

History

History
111 lines (76 loc) · 5.07 KB

building_fbx.md

File metadata and controls

111 lines (76 loc) · 5.07 KB

Building the FBX Python SDK for Blender 2.8.x

Introduction

Autodesk provides the FBX SDK free of charge on their website, both for C++ and Python. However, for the longest time, the SDK was only available for Python 2.7 and 3.3. This made it automatically incompatible with Blender 2.8.x, which is based on Python 3.7.4.

Recently, Autodesk changed course and released the SIP bindings for its SDK. This is making it possible for anyone to build the Python SDK against any Python version they want with limited effort. Building a version compatible with Blender 2.8.x is now easy - just follow the steps below!

Licensing

You are responsible to adhere to the Autodesk FBX SDK's terms and conditions if you use it in your project or try and distribute it! While you can access a lot of code from the SDK, it does NOT make the SDK an open source project like Blender.

Getting started

On Windows

To start building your own FBX Python SDK, please make sure you have the following things setup:

On Linux

Get Python 3.7.4 from your distribution package manager or build it yourself from sources.

Under Linux, all references to python should be python3 or python3.7 instead (if you're building with Python 3).

Ubuntu (apt-get)

Install all packages below with sudo apt-get install and then the package name:

  • build-essential
  • libsqlite3-dev
  • libbz2-dev
  • libxml2-dev

If the installation of any package fails, try to run sudo apt-get update first.

CentOS (yum)

The quickest way to install the required development packages is using sudo yum groupinstall 'Development Tools'.

Next you will also need sudo yum install libxml2-devel

Download

Setting up

Install

Install the FBX SDK and the Python Bindings.

On Linux

Change the permissions for the installers if necessary to allow them to be executed. Start a terminal in the directory where you unpacked the installers and write chmod ugo+x fbx20201_fbxpythonbindings_linux and chmod ugo+x fbx20201_fbxsdk_linux.

Next you need to run the installers from the same terminal and provide the folder where to install as an argument to the installer. E.g. ./fbx20201_fbxpythonbindings_linux /home/user/Documents/fbx_python_bindings (make sure the folder you're installing to exists before hand).

Folder setup on Windows

For ease of operations, create a directory in your documents or on a drive that doesn't require admin rights when you work.

  • Unpack the Sip package to this directory, e.g.
    • E:\fbxsdk\sip
  • Copy the contents of the FBX Python bindings from the installation, e.g.
    • C:\Program Files\Autodesk\FBX\FBX Python Bindings\2020.0.1, to:
    • E:\fbxsdk\fbx

Environment Variables

Create these two environment variables:

  • FBXSDK_ROOT
    • Set to the place where you installed the FBX SDK to, e.g.
    • C:\Program Files\Autodesk\FBX\FBX SDK\2020.0.1
    • /home/user/Documents/fbx_sdk
  • SIP_ROOT
    • To the location that you unpacked the SIP package to, e.g.
    • E:\fbxsdk\sip
    • /home/user/Documents/sip-4.19.13
  • PATH (on Windows - can also be done temporarily)
    • Make sure that Python 3.7 is the Python version that is referenced in the PATH variable, e.g.
    • _C:\Users\username\AppData\Local\Programs\Python\Python37_

Preparing Sip

In the directory where you unpacked Sip (in the example above E:\fbxsdk\sip) run python configure.py in your commandline.

If you're using a recent Ubuntu Linux version find the siputils.py and navigate the line libs.extend(self.optional_list("LIBS)) and move it in front of the loop for l in self.extra_libs:. Otherwise you might encounter an ImportError later stating that fbx.so has an undefined symbol: xmlFree.

Building the FBX Python SDK

In the directory that you copied the FBX bindings to (in the example above E:\fbxsdk\fbx), run python PythonBindings.py Python3_x64 buildsip from the commandline. (Under Linux use python3 instead of python)

Copying the FBX SDK into place

Once the build step is done, the FBX Python SDK files will be in build\Distrib\site-packages\fbx (e.g. E:\fbxsdk\fbx\build\Distrib\site-packages\fbx).

  • fbx.pyd
  • FbxCommon.py
  • sip.pyd

Copy the files from there to the site-packages directory (so that you have site-packages/fbx.pyd/fbx.so) and you can then import fbx.