Hide menu
CDXFB Converter Example

Table of Contents

Converts a CAD file to CDXFB format used in CAD Exchanger Web Toolkit.

Overview

The CDXFB Converter shows how to import models from different formats and export their data to CDXFB format, which can be used to display CAD models in the web browser with the help of CAD Exchanger Web Toolkit.

Export to CDXFB

Export to CDXFB format is enabled using ModelData_WriterParameters:

ModelData_WriterParameters aParams;
aParams.FileFormat() = ModelData_WriterParameters::FileFormatType::Cdxfb;

The options below can be used to optimize the export. In this snippet the parameters are set to default values explicitly. Assign them the values you need for customization.

aParams.WriteBRepRepresentation() = true;
aParams.WritePolyRepresentation() = true;
aParams.PreferredLOD() = ModelData_RepresentationMask::ModelData_RM_MediumLOD;
aParams.WriteTextures() = false;
aParams.WritePMI() = false;

Let's call ModelData_Model::Save() method to store data in CDXFB file format:

if (!aModel.Save (aDest, aParams)) {
cerr << "Failed to write the file " << aDest << endl;
return 1;
};

Usage

You can try this example with the following model:

./examples/models/Radial_Engine.jt

CDXFB model usually consists of multiple files. When ModelData_Model::Save() is called with "scenegraph.cdxfb", a few auxiliary files will be created next to scenegraph.cdxfb. Therefore writing multiple CDXFB models to a single directory might make it hard to navigate. It is recommended to save each CDXFB model to a separate folder. Any folders you specify in the output path that are not yet present in the filesystem will be created automatically.

Save the model to the source folder for this example:

./examples/cxx/conversion/cdxfbconverter/Radial_Engine.jt.cdxfb/scenegraph.cdxfb

Files