Guides and Articles

Use this documentation when building your Tekla Structures apps

Exercise 8: Add text to drawing

Updated: 31 Oct 2017

You will learn how to do simple editing of a drawing that is opened in Tekla Structures. In this exercise you will add lines and texts to a drawing.

After downloading the TSOpenAPISelfLearningExercises package from GitHub (button above), find the example code for this exercise at \Exercise8-Add-Text-To-Drawing\ folder.

Before you start:

  1. In Tekla Structures, open this model, it includes the model after exercise 7 with two drawings added.

    • Extract the .zip file to \C:\TeklaStructuresModels\ for easy access.

    • In Tekla Structures, open the drawing with the name "GA-drawing before editing".

  2. In Microsoft Visual Studio, open the project that you created in exercise 7.

 Add text to drawing

Create text from user input centered under every view in the drawing and a rectangular box drawn around the text. Your application should include the following steps:

  1. Create an instance of DrawingHandler.

  2. Add a textbox to your form, for the text to be inserted.

  3. Add a button to the form that inserts the text to the drawing and also draws a box around the text. The click-event should include the following:

    • Loop through every view in the drawing.

    • Get RectangleBoundingBox for the texts frame.

    • Calculate the center point of the view

    • Insert the text below the view, to the calculated center point.

    • Draw a box around the text according to the bounding box.


The result should look similar to this:

Tekla structures Open API add text to drawing