Specify 3D File Save Options in C#

Overview

This article explains how you can save 3D files into different formats after loading them in Scene object using C#. By loading and saving, you can perform number of different conversions e.g.

  • Convert FBX to X in C#
  • Convert GLTF to OBJ in C#
  • Convert OBJ to X in C#
  • Convert STL to OBJ in C#
  • Convert RVM to 3DS in C#

3D File Save Options

There are several Scene.Save method overloads that accept a SaveOptions object. This should be an object of a class derived from the SaveOptions class. Each save format has a corresponding class that holds save options for that save format, for example, there is ColladaSaveOptions for the FileFormat.Collada save format.

Use of the Collada Save Options

The C# code below shows how to set save options before saving a 3D file to Collada format.

Use of the Discreet3DS Save Options

The C# code below shows how to set save options before saving a 3D file to a Discreet 3DS format.

Use of the FBX Save Options

The C# code below shows how to set save options before saving a 3D file to an FBX format.

FBXSaveOptions also exposes EnableCompression property which can be used to compress large binary data in the FBX file. Default value of this property is true. Below code snippet explains how can you work with this property while saving a scene.

Use of the Obj Save Options

The code below shows how to set save options before saving a 3D file to an Obj format.

Use of the STL Save Options

The C# code below shows how to set save options before saving a 3D file to STL format.

Use of the U3D Save Options

The C# code below shows how to set save options before saving a document to U3D format.

Use of the glTF Save Options

The C# code below shows how to set save options before saving a document to glTF format.

PrettyPrint in glTF Save Options

You can also use PrettyPrint property of GLTFSaveOptions class for human-understandable JSON print. The code below shows how to use this functionality. 

Save Dependencies of a 3D Scene in the Real File System

Developers may require to save all 3D scene dependencies in the real file system. They can define the path of a local directory, save in the MemoryFileSystem object or simply discard dependencies. The FileSystem property is added in the all save option classes.

Discard Saving the Material Files

Save Dependencies in the Local Directory

Save Dependencies in the MemoryFileSystem Object

Use of the Google Draco (.drc) Save Options

The C# code below shows how to set save options before saving a 3D model to DRC format.

Use of the RVM Save Options

The C# code below shows how to set save options before saving a 3D model to RVM format.