Exercise 8: Add text to drawing
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:
-
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".
-
-
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:
-
Create an instance of DrawingHandler.
-
Add a textbox to your form, for the text to be inserted.
-
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:
-
Checks TeklaStructures drawing editor is active and a drawing is open.
-
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: