Open the .cs file the Tekla macro recorder wrote, and look for the wall panel you just modified. It isn’t there. There’s no part, no beam, no model. There’s akit.PushButton("view_modify", "view_dial").
It’s C#. It isn’t the Open API. Knowing the difference is the whole trick to turning a recording into a tool.
The recorder writes dialog clicks, not model code
Record “load saved view settings and apply them” in a drawing, and the body of the macro is three lines:
wpf.InvokeCommand("CommandRepository", "View.Properties_Drawing"); // open the dialog
akit.ValueChange("view_dial", "gr_view_get_menu", "RebarMeshView"); // pick saved settings by name
akit.PushButton("view_modify", "view_dial"); // press Modify
Every argument is the internal name of a dialog, a field or a button. Recent versions wrap it in a UserMacros.Macro class with a [MacroEntryPoint] attribute. Older recordings, and the macros Tekla ships, start from Script.Run(IScript akit) instead. In my 2025 macros\modeling folder, 24 macros use these calls and no Open API at all. CleanUpNumberingBeforeCreatingDrawings.cs still says // Generated by Tekla.Technology.Akit.ScriptBuilder at the top: 25 akit lines that open the numbering settings, save yours, load another set, clear and redo the numbering, then put your settings back.
Why a recording works on your model and fails on the next one
A recording replays the screen as it was when you pressed record. Each line assumes something:
- The saved settings exist.
RebarMeshViewis a file in your model or firm folder. A colleague without that file doesn’t get your settings. - The selection is right. The macro acts on what’s selected when it runs, not on what was selected when you recorded it.
- The window has that name. Some calls address a view window directly, as in
"View_01 window_1". - The dialog stays the same. An upgrade can rename a field, and the macro is then talking to something that’s gone.
- You never need to pick. The recorder doesn’t catch picks, and most modelling commands start with one.
For a sense of how far UI scripting has to stretch, open Show Exact Geometry of Selected Parts.cs, shipped with Tekla. It imports keybd_event from user32.dll to hold down Shift while it runs the command. It works. It’s also a macro pressing your keyboard for you.
Rewrite the part that touches objects
When the job is about elements (read a mark, write a UDA, move an embed), go through the model, not the dialog. Tekla ships Copy Mark Number To Uda.cs, which copies every assembly mark in the model into a PRELIM_MARK UDA. Here’s the same idea for only the elements you pick, as a complete macro:
#pragma warning disable 1633
#pragma reference "Akit5"
#pragma reference "Tekla.Structures"
#pragma reference "Tekla.Structures.Model"
#pragma warning restore 1633
using System;
using Tekla.Structures.Model;
using Tekla.Structures.Model.Operations;
using Tekla.Structures.Model.UI;
namespace Tekla.Technology.Akit.UserScript
{
public class Script
{
public static void Run(Tekla.Technology.Akit.IScript akit)
{
var model = new Model();
ModelObjectEnumerator picked;
try
{
picked = new Picker().PickObjects(Picker.PickObjectsEnum.PICK_N_PARTS,
"Pick the elements, middle-click to finish"); // the step a recording can't do
}
catch (Exception) { return; } // Esc throws
int count = 0;
while (picked.MoveNext())
{
var part = picked.Current as Part;
if (part == null) continue;
string mark = "";
if (!part.GetReportProperty("ASSEMBLY_POS", ref mark)) continue; // check the false
if (part.SetUserProperty("PRELIM_MARK", mark)) count++; // a UDA needs no Modify()
}
model.CommitChanges();
Operation.DisplayPrompt(string.Format("{0} elements marked.", count)); // C# 5 on 2024: no $""
}
}
}
Save it as Mark Picked Elements.cs in macros\modeling. The file name becomes its name in the Applications & components catalog. It doesn’t care what the dialogs are called, whose settings files exist, or what was selected before. It asks.
Tekla 2024 compiles your macro as C# 5
That string.Format on the last line isn’t a style choice. Tekla compiles a macro itself when you run it, and up to 2024 it uses the old in-box compiler: C# 5. An interpolated string, $"{count} elements marked.", stops it with CS1056: Unexpected character '$'. So do ?., nameof and out var. From 2025 Tekla ships a newer compiler and they’re fine.
It compiles in Visual Studio. Tekla 2024 isn’t Visual Studio. If anyone you share the file with is still on 2024, write C# 5. And if a macro behaves like its previous version after you copy an older file over it, Tekla didn’t recompile: it keeps a compiled copy in MacroCacheFolder under %LOCALAPPDATA%\Trimble\Tekla Structures\<version>\Settings. Delete the cached .cs.dll.
Keep akit for the dialogs the API can’t reach
Don’t throw every recorded line away. Some dialogs have no API behind them, and then a few akit lines are the honest answer. Tekla’s own CreateSurfaceView.cs does both: the Open API Picker to pick a face, then akit to fill in the view dialog.
Grasshopper Tekla Drawing Link does the same. When a view’s saved settings have to load completely, detailed settings and filters included, it writes a small macro like the three lines above, saves it as GH_macro_NN.cs and runs it with Operation.RunMacro. Marks with saved settings go the same way: part, rebar, pour, bolt and weld marks. It’s slower, so in the view components it’s a menu option, not the default.
The rule I’d give anyone: objects through the API, dialogs through akit, and only the dialogs.
Before you rewrite a recording
- Read it first. Every
akitline is a dialog name, a field name or a button. - Move anything that reads or changes elements to the Open API, and ask for picks with
Picker. - Keep akit only for dialogs with no API, and assume the saved settings may be missing.
- Write C# 5 if anyone runs it on Tekla 2024, and commit your changes.
Your agent writes modern C#. Tekla 2024 doesn’t read it. Left alone, an AI agent fills a macro with interpolated strings, and the error only shows up inside Tekla. The skill carries the C# 5 rule and a preflight script that compiles the macro with Tekla’s own compiler, so the agent finds out first. In the course, your first tools are macros like the one above: written by the agent, compiled for your Tekla version, read by you.
Tekla Open API Course: build real Tekla tools with an AI agent →
Related: Tekla automation: custom components, macros, plug-ins and AI · Tekla UDAs from C#: why GetUserProperty returns false (it’s not objects.inp) · What is Tekla Open API? A guide for detailers and engineers
