In Mechanical scripting how can I create a Named Selection that is scoped to a list of node numbers?

Landon Mitchell Kanner
Landon Mitchell Kanner Member, Employee Posts: 291
25 Answers 100 Comments 25 Likes First Anniversary
✭✭✭✭
edited June 2023 in Structures

I have a list of node numbers in a CSV file. I would like to create a named selection with the node numbers, so that I can visualize where are these nodes located at the mesh.

Is this possible with Mechanical Scripting?

Tagged:

Answers

  • Landon Mitchell Kanner
    Landon Mitchell Kanner Member, Employee Posts: 291
    25 Answers 100 Comments 25 Likes First Anniversary
    ✭✭✭✭
    nodeIDs = [1,3,9]
    ns = ExtAPI.DataModel.Project.Model.AddNamedSelection()
    ns.ScopingMethod = ns.ScopingMethod.Worksheet
    for nodeID in nodeIDs:
      criterion=Ansys.ACT.Automation.Mechanical.NamedSelectionCriterion()
      criterion.Action= criterion.Action.Add
      criterion.EntityType = criterion.EntityType.MeshNode
      criterion.Criterion = criterion.Criterion.NodeNumber
      criterion.Operator = criterion.Operator.Equal
      criterion.Value = nodeID
      ns.GenerationCriteria.Add(criterion)
    ns.Generate()