Python wrapper for Autodesk Maya FBX plugin
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mayafbx-2.0.1.tar.gz.
File metadata
- Download URL: mayafbx-2.0.1.tar.gz
- Upload date:
- Size: 143.2 kB
- Tags: Source
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c85e60b003a4b7f4b5df1622933406d8872cae2349dc6452af7aa546ba6db8f2
|
|
| MD5 |
de579e674fe577df4ea88269b1985156
|
|
| BLAKE2b-256 |
5c6dc8b60903075d216901be8d08ff361c48f87b7dae8e60b75c03f5d311fdff
|
File details
Details for the file mayafbx-2.0.1-py3-none-any.whl.
File metadata
- Download URL: mayafbx-2.0.1-py3-none-any.whl
- Upload date:
- Size: 24.3 kB
- Tags: Python 3
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87f52b4755b94bf482d6fc004afa3e72a57c93a9eab87e8463260d660c7d4373
|
|
| MD5 |
ec85791e37fbff25cfab3695e02a1998
|
|
| BLAKE2b-256 |
b946efcb7d088aa686c9828df948ebccd7369040f5de442f65dfeb2637d5571a
|