License Methods
The license methods read the license number and check out or test the licenses of the current session or for an MPH file. This functionality can be used, for example, to limit the use of an application to one or a few license numbers or to dynamically adapt functionality of an application depending on which product licenses are available.
Example code
The following code tries to check out a license for the AC/DC Module, and displays an error message if it fails:
if (!checkoutLicense("ACDC"))
  alert("There seems to be a problem. Please contact Alice and Bob at 123-456-7890.");
You can use this to customize license error messages by calling a method containing this code before any add-on product specific features are used by the application.
In the Application Builder root node you can further select the Ignore license errors during launch check box. This will make it possible for users to start an application regardless of which licenses are available. However, this will not work if the application, at startup, uses features required by an add-on product. The application has to be created in such a way that the add-on product specific features are not used in the startup phase of the application but instead are deferred to later in the workflow.
To emulate a scenario where there are not enough available licenses you can, for example, disable one or more products in the Licensed and Used Products in Session dialog box, available from the File menu in the COMSOL Desktop environment.
The following code tests if the COMSOL installation has the capability to use an MPH file:
boolean ok = hasProductForFile(“model_file.mph”);
Note that even if hasProductForFile return true, in a floating network license situation there may not be any free licenses to check out. If your application is going to process several MPH files and you want to make sure all licenses are checked out before the processing starts, instead use the checkoutLicense or checkoutLicenseForFile methods.
License Feature Strings
The following table contains the product strings for all add-on products in the COMSOL 6.1 product suite that can be used by the method checkoutLicense:
DESIGN, CADIMPORT
LiveLink™ for AutoCAD®
LLAUTOCAD, CADIMPORT
LiveLink™ for PTC® Creo® Parametric
LLCREOPARAMETRIC, CADIMPORT
LiveLink™ for Excel®
LiveLink™ for Inventor®
LLINVENTOR, CADIMPORT
LiveLink™ for MATLAB®
LiveLink™ for Revit®
LLREVIT, CADIMPORT
LiveLink™ for PTC® Pro/ENGINEER®
LLPROENGINEER, CADIMPORT
LiveLink™ for Simulink®
LiveLink™ for Solid Edge®
LLSOLIDEDGE, CADIMPORT
LiveLink™ for SOLIDWORKS®
LLSOLIDWORKS, CADIMPORT