Check the connection between the application and Tekla Structures

Updated: 20 May 2024

Before you can access any of the Tekla Open API objects, you will need to initialize the connection between Tekla Structures and your application.

Because applications are not started together with Tekla Structures they cannot expect to have Tekla Structures running upon execution.

In this guide, we go through two ways of checking if the Tekla Structures is running and a model is open.

NOTE: It is recommended to copy applications in a subfolder inside the Tekla Structures Extension folder. Each version of Tekla Structures uses a different folder. For example, the default Extension folder of Tekla Structures 2024 is here:

C:\ProgramData\Trimble\Tekla Structures\2024.0\Environments\common\extensions\

Starting with Tekla Structures 2024, developers testing applications from the Microsoft Visual Studio should read this guide to get more information:

Gacless Tekla Structures 2024 - Developer Impact

Check the connection using model.GetConnectionStatus();

// Create a new instance of class Tekla.Structures.Model: 
Model myModel = new Model();

// Check that the model connection succeeded:
if (myModel.GetConnectionStatus()) 
{ 
    …
}

For drawings, the following creates a new instance to the drawings object:

DrawingHandler CurrentDrawingHandler = new DrawingHandler();

Check the connection using TeklaApplicationLibrary

// Check, if the model is loaded by checking if it has a name
if (!string.IsNullOrEmpty(TeklaStructures.Model.Name))
{
    // Model is available.
}

//After a model has been loaded, an event is raised.

TeklaStructures.Model.Loaded += delegate
{
    // Model has been loaded.
};

 

Was this helpful?
The feedback you give here is not visible to other users. We use your comments to improve the content.