How to Convert 3D Models in .NET

How to Convert 3D Models in .NET

Aspose.3D.Converter for .NET makes format conversion a two-step operation: load the source file with Scene.Open(), then save to the target format with Scene.Save(). The output format is inferred from the file extension.

Step-by-Step Guide

Step 1: Install the Package

dotnet add package Aspose.3D.Converter --version 1.0.0

Step 2: Import Namespaces

using Aspose.ThreeD;
using Aspose.ThreeD.Formats;

Step 3: Load the Source File

var scene = new Scene();
scene.Open("input.fbx");

Step 4: Save in the Target Format

scene.Save("output.glb");

The library detects the target format from the extension. Supported export formats: OBJ, STL, glTF 2.0 / GLB, FBX, and COLLADA.


Step 5: Use Format-Specific Save Options

For fine-grained control, pass a SaveOptions subclass:

// FBX ASCII output
scene.Save("output.fbx", new FbxSaveOptions { IsAscii = true });

// OBJ with flipped coordinate system
scene.Save("output.obj", new ObjSaveOptions { FlipCoordinateSystem = true });

// COLLADA with indented XML
scene.Save("output.dae", new ColladaSaveOptions { Indented = true });

Common Conversion Recipes

SourceTargetCode
OBJ to GLBscene.Open("input.obj"); scene.Save("output.glb");Binary glTF for web viewers
FBX to STLscene.Open("input.fbx"); scene.Save("output.stl");Triangulated mesh for 3D printing
glTF to COLLADAscene.Open("input.gltf"); scene.Save("output.dae");DAE exchange format
STL to OBJscene.Open("input.stl"); scene.Save("output.obj");Wavefront for modelling tools

Common Issues and Fixes

Output file is empty or very small

Ensure the source file loaded successfully. Check scene.RootNode.ChildNodes.Count after Open().

Materials lost during conversion

Not all formats carry the same material properties. OBJ materials use Lambert/Phong; glTF uses PBR. Material mapping is best-effort across format boundaries.

Scale difference between source and output

Different tools use different unit systems. Apply ObjLoadOptions.Scale on import or adjust node.Transform.Scale before saving.


Frequently Asked Questions (FAQ)

Can I convert PLY to another format?

PLY is import-only. Load a PLY file and save to any export format (OBJ, STL, GLB, FBX, COLLADA).

Does conversion preserve animations?

Animation data (AnimationClip) is preserved when both formats support it (e.g., FBX to glTF). STL and OBJ do not carry animation data.

Can I batch-convert multiple files?

Create a new Scene for each file in a loop. Each Scene is independent and can be processed in parallel.