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

C++ Examples

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

Building with Microsoft Visual Studio

Note
Currently project files shipped with SDK are created for Visual Studio 2013. To downgrade to an earlier Visual Studio version (2010 or 2012), open the project file and replace the platform toolset and the linker settings in the project properties dialog box, as explained below. If you work with newer versions (2015 or above) Visual Studio will automatically upgrade during first opening.
  • Open a respective project file (*.vcxproj).
  • Add paths to the include and library directories (${install_dir}/inc, ${install_dir}/${platform}/${compiler}/lib).

The following screenshots demonstrate how to set environment in Visual Studio:

msvs_dirs.png
Setting include and .lib directories in Visual Studio
msvs_dirs_path.png
Setting .dll directory in Visual Studio

The following screenshots demonstrate how to downgrade to Visual Studio 2010:

examples_prop_toolset.png
Setting Platform Toolset to VS2010
examples_prop_lib.png
Setting Linker settings to VS2010
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.

Instead of setting environment for every project in Visual Studio, you can set the environment variables INCLUDE, LIB and PATH in a .bat file. This file would set these variables and launch Visual Studio. In this case any project would inherit these settings.

Building with GNU Makefiles

On Linux or MacOS, to build an example with the help of GNU make, change the current directory to the example directory and type:

  • make or make release to build release mode;
  • make debug to build debug mode.

C# Examples

C# examples are located in the subfolder ./examples/csharp of the SDK package.

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

Building with Microsoft Visual Studio

  • Open a respective project file (*.csproj).
    Note
    Most likely you will notice warnings by Visual Studio that some references could not be resolved (see image below). This is due to Visual Studio limitations to enforce absolute file names (and paths) to be used in the project - assembly references cannot be resolved in user's environment. Please proceed as detailed below
    msvs_cs_asm.png
    Warnings in Visual Studio about unresolved assembly references
  • Manually add respective assembly references with the same name (e.g. CadExCoreNet, CadExParaNet, etc) by browsing the subdirectory corresponding to your target configuration (e.g. ./csharp/win64).
msvs_cs_asm_addref.png
  • Select target platform (32- or 64-bit) in the project settings ("Build" tab). For instance, the following image demonstrates how to set 64-bit configuration:
    msvs_cs_build_64.png
  • Build and run the example.

Java Examples

Java examples are located in the subfolder ./examples/java of the SDK package.

Note
Insert contents of the license key your received for your evaluation process into your example code at the following line:
//insert here the activation key!
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.