Guides and Articles

Use this documentation when building your Tekla Structures apps

Exercise 5: Let the user select profile for columns

Updated: 31 Oct 2017

API contains Forms dialogs for profile catalog, rebar catalog, and mesh catalog to help developers of applications (and plug-ins) that have Forms and need to provide for example profile selection in UI.

You will learn how to use customized user interface controls to select profiles from the catalogs in Tekla Structures. After downloading the TSOpenAPISelfLearningExercises package from GitHub (button above), find the example code for this exercise at \Exercise5-UI-Select-Profile\ folder.

Before you start, open the project that you created in exercise 4.

Add user interface controls to Microsoft Visual Studio’s Toolbox

  1. Open the Form1.cs[Design] tab.

  2. On the Toolbox tab, right- click General and select Choose Items.

  3. Click browse, navigate to \Program Files\Tekla Structures\[version]\nt\bin\dialogs\Tekla.Structures.Dialog.dll, open the Designer and click OK.

Let user select profile for columns

  1. To get user interface controls to work, your Form must inherit from FormBase. In the Form’s constructor, call:

    base.InitializeForm();
  1. On the Toolbox tab, under General, double-click ProfileCatalog to add it on your form. The item, that user selects from the dialog, will be stored to a SelectedProfile property.
  2. Add a textbox to show the selected profile. When user types a profile to the textbox and clicks Select button, the typed profile should be selected automatically from the profile catalog dialog. Setting the property SelectedProfile to a certain value will select the value from the dialog when the dialog opens (if the value is included in the catalog).

  3. To use the interface controls, create callbacks for the events SelectClicked and SelectionDone.

    • The SelectClicked event is raised when user clicks the Select button in your form. Modify the callback so that the value of SelectedProfile is set according to the value in the Form:

      profileCatalog1.SelectedProfile = ColumnsProfileTextBox.Text;
    • The SelectionDone event is raised when the profile or rebar selection dialog is closed. To update the text shown in your Form, use the method SetAttributeValue() and the value stored in SelectedProfile:
      SetAttributeValue(ColumnsProfileTextBox,profileCatalog1.SelectedProfile);
  4. Modify the hardcoded values for the profile in the code.

    • Use values defined in the textboxes. For example:

      Column.Profile.ProfileString = ColumnsProfileTextBox.Text;
  5. Then, bound values of controls to attributes.
  6. Test your application.

 

Your application form should look something like this:

Tekla structures open API Application form user select profile for columns