pyffi.formats.dae — COLLADA (.dae)

Last Built: Mar 06, 2020

pyffi.formats.dae — COLLADA (.dae)


This module is not yet fully implemented, and is certainly not yet useful in its current state.


class pyffi.formats.dae.DaeFormat[source]

Bases: pyffi.object_models.xsd.FileFormat

This class implements the DAE format.

class Data(version=17039616)[source]

Bases: pyffi.object_models.Data

A class to contain the actual collada data.


Get the collada version, as integer (for instance, 1.4.1 would be 0x01040100).


The version, as integer.


Quickly checks whether the stream appears to contain collada data. Resets stream to original position. If the stream turns out to be collada, L{getVersion} is guaranteed to return the version.

Call this function if you simply wish to check that a file is a collada file without having to parse it completely.


stream (file) – The file to inspect.


True if stream is collada, False otherwise.


Read collada data from stream.


stream (file) – The file to read from.


Write collada data to stream.


stream (file) – The file to write to.

Regression tests

Create a DAE file

>>> daedata = DaeFormat.Data()
>>> print(daedata.collada) 
<...Collada object at ...>

Read a DAE file

>>> from os.path import dirname
>>> dirpath = __file__
>>> for i in range(4): #recurse up to root repo dir
...     dirpath = dirname(dirpath)
>>> repo_root = dirpath
>>> format_root = os.path.join(repo_root, 'tests', 'formats', 'dae')
>>> # check and read dae file
>>> stream = open(os.path.join(format_root, 'cube.dae'), 'rb')
>>> daedata = DaeFormat.Data()
Traceback (most recent call last):
>>> # get DAE file root element
>>> #print(daedata.getRootElement())
>>> stream.close()

Parse all DAE files in a directory tree

>>> for stream, data in DaeFormat.walkData(format_root):
...     try:
...         # the replace call makes the doctest also pass on windows
...         os_path =
...         split = (os_path.split(os.sep))[-4:]
...         rejoin = os.path.join(*split).replace(os.sep, "/")
...         print("reading %s" % rejoin)
...     except Exception:
...         print("Warning: read failed due corrupt file, corrupt format description, or bug.")
reading tests/formats/dae/cube.dae
Warning: read failed due corrupt file, corrupt format description, or bug.

Create a DAE file from scratch and write to file

>>> daedata = DaeFormat.Data()
>>> from tempfile import TemporaryFile
>>> stream = TemporaryFile()
>>> daedata.write(stream) 
Traceback (most recent call last):