Cancel
Showing results for 
Search instead for 
Did you mean: 

FEMAP API c# is there a way to check for network license availability and wait for license

Creator
Creator

Hello,

 

I have an application that uses the FEMAP api for some mesh preprocessing; it can be used in an automated workflow.  I am wondering what is the best way for the app to check for an available network FEMAP license, and have the app either wait or stop gracefullly, or continue depending on whether it can get a license.  I looked at and tried the pModel.feLicenseIsAvailable method, but I am not sure that is what I need.

 

Right now, the application throws and exception, displays a message box saying user limit reached, and crashes when 

pModel=new femap.model();  

fails due to no license availablity.   

try
{
pModel = new femap.model();

if(pModel.feLicenseIsAvailable(femap.zFeatureType.FEAT_NX_NASTRAN_BASIC)==femap.zReturnCode.FE_NOT_AVAILABLE)
{
// couldn't get this working
}
else
{
//pModel = new femap.model();
}

pModel.feAppVisible(false);
}
catch (Exception e)
{
System.Diagnostics.Debug.Print(e.ToString());
pModel = null;
System.Environment.Exit(1); // Exit if there is no model
}

Thanks

 

Drew

2 REPLIES 2

Re: FEMAP API c# is there a way to check for network license availability and wait for license

Genius
Genius

try using the feLicenseMethod method.

You'll end up with something like:

 

            femap.model pModel;
            try
            {
               
                /* output type for feLicenseMethod:
                0 = None, this means that licensing has somehow failed 
                1 = Dongle
                2 = Node/Curve limited Demo
                4 = FLEXlm-based Network Licensing
                5 = API-only Licensing

                return codes:
                FE_FAIL - Licensing information is not valid
                FE_SECURITY - Licensing method is valid, but currently exceeding some limitation on the license (like a node limit)
                 */

                pModel = new femap.model();
                int licensetype = 4;
                if (pModel.feLicenseMethod(out licensetype) == femap.zReturnCode.FE_SECURITY)
                {
                    // no network license available
                }

                else
                {
                    // license available
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.Print(e.ToString());
                pModel = null;
                System.Environment.Exit(1); // Exit if there is no model
            }

using this method you can check the license type and if there is a licensenode available (if not it returns the FE_SECURITY code)

Maarten Elings | Engineer

Re: FEMAP API c# is there a way to check for network license availability and wait for license

Creator
Creator

Thank you -

 

Drew