Category: Tekla API

A series of blog posts exploring the Tekla API.  Code examples, explanations and (where relevant) videos will be provided.

  • Tekla Open API: How to access a Tekla Model Object from the Equivalent Object in a Drawing?

    Tekla Open API: How to access a Tekla Model Object from the Equivalent Object in a Drawing?

    The trick is to use to the drawing’s “PartIdentifier” to select the relevant object in the model space.

    Once you’ve done that, you can query the model object for whatever you want.

    Here is a code sample I’ve extracted from one of our Tekla API Applications. The basic steps:

    • Get the Drawing
    • Get the part identifier
    • Select it in the model
    SinglePartDrawing singlePartDrawing = (SinglePartDrawing)drawing;
    Tekla.Structures.Model.ModelObject modelObject = model.SelectModelObject(singlePartDrawing.PartIdentifier);
    Tekla.Structures.Model.Part part = (Tekla.Structures.Model.Part)modelObject;

  • QR Code on Drawings

    We are now placing smart QR codes on drawings. Why? What benefit is accrued by doing so?

    1. You can see a 3d view of an assembly.
    2. You can conduct spot measurements of the assembly.
    3. You can check whether your drawing is the latest revision.
    4. You can add markups directly to a document number – and see it’s revisions over time

    Instructions on how to make it work

    • Set up a project on prolox.io
    • Get the project’s public access token.
    • Log into the Prolox’s Tekla’s client application. Use your prolox login email and password and the project’s public access token.
    • Using Tekla 2023 and with the relevant model open (please open only 1 model) – run the client code.
    • All the values will be updated.

    Rules – To prevent obsolete data from being used or shown

    • If you update the model, you must re-upload the IFC file in prolox.
    • If you update the revision number, you must re-do the prolox Tekla client program. This will update the revision numbers in prolox.
    • If you delete a drawing you must update the revision number for the deleted drawing and re-run the TeklaQRCode program. (so that all revision numbers are updated on the cloud, and so that if anyone scans an old drawing, they will be immediately notified.)

    Updating the Drawings:

    • When you update the drawing PLEASE USE THE SAME REPOSITORY. This is so that we can have old revisions.

    Setting up the template

    • You must set up the drawing template to that the QR Code program works and puts the QR code in the right location. If you don’t set it up properly it will fail.
    • Assume each page has an origin point of (0,0) at the bottom left hand side of the page.
    • The drawing template’s borders start at (5,5).
    • There must be a good amount of white space between the QR code and borders, otherwise the QR code may fail to be read. Which means the entire thing fails.
    QR standards / documentation.

  • Dont Lose time with missing dimensions

    Do you loose time with missing dimensions

    Have you ever used the wrong revision?

    Here is what is cooking at Tek1.

    If you would lik to to know more

    Here is a solution where you can scan the QR code and bring up the assembly model. know the revision number of the drawing which you should be using

    you may visite tek1.com.au for more information

  • Precast Panels with Tekla Structures

    This is probably first precast project we have attempted with tekla structures as the tool.

    We have done a few with Revit, and lot with Autocad.

    There is raging argument with no one really know (unless one has walked in the weeds) which is a better tool

    I believe no tool as out of the box is really very good.

    Tek1 has been working some using Autocad, develping lot of tools for detailing precast panels.

    Once something is very useful, everyone wants to steal that.

    Code protection is very vital to maintain any sort of edge.

  • Why aren’t the user defined attributes being defined – in Tekla’s “Open” API

    Why aren’t the user defined attributes being defined – in Tekla’s “Open” API

    If you want to waste time on a poorly documented API (which doesn’t make any sense) I would highly recommend getting on Tekla. I’m documenting this so some poor soul doesn’t waste a day trying to debug this:

    // what’s wrong with this?
    
      Beam b = new Beam();
    
      b.SetUserProperty("USER_FIELD_1", "your data");
    
      b.Insert();

    Do you see the problem? First insert the beam, and then apply the UDA and it should work:

    // it only works AFTER you insert
    
      Beam b = new Beam();
    
      b.Insert();
    
      b.SetUserProperty("USER_FIELD_1", "your data");

    What glorious waste of time trying to work out why it failed!

    But the problem is not with you – the problem is with the API. It fails silently, and the documentation is poor. Hopefully this note saves someone a lot of headaches.

  • How to check if you have a legitimate Tekla Profile using the Tekla Open API

    Our use case?

    1. Detailers copy / paste profiles from structural drawings into a CSV file.
    2. This CSV file is then used to create a model.
    3. It is essential that the profiles are recognisable by Tekla.

    How can we check?

    • Through a data validation directly in Excel. Or
    • By validating the data directly in your code.
    using Tekla.Structures.Catalogs;
    // download this dll from Nuget
    
                    public bool CSVProfilesAreCorrect(List<CSVFieldsImplemented> dataRows)
            {
                HashSet<string> csvProfiles = dataRows.Select(row => row.Profile).ToHashSet<string>();
                HashSet<string> teklaProfiles = getAllTeklaProfiles().ToHashSet<string>();
    
                if (_areCSVProfilesCorrect())
                {
                    return true;
                }
                else
                {
                    throw new SystemException($"The CSV files have these profiles which don't exist in Tekla: {String.Join(", ", string.Join(", ", csvProfiles.Except(teklaProfiles)))}");
                }
    
                bool _areCSVProfilesCorrect()
                {   
                    // all the csv profiles
                    // must be contained in tekla profiles
    
                    return csvProfiles.All(profile => teklaProfiles.Contains(profile));
                }
            }
    
    // and we call it like so:
    CSVValidator validator = new CSVValidator(db);
    
    if (validator.CSVProfilesAreCorrect(extractor.CSVRecords))
    {
        // do the modelling
    }        

    Voila! Now it’s hard to make a mistake.

    If you want to get all materials – it’s very similar to the above. Use the CatalogHandler.GetMaterialItems() method along with the materialItem.MaterialName property. The code to actually do that – I will leave as an exercise to the reader.

  • How to Get Tekla Model Objects if selected by Users (Tekla API)

    How to Get Tekla Model Objects if selected by Users (Tekla API)

    A user has pre-selected a set of model objects.

    We need to retrieve them via the API. How do we do it?

    All of our code is extracted from our production apps.

  • ByCoordinateSystems (i.e. the Tekla API method)? AlignCoordinateSystem (the AutoCAD .net API method)? What are they? What do they mean?

    What problem does it solve?

    I have some treasure, buried somewhere.

    I know how to get there from my town.

    • Go 10km forward, and then 5 km left, and then 2 km right.
    • Walk forward 10 steps, and now
    • dig.

    This is great from my current location. But how will you get there from YOUR location? Without changing the location of the treasure, I can tell you how to get there, from your location by aligning coordinate systems.

    But it can be confusing. Here’s how I think about it intuitively. Forget the maths, just think about it intuitively.

    Consider both examples:

    If you think about it that way, it will be much harder to get confused.

  • How to programmatically filter model objects, in a Tekla model, by Part Position? (Tekla API)

    How to programmatically filter model objects, in a Tekla model, by Part Position? (Tekla API)

    Suppose you have a Tekla model and you want to programmatically filter for parts with a revision mark of abc/1. How would you do that?

    1. One way would be to iterate through the entire model, check for items which match your condition (perhaps via a LINQ query).
    2. The second would be to use Tekla’s native filtering metchnicsms, which seem to be FAST:

    When I originally tried the code, I had a single Binary Filter expression for just the part Position Number. I made a fatal mistake – I had assumed that Tekla would be smart enough to release that given I want a part position number, I also wanted a part. The API returned almost everything under the sun. And I have no idea why. So then I added a second Binary filter expression – this time one for parts.

    Given we have two “filters”, we need to add them into a filter collection, and then finally, when we search, we search by .GetObjectsByFilter(filterCollection).

    Here is the code: