In the early 2000s, when the Tcl interpreter was taking shape for OpenSees, Frank used a dummy tag 123456789
to determine if a load pattern had already been defined while parsing the load
and sp
commands. Here is the 2001 source code for TclModelBuilder.cpp–clearly written by Frank because he does not capitalize anything when he comments.

I gave Frank a hard time about this dubious software engineering decision: “What if someone legitimately defined a load pattern with tag 123456789? It’ll totally break your parsing logic”. Frank relented and modified the code to use more reliable true/false logic.
Today, I did some recursive grepping for other occurrences of sequential numbers like 12345 or 54321. Discounting a class tag, which is truly harmless, the only thing that came up was some questionable logic in MPCORecorder.cpp and RemoveRecorder.cpp. I’ll spare you the screenshots, but the links will take you to the offending lines on GitHub. In summary though:
- Don’t use the MPCO recorder if your model has a section with tag -123456.
- Don’t remove elements from your model if you have issued more than 987654 nodal load commands or if you remove an element with tag -32922 that also has more than six nodes, regardless of the number of nodal loads.
I know these rules sound crazy, but I’m just interpreting the code.
There could be other magic numbers embedded in OpenSees, e.g., a YYYYMMDD birth date of whoever wrote Concrete23, or their first born. But there’s no easy way to find those occurrences.
I admit though, on the C++ side of OpenSees, it is a little difficult to get unique tags out of the domain and model builder. So I can see the appeal of using a number “that no one will ever use”. But, eventually, someone will use it.
However, if you’re writing a Python or Tcl script for OpenSees, there’s no excuse for using magic numbers like 12345 in your script.
You need a burner node tag? Use getNodeTags
, then add one to the maximum value. You need a throw away element tag? Use getEleTags
and add one. You need a parameter tag for a hot minute? Well, you know what to do with getParamTags
.
Here’s what you would do in OpenSeesPy.
uniqueNodeTag = max(ops.getNodeTags()) + 1
uniqueEleTag = max(ops.getEleTags()) + 1
uniqueParamTag = max(ops.getParamTags()) + 1
The syntax for a one liner in OpenSees Tcl is even messier than I expected.
set uniqueNodeTag [expr [tcl::mathfunc::max {*}[getNodeTags]] + 1]
set uniqueEleTag [expr [tcl::mathfunc::max {*}[getEleTags]] + 1]
set uniqueParamTag [expr [tcl::mathfunc::max {*}[getParamTags]] + 1]
Abracadabra, no more magic numbers in your scripts!
The magic numbers remind me of the scene from Spaceballs where Dark Helmet gets the combination to unlock Planet Druidia’s atmosphere.
Hello, Michael
Is there a way to get a list of the tags for materials and sections as well? That’d be very useful as well when you need to create burner tags for these types of objects.
LikeLike
Hola Gustavo,
A similar command was added recently for coordTransf objects. Would be straightforward to do the same thing for sections and materials.
Michael
LikeLike