mayafbx
A Python wrapper for the Maya FBX plugin
Documentation • API Reference • PyPI • GitLab • GitHub • Contributing • ChangelogInstallation
pip install mayafbx
Comparison
Below is an example of exporting an FBX file using standard Maya commands:
from maya import mel
mel.eval("FBXResetExport")
mel.eval("FBXProperty Export|IncludeGrp|Animation -v true")
mel.eval("FBXProperty Export|IncludeGrp|Animation|ExtraGrp|RemoveSingleKey -v true")
mel.eval("FBXProperty Export|IncludeGrp|CameraGrp|Camera -v false")
mel.eval('FBXExport -f "C:/outfile.fbx" -s')
Here's how to achieve the same result with mayafbx:
import mayafbx
options = mayafbx.FbxExportOptions()
options.animation = True
options.remove_single_key = True
options.cameras = True
mayafbx.export_fbx("C:/outfile.fbx", options, selection=True)
Alternatively, all fields can be passed directly to the constructor as kwargs:
import mayafbx
options = mayafbx.FbxExportOptions(animation=True, remove_single_key=True, cameras=True)
mayafbx.export_fbx("C:/outfile.fbx", options, selection=True)
Example
This example shows how to export animation from a cube and import it back.
import os
import tempfile
from maya import cmds
import mayafbx
# start from an empty scene
cmds.file(new=True, force=True)
# create a cube with 2 keyframes
cube = cmds.polyCube()[0]
cmds.setKeyframe(cube, attribute="translateX", time=1, value=0)
cmds.setKeyframe(cube, attribute="translateX", time=24, value=10)
# prepare options to export baked animation
options = mayafbx.FbxExportOptions()
options.animation = True
options.bake_animation = True
options.bake_resample_all = True
# export the scene as FBX
filepath = os.path.join(tempfile.gettempdir(), "testcube.fbx")
mayafbx.export_fbx(filepath, options)
# remove all keys from the cube
cmds.cutKey(cube, attribute="translateX", option="keys")
# prepare options to import animation back to the cube
options = mayafbx.FbxImportOptions()
options.merge_mode = mayafbx.MergeMode.kMerge
options.animation = True
# import the previously exported FBX
mayafbx.import_fbx(filepath, options)
Contributing
Contributions of any kind are welcome. Please open an issue, or read the contribution guidelines and open a merge request.
Release files for mayafbx 2.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mayafbx-2.0.1.tar.gz | 143.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mayafbx-2.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 167.5 kB
Release files / mayafbx-2.0.1.tar.gz
| Download URL | mayafbx-2.0.1.tar.gz |
|---|---|
| Size | 143.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c85e60b003a4b7f4b5df1622933406d8872cae2349dc6452af7aa546ba6db8f2
|
|
BLAKE2b-256 checksum How to use checksums |
5c6dc8b60903075d216901be8d08ff361c48f87b7dae8e60b75c03f5d311fdff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Alpine Linux","version":"3.23.4","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / mayafbx-2.0.1-py3-none-any.whl
| Download URL | mayafbx-2.0.1-py3-none-any.whl |
|---|---|
| Size | 24.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
87f52b4755b94bf482d6fc004afa3e72a57c93a9eab87e8463260d660c7d4373
|
|
BLAKE2b-256 checksum How to use checksums |
b946efcb7d088aa686c9828df948ebccd7369040f5de442f65dfeb2637d5571a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Alpine Linux","version":"3.23.4","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|