Using the Selection Manager in DesignModeler

The DesignModeler API SelectionManager allows you to work with graphical selections. It provides service to get information from and to modify, clear, or retrieve the current selection. Additionally, it enables you to create new selections or add entities to the new selection.

Working with the Current Selection

The following Selection Manager commands allow you to perform different actions on the currently selected graphic.

To access the Selection Manager:

selection_manager = ExtAPI.SelectionManager 

To clear the current selection:

selection_manager.ClearSelection()

To retrieve the current selection:

selection = selection_manager.CurrentSelection

This command returns the object ISelectionInfo, which describes the selected entities.

To retrieve entities:

selection.Entities

Creating a New Selection and Adding Entities

The Selection Manager enables you to create new selections and add entities to the current selection. Both of these tasks can be accomplished either by creating a new object ISelectionInfo or by directly using a list of entities.

To create a new selection using a new object ISelectionInfo:

face = ExtAPI.DataModel.GeoData.Bodies[0].Faces[0]
selection = selection_manager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)
selection.Entities = [face]
selection_manager.NewSelection(selection)

To create a new selection using a list of entities:

face = ExtAPI.DataModel.GeoData.Bodies[0].Faces[0]
selection_manager.NewSelection([face])

To add entities to the current selection using a new object ISelectionInfo:

face = ExtAPI.DataModel.GeoData.Bodies[0].Faces[0]
selection = selection_manager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)
selection.Entities = [face]
selection_manager.AddSelection (selection)

To add entities to the current selection using a list of entities:

face = ExtAPI.DataModel.GeoData.Bodies[0].Faces[0]
selection_manager.AddSelection([face])

Release 18.2 - © ANSYS, Inc. All rights reserved.