Using ACT, how can I create a Named Selection that will regroup the geometric entities scoped in two

Options
Pernelle Marone-Hitz
Pernelle Marone-Hitz Member, Moderator, Employee Posts: 813
First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
edited June 2023 in Structures

Using ACT, how can I create a Named Selection that will regroup the geometric entities scoped in two other Named Selection?

Tagged:

Answers

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 813
    First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
    Answer ✓
    Options

    Let's assume there are already two face named selection in the tree, named MyNS1 and MyNS2.

    • To create another Named Selection, one can use:

        NamedSelections=ExtAPI.DataModel.Project.Model.NamedSelections
        MyNewNS=NamedSelections.AddNamedSelection()
      
    • The name of this new Named Selection can be changed through:

        MyNewNS.Name="MyNS3"
      
    • To define the scoping of this third Named Selection, one should first retrieve the list of Ids of the geometry scoped in MyNS1 and MyNS2:

        for NS in NamedSelections.Children:
            if NS.Name=="MyNS1":
                MyIds1=NS.Ids
            if NS.Name=="MyNS2":
                MyIds2=NS.Ids
        MyIds3=MyIds1+MyIds2
      
    • Lastly, let's assign the list MyIds3 to the scoping of MyNS3:

        temp_sel=ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)
        temp_sel.Ids=MyIds3
        MyNewNS.Location=temp_sel