Any file to be rendered with the help of CAD Exchanger Web Toolkit needs to be converted into a web-friendly format CDXFB. This can be done using CDXFB Converter tool or CAD Exchanger SDK.
For users who want to evaluate the functionality of the Web Toolkit without going into the details of using the CAD Exchanger SDK, it is recommended to use CDXFB Converter tool. More information about it can be found on the CDXFB Converter tool. However, with full-fledged operation after evaluation, it will still be necessary to use the SDK. For other purposes, the best solution is using CAD Exchanger SDK.
In this tutorial, we will first consider CDXFB Converter Tool usage to convert a CAD model to the native .cdxfb format and then we will take a look at CAD Exchanger SDK for conversions and thumbnail generation. If you need something more complex than just converting files, then CAD Exchanger SDK also should fit your needs.
Note: C# with .NET 5 will be used when writing this example. If you are interested in another programming language, please take a look at the CDXFB Converter and Offscreen Rendering examples.
In our tutorial we will use Radial_Engine.jt
file (model can be downloaded from this link). This file should be copied to data/models
folder, created in Step 1.
Note: Thumbnail generation is only available using the SDK. If you're using CDXFB Converter Tool for this tutorial, save the image below on your computer to use as thumbnail:
Thumbnail must be located in
<path-to-JT Viewer-folder>/data/thumbnails/Radial_Engine.jt.png
You can obtain the latest version of CAD Exchanger SDK by signing up for a free evaluation on our website.
Note: CDXFB Converter tool is available in CAD Exchanger SDK 3.16.0 or higher
CDXFB Converter Tool is a command-line application based on cdxfbconverter. It was created to simplify the evaluation of the Web Toolkit functionality.
CDXFB Converter Tool located in SDK package:
<CAD-Exchanger-SDK-folder>\win64\vc14.1\bin\CDXFBConverter.exe
<CAD-Exchanger-SDK-folder>/lin64/gcc7/bin/CDXFBConverter
The license key for CDXFB Converter Tool application should be copied into the directory containing CDXFBConverter application.
To launch CDXFB Converter Tool:
Terminal
or Command Prompt
application.
CDXFB Converter Tool is not delivered with the SDK for Python. This is due to the distribution of the SDK for Python using pip.
To convert a file to .cdxfb format please use the cdxfbconverter
example downloaded from GitHub.
To run python cdxfbconverter
example:
cadex_license.py
) into root python examples folder.Terminal
or Command Prompt
application.cdxfbconverter
example.
Note: The complete code of this program can be found in
<CAD-Exchanger-SDK-folder>/examples/<programming-language>/conversion/cdxfbconverter
folder.
cdxfbconverter
folder in JT Viewer
directory created in Step 1.ConverterProject
project name). 3. Copy license fileNote : Uncheck the "Create folder for solution" checkbox, otherwise your folder structure will be slightly different.
cadex_license.cs
into cdxfbconverter
folder.cdxfbconverter/cadex/sdk/
folder).cadex_license.cs
file and add references to the CadExCoreNet
and CadExViewNet
libraries.Note:
- Path to the CadExCoreNet library is specified as
..\cadex\sdk\csharp\netstandard2.0\CadExCoreNet.dll
- Path to the CadExViewNet library is specified as
..\cadex\sdk\csharp\netstandard2.0\CadExViewNet.dll
First, create basic C# application which connects CAD Exchanger SDK and activates license key. Also need to add paths to native CAD Exchanger SDK libraries.
cdxfbconverter/ConverterProject/Program.cs
Next, use the universal reader to read and convert the model to the CAD Exchanger's native in-memory representation.
Program.cs
Finally, save the model to CDXFB.
Program.cs
Optionally, you can optimize the resulting file size by choosing the information saved to CDXFB format. For more information please refer to Optimizing CDXFB file contents.
Program.cs
In our tutorial, we are also using a thumbnail as a preview of the 3D file. To enable that, we add the ability to output PNG to our application:
Setup parameters to display one of available representation.
Program.cs
Convert model into visualisation entities.
Program.cs
Create scene and display all entities.
Program.cs
Setup offscreen viewport with transparent background and perspective camera.
Program.cs
Attach viewport to the scene. Apply scene changes to viewport and wait until all async operations are finished. Then fit and center model on the image.
Program.cs
Grab rendered frame into image.
Program.cs
If running the application directly from Visual Studio, the working path is bin/Debug
subfolder of the project. In that case you can use the following paths as command line arguments:
../../../../data/models/Radial_Engine.jt
../../../../data/cdxfb/Radial_Engine/Radial_Engine1.cdxfb
../../../../data/thumbnails/Radial_Engine.jt.png
Finally, we should also update the start page to display correct thumbnail and file name.
index.html
With that, we should see Radial_Engine.jt
model name and thumbnail on the start page: