Installation

Installation von Aspose.3D FOSS für Python

Aspose.3D FOSS for Python wird als reines Python‑Paket auf PyPI verteilt. Es gibt keine nativen Erweiterungen zu kompilieren, keine Systembibliotheken zu installieren und kein Microsoft Office oder andere Drittanbieter‑Runtime erforderlich.


Voraussetzungen

AnforderungDetail
Python-Version3.7, 3.8, 3.9, 3.10, 3.11 oder 3.12
Paketmanagerpip (im Lieferumfang von CPython enthalten)
BetriebssystemWindows, macOS, Linux (jede Plattform, die CPython ausführt)
Compiler / Build-ToolsNicht erforderlich
SystempaketeNicht erforderlich

1. Installation über pip (Empfohlen)

Der einfachste Weg, Aspose.3D FOSS zu installieren, ist direkt von PyPI:

pip install aspose-3d-foss

pip wird das Paket herunterladen und installieren und es in Ihrer Umgebung verzeichnen. Keine Nachinstallationskonfiguration ist nötig.

Um eine festgelegte Version für reproduzierbare Builds zu installieren:

pip install aspose-3d-foss==26.1.0

2. Einrichtung einer virtuellen Umgebung (empfohlen für Projekte)

Die Verwendung einer virtuellen Umgebung hält die Bibliothek von anderen Python‑Projekten isoliert und vermeidet Versionskonflikte.

Erstelle und aktiviere eine virtuelle Umgebung:

##Create the environment
python -m venv .venv

##Activate on Linux / macOS
source .venv/bin/activate

##Activate on Windows (Command Prompt)
.venv\Scripts\activate.bat

##Activate on Windows (PowerShell)
.venv\Scripts\Activate.ps1

Installieren Sie die Bibliothek innerhalb der aktivierten Umgebung:

pip install aspose-3d-foss

Abhängigkeiten für Reproduzierbarkeit aufzeichnen:

pip freeze > requirements.txt

Um die Umgebung auf einem anderen Rechner zu reproduzieren:

python -m venv .venv
source .venv/bin/activate   # or the Windows equivalent
pip install -r requirements.txt

3. Installation überprüfen

Nach der Installation überprüfen Sie, ob die Bibliothek korrekt importiert wird:

from aspose.threed import Scene

scene = Scene()
print("Aspose.3D FOSS installed successfully")
print(f"Root node name: {scene.root_node.name}")

Erwartete Ausgabe:

Aspose.3D FOSS installed successfully
Root node name:

Hinweis: Der Wurzelknoten hat keinen Standardnamen — scene.root_node.name gibt eine leere Zeichenkette zurück.

Sie können die installierte Version auch mit pip überprüfen:

pip show aspose-3d-foss

Dies gibt die Version, den Autor und die Lizenz (MIT) aus.


Schnellstart: Szene laden und inspizieren

Das folgende Skript lädt eine 3D‑Datei, gibt Informationen zu jedem Mesh‑Knoten aus und exportiert die Szene erneut im GLB‑Format:

from aspose.threed import Scene
from aspose.threed.formats import ObjLoadOptions

##Load an OBJ file with material support
options = ObjLoadOptions()
options.enable_materials = True
options.flip_coordinate_system = False

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

##Print the scene hierarchy
print(f"Top-level nodes: {len(scene.root_node.child_nodes)}")

for node in scene.root_node.child_nodes:
    if node.entity is None:
        continue
    mesh = node.entity
    print(f"  Node: {node.name}")
    print(f"    Vertices: {len(mesh.control_points)}")
    print(f"    Polygons: {len(mesh.polygons)}")
    if node.material:
        print(f"    Material: {type(node.material).__name__}")

##Re-export to GLB (binary glTF)
scene.save("output.glb")
print("Saved output.glb")

Wenn Sie noch keine OBJ-Datei haben, kann die Bibliothek auch eine Szene von Grund auf neu erstellen:

from aspose.threed import Scene

##Create an empty scene and save it as glTF
scene = Scene()
scene.save("empty.gltf")
print("Created empty.gltf")

Plattformhinweise

Windows, macOS, Linux: Die Bibliothek ist auf allen Plattformen identisch. Es gibt keine plattformspezifischen Codepfade oder Binärerweiterungen.

Docker / serverless: Da es keine Systempaket‑Abhängigkeiten gibt, funktioniert die Bibliothek in schlanken Docker‑Images (wie python:3.12-slim), ohne zusätzliche apt‑ oder yum‑Pakete zu installieren.

CI/CD: Fügen Sie pip install aspose-3d-foss zu dem Abhängigkeitsschritt Ihrer CI-Pipeline hinzu. Keine zusätzliche Einrichtung ist erforderlich.

Conda: Wenn Ihr Projekt Conda verwendet, installieren Sie die Bibliothek von PyPI innerhalb einer Conda-Umgebung:

conda create -n my-env python=3.12
conda activate my-env
pip install aspose-3d-foss

Zusätzliche Ressourcen

 Deutsch