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 C++ examples open cmake-gui, choose the example's subdirectory, choose build directory and press "Configure" button.

cmake-gui_msvc_ide_step1.png

Next specify required Visual Studio version (e.g. Visual Studio 15 2017 Win64).

cmake-gui_msvc_ide_step2.png

When configuring has been done press "Generate" button.

cmake-gui_msvc_ide_step3.png

This will create Visual Studio project and solution files in the build subdirectory.

Note
For building Qt-based examples set QT_ROOT_DIR entry to Qt 5 installation folder and reconfigure project again.

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.2/examples/cxx/cadexgen
cmake -H. -Bbuild -G "Unix Makefiles"

Note
To get the list of supported generators invoke cmake --help.
To build a debug configuration add the switch -DCMAKE_BUILD_TYPE=Debug.
For building Qt-based examples add the switch -DQT_ROOT_DIR=<path_to_qt_directory>

To run built examples, you should add the path to CAD Exchanger dynamic libraries directory to the environment variable LD_LIBRARY_PATH on Linux and DYLD_LIBRARY_PATH on MacOS.

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

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

There are two ways to configure C# examples:

  1. Cmake-based. Generation of C# projects is exactly the same as generation of C++ projects for Visual Studio (see Building with Microsoft Visual Studio on Windows).
    Note
    Cmake 3.8.0 or higher is required to generate C# projects for Visual Studio.
  2. Visual Studio project files.
    • 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.2/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.2/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.2/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.2/win64/vc12/bin;%PATH%
eclipse_java_gen_var.png
  • Run As Java Application.