Skip to content

Instantly share code, notes, and snippets.

View benkoshy's full-sized avatar

Ben Koshy benkoshy

View GitHub Profile
@benkoshy
benkoshy / tekla-api-spot-the-bug.md
Created June 28, 2026 23:24
Tekla API - Spot the Bug - MoveObject

If you enjoy trying to spot bugs in the API, with unexpected behaviour: checkout the Tekla API.

The following does not move the object. Can you discern why?

 // set up second beam_moved_geometrically
 Beam beam2manuallyTransformed = beamFactory(startPointFactory(), endPointFactory(), "2"); // orange class string            
 beam2manuallyTransformed.Insert();
@benkoshy
benkoshy / tekla-api-mutating-without-telling-me.md
Last active June 27, 2026 22:50
Tekla API Move Object - Mutates Points Without Telling me!

Watch out!

Another one of those "gotcha's" by Tekla.

I got bitten. I couldn't work out why this was failing. And then I realised. They're mutating. Watch out!

        [Test]
        public void TestMutationOfPointsWhenApplyingMoveOperations()
        {
@benkoshy
benkoshy / tekla-api-matrix-transformations-summary.md
Last active June 25, 2026 00:39
Tekla API Matrix Transformations explained

Key Take Out

WorldCoordinateSystem

The world Coordinate system is a Coordinate System with Origin defined as (0,0,0) and the XAxis defined as (1,0,0) and the YAxis as: (0,1,0).

FromCoordinateSystem

FromCoordinateSystem(beamCS) is the same as ByCoordinateSystems(beamCS, worldCS)

@benkoshy
benkoshy / tekla-api-hello-world.md
Last active May 30, 2026 07:09
Tekla Open API - hello world application

A hello world program.

Ensure you have the Australasia environment loaded. Or otherwise change the profile string to a profile in your environment

Model model =  new Model();

if (model.GetConnectionStatus())
@benkoshy
benkoshy / shed_builder-get-profiles.md
Last active May 25, 2026 08:21
Get All Profiles with a Height Property - using the Tekla Open API
public static List<string> getProfiles()
        {
            List<string> profiles = new List<string>();
            CatalogHandler catalogHandler = new CatalogHandler();

            if (catalogHandler.GetConnectionStatus())
            {
                ProfileItemEnumerator profileItemEnumerator = catalogHandler.GetLibraryProfileItems();
@benkoshy
benkoshy / shed_builder.md
Created May 25, 2026 08:17
The main bits of the Shed Builder program

Key Methods:

public class TeklaModelCreator : IBeamCreator
{

    Model model; 

    public TeklaModelCreator()
    {
        this.model = new Model();
@benkoshy
benkoshy / tekla-api-access-a-profiles-properties.md
Created May 14, 2026 00:27
Tekla API - How to access a profile's property information e.g. Height, Width etc.
        public double getHeight(string profileString)
        {
            LibraryProfileItem libraryProfileItem = new LibraryProfileItem();
            libraryProfileItem.Select(profileString);

            List<ProfileItemParameter> parameters = libraryProfileItem.aProfileItemParameters.Cast<ProfileItemParameter>().ToList();
            double height = parameters.First(p => p.Property.ToUpper() == "HEIGHT").Value;

 return height;
@benkoshy
benkoshy / autocad_dot_net_API_projections.md
Created January 8, 2026 02:12
autocad .net - matrix projection
// insert the usual references


Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;

using (Transaction tr = db.TransactionManager.StartTransaction())
{
@benkoshy
benkoshy / autocad_dot_net_API_create_rotated_dimension.md
Last active November 18, 2025 07:06
A method to create a rotated dimension using the AutoCAD .net API

A method to create a rotated dimension using the AutoCAD .net API

protected void drawDimensions(Point3d dimensionPoint, Point3d point1, Point3d point2, double rotation)
{
    using (Transaction tr = db.TransactionManager.StartTransaction())
    {
        BlockTable blockTable = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
        BlockTableRecord modelSpace = tr.GetObject(blockTable[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
@benkoshy
benkoshy / tekla-api-access-model-object-from-drawing.md
Last active October 15, 2025 23:19
Tekla API - How to access a drawing's model object?

Sometimes you will want to query an object's properties - that you found in a drawing. How do you do that?

Let us suppose we have a single part. Then we need to:

  • Get the Drawing
  • Get the part identifier
  • Select it in the model
SinglePartDrawing singlePartDrawing = (SinglePartDrawing)drawing;