Hide menu
Loading...
Searching...
No Matches
Export Example

Table of Contents

Converts a 3D model in memory and writes it to a target CAD file.

Overview

The Export Example shows how to export model data from ModelData_Model object to different file formats.

In this example we create a Writer which allows us to write data to a specific file format. It essentially mirrors the Importing Example.

Main Function

At the moment CAD Exchanger SDK supports a big variety of model types. Here we will export model data from ModelData_Model object to OBJ file format as one of the most popular one. Similar to the Import Example our main function will have the following structure:

ModelData_Model aModel;
if (!ModelData_ModelReader().Read (aSource, aModel)) {
cerr << "Failed to read the file " << aSource << endl;
return 1;
}
OBJ_Writer aWriter;
OBJ_WriterParameters& aWriterParams = aWriter.Parameters();
aWriterParams.LengthUnit() = Base_LengthUnit::Base_LU_Centimeters;
aWriterParams.ToGenerateMtlFile() = true;
  • Finally we can convert model data to a chosen format and save it:
if (!aWriter.Transfer (aModel)) {
cerr << "Failed to transfer model data to specified format" << endl;
return 1;
}
if (!aWriter.WriteFile (aDest)) {
cerr << "Failed to write the file " << aDest << endl;
return 1;
}

Summary

CAD Exchanger SDK provides a lot of packages for model data conversion. It's possible to read, write and transfer almost every existing model data format simply using algorithm described above.

To learn more about conversion possibilities please visit the Converter Details.

Files