Skip to main content

Python wrapper for Autodesk Maya FBX plugin

Project description

mayafbx

PyPI Buy Me a Coffee

A Python wrapper for the Maya FBX plugin

DocumentationAPI ReferencePyPIGitLabGitHubContributingChangelog

Installation

pip install mayafbx

You can also download and extract mayafbx-{version}.zip from latest release. The zip archive have is structured as follows:

.
├── LICENSE
├── METADATA.json
├── README.md
└── mayafbx/
    ├── __init__.py
    └── ...

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mayafbx-2.0.0.tar.gz (143.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mayafbx-2.0.0-py3-none-any.whl (24.3 kB view details)

Uploaded Python 3

File details

Details for the file mayafbx-2.0.0.tar.gz.

File metadata

  • Download URL: mayafbx-2.0.0.tar.gz
  • Upload date:
  • Size: 143.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","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

Hashes for mayafbx-2.0.0.tar.gz
Algorithm Hash digest
SHA256 ffa9f769b292358bbd2ec02373e3999fb5346fb2557e511ef6977bb8488780fb
MD5 80beab0a1312848bd694cf24c8ba70ab
BLAKE2b-256 30ec7100069b96489378a7fa63ed12cbab4b2c174945d783e4810d1705046869

See more details on using hashes here.

File details

Details for the file mayafbx-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: mayafbx-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 24.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","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

Hashes for mayafbx-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 553895bb74400d9696b1fd0d7498e4553cc3a21e9f9a8764eeb1a6f2d39dfc7e
MD5 b8e93ba20815423b147f68facccf11af
BLAKE2b-256 0232325c7300513047cfeff4b2eb56e4dda116759e7c2c95ab23b28b0b33b28f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page