How to delete Ansys.ACT.Automation.Mechanical.DataModelObject from tree by script?
Hello all,
I created the ACT extension which creates Ansys.ACT.Automation.Mechanical.DataModelObject in the Mechanical Tree during the run. The extension could be run several times. It would be helpful to rewrite DataModelObject during the next run instead of deleting them manually but this object has no method delete().
How do I rewrite DataModelObject?
Thanks
Best Answer
-
HI @dafedin , can you try the solutions provided here?
https://discuss.ansys.com/discussion/526/how-to-delete-a-custom-object-by-script
https://discuss.ansys.com/discussion/2542/how-to-delete-load-objects-in-wb-ls-dyna
(second post mentions LS-Dyna but it would work with other extensions too).1
Answers
-
Hello Pernelle,
Great thanks! The first link shows a discussion with the workaround. I showed the successful code in my comment there:
https://discuss.ansys.com/discussion/526/how-to-delete-a-custom-object-by-script
1 -
This function works for both native and ACT objects and minimizes the use of InternalObject:
def DeleteObject(obj): try: ID = obj.ObjectId except: ID = obj.InternalObject.ID JScmds = 'DS.Tree.DeleteObject({})'.format(ID) ExtAPI.Application.ScriptByName("jscript").ExecuteCommand(JScmds)
0