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

Options
Chemsdine CHEMAI
Chemsdine CHEMAI Member, Employee Posts: 201
First Anniversary Ansys Employee Solution Developer Community of Practice Member 5 Likes
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
    First Anniversary Ansys Employee Solution Developer Community of Practice Member 5 Likes
    Answer ✓
    Options

    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: 101
    First Anniversary Ansys Employee Solution Developer Community of Practice Member Photogenic
    Answer ✓
    Options

    And don’t forget NS.Generate()

Answers

  • Erik Kostson
    Erik Kostson Member, Employee Posts: 130
    First Answer Name Dropper First Anniversary Ansys Employee
    edited April 30
    Options

    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: 2
    First Comment
    Options

    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: 2
    First Comment
    Options

    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, Employee Posts: 130
    First Answer Name Dropper First Anniversary Ansys Employee
    edited April 30
    Options

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

    Thank you

    Erik