The Tree
object provides access to the Mechanical tree.
To access this object, simply enter Tree
. The following table
provides a sampling of the APIs available on this object. Some usage examples appear
after the table. For a comprehensive listing of methods and properties of the
Tree
, see Tree in the
ACT Online API and XML Reference Guide.
Member | Description |
---|---|
ActiveObjects | Lists all selected objects. Read-only. |
AllObjects | Lists all of the objects available in the tree. Read-only. |
GetPathToFirstActiveObject | Shows the full statement that must be typed to get the selected object. |
Refresh | Refreshes the tree. |
To access all objects selected in the tree:
Tree.ActiveObjects
To access all objects in the tree:
Tree.AllObjects
To access the first object selected in the tree:
Tree.GetPathToFirstActiveObject()
Here are some other helpful APIs for performing tasks in the tree:
Iterating
for obj in Tree
Sort
Tree.Sort()
Tree.ClearSort()
Filter
Tree.Filter(tag="tagname")
Tree.Filter(state=ObjectState.Suppressed)
Tree.Filter(visibility=False)
Tree.ClearFilter
Find
objects = Tree.Find(name="substring", state=ObjectState.Unsuppressed)
for obj in objects:
Events
def myFunc(sender, args):...
Tree.OnActiveObjectChanged += myFunc
Grouping
Tree.Group([obj1, obj2, obj3, ...])
Tree.HideAllGroupingFolders()
Tree.ShowAllGroupingFolders()
Multi-select
Tree.Activate([obj1, obj2, obj3, ...])