CAD Exchanger SDK
Examples

Introduction

CAD Exchanger SDK includes a set of C++, C# and Java examples demonstrating its functionality. The examples are located in the ${install_dir}/examples subdirectory.

The examples are provided under a permissive Modified BSD License. You may insert their source code into your application and modify as needed.

Prerequisites

Before launching examples make sure you:

  • Activate a license key received during evaluation (or after purchasing a commercial license);
  • Set your development environment. Refer to Setting up development environment for common settings and language-specific sections below.
Note
Whenever you modify an example code to use any other supported converter, change between 32 and 64 bit architectures, switch between debug and release modes make sure you update environment settings and (optionally) the example code to reflect the changes.

List of Examples

Links in the below table lead to C++ versions of respective example. For other language just navigate into corresponding subfolder in the SDK package.

Select any example that most closely matches your target use case and introduce modifications specific to your case.

Example Purpose
General Example Demonstrates how to simply convert CAD files with the help of CAD Exchanger SDK
Model Explorer Demonstrates how to explore imported model contents
Assembly Creation Demonstrates how to create an assembly of sub-assemblies and parts of solid primitives and to export to target format
Meshing Example Demonstrates how to create polygonal representations using computational meshers
Progress Status Example * Demonstrates how to integrate support of progress status update
CAD Exchanger Viewer Example * Demonstrates how to use and setup CAD Exchanger viewer
B-Rep Bottom-up Creation Example * Demonstrates how to create B-Rep representation bottom-up

(*) Available in C++ only.

C++ Examples

C++ examples are located in the subfolder ./examples/cxx.

Note
Save the license key file you received for your evaluation program as ${install_dir}/examples/cxx/cadex_license.cxx. When you become a customer you will substitute it with a commercial license key.

Building

C++ examples are provided with cmake-based configuration files. To build examples download the cmake tool from cmake.org.

Building with Microsoft Visual Studio on Windows

To build a particular example open the Windows command prompt window and switch to the example's subdirectory and invoke cmake specifying required Visual Studio version (e.g. Visual Studio 2015):

cd C:\dev\cadexchanger\3.4\examples\cxx\cadexgen
cmake -H. -B.\build -G "Visual Studio 14 2015 Win64"

This will create Visual Studio project and solution files in the build subdirectory. Open the solution file in Visual Studio and switch to the Release configuration:

msvs_cfg.png
Setting target configuration in Visual Studio
Note
To get the list of supported Visual Studio versions invoke cmake --help.
To build a debug configuration add the switch -DCMAKE_BUILD_TYPE=Debug. In this case make sure you use debug configuration in Visual Studio.
For Qt-based examples add the switch -DQT_ROOT_DIR=<path_to_qt_directory>.

Build the example in Visual Studio, and add the path to CAD Exchanger dynamic libraries directory in project properties:

msvs_dirs_path.png
Setting .dll directory in Visual Studio

Instead of setting environment for every project in Visual Studio, you can set the environment variable PATH in a .bat file that would launch Visual Studio. In this case any project will inherit these settings.

Note
Pay attention that you need to set respective directories depending on your particular configuration, including target architecture (x86 or x64), compiler (e.g. vc12 or vc14), and mode (release or debug). Refer to Setting up development environment for detailed descriptions of subfolders.

Building with GNU Makefiles

On Linux or MacOS, to build an example with the help of GNU make, use respective generator with cmake:

cd /dev/cadexchanger/3.4/examples/cxx/cadexgen
cmake -H. -B.\build -G "Unix Makefiles"

When building a debug configuration or Qt-based examples use additional switches described above.

C# Examples

C# examples are located in the subfolder ./examples/csharp.

Note
Insert contents of the license key your received for your evaluation period into your example code at the following line:
// insert the license key here!
//string theKey = "";

Building with Microsoft Visual Studio

  • Add a directory with 64-bit native C++ libraries (e.g. ./win64/vc14/bin) to the environment variable PATH. This is required for the Windows operating system to find these libraries during application's execution.
  • Open a selected example's project file (*.csproj).
  • By default, the example project files are configured to target 64-bit platforms and to use 64-bit assemblies located in ./csharp/win64 directory. If you need to enforce using 32-bit configuration then add a respective directory with 32-bit native C++ libraries (e.g. ./win32/vc14/bin) and update assembly references (e.g. CadExCoreNet, CadExParaNet, etc) by browsing the subdirectory corresponding to 32-bit configuration (e.g. ./csharp/win32).
  • If you modify the example by adding some new format then make sure you add a respective assembly to the list of references (e.g. CadExVRMLNet if you integrate the VRML converter).
  • Build and run the example.

Java Examples

Java examples are located in the subfolder ./examples/java.

Note
Insert contents of the license key your received for your evaluation period into your example code at the following line:
// insert the license key here!
//string theKey = "";

Building with Eclipse

The following instructions are applicable to setting release environment and using release libraries (from "vc12/bin" folder).

Note
If you want to setup debug environment and use debug libraries (from "vc12/bind" folder) take into consideration that you should use modified path in the steps below: path + "d" suffix (e.g. C:/dev/cadexchanger/3.4.0/win64/vc12/bind). To load appropriate dynamic library you should modify the source code and make loadLibrary() call with name of library + "d" suffix:
System.loadLibrary("CadExCored");
  • Create your Java project as usual.
  • Copy content of example file to project's java-file.
  • In the "Project Properties" dialog, choose the "Java Build Path" link, then click on the "Libraries" tab, and then click on the "Add External JARs" link. Navigate to the appropriate directory (e.g. C:/dev/cadexchanger/3.4.0/java) and select jar-files (e.g. CadExCoreJava.jar, CadExParaJava.jar, etc).
eclipse_java_gen_jar.png
  • In the "Run As" dialog, go to the "Arguments" tab and in the "VM Arguments" window create the following argument:
    -Djava.library.path=C:/dev/cadexchanger/3.4.0/win64/vc12/bin
eclipse_java_gen_arg.png
Note
Windows Only: Still in the "Run As" dialog, go to the "Environment" tab and create a new "PATH" variable with value:
C:/dev/cadexchanger/3.4.0/win64/vc12/bin;%PATH%
eclipse_java_gen_var.png
  • Run As Java Application.