Tree Object

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.

MemberDescription

ActiveObjects

Lists all selected objects. Read-only.

AllObjects

Lists all of the objects available in the tree. Read-only.

GetObjectsByName

Lists all objects that match the specified name.

GetObjectsByType

Lists all objects that match the specified type.

To do so, use the method GetObjectsByType and pass the type (such as Force) as an argument. The whole namespace of the type must be specified.

GetPathToFirstActiveObject

Shows the full statement that must be typed to get the selected object.

Suspend

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 Downloads > ACT Resources. To display the online version, expand the Help & Support 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()

 


Release 18.2 - © ANSYS, Inc. All rights reserved.