Blog

Build FBX Python SDK for Windows

Introduction

This post shares my steps for building the FBX Python SDK on windows. Previously, Autodesk only provides pre-compiled versions of the SDK that are locked to specific Python versions (Python 3.3 as of this blog post). In more recent SDK versions they have started publishing the "bindings" scripts in addition to the pre-built versions. This allows us to build the FBX Python SDK for a different target interpreter.

My goal was to be able to use the FBX Python SDK on Windows with Pyton 3.8 (x64)

Requirements

  • Visual Studio 2019 w/ C++ build tools
  • https://visualstudio.microsoft.com/
  • FBX C++ SDK 2020.1
  • https://www.autodesk.com/products/fbx/overview
  • NOTE: The VS2017 version is recommended and is assumed in the instructions below
  • FBX Python Bindings 2020.1
  • (https://www.autodesk.com/products/fbx/overview)
  • NOTE: This is not the "Python SDK" but specifically the "bindings"
  • SIP 4.19.3 (https://www.riverbankcomputing.com/software/sip/download)
  • NOTE: As of 2020.1 the SDK will not compile with any version of SIP newer than this

Building the FBX Python SDK

Building the FBX C++ SDK requires Visual Studio installed with the C++ compiler toolchain. We will also need to manually build Riverbank Computing's SIP library since the one available via pip is not compatible with the bindings project.

NOTE These instructions assume you are using a 64-bit python interpreter by default. Please use the correct instructions for your interpreter version.

Setup build files

The FBX C++ SDK, FBX Python Bindings project and SIP all must be extracted to a directory that doesn't require admin privileges and does not have spaces in the path. The installers for both the FBX C++ SDK and the FBX Pyton Bindings project will choose a default that is not suitable. For these instructions I recommend the following:

  • FBX C++ SDK C:\fbx\2020.1\sdk
  • FBX Python Bindings C:\fbx\2020.1\bindings
  • SIP C:\fbx\sip

Setup the environment

We will need to setup 3 environment variables so that the bindings script can correctly build:

  • Set FBXSDK_ROOT to C:\fbx\2020.1\sdk
  • Set FBXSDK_LIBS_64_FOLDER to C:\fbx\2020.1\sdk\lib\vs2017\x64\release
  • For 32-bit: set FBXSDK_LIBS_32_FOLDER to C:\fbx\2020.1\sdk\lib\vs2017\x86\release
  • Set SIP_ROOT to C:\fbx\sip

Build

We need to start a command prompt that has all the VC++ toolchain tools available. The recommended way to do this would be to start the x64 Native Tools Command Prompt for VS 2019 (x86 Native Tools Command Prompt for VS 2019 for 32-bit) from the start menu. Alternatively, a standard command prompt can be loaded and vcvarsall.bat can be called.

To build the bindings:

  • cd C:\fbx\2020.1\bindings
  • python PythonBindings.py Python3_x64 buildsip
  • For 32-bit: python PythonBindings.py Python3_x86 buildsip

If any errors occur please refer to the troubleshooting notes below. Once the build is complete it will generate a distribution directory. This can be copied to the interpereter's site-packages directory, the user's site-packages directory or to a virtualenv's site package directory.

e.g cp C:\fbx\2020.1\bindings\Distrib\site-packages\fbx to C:\Users\<USER>\AppData\Roaming\Python\Python38\site-packages

Troubleshoot

  • C:\Program is not a command
  • Don't the FBX C++ SDK/Bindings to their default location of C:\Program Files\.... Use a custom location with no spaces in the name
  • Could not find nmake
  • Use the visual studio command prompt or make sure you call vcvarsall.bat
  • Could not find fbx.pyd
  • Check the logs, you probably got a compile error or a link error
  • Link failed with libfbxsdk-md.lib
  • Check your FBXSDK_LIBS_64_FOLDER environment variable (or restart your command prompt if it is set)