Select Bolts From Model Space Based on Tolerance using WPF (Tekla Open API)

_config.yml

Background: What are we trying to do:

The boss storms in:

“Ben, I need to select some bolts by their tolerances.”

The Plan:

  1. The user selects some bolts (in the model space).
  2. Of the bolts that are selected we query the tolerances of those bolts.
  3. We display the tolerances in a list.
  4. We allow for the selection of those bolts directly from the WPF window.

1. We want to select only bolts from the model space:

Now there are a couple of ways we can do this:

  • We can ask the user to select some objects in the model and we can programmatically filter out all of the bolts (this seems the easiest).
  • We could possibly apply a selection filter and ask the user to select only the relevant objects that he wants.

Select Bolts Tutorial (Tekla Open API) - How to Programmatically Select Parts in the Tekla Model tekla-api-select-bolts-p2-how-to-select-bolts-using-the-picker.md

Option 1: Programmatically select the pertinent parts

Option 2: Use the picker?

We are forced in a corner – we’ll have to programmatically select everything, and then filter out. Because we want only BoltGroups, we can filter based on that particular type:

2. & 3. Get the Tolerances and Display them in the UI

Now we have the bolt groups. We can place them in an observable collection within our ViewModel and we can expose that as a property to bind to it within our view. We want to bind to the tolerances only, so we do so – see the XAML below:

4. Select the Bolts in the Model

Now we have the selected items in our hand. We can select them in our model. Please refer to a previous post on how this is done.

Voila! We’ve finished our job and now it’s time to check out the latest ads running in my Facebook feed.

Written on October 18, 2017