How to Get Started with 3D in Python
Prerequisites
- Python 3.8 or later
- pip package manager
Step 1 — Install the Package
Install Aspose.3D FOSS for Python from PyPI:
pip install aspose-3d-fossVerify the installation:
import aspose.threed as a3d
print(a3d.__version__)Step 2 — Create Your First 3D Scene
A Scene is the root container for all 3D objects. The constructor accepts an optional
entity, parent scene, and name:
import aspose.threed as a3d
# Create an empty scene (CLM-3d-35d727)
scene = a3d.Scene()
# Access the root node of the scene (CLM-3d-859ac2)
root = scene.root_node # root_node is a property, not a method — no ()
print("Root node:", root)Step 3 — Add a Mesh to the Scene
Mesh represents polygon geometry. Node attaches entities to the scene graph:
import aspose.threed as a3d
scene = a3d.Scene()
# Create a named mesh (CLM-3d-529c11)
mesh = a3d.Mesh("my_mesh")
# Create a node and attach the mesh (CLM-3d-0edae8)
node = a3d.Node("my_node", mesh)
# Add the node as a child of the root (CLM-3d-a403f5)
scene.root_node.add_child_node(node) # root_node is a property, not a method — no ()Step 4 — Load an Existing 3D File
Scene.open() loads a 3D file from disk or stream. It accepts a path and optional
load options:
import aspose.threed as a3d
# Load an OBJ file (CLM-3d-d84964)
scene = a3d.Scene()
scene.open("model.obj")
# Inspect the loaded scene
root = scene.root_node # root_node is a property, not a method — no ()
print("Child nodes:", len(root.child_nodes)) # child_nodes is a property, not a method — no ()To detect the file format before loading:
import aspose.threed as a3d
# Detect the format from a file name (CLM-3d-d2de62)
fmt = a3d.FileFormat.detect(None, "model.fbx")
if fmt:
print("Detected format:", fmt.extension) # extension is a property, not a method — no ()Step 5 — Save Output to a File
Scene.save() exports the scene to any supported format. The recommended approach is
extension-based auto-detection: Aspose.3D infers the format from the file extension
(CLM-3d-8051bd, CLM-3d-b28d7a, CLM-3d-de8e1a):
import aspose.threed as a3d
scene = a3d.Scene()
# ... populate scene ...
# Save as Wavefront OBJ — extension auto-detects the format
scene.save("output.obj")
# Save as glTF 2.0 binary — .glb extension triggers binary GLB output
scene.save("output.glb")You can also pass an explicit format using the factory methods FileFormat.WAVEFRONT_OBJ()
or FileFormat.GLTF2(), but extension auto-detection is simpler and more portable.
Next Steps
- How to Load 3D Models in Python — formats, options, scene graph traversal
- How to Convert 3D Models in Python — batch conversion workflows
- How to Build Mesh Geometry in Python — control points, polygons, normals
- FAQ — common questions and troubleshooting