What is the new way to work with Worksheet Named Selection from the 2020R2?

Chemsdine CHEMAI
Chemsdine CHEMAI Member, Employee Posts: 201
100 Likes 100 Comments Second Anniversary Ansys Employee
✭✭✭✭
edited June 2023 in Structures

What is the new way to work with Worksheet Named Selection from the 2020R2?

Tagged:

Best Answers

  • Chemsdine CHEMAI
    Chemsdine CHEMAI Member, Employee Posts: 201
    100 Likes 100 Comments Second Anniversary Ansys Employee
    ✭✭✭✭
    Answer ✓

    Before the 2020R2 :

    NS = Model.AddNamedSelection() 
    NS.ScopingMethod = GeometryDefineByType.Worksheet 
    NS_location = NS.Location 
    Row = NS_location.AddRow() 
    NS_location.SetEntityType(Row, NamedSelectionWorksheetEntityType.Face) 
    NS_location.SetCriterion(Row, NamedSelectionWorksheetCriterion.Location_Z) 
    NS_location.SetOperator(Row,NamedSelectionWorksheetOperator.GreaterThan) 
    NS_location.SetValue(Row,-7)
    

    From the 2020R2:

    NS = Model.AddNamedSelection() 
    NS.ScopingMethod=GeometryDefineByType.Worksheet 
    Criteria = NS.GenerationCriteria 
    Criteria.Add(None) 
    Criteria[0].EntityType = SelectionType.GeoFace 
    Criteria[0].Criterion = SelectionCriterionType.LocationZ 
    Criteria[0].Operator = SelectionOperatorType.GreaterThan 
    Criteria[0].Value = Quantity(“-7 [m]”)
    
  • Pierre Thieffry
    Pierre Thieffry Member, Moderator, Employee Posts: 107
    25 Answers Second Anniversary 10 Comments 25 Likes
    ✭✭✭✭
    Answer ✓

    And don’t forget NS.Generate()

Answers

  • Erik Kostson
    Erik Kostson Member, Moderator, Employee Posts: 276
    50 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭
    edited April 30

    Just to add if we want to say remove a Planar surface/face (2023 R2):

    ns=model.NamedSelections.Children
    myns=ns[0]
    myns.ScopingMethod=GeometryDefineByType.Worksheet
    Criteria=myns.GenerationCriteria
    Criteria.Add(None)
    index=len(Criteria)-1
    Criteria[index].Action=SelectionActionType.Remove
    Criteria[index].EntityType = SelectionType.GeoFace 
    Criteria[index].Criterion = SelectionCriterionType.Type
    Criteria[index].Operator=SelectionOperatorType.Equal
    Criteria[index].Value = 1 # 1 for plane, 2 cylinder, etc
    myns.Generate()
    Tree.Refresh()
    
  • Joona
    Joona Member Posts: 3
    First Comment
    **

    Regarding the same topic:
    what is the code for Value = Plane, which comes from a dropdown menu if done manually.
    Example remove faces which are planes by their type

  • Joona
    Joona Member Posts: 3
    First Comment
    **

    I repeat my comment because the first one from yesterday did not appear.
    How to set in the value column "Plane" (comes from the dropdown menu)? Quantity("Plane") does not work.
    Example: remove faces whose type equals "Plane".

  • Erik Kostson
    Erik Kostson Member, Moderator, Employee Posts: 276
    50 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭
    edited April 30

    See my answer above it is shown there (Criteria[index].Value = 1 # 1 for plane, 2 cylinder, etc).

    Thank you

    Erik