How to add large number of objects in the tree without refreshing the tree each time using ACT autom

Pernelle Marone-Hitz
Pernelle Marone-Hitz Member, Moderator, Employee Posts: 871
100 Answers 500 Comments 250 Likes First Anniversary
✭✭✭✭
edited June 2023 in Structures

How to add large number of objects in the tree without refreshing the tree each time using ACT automation APIs in Mechanical?

Tagged:

Answers

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 871
    100 Answers 500 Comments 250 Likes First Anniversary
    ✭✭✭✭
    Answer ✓

    If one tries to add a lot of objects in the tree in Mechanical, using automation APIs, it refreshes tree each time an object is added. This can lead to large delays in the process.

    So one can suspend the tree first and then add the objects, for example:

        with(ExtAPI.DataModel.Tree.Suspend()):
                for i in range(100):
                        ExtAPI.DataModel.Project.Model.AddComment()
    

    This will be significantly faster as compared to simply adding 100 objects in the tree.