1. Products
  2.   Aspose.3D
  3.   Aspose.3D FOSS for Python

Aspose.3D FOSS for Python

Open-source Python library for building 3D scenes, meshes, and materials, and converting between OBJ, STL, glTF, COLLADA, and 3MF formats.

Open-Source Python Library for 3D Scene & Mesh Processing

Aspose.3D FOSS for Python is a free, open-source library for building, importing, and exporting 3D scenes in Python applications. Install it with a single pip command (see below) and start assembling scene graphs, constructing mesh geometry, assigning materials, and converting between popular 3D file formats, all without any native dependencies. The library exposes a Pythonic API built around Scene, Node, Mesh, and Material, the core objects every 3D developer needs. Build a scene graph by creating Node objects and attaching mesh entities and materials with create_child_node(), construct mesh geometry directly with Mesh.create_polygon(), and assign surface properties using PbrMaterial, LambertMaterial, or PhongMaterial. Import and export OBJ, STL, glTF/GLB, COLLADA, and 3MF scenes through a unified Scene.open() / Scene.save() API, or call format-specific exporter and importer classes directly for finer control. Aspose.3D FOSS for Python is MIT-licensed and installs with a single pip command, with no native extensions to compile and no dependency on any commercial CAD application. This FOSS edition focuses on scene construction, mesh geometry, and format conversion — interactive rendering and GPU shader pipelines are not implemented in this open-source edition. Developers requiring enterprise features and production support can use Aspose.3D for Python — Enterprise Product alongside these open-source libraries.

Scene Graph & Node Hierarchy

  • Scene container: Scene is the entry point — Scene.open() loads a file, Scene.save() writes one, and Scene.from_file() offers a shortcut for quick loads.
  • Hierarchical nodes: Build parent/child structures with Node.add_child_node() and Node.create_child_node(); traverse with the child_nodes and parent_node properties.
  • Attach entities and materials: Node.add_entity() and the entity / material properties combine mesh, camera, and light entities with scene nodes directly.
  • Custom properties: find_property(), get_property(), set_property(), and remove_property() attach arbitrary metadata to nodes and most scene objects.

Where Scene Construction Is Used

  • Procedural content generation: assemble scenes entirely in code for tests, demos, or generative pipelines.
  • Asset pipeline tooling: build intermediate scene graphs when converting between CAD, game-engine, and web 3D formats.
  • Batch scene assembly: script repeatable scene layouts, such as product catalogs rendered as 3D thumbnails, without a 3D editor.
  • CI test fixtures: construct minimal scenes on the fly to validate downstream tooling.

Mesh & Geometry Construction

  • Build polygons directly: Mesh.create_polygon() and the control_points list define vertex data and faces entirely in code.
  • Parametric primitives: Box, Sphere, Cylinder, Pyramid, Dish, and Torus each expose to_mesh() to produce editable Mesh geometry.
  • Triangulation: PolygonModifier.triangulate() converts arbitrary polygons into triangle meshes for engines that require triangulated input.
  • Mesh introspection: the polygon_count, polygons, and control_points properties expose vertex and face data for analysis or custom processing.

Where Mesh Tools Are Used

  • Game asset prototyping: generate placeholder or parametric geometry for prototypes without a modeling tool.
  • Geometry validation: inspect polygon counts and control points to QA imported assets before shipping.
  • Format-neutral mesh processing: triangulate meshes imported from one format before exporting to another that requires triangles.
  • Procedural generation pipelines: build geometry programmatically for data visualization or generative design.

Multi-Format Import & Export

  • Round-trip formats: Scene.open() / Scene.save() support OBJ, STL, glTF/GLB, COLLADA, and 3MF for import and export.
  • Dedicated exporter/importer classes: ObjExporter, StlExporter, GltfExporter, ColladaExporter, and ThreeMfExporter — plus their matching importers — expose export() / import_scene() directly for finer control than Scene.save() / Scene.open().
  • Format detection: FileFormat.get_format_by_extension() resolves a FileFormat from a file extension so your code doesn’t have to hardcode format logic.
  • Plugin discovery: IOService.get_plugin_for_extension() and get_plugin_for_format() look up the registered importer, exporter, and detector for any supported format at runtime.

Where Format Conversion Is Used

  • Asset migration: move 3D content between CAD tools, game engines, and web viewers without round-tripping through a GUI.
  • Web-ready conversion: convert OBJ, STL, or COLLADA assets to glTF/GLB for browser-based 3D viewers.
  • Batch conversion pipelines: script bulk format conversion for asset libraries or build pipelines.
  • Automated validation: detect and verify file formats as part of ingestion or QA tooling.

Material System

  • Physically based rendering: PbrMaterial exposes albedo, metallic_factor, and roughness_factor for realistic surface definitions.
  • Classic shading models: LambertMaterial provides diffuse_color, ambient_color, emissive_color, and transparent_color; PhongMaterial adds specular_color, shininess, and reflection_color on top.
  • Assign materials directly on nodes: pass a material straight into Node.create_child_node() alongside the mesh entity, or set the material property afterward.
  • Format-aware export: material properties set in Python carry through to glTF (pbrMetallicRoughness), COLLADA, and 3MF exports.

Where the Material System Is Used

  • Automated branding: batch-recolor or re-material 3D product models for catalogs.
  • Asset pipeline remapping: translate materials from one format’s conventions to another during conversion.
  • Test fixture generation: produce materials programmatically for rendering/export test suites.
  • Game engine export prep: assign PBR material properties before exporting to glTF for engines such as Unity or Godot.

Load an OBJ Scene and Inspect Its Geometry

Install with pip, then open an OBJ file into a Scene and walk the node hierarchy to inspect the mesh data attached to each node.

pip install aspose-3d-foss
from aspose.threed import Scene
from aspose.threed.formats.obj import ObjLoadOptions

scene = Scene()
options = ObjLoadOptions()
options.enable_materials = True
scene.open("model.obj", options)

for node in scene.root_node.child_nodes:
    if node.entity is not None:
        mesh = node.entity
        print(f"{node.name}: {len(mesh.control_points)} vertices, {mesh.polygon_count} polygons")

Build a Primitive Mesh and Export to glTF

Create a Box primitive, convert it to a Mesh with to_mesh(), assign a LambertMaterial, attach it to the scene’s root node, and save directly to glTF.

from aspose.threed import Scene
from aspose.threed.entities import Box
from aspose.threed.shading import LambertMaterial
from aspose.threed.utilities import Vector3

scene = Scene()
box = Box(length=2.0, width=1.0, height=1.0)
material = LambertMaterial()
material.diffuse_color = Vector3(0.2, 0.6, 0.9)

scene.root_node.create_child_node("Crate", entity=box.to_mesh(), material=material)
scene.save("crate.gltf")

Triangulate Imported Geometry

Open an OBJ scene and run every node’s mesh entity through PolygonModifier.triangulate(), replacing the entity with its triangulated version when conversion succeeds.

from aspose.threed import Scene
from aspose.threed.entities import PolygonModifier

scene = Scene()
scene.open("model.obj")

for node in scene.root_node.child_nodes:
    if node.entity is not None:
        triangulated = PolygonModifier.triangulate(node.entity)
        if triangulated is not None:
            node.entity = triangulated

Create a PBR Sphere and Export to STL

Create a Sphere primitive, assign a PbrMaterial with albedo, metallic, and roughness values, attach it to the scene, and export to STL.

from aspose.threed import Scene
from aspose.threed.entities import Sphere
from aspose.threed.shading import PbrMaterial
from aspose.threed.utilities import Vector3

scene = Scene()
sphere = Sphere()
material = PbrMaterial(albedo=Vector3(0.8, 0.1, 0.1))
material.metallic_factor = 0.9
material.roughness_factor = 0.2

scene.root_node.create_child_node("Ball", entity=sphere.to_mesh(), material=material)
scene.save("ball.stl")

Frequently Asked Questions

What is the licensing model for Aspose.3D FOSS for Python?

Aspose.3D FOSS for Python is distributed under the MIT License, a permissive open-source license that allows free use, modification, and redistribution, provided the original copyright notice and license text are preserved.

Can I use Aspose.3D FOSS for Python in commercial products?

Yes. The MIT License explicitly permits use in commercial, closed-source products without royalty obligations, as long as the license text is included with any distributed copies of the source.

How do I install Aspose.3D FOSS for Python? What Python versions are supported?

Install with pip install aspose-3d-foss. The project declares python_requires=">=3.7", so Python 3.7 and later are supported.

Does Aspose.3D FOSS for Python require any native dependencies?

No. The package is pure Python with no runtime dependency entries declared in its packaging metadata — there is no native extension module or external binary dependency to install separately.

Which 3D file formats can Aspose.3D FOSS for Python read and write?

OBJ, STL (binary and ASCII), glTF/GLB, COLLADA (.dae), and 3MF all support a reliable round trip through Scene.open() / Scene.save(). FBX loading is supported through the FBX importer, but FBX saving is not implemented — FbxExporter.save() and FbxExporter.save_to_stream() both raise a not-implemented error at call time.

What are the current limitations of FBX support?

FBX import is experimental — the parser has known structural issues with deeply nested or unusual FBX scope structures and can hit Python’s recursion limit on complex files. FBX export is not available at all in this release. For production workflows, prefer OBJ, glTF/GLB, COLLADA, or 3MF, and reserve FBX for simple, flat-geometry import only.

  

Support and Learning Resources

 English