How to select geometry from GUI though script (Highlight in GUI,Not using Named Selection)
Best Answer
-
my_selection = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities) my_selection.Ids = [27,28] ExtAPI.SelectionManager.ClearSelection() ExtAPI.SelectionManager.AddSelection(my_selection)
Alternatively:
... ExtAPI.SelectionManager.NewSelection(my_selection)
0
Answers
-
Note there is also the option to not actually "select" the geometry in the selection manager, but to simply highlights it in the graphics window. This is useful when having multiple types of selections (i.e. primary and secondary) and you may want them to display in different colors before performing an operation on them....
You can use this general graphics method to create non-clickable graphics of the geometry. There are properties of the created "MyFaceGraphic" like color, DepthTest (is it hidden when something is in front of it), toggle showing points on face or not, etc....MyFaceGraphic = ExtAPI.Graphics.Scene.Factory3D.CreateGeometry(MyFace)
ExtAPI.Graphics.Scene.Clear() to remove all custom graphics from the GUI window.
Also a good idea to use this for faster graphics processing:
with ExtAPI.Graphics.Suspend():
#do something1 -
@Landon Mitchell Kanner said:
my_selection = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities) my_selection.Ids = [27,28] ExtAPI.SelectionManager.ClearSelection() ExtAPI.SelectionManager.AddSelection(my_selection)
Alternatively:
... ExtAPI.SelectionManager.NewSelection(my_selection)
I have an additional question, is there any way to select a geometry in specified location without using the named selection?
0 -
Not straightforward, but you could use GeoData to access geometrical properties of your model (for example, areas of surfaces), and select the entities that match your criteria. Using named selections would probably be more efficient, though.
1 -
is there any way to select a geometry in specified location without using the named selection?
Yes. See for example:
https://discuss.ansys.com/discussion/2839/how-to-get-a-body-or-node-id-associated-with-a-known-coordinate-point0