How to create a simple plugin for AXISVM

While AXISVM offers a comprehensive range of features, it also provides the flexibility to extend its capabilities through the development of plugins. Creating AXISVM plugins allows users to customize and enhance the software to meet specific project requirements. In this article, we will explore the process of creating AXISVM plugins to expand its structural analysis capabilities.

This article is a general guide detailing the fundamental steps necessary for the creation of a simple plugin for AXISVM X7 using C# and Visual Studio 2022. While the instructions provided are specific to these tools, similar steps can be followed in other programming languages, as well. 

The plugin allows the user to create a line in AXISVM by specifying the X, Y, and Z coordinates of the start and end nodes of the line, as shown below. It is worth mentioning that while this simple plugin is created for demonstration purposes only, AXISVM allows for more advanced features to be implemented, as provided in AXISVM API.

The General steps to create a plugin for AXISVM includes:

Create a new class library project #

The new plugin will be provided to AXISVM as a DLL file. When AXISVM is launched, it looks for *.DLL files in the Plugins folder (<AXISVM installation folder>\plugins) and its subfolders. Therefore, a new C# Class Library (.Net Framework) must be created, as shown below. When the compiler builds this class library, a new DLL containing the new plugin is generated. 

It should be mentioned that the 64-bit version of AXISVM (AXISVM_x64.exe) can only open 64-bit DLLs, and the 32-bit version of AXISVM (AXISVM.exe) can only open 32-bit DLLs. 

The next step is to configure the new class library project by providing the project name, location, and solution name, as shown below. It is important to choose the proper .Net Framework for the interface that will be imported later, as AXISVM supports several versions of .Net Frameworks. Here, .Net Framework 4.8 is used.

Import the AXISVM Interop and plugin interface #

In this step, the Interop and the plugin interface are added to the class library. Several interfaces are available depending on the used framework. For the .Net framework (4.x), the Interop Interop.AXISVM.FW4.dll and interface AXISVMDotNetAddonPluginInterface_v1.0.FW4.dll must be used. The following steps must be followed to include these two DLL files: 

  1. Right-click on References and select “Add Reference” from the menu. This will open the Reference Manager window.
  2. In the Reference Manager window, click on the “Browse” button.
  3. Navigate to the AXISVM installation directory and select the two DLL files. Then, click on the “Open” button.
  4. Ensure that the checkboxes next to the selected DLL files are checked.
  5. Finally, click on the “OK” button to complete the process.

Create a new Class and Form #

The new AXISVMDotNetAddonPluginInterface_v1.0 interface allows the creation of both plugins and addons. Plugins in AXISVM X7 are accessed from the menu bar by navigating to the “Plugins” menu, while addons are accessed in the toolbar as buttons, providing users with convenient access to the added features, as shown below. 

All the plugins and addons created for AXISVM should implement all the methods and properties of AXISVMDotNetAddonPluginInterface_v1.0 interface. 

In order to implement the interface, the following steps must be followed: 

  1. Ensure that the DLL files are added to References, as shown below. 
  2. Create a new Form in the project ( Right click on the project name => from “Add” select “Form”)
  3. Add components to the Form, including a DataGridView and a Button.
  4. Create a new Class in the project ( Right click on the project name => from “Add” select “Class”)
  5. Declare that the class implements the interface by adding :IAXISVMDotNetAddonPluginInterface_v1_0 to the class name. The class declaration should be public class Class1:IAXISVMDotNetAddonPluginInterface_v1_0, as shown below.

Implement all the methods and properties of the interface #

The created class must implement a set of properties and methods to configure the new plugin. The AXISVM API documentation provides a comprehensive description of all the implemented properties and methods, along with their respective usage instructions. Here, only a short description is given. 

The following steps must be followed to configure the plugin and the addon by implementing the interface methods:

1- In the created class, import the two namespaces.

using AXISVM;

using AXISVMDotNetAddonPluginInterface_v1_0;

2- Copy the content of the following code snippet to the created class. These properties and methods are obligatory and must be used in any new plugin. A concise description is provided as a comment above each property or method, highlighting its purpose and functionality.

  • The property Plugin_MenuItemText should return the name of the plugin. Here it is called “NewPlugin”.
  • The methods Plugin_Init and Addon_Init are called by AXISVM when AXISVM is fully loaded.
  • The methods Plugin_Execute and Addon_Execute are called when the user clicks on the plugin or the addon. The main Form should be created and displayed inside this function. 
  • The methods Plugin_IsMenuItemVisible and Addon_IsItemVisible determine if the plugin and the addon are visible. They should return a value of 1 to be visible.

The methods Plugin_IsMenuItemEnabled and Addon_IsItemEnabled determine if the plugin and the addon are enabled, and the user can click on them. They should return a value of 1 to be enabled.

				
					public class Class1:IAxisVMDotNetAddonPluginInterface_v1_0
{
    // Variables used by AxisVM to assign the plugin, addon and application handles.
    static private int _AxisVMAddonFormHandle = 0;
    static private int _AxisVMMainFormHandle = 0;
    static private int _AxisVMApplicationHandle = 0;
  
    // The version of the plugin. It must be 1.
    public int Version { get { return 1; } }
    // The subversion of the plugin. It must be 0.
    public int SubVersion { get { return 0; } }
    // Properties used by AxisVM to assign the plugin, addon and application handles. 
    public int AxisVMMainFormHandle { get { return _AxisVMMainFormHandle; } set { _AxisVMMainFormHandle = value; } }
    public int AxisVMApplicationHandle
    {
        get { return _AxisVMApplicationHandle; }
        set { _AxisVMApplicationHandle = value; }
    }

    // This property should return the name of the plugin that will appear in AxisVM.
    public string Plugin_MenuItemText { get { return "NewPlugin"; } }
    // Determines whether the AddonPlugin is a modal window (AxisVM application/forms
    // will be disabled while AddonPlugin is running including the selection toolbar) or a
    // non-modal window. 
    // A modal AddonPlugin must return 1 and a non-modal must return 0
    public int Plugin_IsModalWindow { get { return 1; } }

    // Returns AddonPlugin’s hint (text). Hint is shown when cursor hovers over the Addon’s
    // button.
    public string Addon_HintText { get { return "NewPlugin"; } }
    // Modal window or non-modal window for the addon.
    public int Addon_IsModalWindow { get { return 1; } }
    // Determines the AddonPlugin’s button icon. If no data return, the default icon is used.
    public byte[] Addon_IconBitmap { get { return new byte[] { }; ; } }
    // Determines the transparent colour of the button icon.
    public int Addon_IconBitmapTransparentColor { get { return 0; } }
    // Determines the id of the form where addon button will be displayed.
    // 0 for the main form.
    public int Addon_ButtonPlaceFormId { get { return 0; } }
    // Determines the id of the toolbar (tab) on the form, where AddonPlugin’s button will
    // be displayed.
    // 0 => geometry,  1 => elements, 2 => loads, 3 => mesh ... 
    public int Addon_ButtonPlaceToolbarId { get { return 1; } }
    // Properties used by AxisVM to assign the plugin, addon and application handles. 
    public int Addon_FormHandle { get { return _AxisVMAddonFormHandle; } set { _AxisVMAddonFormHandle = value; } }
    
    public void Addon_Deinit(object iAxisVMApp)
    {
        iAxisVMApp = null;
    }
    // This function is called when the user clicks the AddonPlugin button.
    public int Addon_Execute(object iAxisVMApp)
    {
        return 0;
    }
    // Returns AddonPlugin’ hint (text) depending on the used language.
    // Hint is shown when cursor hovers over the Addon’s button.
    public string Addon_GetTranslatedHintText(int PrgLang)
    {
        return "NewPlugin";
    }
    // This function is called by AxisVM when AxisVM is fully loaded
    // (IAxisVMApplication Loaded event is fired) and COM server is available.
    public void Addon_Init(object iAxisVMApp)
    {
    }
    // AxisVM will call this function when AddonPlugin’s button is about to be displayed.
    // If it returns 0 then the button will be disabled otherwise it will be enabled.
    public int Addon_IsItemEnabled(object iAxisVMApp)
    {
        return 1;
    }
    // AxisVM will call this routine when AddonPlugin’s button is about to displayed.
    // If it returns 0 then the button won't be displayed otherwise it will be displayed.
    public int Addon_IsItemVisible(object iAxisVMApp)
    {
        return 1;
    }

    public void Plugin_Deinit(object iAxisVMApp)
    {
    }
    // This function is called when the user clicks the plugin menu item. 
    public int Plugin_Execute(object iAxisVMApp)
    {
        return 0;
    }
    // This function is called by AxisVM each time when the program language changed
    public string Plugin_GetTranslatedMenuItemText(int PrgLang)
    {
        return "NewPlugin";
    }

    public void Plugin_Init(object iAxisVMApp)
    {
    }
    // This function is called by AxisVM when the AddonPlugin menu is displayed to
    // determine whether the menu item can be enabled or not. 0 for disabled.
    public int Plugin_IsMenuItemEnabled(object iAxisVMApp)
    {
        return 1;
    }
    // This function is called by AxisVM when the AddonPlugin menu is displayed to
    // determine whether the menu item can be visible or not. 0 for hidden.
    public int Plugin_IsMenuItemVisible(object iAxisVMApp)
    {
        return 1;
    }   
}

				
			

3- Copy the following variables and methods to the created class. These variables and methods are not obligatory for other plugins. They are used here to define and initialize the global variables of the main interface in AXISVM API (AXISVMApplication) and the running model in AXISVM (AXISVMModel). The function ShowPlugInForm is used to show the created Form when the user clicks on the Plugin or the Addon button in AXISVM.

				
					// Instance of the open model.
IAxisVMModel AxisVMModel;
// The main interface in AxisVM Interop.
IAxisVMApplication AxisVMApplication;

// Assigning an instance of AxisVMApplication to our global variable.
private void initializeAxisVMApplication(object iAxisVMApp) {
    AxisVMApplication = (AxisVMApplication)iAxisVMApp;
}
// Assigning an instance of the current model to our global AxisVMModel variable.
private void initializeAxisVMModel(object iAxisVMApp)
{
    AxisVMModel = AxisVMApplication.Models.Item[1];
}
// Show the form when the user click on the addon or plugin.
private void ShowPlugInForm() {
    Form1 form1 = new Form1(AxisVMModel);
    form1.Show();
}

				
			

4- Add the following calls of the methods in Plugin_Execute and Addon_Execute methods.

				
					initializeAxisVMApplication(iAxisVMApp);
initializeAxisVMModel(iAxisVMApp);
ShowPlugInForm();

				
			

5- Build the project by selecting Build from the build menu in Visual Studio or press Ctrl+Shift+B

Copy the DLL file to AXISVM Plugins directory #

If the build is successful, a DLL file will be found in the bin directory of the class library. To find the DLL file, the followings steps must be followed:

  1. Right-click on the project name and select “Open Folder in File Explorer”. The project folder will be open. 
  2. Go to “bin” and then to the “Debug” or “Release” directory (depending on the solution configuration in visual studio).
  3. The created DLL file for the plugin can be found in the directory as “projectname.dll”. Here, NewPlugin.dll.
  4. Copy the DLL file to the plugins folder in the AXISVM installation directory (<AXISVM installation folder>\plugins)

If everything is configured correctly, the plugin should appear in the Plugins menu in AXISVM, and the addon should appear in the chosen tab.

The final result for the created plugin:

The Visual Studio project can be downloaded here:

Common problems #

  • The plugin is not loaded (not shown in the Plugins menu):
  • Possible ways to solve the problem: 
    • 1. Try to re-register the AXISVM.NET server: IAXISVMDotNetPluginInterface_v2_3 
      • run !UNREGISTER_DOT_NET_PLUGIN_SERVER_v2.3.BAT 
      • then run !REGISTER_DOT_NET_PLUGIN_SERVER_v2.3.BAT 
      • run !UNREGISTER_DOT_NET_ADDONPLUGIN_SERVER_v1.0.BAT 
      • then run !REGISTER_DOT_NET_ADDONPLUGIN_SERVER_v1.0.BAT 
    • 2. Set adequate target framework version in Advanced compiler settings. 
    • Choose the correct .Net Framework.
    • 3. Look in PluginFinder.dll_ERROR.LOG located in the AXISVM folder for System.IO.FileNotFoundException exceptions logging, and to check which .NET assemblies are required for DLL.

For a more detailed example of using the com server to create a model, apply loads, boundary conditions and run the analysis Creation of a simple model using AXISVM COM server