Skip to main content

A library that can be used to easily convert a collada file (.dae) to a wavefront file (.obj).

Project description

collada2obj

This Python library can be used to easily convert collada (i.e., .dae) files to wavefront (i.e., .obj ) files. This transformation between file formats for 3d models is useful for a variety of applications, though this library was motivated by the need for this transformation in some robotics applications.

At the moment, this library is a work in progress and is not yet fully functional. However, the basic functionality is there and the library can be used to convert simple collada files to obj files.

See the examples directory for example usages of the library.

Installation

To install this library, you can use pip:

pip install collada2obj

Local Installation

If you want to install this library locally, you can clone this repository and install it using pip in the following way: Change to the root directory of this repo and then run the following command:

pip install -e .

Usage

import ipdb
import typer
import xml.etree.ElementTree as ET
import numpy as np

from collada2obj import MeshConverter

def main(input_filename: str = "./base.dae", output_filename: str = "./out.obj"):
    # Setup

    # PARSE XML
    tree = ET.ElementTree(file=input_filename)

    # FIX xmlns problem
    # http://stackoverflow.com/questions/13412496/python-elementtree-module-how-to-ignore-the-namespace-of-xml-files-to-locate-ma
    for el in tree.iter():
        if '}' in el.tag:
            el.tag = el.tag.split('}', 1)[1]  # strip all namespaces

    # geometry_0
    meshes = tree.findall('library_geometries/geometry/mesh')

    models = []
    for ii, mesh_ii in enumerate(meshes):
        # Setup
        print(f"Processing mesh {ii}...")
        converter_ii = MeshConverter(mesh_ii)

        # model = reduce(MeshConverter.reduce, models)

        # Export
        converter_ii.export_obj(output_filename)

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

collada2obj-0.0.2.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

collada2obj-0.0.2-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file collada2obj-0.0.2.tar.gz.

File metadata

  • Download URL: collada2obj-0.0.2.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for collada2obj-0.0.2.tar.gz
Algorithm Hash digest
SHA256 52eb7c0a4661f2311b55ae9873b4957f467281899cda249bd8cc274aa54351cc
MD5 8a2e8276e6de14fe4730694d18f9061e
BLAKE2b-256 60abaf6a1a7a4fc456cf5d43535519e778debc2df9dcdd45dde3624dedacef75

See more details on using hashes here.

File details

Details for the file collada2obj-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: collada2obj-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for collada2obj-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7dd252a7bb05b6125de46dc09f72802d11e317b0245b8fe3579aaf30b4e6b2d8
MD5 665ecdd95894b390609d09a69e953742
BLAKE2b-256 2c1c10ea0bfd607603134dabff2d09dd62536dbc0f14c2d9a519cb4b1dc430c8

See more details on using hashes here.

Supported by

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