Guides and Articles

Use this documentation when building your Tekla Structures apps

Check the connection between the application and Tekla Structures

Updated: 20 Apr 2018

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 trough two ways of checking if the Tekla Structures is running and a model is open.

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.
};