Introduction to Tekla Tedds Add-Ins

Updated: 15 Jan 2024

Introduction

Tedds includes an Add-In architecture that allows anyone with Microsoft .Net programming experience to extend the Tedds function library with their own custom functions. Creating an Add-In allows you to integrate Tedds with your existing in-house software applications or applications and services from other 3rd parties.

To create a Tedd's Add-In you must develop a Microsoft .Net assembly which exposes classes and methods which conform to the following rules:

  • The class(es) containing the methods must be public so that they are visible from the outside of the assembly
  • Each class method must be public static (C#) or public shared (VB) so that it is visible from the outside of the assembly
  • Parameters and return values must be one of the following primitive types: void(return value only), bool, int, double or string
  • Function names must have a maximum length of 32 characters.

Once an Add-In is registered with Tedds, each of the public static/shared methods in the Assembly will be available to your Tedds calculations. To register your Add-In with Tedds refer to the Registration topic below.

Registration

To use a Tedds Add-In the Microsoft .Net assembly you have written must be registered with Tedds. To register an assembly follow the steps below:

  1. If either Tedds or Tedds for Word are open, close them.
  2. Locate the Tedds add-In registration directory, which is normally at "C:\ProgramData\Tekla\Structural\Tedds\AddIns".
  3. In the Tedds add-In registration directory, create a text file that is named with the fully qualified namespace of your add-in, and uses the file extension ".addin". For example, if your assembly namespace was MyCompany and the add-In class you want to register is named MyAddIn, then you would name the text file "MyCompany.MyAddIn.addin"
  4. Open the text file you created in step 3. On the first line of the text file, type the full path to the assembly that contains your add-in and save the file. For example C:\TeddsAddIns\MyCompany.MyAddIn.dll.

Testing

To test if your add-in has been registered successfully follow the steps below:

  1. Launch Tedds for Word
  2. In a new Tedds for Word document, type the expression ListFunctions() = ?
  3. Calculate the document
  4. Calculating the ListFunctions will list in your document all of the registered Tedds functions in a list which is sorted alphabetically. If your add-in has been registered and loaded correctly the functions you have published in your add-In should be included in this list.

Database Add-In Example

This documentation includes an example Tekla Tedds Add-In which implements several functions for using a simple compact SQL database. Once this Add-In is registered then all of the DBase… functions exposed by the Add-In can then be used in Tedds calculations.

The example source code is provided in both C# and VB.Net and includes extensive comments to demonstrate how to write your own Add-In.

To use the example add-in follow the steps below:

  1. Using Microsoft Visual Studio, create a new C# or VB.Net Windows Class Library project.
  2. Download the TeddsAddInExamples from GitHub by clicking Clone or Download and then clicking Download ZIP. Extract the zip file to a directory on your system.
  3. Copy either DBaseAddIn.cs for C# or DBaseAddIn.vb for VB.NET to your new class library project directory and then add it to your project.
  4. Add a reference to Tedds.ExprInterop.dll which is located in the Tedds installation directory (normally C:\Program Files\Tekla\Structural\Tedds)
  5. Add a reference to the .NET component System.Data.SqlServerCe version 3.5.1.0
  6. Build the project
  7. Register the example Add-In with Tedds using the steps described in the Tedds add-ins Registration documentation.

The example calculation below uses the example add-in to load some analysis Node and Force data from an example database included with the source code (ExampleData.sdf) and creates a drawing using that data, the functions are then used to modify the database.

Load data from the example database using the DBase add-in functions.

Example calculation

1. Select database

DBaseOpen() = ?

 

2. Load node data from database

DBaseExecuteReader(“SELECT * FROM Nodes”) = ?

 

3. Set variables for id, x and y for each node

i = 1
EvalWhile( “DBaseNextRecord()”,
   “SetVar( \“id[i]\”, DBaseRead(0) )”,
   “SetVar( \“x[i]\”, DBaseReadLength(1) )”,
   “SetVar( \“y[i]\”, DBaseReadLength(2) )”,
   “Increment(\“i\”)” ) = ?

 

4. In order to initialise a drawing canvas we need to find the maximum height and width from the database

width = DBaseExecuteScalar(“SELECT X FROM Nodes ORDER BY X DESC”) * 1m
height = DBaseExecuteScalar(“SELECT Y FROM Nodes ORDER BY Y DESC”) * 1m

 

5. Create a drawing

6. Initialise drawing

DrawCreateDrawing( width, height) = ?
DrawLineColour(“LightBlue”)=?
DrawGrid( 0 m, 0 m, width, height, 1 m, 1 m) = ?
DrawLineColour(“Black”)=?
DrawLineWidth( height / 50 ) = ?

 

7. Draw nodes

i = 1;j = 2
EvalWhile( “And( VarExists(\“id[i]\”), VarExists(\“id[j]\”) )”,
   “DrawLine( x[i], y[i], x[j], y[j] )”,
   “Increment(\“i\”)”,
   “Increment(\“j\”)” ) = ?

 

8. Initialise drawing for forces

DrawLineWidth( height / 200 ) = ?
DrawLineColour( "Green" ) = ?
DrawFontColour( "Green" ) = ?
DrawFont( "Arial", height / 20 ) = ?
DrawLabelStringOrientation( "Horizontal" ) = ?

 

9. Add forces to drawing directly from the database

10. Load forces from database

DBaseExecuteReader(“SELECT * FROM Forces”) = ?

 

11. Draw forces

EvalWhile( “DBaseNextRecord()”,
   “SetVar( \“i\”, DBaseRead(0) )”,
   “DrawLabel( x[i], y[i] + DBaseReadLength(1) / 20, x[i], y[i], StrFormat(\“[1,f0,N] @ [2]\”, DBaseReadForce(1), i) )” ) = ?

 

12. Change node data in the database

In order to check that our add in correctly obeys dimensions rotate the nodes through 90° and offset by [2ft, 7ft] (All other lengths have been in meters)

i = 1
EvalWhile( “VarExists(\“id[i]\”)”,
   “DBaseSet( \“Nodes\”, \“X\”, y[i] + 2 ft, \“Id\”, id[i] )”,
   “DBaseSet( \“Nodes\”, \“Y\”, -x[i] + 7 ft, \“Id\”, id[i] )”,
   “Increment(\“i\”)” ) = ?

 

13. Repeat drawing with offset to show changes

14. Load node data from database

DBaseExecuteReader(“SELECT * FROM Nodes”) = ?

 

15. Set variables for id, x and y for each node

i = 1
EvalWhile( “DBaseNextRecord()”,
   “SetVar( \“id[i]\”, DBaseRead(0) )”,
   “SetVar( \“x[i]\”, DBaseReadLength(1) )”,
   “SetVar( \“y[i]\”, DBaseReadLength(2) )”,
   “Increment(\“i\”)” ) = ?

 

16. In order to initialise a drawing canvas we need to find the maximum height and width from the database

width = DBaseExecuteScalar(“SELECT X FROM Nodes ORDER BY X DESC”) * 1m
height = DBaseExecuteScalar(“SELECT Y FROM Nodes ORDER BY Y DESC”) * 1m

 

17. Initialise drawing

DrawCreateDrawing( width, height) = ?
DrawLineColour(“LightBlue”)=?
DrawGrid( 0 m, 0 m, width, height, 1 m, 1 m) = ?
DrawLineColour(“Black”)=?
DrawLineWidth( height / 50 ) = ?

 

18. Draw nodes

i = 1;j = 2
EvalWhile( “And( VarExists(\“id[i]\”), VarExists(\“id[j]\”) )”,
   “DrawLine( x[i], y[i], x[j], y[j] )”,
   “Increment(\“i\”)”,
   “Increment(\“j\”)” ) = ?

 

19. Initialise drawing for forces

DrawLineWidth( height / 200 ) = ?
DrawLineColour( "Green" ) = ?
DrawFontColour( "Green" ) = ?
DrawFont( "Arial", height / 20 ) = ?
DrawLabelStringOrientation( "Horizontal" ) = ?

 

20. Load forces from database

DBaseExecuteReader(“SELECT * FROM Forces”) = ?

 

21. Draw forces

EvalWhile( “DBaseNextRecord()”,
   “SetVar( \“i\”, DBaseRead(0) )”,
   “DrawLabel( x[i], y[i] + DBaseReadLength(1) / 20, x[i], y[i], StrFormat(\“[1,f0,N] @ [2]\”, DBaseReadForce(1), i) )” ) = ?

 

22. Label offset

DrawLineColour( "Red" ) = ?
DrawFontColour( "Red" ) = ?
DrawDimensionStringFormat( “f”, 0, “’”, True ) = ?
DrawDimensionLine(0 ft, 0 ft, 2 ft, 0 ft) = ?
DrawDimensionLine(0 ft, 0 ft, 0 ft, 7 ft) = ?

 

23. Close database

DBaseClose() = ?

 

Was this helpful?
The feedback you give here is not visible to other users. We use your comments to improve the content.