PyPMXVMD
Python MikuMikuDance File Parser Library
PyPMXVMD is a Python library for parsing and modifying MikuMikuDance (MMD) files, supporting the following formats:
- VMD (Vocaloid Motion Data) - Motion/animation data
- PMX (Polygon Model eXtended) - 3D model data
- VPD (Vocaloid Pose Data) - Pose data
Features
- Full support for reading and writing VMD, PMX, and VPD files
- Conversion between binary and text formats
- Object-oriented API design, easy to use
- Complete type annotation support
- Cython acceleration(3.7x faster) for core parsing and binary I/O (VMD/PMX, binary read/write)
- No external dependencies (core functionality)
- Supports Python 3.8+
Installation
# Install from PyPI
pip install pypmxvmd
# Install from source
git clone https://github.com/pypmxvmd/pypmxvmd.git
cd pypmxvmd
pip install -e .
# Install development dependencies
pip install -e ".[dev]"
Optional: Build Cython Accelerators
The core parsing path supports Cython-accelerated modules for VMD/PMX and binary I/O. In typical workloads, the Cython implementation is ~3.7x faster on average than the previous implementation. Prebuilt wheels are provided for Windows (cp38-cp313). Other platforms or versions compile locally. If the compiled modules are not available, the library automatically falls back to pure Python.
pip install cython
python scripts/build_cython.py
Quick Start
Basic Usage
import pypmxvmd
# Load VMD motion file
motion = pypmxvmd.load_vmd("motion.vmd")
print(f"Bone frames: {len(motion.bone_frames)}")
print(f"Morph frames: {len(motion.morph_frames)}")
# Modify and save
pypmxvmd.save_vmd(motion, "modified_motion.vmd")
# Load PMX model file
model = pypmxvmd.load_pmx("model.pmx")
print(f"Vertices: {len(model.vertices)}")
print(f"Materials: {len(model.materials)}")
# Load VPD pose file
pose = pypmxvmd.load_vpd("pose.vpd")
print(f"Bone poses: {len(pose.bone_poses)}")
Automatic Format Detection
import pypmxvmd
# Automatically detect file type and load
data = pypmxvmd.load("file.vmd") # Returns VmdMotion
data = pypmxvmd.load("file.pmx") # Returns PmxModel
data = pypmxvmd.load("file.vpd") # Returns VpdPose
# Automatically detect data type and save
pypmxvmd.save(motion, "output.vmd")
pypmxvmd.save(model, "output.pmx")
pypmxvmd.save(pose, "output.vpd")
Text Format Conversion
PyPMXVMD supports converting binary files to readable text format for viewing and editing:
import pypmxvmd
# VMD -> Text
motion = pypmxvmd.load_vmd("motion.vmd")
pypmxvmd.save_vmd_text(motion, "motion.txt")
# Text -> VMD
motion = pypmxvmd.load_vmd_text("motion.txt")
pypmxvmd.save_vmd(motion, "motion.vmd")
# PMX -> Text
model = pypmxvmd.load_pmx("model.pmx")
pypmxvmd.save_pmx_text(model, "model.txt")
# VPD -> Text
pose = pypmxvmd.load_vpd("pose.vpd")
pypmxvmd.save_vpd_text(pose, "pose.txt")
Using Parser Classes
If you need more control, you can use the parser classes directly:
from pypmxvmd import VmdParser, PmxParser, VpdParser
# VMD Parser
vmd_parser = VmdParser()
motion = vmd_parser.parse_file("motion.vmd", more_info=True)
vmd_parser.write_file(motion, "output.vmd")
# PMX Parser
pmx_parser = PmxParser()
model = pmx_parser.parse_file("model.pmx", more_info=True)
pmx_parser.write_file(model, "output.pmx")
# VPD Parser
vpd_parser = VpdParser()
pose = vpd_parser.parse_file("pose.vpd", more_info=True)
vpd_parser.write_file(pose, "output.vpd")
Data Structures
VmdMotion (VMD Motion)
class VmdMotion:
header: VmdHeader # File header information
bone_frames: List[VmdBoneFrame] # Bone keyframes
morph_frames: List[VmdMorphFrame] # Morph keyframes
camera_frames: List[VmdCameraFrame] # Camera keyframes
light_frames: List[VmdLightFrame] # Light keyframes
shadow_frames: List[VmdShadowFrame] # Shadow keyframes
ik_frames: List[VmdIkFrame] # IK keyframes
PmxModel (PMX Model)
class PmxModel:
header: PmxHeader # File header information
vertices: List[PmxVertex] # Vertex list
faces: List[int] # Face indices
textures: List[str] # Texture paths
materials: List[PmxMaterial] # Material list
bones: List[PmxBone] # Bone list
morphs: List[PmxMorph] # Morph list
frames: List[PmxFrame] # Display frames
rigidbodies: List[PmxRigidBody] # Rigidbody list
joints: List[PmxJoint] # Joint list
VpdPose (VPD Pose)
class VpdPose:
model_name: str # Model name
bone_poses: List[VpdBonePose] # Bone pose list
morph_poses: List[VpdMorphPose] # Morph pose list
API Reference
Core Functions
| Function | Description |
|---|---|
load_vmd(path) |
Load VMD file |
save_vmd(motion, path) |
Save VMD file |
load_pmx(path) |
Load PMX file |
save_pmx(model, path) |
Save PMX file |
load_vpd(path) |
Load VPD file |
save_vpd(pose, path) |
Save VPD file |
load(path) |
Auto-detect and load |
save(data, path) |
Auto-detect and save |
Text Format Functions
| Function | Description |
|---|---|
load_vmd_text(path) |
Load VMD from text |
save_vmd_text(motion, path) |
Save VMD as text |
load_pmx_text(path) |
Load PMX from text |
save_pmx_text(model, path) |
Save PMX as text |
load_vpd_text(path) |
Load VPD from text |
save_vpd_text(pose, path) |
Save VPD as text |
load_text(path) |
Auto-detect and load text |
save_text(data, path) |
Auto-detect and save text |
Project Structure
pypmxvmd/ # Main package
__init__.py # Public API (load/save helpers)
common/ # Core implementation
io/ # Binary/text IO (+ Cython accel)
models/ # Data models (VMD/PMX/VPD)
parsers/ # Parsers (+ fast modules)
validators/ # Validation helpers
docs/ # Documentation
API.md # English API
API_CN.md # 中文 API
scripts/ # Build helpers
build_cython.py
build_wheels.py
tests/ # Tests + fixtures
Testing
# Run all tests
pytest tests/ -v
# Run specific test
pytest tests/test_vmd_parser.py -v
# Run coverage test
pytest tests/ --cov=pypmxvmd --cov-report=html
Development
# Install development dependencies
pip install -e ".[dev]"
# Code formatting
black pypmxvmd/
isort pypmxvmd/
# Type checking
mypy pypmxvmd/
# Code linting
flake8 pypmxvmd/
Changelog
v2.7.1
- Updated core parsers and binary I/O with Cython fast paths
- Added/expanded Windows wheel builds (cp38-cp313)
- Improved text format auto-detection and test coverage
v2.5.1
- Added optional Cython acceleration for core parsing and binary I/O
- Cython path averages ~3.7x faster than the previous implementation
v2.0.0 (2024)
- Complete refactor to object-oriented architecture
- Added complete type annotations
- Support for text format export/import
- Improved error handling and validation
- Added progress callback support
v1.x (Original)
- Based on Nuthouse01's original implementation
- Functional API
Acknowledgments
This project is refactored from the original MMD scripting tools by Nuthouse01.
License
MIT License - See LICENSE file for details
Contributing
Issues and Pull Requests are welcome!
- Fork this repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Create a Pull Request
Metadata
Release files for pypmxvmd 2.7.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pypmxvmd-2.7.2.tar.gz | 634.7 kB | Without provenance | Details for pypmxvmd-2.7.2.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| pypmxvmd-2.7.2-cp313-cp313-win_amd64.whl | CPython 3.13 | CPython 3.13 | Windows x86-64 | Details for pypmxvmd-2.7.2-cp313-cp313-win_amd64.whl |
| pypmxvmd-2.7.2-cp312-cp312-win_amd64.whl | CPython 3.12 | CPython 3.12 | Windows x86-64 | Details for pypmxvmd-2.7.2-cp312-cp312-win_amd64.whl |
| pypmxvmd-2.7.2-cp311-cp311-win_amd64.whl | CPython 3.11 | CPython 3.11 | Windows x86-64 | Details for pypmxvmd-2.7.2-cp311-cp311-win_amd64.whl |
| pypmxvmd-2.7.2-cp310-cp310-win_amd64.whl | CPython 3.10 | CPython 3.10 | Windows x86-64 | Details for pypmxvmd-2.7.2-cp310-cp310-win_amd64.whl |
| pypmxvmd-2.7.2-cp39-cp39-win_amd64.whl | CPython 3.9 | CPython 3.9 | Windows x86-64 | Details for pypmxvmd-2.7.2-cp39-cp39-win_amd64.whl |
| pypmxvmd-2.7.2-cp38-cp38-win_amd64.whl | CPython 3.8 | CPython 3.8 | Windows x86-64 | Details for pypmxvmd-2.7.2-cp38-cp38-win_amd64.whl |
Total release size: 4.8 MB
Release files / pypmxvmd-2.7.2.tar.gz
| Download URL | pypmxvmd-2.7.2.tar.gz |
|---|---|
| Size | 634.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6c0777c21ce8a2cfe62722987eab44c5438e991e523df6b091e8ac427d28ed0e
|
|
BLAKE2b-256 checksum How to use checksums |
a0e49f3bbeb277d60d68995bb5d059e5270c31ca5d0e194fb54875042c753f73
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.17
|
Release files / pypmxvmd-2.7.2-cp313-cp313-win_amd64.whl
| Download URL | pypmxvmd-2.7.2-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 735.3 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
487fdcac608b475f4f313d76ec1f3871073509ee70e666e070e851739bc9327d
|
|
BLAKE2b-256 checksum How to use checksums |
56a9f21065aae518b8bd4ebd5546b31ab5cfc064451cf77468923d7cdc5146a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.17
|
Release files / pypmxvmd-2.7.2-cp312-cp312-win_amd64.whl
| Download URL | pypmxvmd-2.7.2-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 737.7 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
d24118f72b453b0892b73e31fda77beae345a3c87503212b8588980643d28b99
|
|
BLAKE2b-256 checksum How to use checksums |
7f1b1977a79fce359ab69da2e1fc3ad3b386fc6a63ebc419a9380a3f20aa7711
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.17
|
Release files / pypmxvmd-2.7.2-cp311-cp311-win_amd64.whl
| Download URL | pypmxvmd-2.7.2-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 621.8 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
5fc98736d9a5801a13031a1f08f0f819010a738d7f2a3ddc416078589e150894
|
|
BLAKE2b-256 checksum How to use checksums |
fee404e44d2190948e24e81be3fbac7058ba43de6d3d6991d1bc7dad2c990e8e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.17
|
Release files / pypmxvmd-2.7.2-cp310-cp310-win_amd64.whl
| Download URL | pypmxvmd-2.7.2-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 737.2 kB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
15894e390c0a847ef7cd93a24ded0414693b699d486a2a94c05b5510394872ce
|
|
BLAKE2b-256 checksum How to use checksums |
b18b6a7034199a608ad1a68f401de50b58ec63863da70ba9f50ec00fb8ec8882
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.17
|
Release files / pypmxvmd-2.7.2-cp39-cp39-win_amd64.whl
| Download URL | pypmxvmd-2.7.2-cp39-cp39-win_amd64.whl |
|---|---|
| Size | 738.2 kB |
| Tags | CPython 3.9 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
84cd6ed744c292ef338d73c397afe8c54b5243428bd354a88882af8663faf7d0
|
|
BLAKE2b-256 checksum How to use checksums |
dce3f90bfc62f6f159052dc3e71f60e08027a65b819541aa93d911ecb2b02933
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.17
|
Release files / pypmxvmd-2.7.2-cp38-cp38-win_amd64.whl
| Download URL | pypmxvmd-2.7.2-cp38-cp38-win_amd64.whl |
|---|---|
| Size | 621.6 kB |
| Tags | CPython 3.8 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
96934bc038e6c59c64f020f2c90d09b2c98809547b12850ab36175de833162f4
|
|
BLAKE2b-256 checksum How to use checksums |
7d7db0f20cf59d2721ec61cba31c4cfd129a97a35445ed016b1e7f7799cd10f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.17
|
Security for pypmxvmd 2.7.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.