Skip to main content
So far, you have seen how to create new entities in TD, but OpenTD can also be used to query existing models and modify their contents. For most entity types, there is a ThermalDesktop method to get all items of that type in the model, and a method to get a specific item. For example, GetNodes() returns a list of all Nodes, and GetNode(string handle) returns a specific node if you know its AutoCAD handle. (See the Work with connections, handles, markers, and domains section) It is often convenient to use the LINQ Single or Where methods to search a returned list of entities to find the items that meet some criteria. For example, to find all the arithmetic nodes on layer “sheet”, you could do something like this:
The variable arithmeticNodes would now be an IEnumerable<Node> containing all of the arithmetic nodes on layer “sheet”. Note: You can use foreach to iterate over the elements of an IEnumerable, just like a List. Or you can convert the IEnumerable to a List using the ToList() method. Another useful LINQ technique is to use the Select method to extract a related list from an input list. For example, the following line creates an IEnumerable<string> containing the handles of all of the nodes returned by GetNodes():
To delete any item with an AutoCAD handle, use the ThermalDesktop.DeleteEntity method. For items without handles, there are specialized delete methods such as ThermalDesktop.DeleteSymbol, which accepts the name of the symbol to delete. The following examples demonstrate querying, modifying, and deleting entities in a model.

Query and edit a model

Here is a program that demonstrates how to query a model and make simple edits. For the purposes of this program, we will first create a model and then query it, but the model could have been created by any means, including the GUI. The query techniques are the same.

Query and edit finite elements

As mentioned previously in the Additional information on positioning entities using BaseTrans and LocalTrans section, if you want to edit a mesh created by an FEMeshImporter, you will first have to get the objects representing the actual nodes and elements. Editing the FEMeshImporter directly only offers limited functionality. This is demonstrated in the following program: