ExtAPI.DataModel.Project.Model.[...]. In current, recent versions of Mechanical, this is commonly shortened — you can start directly from Model.[...] rather than typing the full ExtAPI.DataModel.Project prefix each time, which is why the “Hello, Mechanical!” example in the previous article was able to start every line with simply Model.
There’s an important branch in this rule depending on how many instances of a given object type can exist:
- If an object type can only ever have one instance in the tree (like the Mesh, or the general Model node), you address it directly by name —
Model.Mesh, for example. - If an object type can have multiple instances (like solids under Geometry, or multiple contacts, or multiple analyses), you need to go through
.Childrenor.GetChildren()and index into the result.
Model.Geometry.Children[2] (remembering that indexing starts at [0], so the third item is index 2).

![The tree with the third Solid under Geometry highlighted, corresponding to Model.Geometry.Children[2]](https://mintcdn.com/synopsys-00a47cbc/Srh1_f--TdKCLyqD/resources/articles/images/art3-02-third-solid-highlighted_0.png?fit=max&auto=format&n=Srh1_f--TdKCLyqD&q=85&s=2d15228e8278d7ac4d13b6a062b93f46)
📎 Files for this article:Note: Model was created in 26R1 Here is the complete script, exactly as provided:Model1.wbpz·Model1_get_faces_Ids.py

- Use
DataModel.GetObjectsByName("...")to find an object in the tree by its display name, and store it in a variable (here,contact_group) so you don’t have to re-type a long lookup call every time you need it.GetObjectsByNamereturns a list, so[0]picks out the first match. - From there, use
.Childrento step down into the individual contact objects, inside a loop so you can process every contact (and its target) in one pass rather than hardcoding each one. - Each child’s source and target geometry is reached through the
SourceLocationandTargetLocationproperties, and the actual numeric face ID comes from indexing into.Ids[0]on each of those.

Model tree. A handful of other entry points cover common needs:
Ansys.Mechanical.Graphics.Tools— for setting legend features on plots and views.ExtAPI.SelectionManager— for working with entity selection (what’s currently selected in the GUI).ExtAPI.DataModel.GeoData— for querying raw geometry information.ExtAPI.DataModel.GetObjectByName— for selecting a specific entity by its descriptive name.