1.1 Initializing HOOPS Exchange

Several steps are required in order to initialize HOOPS Exchange, which include loading the libraries, setting the license key, and initializing the library's internal structures.

Prerequisite: Initialize the environment

HOOPS Exchange uses dynamic loading during its execution. If you are using HOOPS Exchange on a Linux or OS X platform, you must configure your compiler for this requirement. This means defining the HAVE_DLFCN_H preprocessor flag and linking against DLFCN using the -ldl linker option.

Because HOOPS Exchange effectively links at run time, you do not need to specify any link libraries during compilation. You do, however, still need to point to the HOOPS Exchange headers, which can be found at <HOOPS_EXCHANGE>/include.

To use the HOOPS Exchange API you need to include A3DSDKIncludes.h in your source and define INITIALIZE_A3D_API.

#define INITIALIZE_A3D_API
#include "A3DSDKIncludes.h"

In order to run an application built on HOOPS Exchange on Windows platforms, Visual Studio 2008, Visual Studio 2010, and Visual Studio 2013 redistributables must be installed on the target machine.

Automatic initialization

HOOPS Exchange can initialize itself automatically in most cases using the HOOPS Exchange Loader. You need to provide the path where you've installed HOOPS Exchange:

const A3DUTF8Char* pcLibPath = "/<my_path>/HOOPS_Exchange/bin/<my_platform>";
A3DSDKHOOPSExchangeLoader sHoopsExchangeLoader(pcLibPath);

Although the HOOPS Exchange Loader does most of the initialization by itself, you still need to provide your license key by copying A3DSDKLicenseKey.h to /<my_path>/HOOPS_Exchange/include. That header file can be generated on the HOOPS Exchange downloads page in the Tech Soft 3D Developer Zone. You don't need to specifically include it using an include directive - A3DSDKIncludes.h will include it for you.

Once the loader is instantiated, you can load a CAD file using the following code:

A3DStatus importResult = sHoopsExchangeLoader.Import(A3DImport(filename));

If necessary, see the "ImportExport" sample project for an example of how the HOOPS Exchange Loader is used in an application.

Manual initialization

If you need more control over each step of the HOOPS Exchange initialization process, you can perform the steps below as an alternative to using the HOOPS Exchange Loader.

Step 1: Runtime initializations

Locate the HOOPS Exchange libraries by calling A3DSDKLoadLibrary.

if (A3DSDKLoadLibrary("/<my_path>/HOOPS_Exchange/bin/<my_platform>") == false)
{
// handle load library error
}

For extra safety, you should also check that the major and minor library versions match what is in the HOOPS Exchange header, as different versions of HOOPS Exchange are not binary compatible.

A3DInt32 iMajorVersion, iMinorVersion;
A3DDllGetVersion(&iMajorVersion, &iMinorVersion);
if ( iMajorVersion != A3D_DLL_MAJORVERSION || iMinorVersion != A3D_DLL_MINORVERSION )
{
// handle library mismatch error
}

Step 2: Setting the license

Your license key can be generated on the HOOPS Exchange downloads page in the Tech Soft 3D Developer Zone. The key is delivered in a header file called A3DSDKLicenseKey.h. Replace the existing A3DSDKLicenseKey.h in <HOOPS_EXCHANGE>/include with this new file. Lastly, call A3DLicPutLicense at run time:

if (A3DLicPutLicense(A3DLicPutLicenseFile, myCustomerKey, myProductKey) != A3D_SUCCESS)
{
// handle license error
}

Step 3: Initialize internal structures

The final step enables HOOPS Exchange to complete its internal initialization:

if (A3DDllInitialize(A3D_DLL_MAJORVERSION, A3D_DLL_MINORVERSION) != A3D_SUCCESS)
{
// handle initialization error
}

Termination

When your application is done using the HOOPS Exchange libraries, you should clean up by calling:

A3DSDKUnloadLibrary();

This last step should not be performed if you've used automatic initialization with the HOOPS Exchange Loader.