How to Convert Engineering Components to Detailing Components – (Tekla Open API Tutorial)

_config.yml

What do we want to do?

  1. We have received a Tekla model from someone.
  2. The model we have received was built using an Engineering Modelling license.
  3. We have a full detailing license.
  4. There are components in this model, but we can’t number them because they were produced using an engineering license. If you want to number them, well they ought to have been created with a detailing license. So what do we do now?
  5. The only way to number these components is to first convert these components to a “detailing component”. The detailing component is a “type” of component.
  6. The problem is that there is no method exposed by the Tekla “Open” API which allows us to programmatically call this functionality. Also to make things more confusing: the nomenclature used in the user interface is different to the nomenclature used by the creators of the Open API.
  7. So what then is the solution?

The Solution

Here is a video explaining both the problem and demonstrating a solution:

Tekla Macro - How to Convert Engineering Components To Detailing Components from Tek1 on Vimeo.

This is what we need to do:

  1. We need to select all components.
  2. For each of the selected components we need to manually “ConvertToDetailingComponent”.
  3. The way we do this is to pre-record a macro in Tekla.
  4. We then dump the .cs file in this location: C:\ProgramData\Tekla Structures\19.1\Environments\australasia\macros\modeling

First we need to record the macro:

  1. First: Select a component that you want to convert to a “Detailing Component”.
  2. Start recording the macro.
  3. Right click with your mouse and select “ConvertToDetailingComponent”.
  4. End the macro.
  5. Call it an appropriate name. I’ve called my macro “ConvertToDetailingComponent”.
  6. Obtain the source file from this location: C:\ProgramData\Tekla Structures\19.1\Environments\australasia\macros\modeling
  7. You will need to send that source file with your code to ensure that it works on any computers which you send to the users of your plugin.
  8. Then you will have to call that very same macro you created from your plugin.

Here is a demonstration of how this is done:

_config.yml

Please take note of how I first selected the “component” and only then started recording the macro? Once we’ve recorded the macro and named it appropriately, we’ll need to call it from our code.

Now let’s get started on the plugin:

In the idea world, I would prefer the user to select which components he or she wants to convert, rather than letting the program determine that automatically. The problem is that I don’t know how exactly to do that: how can one identify the objects that are currently selected using the Tekla Open API?

Consequently I am forced to resolve the problem by getting the program to ask the user to select the relevant objects, and to then filter those objects down to what we need. The API requires us to find “connections” and to then run the macro we just created, on those connections.

We do so, and we run the code.

It works beautifully.

You will note that we run the macro on all components, regardless of whether it is an engineering component or not. We could probably have found an enumeration which determine the type of connection we are dealing with, but since it works, I’m quite happy to let it stand.

For anyone who’s interested here is the code. I have added comments so you should be able to follow it pretty easily:

Written on May 15, 2017