At work I look after Tekla templates from the last ten years. I wrote almost none of them.
That’s fine until something changes for all of them at once. A UDA gets renamed, the company address moves, a revision column needs one more character. Template Editor has no batch edit. It opens one template, you find the field, change it, save, and open the next one.
A .rpt or .tpl is a text file, so search before you open anything
Every report and drawing table is plain text: blocks, properties and formula strings. Template Editor is one way to edit it, not the only one. So the first job on a library you didn’t write is a list: which templates read the attribute you’re about to change.
Get-ChildItem D:\Templates -Recurse -Include *.rpt, *.tpl |
Select-String -Pattern '(?<=\\"|\.)DR_DRAWN_BY(?=\\")' -CaseSensitive | # inside a formula only
Group-Object Path | Select-Object Count, Name
The pattern looks fussy for a reason. Tekla’s own templates are a good test. In the ones that ship with 2026.0, 103 files read the drawing UDA DR_DRAWN_BY, and they spell it four ways in formulas:
GetValue(\"USERDEFINED.DR_DRAWN_BY\")
GetValue(\"DRAWING.USERDEFINED.DR_DRAWN_BY\")
GetValue(\"CURRENT_DRAWING.USERDEFINED.DR_DRAWN_BY\")
GetValue(\"DR_DRAWN_BY\") // bare, in 3 files: a search for USERDEFINED. misses it
The same letters also turn up in field names, like name = "USERDEFINED.DR_DRAWN_BY_field";. That’s a label, not the attribute. The backslash-quote on both sides is what tells them apart: inside a formula string, every quote is escaped.
Find-and-replace breaks templates in ways Tekla doesn’t report
Ten years of templates is ten years of different people and different Tekla versions. A replace that’s right for one file can quietly break the next. Three to check for before you run anything:
- Case. PowerShell’s
-replaceignores case. UDA names don’t.USERDEFINED.COMMENTandUSERDEFINED.commentare two attributes, and both ship with Tekla. Match the wrong one and the field comes out blank on the next report. - Encoding. Older templates are often ANSI, newer ones UTF-8. Read one as the wrong encoding and write it back, and every ° and ² in your headers turns into garbage.
- Line endings. Template Editor needs Windows CRLF. A file saved with Unix LF endings, which is what an AI agent’s file tools often write, makes it crash on open: exception
0xc0000409, no dialog, no line number. Packing two statements onto one line does the same.
This rename handles all three. It reads and writes raw bytes, so ANSI and UTF-8 both come back as they were, and it doesn’t touch line endings:
$old = 'DR_DRAWN_BY'; $new = 'DRAWN_BY'
$latin1 = [Text.Encoding]::GetEncoding(28591) # one byte = one char, any encoding survives
$pattern = '(?<=\\"|\.)' + [regex]::Escape($old) + '(?=\\")' # exact name, formulas only
Get-ChildItem D:\Templates-copy -Recurse -Include *.rpt, *.tpl | ForEach-Object {
$text = $latin1.GetString([IO.File]::ReadAllBytes($_.FullName))
$edit = [regex]::Replace($text, $pattern, $new) # case-sensitive, unlike -replace
if ($edit -cne $text) { # -ne would ignore case too
[IO.File]::WriteAllBytes($_.FullName, $latin1.GetBytes($edit))
$_.Name
}
}
Run it on a copy of the folder, never the live firm folder. Tested on a copy of 17 shipped templates, one with non-ASCII text: renaming back gave byte-identical files.
Check every file before anyone opens one in Tekla
A template that won’t open doesn’t tell you why. So the check has to run before Tekla does. The free tekla-templates skill has a script that sweeps a whole folder:
scripts\Test-TeklaTemplates.ps1 -Path D:\Templates-copy
# clean / parse-fail / TplEd-incompatible (LF, packing, comments, notes > 120 chars) / grammar
# exit 0 = all clean: only then copy the folder back
The grammar check also catches an invented property key. Tekla ignores those without a word, so a typo like lenght is a setting that never applies.
You fixed the firm folder. The model still shows the old title block.
Tekla takes the first template it finds with that name, and the model folder comes before the firm and project folders. If someone once copied a title block into <model>\ or <model>\templates\ to try a change, that copy still wins. Your batch edit worked. That model doesn’t read it.
Run the same search over your model folders before you call the change done. In an inherited library, the copies you didn’t know about are the real work.
Before you change a template you didn’t write
- List every template that reads the attribute first. Search formulas, not field names.
- Expect more than one spelling: bare,
USERDEFINED.and prefixed hops. - Replace case-sensitively, byte for byte, on a copy of the folder.
- Check the whole folder for LF endings and packed lines before Template Editor sees it.
- Search the model folders too. A local copy beats the firm folder.
The skill was wrong about one-line blocks once. An early version decided packed formatting was harmless. Then the same template crashed Template Editor packed and opened fine expanded. Now that’s a check script, not a note. The tekla-templates skill is free. The course is the same method aimed at C#: you build Tekla tools with an AI agent, and every trap you hit becomes a check the agent runs next time.
Tekla Open API Course: build real Tekla tools with an AI agent →
Related: Tekla UDAs from C#: why GetUserProperty returns false (it’s not objects.inp) · GetReportProperty in the Tekla Open API: types, units and the silent false · Tekla Open API skill: why AI invents API that doesn’t exist
