How to select active object ?
Hi,
I have a script for the creation of an APDL command on object :
joint_33 = DataModel.GetObjectById(33)
command_snippet_37 = joint_33.AddCommandSnippet()
command_snippet_37.Input = r"""toto"""
I would like my script to be more robust and change the first command line.
Is there a way to select the object not by the ID but with the selection on Mechanical tree ?
Thanks,
Jean
Best Answer
-
Hi @Jean,
There are many ways to select objects in the Mechanical tree in a more robust manner.
To select the active object, useTree.FirstActiveObject
(you can also refer to this post)
You can also select objects based on their names:ExtAPI.DataModel.GetObjectsByName()
will return a list of all objects having the same name (this is robust only if you have unique namings, and hence select the first object in the returned list).
You can also grab objects based on their types (ie, a named selection, a fixed support, etc) throughExtAPI.DataModel.GetObjectsByType()
.
This other post provides examples.0
Answers
-
It's perfect!
Thanks a lot1