Exercise 9: Browse through drawings list and open a 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 \Exercise9-Drawings-List\ folder.
Before you start, open the project you created in exercise 8.
Browse through drawings list and open a drawing
Create a list view to your form that lists all the drawings available in your Tekla Structures model. The user can open a drawing from this list. Follow these steps to create your application:
-
Add a ListView control to your form for listing the available drawings.
-
Add a method that gets the drawings from Tekla Structures and adds them to the list.
-
Use DrawingEnumerator from DrawingHandler to loop through the available drawings.
-
Use Tag in the ListViewItem to store the drawing. ListViewItem represents an item in the ListView.
-
Call the method on the OnLoad event to execute it when the application starts.
-
-
Add a button to your form that checks drawing list is not empty and opens selected drawing in Tekla Structures. In the click-event, see which tag is selected and set that as active drawing.
-
Test your application.
The result should look similar to this: