Hide menu
Loading...
Searching...
No Matches
Licensing and Activation

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"
    using namespace cadex;
    ...
    // Activate the license (aKey must be defined in mtk_license.cxx)
    auto aKey = MTKLicenseKey::Value();
    if (!CADExLicense_Activate (aKey)) {
    std::cerr << "Failed to activate CAD Exchanger license." << std::endl;
    exit (1);
    }
    Contains classes, namespaces, enums, types, and global functions related to Manufacturing Toolkit.
  • Python
    import mtk_license as license
    ...
    # Activate the license (aKey must be defined in mtk_license.py)
    aKey = license.Value()
    if not mtk.LicenseManager.Activate(aKey):
    print("Failed to activate Manufacturing Toolkit license.")
    return 1
    Definition CadExMTK.py:1
  • C#
    using cadex;
    ...
    // Activate the license (the key should be defined in mtk_license.cs)
    string aKey = MTKLicenseKey.Value();
    if (!LicenseManager.Activate(aKey))
    {
    Console.WriteLine("Failed to activate CAD Exchanger license.");
    return 1;
    }
  • Java
    import cadex.*;
    ...
    // Activate the license (the key must be defined in MTKLicenseKey.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:

try:
# using API to read a STP model
aModel = mtk.Model()
aReader = mtk.ModelReader()
aReader.Read(mtk.Base_UTF16String("cylinder.sat"), aModel)
except mtk.LicenseManager_LicenseError:
print("Could not acquire valid CAD Exchanger license")
except Exception:
print("Unprocessed exception caught")

See also: