Tekla.ExtensionMethods 1.0.0.2

dotnet add package Tekla.ExtensionMethods --version 1.0.0.2
                    
NuGet\Install-Package Tekla.ExtensionMethods -Version 1.0.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Tekla.ExtensionMethods" Version="1.0.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Tekla.ExtensionMethods" Version="1.0.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Tekla.ExtensionMethods" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Tekla.ExtensionMethods --version 1.0.0.2
                    
#r "nuget: Tekla.ExtensionMethods, 1.0.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Tekla.ExtensionMethods@1.0.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Tekla.ExtensionMethods&version=1.0.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Tekla.ExtensionMethods&version=1.0.0.2
                    
Install as a Cake Tool

What is this?

Extension methods for Tekla's Open API.

But why?

The old way
ModelObjectSelector Selector = model.GetModelObjectSelector();

// The Old Way
foreach (ModelObject MO in Selector)
{
            Beam B = MO as Beam;
            if (B != null)
            {
            Solid solid = B.GetSolid();
            }
}   

The New Way:
            List<Solid> solids = Selector.GetAllObjects().ToTeklaList<Beam>().Select(b => b.GetSolid()).ToList();

The Ability To Transform via Matrices:


CoordinateSystem cs1 = getCoordinateSystem1();
CoordinateSystem cs2 = getCoordinateSystem2();

// move by operation
Beam beam1_moved_by_operation = beamFactory(startPointFactory(), endPointFactory(), "1"); // we need factory methods because the same points mutate
beam1_moved_by_operation.Insert();
Operation.MoveObject(beam1_moved_by_operation, cs1, cs2);
beam1_moved_by_operation.Select(); // gray       

But who wants to formulate a transformation by hand via coordinate system changes in your head.

What you really want to do is apply a matrix:


Beam beam2manuallyTransformed = beamFactory(startPointFactory(), endPointFactory(), "2"); // orange class string            
beam2manuallyTransformed.Insert();

Matrix final = BeamExtensions.FromObjectToObjectTransformationMatrix(cs1, cs2);
beam2manuallyTransformed.TransformByMutation(final);  // apply a matrix transformation
beam2manuallyTransformed.Modify();
beam2manuallyTransformed.Select(); // update memory                        
model.CommitChanges();

But you could apply any transformation that you wanted!

Matrix Extensions

Helper methods like so

Matrix m = new Matrix().RotateBy(Math.PI / 2, VectorExtensions.YAxis) 		    	              
                       .ThenDisplaceBy(new Vector().ToXaxisWCS());     // curry matrix operations

Point origin = new Point(1,0,0).Transform(m);

Did you catch that? You can apply the transformation to the point, rather than the point to the matrix:

Point newPoint = new Matrix().Transform(new Point(1,0,0));

// but I prefer calling the point, rather than the matrix e.g.
origin.Transform(m);

Ever wanted a simple projection?

 Vector diagonal = new Vector(1, 1, 0);
 Vector xVector = new Vector(1, 0, 0);

 Vector projectionVector = diagonal.ProjectOnto(xVector);

.... and a whole host of other helpers, particularly if you want to use matrices to transform objects.

Further handy helpers if you want to use text strings from users, in order to create grid lines.

Enjoy!

Documentation

Installation
// .net CLI
dotnet add package Tekla.ExtensionMethods
// PMC (Package Manager Console)
NuGet\Install-Package Tekla.ExtensionMethods 

Contributions

Contributions welcome!

If required, add a test.

Notes fo the Maintainer: Packing Instructions

  • Build the solution
  • Update: the assembly version in the csproj file.
  • Update:

In Powershell:

D:\\Documents\\repositories\\TeklaProjects\\Tekla.ExtensionMethods\\Tekla.ExtensionMethods> nuget pack -Symbols -SymbolPackageFormat snupkg
Product Compatible and additional computed target framework versions.
.NET Framework net481 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.8.1

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0.2 103 7/1/2026
1.0.0-alpha 122 6/1/2026 1.0.0-alpha is deprecated because it is no longer maintained.

A set of Extension and Helpers to be used with the Tekla Open API