Category: .net (c#)

I am going to post a series of articles which attempts to explain complicated ideas in a simple fashion.

  • Batch Edit a Part in Tekla Structures

    Batch Edit a Part in Tekla Structures

    TeklaStructures has a batch editing utility for Assemblies.

    However, if we have to batch edit parts there is nothing.

    Expert Steel Detailers demand Utilities

    Our detailers have demanded that we develop a utility to do batch editing of parts.

    (more…)
  • 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.

  • Advance Steel Macro – To place Members

    I’ve created a macro to help create Advanced Steel Members, given a particular spreadsheet file. You are welcome to download and use it – see here. Unfortunately, I don’t have a demo video for you so: Please read the documentation / manual.

  • Advanced Steel Tool – Convert AutoCAD lines to Advanced Steel Beams

    Why bother with this tool?

    Because drawing Advanced Steel Beams is very cumbersome. If you have a CSV file you can draw AutoCAD lines and conver them with a fairly simple macro. Everything is open sourced, so you can fork or submit a PR if you require.

    Here is a video demonstrating this:

    If you want to download it, please see check out this link.

    Source code is available here.

    I had written a more advanced user interface for AutoCAD. Perhaps I will incorpoate that into Advance Steel when I get the time. Porting it is a little tricky/complicated it.

  • Getting Ordered Intersection Points of a Line along a Particular Direction

    It seems to be a common problem: getting intersection points along a line.

    This is what we want:

    We want the ordered points.
    Notice how the points are nicely ordered, from the start point of the picked line?

    Here’s how I solved it:

  • Ordering Lines using Linq (AutoCAD .net API)

    This is a simple example of how Linq can be used to filter, map and order a set of lines.

    The code is pretty self-explanatory. It is a useful example which can be used to springboard towards further, more sophisticated use-cases according to your own requirements.

     

     

  • Check for Fake dimensions in Autocad before using it as reference model

    It is important to check for fake dimensions before using it as reference model in Tekla
    Please watch this video

  • Add If Layer is Missing (AutoCAD .net)

    A very handy method. Often detailers will ask for something to be placed on a particular layer. But since they are using a 100 different drawing templates without any consistency nor standards, the onus is on you to impose that standard on them. So you’d have to check for a layer and add it if it doesn’t already exist. Anyways, that’s enough griping: here is the code: