Compare two Tekla assemblies the way numbering does (C#)

Two cast units. Same profile, same length, same rebar as far as you can see. Tekla gives them two marks.

So you write the obvious C#: read both, diff every property, print what differs. It finds differences numbering doesn’t care about, and walks past the one it does. Comparing two elements is easy. Comparing them the way Tekla numbering does is the job.

Global coordinates make every element unique

Two identical wall panels on gridlines A and F have nothing in common in global coordinates. Numbering doesn’t look there. It looks at each element in its own axes: the main part’s coordinate system, the same one the assembly drawing uses. Read everything through that, and two twins anywhere in the model give the same numbers.

WorkPlaneHandler planes = model.GetWorkPlaneHandler();
TransformationPlane userPlane = planes.GetCurrentTransformationPlane();
planes.SetCurrentTransformationPlane(new TransformationPlane());   // global first: MatrixFactory works in the CURRENT plane
try
{
    Part main = (Part)assembly.GetMainPart();
    Matrix toElement = MatrixFactory.ToCoordinateSystem(main.GetCoordinateSystem());   // the assembly drawing's axes
    Point local = toElement.Transform(plate.GetCoordinateSystem().Origin);
    // read every part, bolt group, weld and rebar through toElement, then compare
}
finally
{
    planes.SetCurrentTransformationPlane(userPlane);   // give the user their work plane back
}

The global plane line matters. MatrixFactory converts from whatever work plane is active, not from global. Set global first and you know what you’re converting from. The finally puts the user’s plane back, even when a read fails.

An element modelled from the other end needs one more step: try B turned end for end and keep the turn that pairs the most parts.

What numbering compares is written in standard.num

The Numbering settings dialog saves to standard.num, a plain text file of key and value pairs. Tekla finds it the way it finds any attribute file, so let Tekla find it for you:

FileInfo num = new TeklaStructuresFiles(model.GetInfo().ModelPath)
    .GetAttributeFile("standard.num");   // model's attributes folder first, then project, firm, system
var settings = new Dictionary<string, string>();
foreach (string line in File.ReadAllLines(num.FullName, Encoding.GetEncoding(1252)))
{
    string[] pair = line.Trim().Split(new[] { ' ', '\t' }, 2, StringSplitOptions.RemoveEmptyEntries);
    if (pair.Length == 2)   // older files prefix the key: "m3_options.m3_holes 1"
        settings[pair[0].Substring(pair[0].LastIndexOf('.') + 1)] = pair[1];
}
bool welds = settings.TryGetValue("m3_Welds", out string w) && w == "1";   // capital W, and off by default
double concrete = double.Parse(settings["m3_concrete_tolerance"], CultureInfo.InvariantCulture);   // mm

The keys don’t always match the dialog. Values from the common\system file shipped with Tekla 2024 to 2026:

DialogKeyShipped value
Part namem3_profile_name1
Holes (bolts)m3_holes1
Weldsm3_Welds0
Rebar / Embedsm3_rebars / m3_embeds1 / 1
Surface treatmentm3_surfacings1
Tolerance: steel / concrete / rebarm3_steel_tolerance / m3_concrete_tolerance / m3_rebar_tolerance1 / 2 / 2 mm

So a missing fillet weld doesn’t split a mark unless someone switched welds on. Class isn’t on the list at all. Show those differences, but don’t count them. And a dialog change never saved as standard isn’t in the file.

A plate that got thicker hasn’t moved

A PL20 end plate changed to PL25 about its centre plane grows 2.5 mm each way. Both faces move past a 1 mm steel tolerance, so a face-by-face check calls the plate moved. An early Numbering Detective build said exactly that: “moved 0 mm along x”. The fix: a part that changed size counts as moved only when its centre moved too.

WEIGHT includes the surface treatments, so weight lies

Weight looks like the perfect catch-all. Reasonable guess. Wrong. Tekla adds a part’s surface treatments to its WEIGHT, and surface treatments have their own numbering switch. Compare raw weights and a treatment numbering ignores shows up as a weight difference.

double weight = 0;
part.GetReportProperty("WEIGHT", ref weight);   // kg, surface treatments included
foreach (ModelObject found in part.GetSurfaceTreatments())
{
    double treatment = 0;
    if (found is SurfaceTreatment && found.GetReportProperty("WEIGHT", ref treatment))
        weight -= treatment;   // treatments are judged by their own switch, not by weight
}

Numbering Detective 1.0 shipped with that bug. Version 1.1, six days later, took treatment weight out of every part and element.

A treatment on the top face equals one on the bottom face

Nothing in the documentation says how numbering compares surface treatments. So the tool’s integration tests ask Tekla: they model 25 pairs of precast beams with treatments, number them with the switch on and off, and check the tool calls a pair different exactly when Tekla gives it two marks. On Tekla 2025 the rule came out like this. The treatment is measured in its part’s axes, not the element’s. Where it reaches along the part (X) and across it (Z), how high it is, and its thickness all count. Where it sits in Y doesn’t, so top face and bottom face get one mark. Name, material and type don’t count either.

Matrix toPart = MatrixFactory.ToCoordinateSystem(part.GetCoordinateSystem());   // the PART's axes
foreach (ModelObject found in part.GetSurfaceTreatments())
{
    if (!(found is SurfaceTreatment treatment)) continue;
    var points = new List<Point>();
    foreach (Point p in treatment.Polygon.ContourPoints)
        points.Add(toPart.Transform(p));
    var box = new AABB(points);
    // count: MinPoint.X, MaxPoint.X, MinPoint.Z, MaxPoint.Z, MaxPoint.Y - MinPoint.Y, treatment.Thickness
    // show only: where it sits in Y, Name, Material, Type
}

Tested on concrete beams. Plates, columns and fire proofing on steel are assumed to follow the same rule, not proven.

Before your code says two elements differ

  • Measure in the main part’s axes, read with the global work plane.
  • Read standard.num on every compare. Its switches decide what counts, not your diff.
  • Use the steel, concrete or rebar tolerance from the same file.
  • A size change is a move only if the centre moved.
  • Take surface treatments out of WEIGHT and compare them on their part.

All of this runs inside Numbering Detective, free on the Tekla Warehouse. Select two assemblies or cast units and it marks every part, bolt group, weld, rebar and treatment as same, changed, only in A or only in B, by your numbering settings. I didn’t type its code. I built it by prompting an AI agent with my Tekla Open API skill loaded.

The agent can’t know what Tekla never wrote down. The work plane rule is in the skill, so the agent starts from it. The surface treatment rule wasn’t written anywhere, so the agent wrote a test that lets Tekla’s own numbering be the judge. That’s how you build in the course: when the docs run out, Tekla becomes the test your agent has to pass.

Tekla Open API Course: build real Tekla tools with an AI agent →

Related: GetReportProperty in the Tekla Open API: types, units and the silent false · Get selected objects in Tekla Open API (and use LINQ on them) · Tekla Open API skill: why AI invents API that doesn’t exist

Tags

Greg Olszewski

Greg Olszewski builds Tekla Open API tools: Grasshopper Tekla Drawing Link, Smart Select, Tekla Lookup. Ten years of C# on Tekla Structures, day job in precast. Now he teaches engineers to build their own.

About Greg ›

COURSE

Build your own Tekla tools

Learn the Tekla Open API in C#, from your first plug-in to tools your team actually uses.

See the course ›