Today we will see how to load NextFEM API in Matlab®, by using built-in commands and without having NextFEM API as a registered type in your PC.

Some simple steps, described in the following, to automatically load NextFEM API inside Matlab, with only a few lines of code.

We look for the installation folder using the Windows registry, then the assembly of NextFEM API is loaded and instantiated. Call the methods inside NF to have model data and results inside Matlab.

% find NextFEM Designer installation

APIpath = strtrim ( replace(winqueryreg('HKEY_LOCAL_MACHINE','SOFTWARE\Classes\NextFEM Designer\shell\open\command',''),'Designer64.exe "%l"','') );


disp('Installation found in ' + convertCharsToStrings(APIpath));


% load NextFEM API

NET.addAssembly(strcat(APIpath , 'NextFEMapi.dll'));


disp("NextFEM API version " + NF.getVersion())



Download this script from here. Please note that in Matlab the strings passed as arguments in API calls are array of characters (char type), hence please use single quote sign in calling NextFEM API.

If you use Octave, you can download this package to access API as COM objects. The Windows Package supplies all the function to let your script interface with COM objects, since Octave does not currently have any NET.addAssembly or similar command.

NextFEM API is COM-visible, hence you proceed as follows:

1.       Register NextFEM API as COM Type Library in your system, by running this command as administrator (CMD, run as Administrator, go to NextFEM installation folder):

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Regasm NextFEMapi.dll /codebase

2.       Now start Octave and try this code:

pkg load windows;  % octave only

feature = @windows_feature; % octave only

feature('COM_SafeArraySingleDim', 1);

nf = actxserver ('NextFEMapi.API');



Please note that we’re using
feature('COM_SafeArraySingleDim', 1) that can be useful also in Matlab to pass mono-dimensional arrays to API calls. If you don’t use it, by default a 2-dimensional array is passed as argument.

To revert to normal behaviour set feature('COM_SafeArraySingleDim', 0) and use release(nf) to release the COM object.

Differently to NET commands in Matlab, COM interfaces are not case-sensitive, hence API methods can be called without specifying the case for method name.