Introduction
Before Manufacturing Toolkit APIs can be used, a license activation is necessary. The MTK has one mechanisms for license activation.
Source file license key
This mechanism is the default and is used for the majority of the licensing models. In this case you are provided with a license key in the form of a source file (*.cxx for C++, *.cs for C#, *.java for Java and *.py for Python). This source file contains a function that returns a string value with the license key inside. To activate the license, include the source file in your project. For compiled languages that means that the license key is compiled into your application. For non-compiled languages the key should be accessible to the interpreter during the run time.
Usage
After the license key is included into the project, the activation function should be called. Here is how that looks:
- ะก++
#include <cadex/LicenseManager_Activate.h>
#include "mtk_license.cxx"
...
auto aKey = MTKLicenseKey::Value();
if (!CADExLicense_Activate (aKey)) {
std::cerr << "Failed to activate CAD Exchanger license." << std::endl;
exit (1);
}
- Python
import manufacturingtoolkit.CadExMTK as mtk
import mtk_license as license
...
aKey = license.Value()
if not mtk.LicenseManager.Activate(aKey):
print("Failed to activate Manufacturing Toolkit license.")
return 1
- C#
...
string aKey = MTKLicenseKey.Value();
if (!LicenseManager.Activate(aKey))
{
Console.WriteLine("Failed to activate CAD Exchanger license.");
return 1;
}
Defines classes, namespaces, enums, types, and global functions related to Manufacturing Toolkit.
Definition LicenseManager_LicenseError.hxx:30
- Java
...
String aKey = MTKLicenseKey.Value();
if (!LicenseManager.Activate(aKey)) {
System.out.println("Failed to activate Manufacturing Toolkit license.");
System.exit(1);
}
When license is not activated
If an API from MTK is used and no license has been activated, then MTK will throw an exception LicenseManager_LicenseError. You can catch exceptions of this type specifically to distinguish them from any other exceptions:
#include <cadex/LicenseManager_LicenseError.hxx>
try {
ModelData::Model aModel;
ModelData::ModelReader aReader;
aReader.Read ("cylinder.stp", aModel);
} catch (LicenseManager_LicenseError&) {
cerr << "Could not acquire valid MTK license" << endl;
} catch (...) {
cerr << "Unprocessed exception caught" << endl;
}