Tekla GetAllObjectsWithType: which base types actually work

Pass typeof(Part) to GetAllObjectsWithType and you get every beam, column, slab and lofted plate in the model. Pass typeof(BaseRebarGroup), a base class the documentation lists the same way, and the API asks Tekla for ModelObjectEnum.UNKNOWN.

No exception, no warning. And nothing in that request asks for a rebar group.

GetAllObjectsWithType reads a lookup table, not your class hierarchy

The documentation says the Type[] overload returns the objects “with the given base type”. That reads like C# inheritance: pass a base class, get every subclass. Reasonable guess. Wrong.

Open Tekla.Structures.Model.dll in a decompiler and the overload turns out to be a translator. It converts your array into ModelObjectEnum values before anything reaches Tekla. Eight base types are special-cased and expand into a fixed list. Every other type maps one to one, and a type that isn’t in the table becomes UNKNOWN. Here is the table, read from the 2021 to 2026 NuGet packages:

You passTekla is asked for
ModelObjectevery object type
PartBeam, PolyBeam, ContourPlate, BentPlate, Brep (items). SpiralBeam and LoftedPlate from 2022.
ReinforcementSingleRebar, RebarGroup, CurvedRebarGroup, CircleRebarGroup, RebarMesh, RebarStrand
BoltGroupBoltArray, BoltCircle, BoltXYList
BaseWeldWeld, PolygonWeld, LogicalWeld
BaseComponentComponent, Connection, Detail, Seam, CustomPart
Tekla.Structures.Model.BooleanBooleanPart, CutPlane, Fitting, EdgeChamfer
LoadLoadPoint, LoadLine, LoadArea, LoadUniform, LoadGroup. Not LoadTemperature.
GridBaseUNKNOWN up to 2025. Grid and RadialGrid in 2026.
BaseRebarGroupUNKNOWN

Say you want every rebar group in your wall panels, straight and curved. The class they share in the documentation is BaseRebarGroup. The API doesn’t know it:

var selector = new Model().GetModelObjectSelector();

// Not in the table: goes to Tekla as ModelObjectEnum.UNKNOWN
var wrong = selector.GetAllObjectsWithType(new[] { typeof(BaseRebarGroup) });

// In the table: single rebars, straight, curved and circular groups, meshes, strands
var rebar = selector.GetAllObjectsWithType(new[] { typeof(Reinforcement) });

Two types have no base that covers them. RebarSet isn’t a Reinforcement at all, it inherits straight from ModelObject. LoadTemperature is a Load in the class tree but missing from the table. Add both by name when you need them.

A hand-typed part list stops at the version you typed it in

The opposite rule sounds just as reasonable: GetAllObjectsWithType “doesn’t do base classes”, so list the part types yourself. It looks explicit, so it feels safer:

var types = new[] { typeof(Beam), typeof(PolyBeam), typeof(ContourPlate), typeof(BentPlate) };
var parts = selector.GetAllObjectsWithType(types);   // no items (Brep), no lofted plates, no spiral beams

If your lifting anchors are modelled as items from the shape catalogue, that take-off has lost them. The list inside the API grows instead: the 2021 package expands Part to five types, 2022 onwards to seven. Hand Tekla the base it knows and you get that growth for free:

// Expanded inside the API to every part type this Tekla version knows
ModelObjectEnumerator parts = selector.GetAllObjectsWithType(new[] { typeof(Part) });

Don’t take my table on trust either. Count what comes back on a model you know:

var count = new Dictionary<string, int>();
var all = selector.GetAllObjectsWithType(new[] { typeof(Part) });
while (all.MoveNext())
{
    string name = all.Current.GetType().Name;              // Beam, ContourPlate, LoftedPlate...
    count[name] = count.TryGetValue(name, out int n) ? n + 1 : 1;
}

Smart Select shipped the wrong rule, with a test to defend it

Confession. Smart Select, my free tool that turns a typed sentence into a Tekla selection, builds its type arrays the “safe” way. The rule sits in a comment: Tekla “doesn’t enumerate the abstract Part base, so expand to every concrete Part subclass”. A unit test states that passing Reinforcement “returns nothing”. My AI agent wrote both, with my skill loaded, and neither got questioned before 1.1 shipped.

So in version 1.1, the one on the Tekla Warehouse as I write this, “parts” means five types: no items, no lofted plates. “Rebar” means four: no curved or circular rebar groups. The test passes, because it checks the hand-made list, not the model.

A wrong rule in a comment misleads the next reader. A wrong rule in a test passes every build.

The fix is the snippet above: pass the base, let the table expand it. Smart Select is free on the Tekla Warehouse. Type “group concrete columns by bottom level” and it shows the one line it understood: Beam where material_type eq CONCRETE and beam_type eq COLUMN.

Filter the selection yourself and GetType() never equals Part

The table only helps when Tekla does the scan. GetSelectedObjects() has no type overload (and it’s an IEnumerator, not an IEnumerable). GetObjectsByFilterName has none either, and GetFilteredObjectsWithType takes one enum, not a type array. So when a tool scans the user’s selection or a saved filter, the type check moves into C#.

Smart Select checks with an exact match on obj.GetType(). Switch its array to typeof(Part) and that check rejects every object, because no object’s runtime type is Part. It’s a Beam or a ContourPlate. Tekla matches by table. C# matches by inheritance. Your code needs both:

Type[] wanted = { typeof(Part), typeof(Reinforcement) };

var picked = new Tekla.Structures.Model.UI.ModelObjectSelector().GetSelectedObjects();
while (picked.MoveNext())
{
    ModelObject obj = picked.Current;
    bool keep = wanted.Any(t => t.IsInstanceOfType(obj));   // not wanted.Contains(obj.GetType()): nothing is exactly a Part
    if (!keep) continue;
    // read report properties, UDAs...
}

Type arrays that return what they say

  • Pass the bases the API knows: Part, Reinforcement, BoltGroup, BaseWeld, BaseComponent, Boolean, Load.
  • Any other base class, like BaseRebarGroup or GridBase before 2026, becomes UNKNOWN without an error.
  • Add RebarSet and LoadTemperature by name. No base covers them.
  • Don’t type the part list yourself. It misses items and lofted plates.
  • Filtering in C#? Use IsInstanceOfType or is, never GetType() ==.

The documentation said “base type”. My agent’s test said “returns nothing”. Neither was the whole answer, and the answer was sitting in the DLL the whole time. That table is going into the skill, so the agent stops guessing in either direction. In the course, the selection reporter you build is where you learn the habit behind it: count what a call really returns on a model you know, before the rule goes into code, a test or your agent’s instructions.

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

Related: Get selected objects in Tekla Open API (and use LINQ on them) · GetReportProperty in the Tekla Open API: types, units and the silent false · 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 ›