Guides and Articles

Use this documentation when building your Tekla Structures apps

Debug a plugin without restarting Tekla Structures

Updated: 3 Feb 2021

While you develop and debug a plugin stopping and restarting Tekla Structures is very time-consuming. Therefore, use the XS_PLUGIN_DEVELOPER_MODE to replace the .dll while having Tekla Structures open. 

Add the following advanced option to the teklastructures.ini file: set XS_PLUGIN_DEVELOPER_MODE=TRUE

Plugin dll files must be located under (.environments\common\extensions\) subfolders.

NOTE: This advanced option cannot be used with nested plugins or with plugin dll files that include static variables.

Debug a plugin and dialog boxes without restarting Tekla Structures.

Debug a plugin in UI development

XS_PLUGIN_DEVELOPER_MODE can also be used for UI development for model and drawing plugins.

Plugins with PluginFormBase(Forms) or PluginWindowBase(Wpf) dialog boxes can be changed and reloaded without restarting Tekla Structures if XS_PLUGIN_DEVELOPER_MODE is set to TRUE.

The workflow is as follows:

  1. Add “set XS_PLUGIN_DEVELOPER_MODE=true” to the teklastructures.ini file and open Tekla Structures.

  2. Run the plugin (model or drawing), or open the plugin dialog box from an object in the view.

  3. In Microsoft Visual Studio, change the plugin UI, build the plugin and copy the changed dlls as a post-build event. (You can also copy the plugin files manually, or set location of compiled binaries to extension directories in Microsoft Visual Studio. Using post-build event is just another option.)

    xcopy $(TargetDir)$(TargetName).dll "C:\ProgramData\Tekla Structures\Work\Environments\common\extensions\DrawingPluginDemo\" /R /Y

  4. Run the UI macro (Reloadplugins.cs) in the Applications & Components catalog on the side pane.

  5. Open the plugin dialog box again, and see if the UI is the new one.

  6. If there is a problem in opening the dialog box after running the Reloadplugins macro, first open another plugin dialog box with Forms and then retry.

  7. The plugin can be debugged and changed without restarting Tekla Structures (works at least with Microsoft Visual Studio 2017).

    • Attach the debugger first and run the plugin.
    • Debugging can be stopped with Detach all from the menu.
    • The code can be changed and rebuilt.
    • Debugging can be started again after Reloadplugins is executed.


Reloadplugins.cs code:

#pragma warning disable 1633 // Unrecognized #pragma directive
#pragma reference "Tekla.Macros.Akit"
#pragma reference "Tekla.Macros.Wpf.Runtime"
#pragma reference "Tekla.Macros.Runtime"
#pragma warning restore 1633 // Unrecognized #pragma directive

namespace UserMacros
   public sealed class Macro

       public static void Run(Tekla.Macros.Runtime.IMacroRuntime runtime)
           Tekla.Structures.ModelInternal.Operation.dotStartAction("dotdiaLoadDialogs", "");
           Tekla.Structures.ModelInternal.Operation.dotStartAction("dotdiaReloadDialogs", "");
           Tekla.Structures.Model.Operations.Operation.DisplayPrompt("Dialogs reloaded..");