pycollada
pycollada is a Python library for reading, writing, and creating COLLADA (COLLAborative Design Activity) documents, an interchange file format for interactive 3D applications. It allows users to load a COLLADA file and interact with it as a Python object, supporting creation from scratch and in-place editing. The current version is 0.9.3, released on January 24, 2026, with a fairly active release cadence addressing compatibility and performance improvements.
Warnings
- breaking Python 3.9 support was removed in pycollada 0.9.3, as Python 3.9 reached end-of-life. Python versions prior to 3.8 were dropped in 0.8.
- breaking NumPy became an explicit install requirement starting from version 0.8. Prior to this, it might have been an implicit dependency or optional. Additionally, versions 0.9.2 and 0.9 included fixes for compatibility with NumPy 2.0/2.3 after `fromstring` byte deprecation.
- gotcha Loading large COLLADA XML documents might fail without explicit `huge_tree` support enabled for the underlying `lxml` parser. This was addressed in version 0.8.
- gotcha When loading COLLADA documents, `pycollada` can raise exceptions like `DaeUnsupportedError` or `DaeBrokenRefError`. By default, these can halt loading.
- gotcha While pycollada 0.9.3 introduced compatibility with Python's built-in `ElementTree` API, `lxml` is still the recommended XML parser for better performance and robustness.
Install
-
pip install pycollada
Imports
- Collada
from collada import Collada
- *
from collada import *
Quickstart
import os
from collada import Collada, material, geometry, source
import numpy as np
# 1. Create a new COLLADA document
mesh = Collada()
# 2. Define geometry: a simple triangle
# Vertices
verts = np.array([
0.0, 0.0, 0.0,
1.0, 0.0, 0.0,
0.0, 1.0, 0.0
])
normals = np.array([
0.0, 0.0, 1.0,
0.0, 0.0, 1.0,
0.0, 0.0, 1.0
])
vert_src = source.FloatSource('my_verts-positions', verts, ('X', 'Y', 'Z'))
norm_src = source.FloatSource('my_normals-normals', normals, ('X', 'Y', 'Z'))
# Indices for a single triangle
triangles = np.array([0, 0, 1, 1, 2, 2]) # vertex index, normal index, ...
geom = geometry.Geometry(mesh, 'geometry0', 'my_triangle_geometry',
[geometry.Triangles(vert_src, norm_src, triangles, 'material0')])
mesh.geometries.append(geom)
# 3. Create a material
effect = material.Effect('effect0', [], 'phong', diffuse=(1, 0, 0, 1))
mat = material.Material('material0', 'red_material', effect)
mesh.materials.append(mat)
mesh.effects.append(effect)
# 4. Save the COLLADA document
output_file = 'my_first_collada.dae'
mesh.write(output_file)
print(f"Created '{output_file}'")
# 5. Load an existing COLLADA document (or the one we just created)
# For demonstration, we'll try to load the file we just saved.
if os.path.exists(output_file):
loaded_mesh = Collada(output_file)
print(f"Loaded '{output_file}' with {len(loaded_mesh.geometries)} geometries.")
# Example: Accessing a geometry
if loaded_mesh.geometries:
print(f"First geometry ID: {loaded_mesh.geometries[0].id}")
else:
print(f"Could not load '{output_file}'. Make sure the file exists.")