ACT provides an API for accessing information about objects contained within the
Tree object in Mechanical.
The Tree object can be accessed via
ExtAPI.DataModel.Tree. The following table provides a
sampling of the APIs available for querying the tree for its contained objects.
Usage examples appear after the table.
| Member | Description |
|---|---|
|
|
Lists all selected objects. Read-only. |
|
|
Lists all of the objects available in the tree. Read-only. |
|
|
Lists all objects that match the specified name. |
|
|
Lists all objects that match the specified type. To do so, use the method
|
|
|
Shows the full statement that must be typed to get the selected object. |
|
|
Prevents updates to the tree. When many objects are added, you can avoid performance issues by specifying that the tree is not refreshed with each addition. This command should be used with the keyword "with" (in Python) or "using" (in C#). |
Note: A comprehensive list can be found in the ANSYS ACT API Reference Guide in the installed help or in the online version available from the ACT Resources page on the ANSYS Customer Portal. To display the page, select . To display the online version, expand the section and click the ACT Online Reference Guide link under Documentation.
In the ACT Console, you can enter commands to query the tree for its contained objects.
To list all objects selected in the tree, type:
ExtAPI.DataModel.Tree.ActiveObjects
To list all objects available in the tree, type:
ExtAPI.DataModel.Tree.AllObjects
To access objects by type, type:
ExtAPI.DataModel.Tree.GetObjectsByType(Ansys.ACT.Mechanical.BoundaryConditions.Force)
To show the command to get the selected object, type:
ExtAPI.DataModel.Tree.GetPathToFirstActiveObject()
To suspend an update and add comments, type:
with ExtAPI.DataModel.Tree.Suspend():
for i in range(5):
ExtAPI.DataModel.Project.AddComment()