Using ACT, how can I create a Worksheet named selection and add the faces included in a previously d

Pernelle Marone-Hitz
Pernelle Marone-Hitz Member, Moderator, Employee Posts: 871
100 Answers 500 Comments 250 Likes First Anniversary
✭✭✭✭
edited June 2023 in Structures

Using ACT, how can I create a Worksheet named selection and add the faces included in a previously defined named selection ?

Tagged:

Answers

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 871
    100 Answers 500 Comments 250 Likes First Anniversary
    ✭✭✭✭
    Answer ✓

    Let's assume a first face named selection exists in the tree, named "FirstNS".

    • A second named selection can be inserted in the tree with:

        Model=ExtAPI.DataModel.Project.Model
        SecondNS=Model.AddNamedSelection()
      
    • The name of the new named selection can be changed through:

        SecondNS.Name="SecondNS through WS selection"
      
    • The scoping method can be changed from Geometry Selection to Worksheet:

        SecondNS_WS=ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.WorksheetSpecific)
        SecondNS.Location=SecondNS_WS
      
    • The criteria to create the new named selection can be changed using:

        SecondNS.Location.AddRow() #Add new row
        SecondNS.Location.SetAction(0,NamedSelectionWorksheetAction.Add) # Set "Action" to "Add"
        SecondNS.Location.SetEntityType(0,NamedSelectionWorksheetEntityType.Face) # Set "Entity type" to "Face"
        SecondNS.Location.SetCriterion(0,NamedSelectionWorksheetCriterion.NamedSelection) # Set "Criterion" to "Named Selection"
        SecondNS.Location.SetOperator(0,NamedSelectionWorksheetOperator.Equal) # Set "Operator" to "Equal"
      
    • The "Value" can be set to "FirstNS" with the following code:

        for NS in Model.NamedSelections.Children:
            if NS.Name == "FirstNS":
                SaveNS = NS
        SecondNS.Location.SetValue(0,SaveNS.Id)
      
    • The new named selection can be generated with:

        SecondNS.Location.Generate()
      
  • Ayush Kumar
    Ayush Kumar Member, Moderator, Employee Posts: 450
    100 Answers 250 Likes 100 Comments First Anniversary
    ✭✭✭✭
    Answer ✓

    For WB version 2020R2 and above:

    Model = ExtAPI.DataModel.Project.Model
    second_ns = Model.AddNamedSelection()
    
    second_ns.Name = "Second NamedSelection through WS selection"
    
    second_ns.ScopingMethod = GeometryDefineByType.Worksheet
    Criteria = second_ns.GenerationCriteria 
    Criteria.Add(None)
    
    Criteria[0].EntityType = SelectionType.GeoFace
    Criteria[0].Criterion = SelectionCriterionType.NamedSelection
    Criteria[0].Operator = SelectionOperatorType.Equal
    Criteria[0].Value = ExtAPI.DataModel.GetObjectsByName("first_ns")[0]
    
    second_ns .Generate()
    ExtAPI.DataModel.Tree.Refresh()