How can I create Groups inside SC from selected faces that are obtained by the small faces tool

Erik Kostson
Erik Kostson Member, Employee Posts: 101
First Answer Name Dropper First Anniversary Ansys Employee
edited September 2023 in General Language Questions

How can I create a Group/Named Selection inside SC from selected faces that are obtained by the small faces tool?

Best Answer

  • Erik Kostson
    Erik Kostson Member, Employee Posts: 101
    First Answer Name Dropper First Anniversary Ansys Employee
    edited September 2023 Answer ✓

    Below is a script that does that (SC small faces tool is not used but the below code does the same):

    allfaces=[]
    allBodies = GetRootPart().GetAllBodies()
    for body in allBodies:
        faces=body.Faces
        for face in faces:
            if face.Area<=0.0002: # max face size in m2
                edges = face.Edges
                for edge in edges:
                    if edge.Shape.Length<=0.007: # max edge length in m
                        allfaces.append((face))
    primarySelection = FaceSelection.Create(allfaces)
    secondarySelection = Selection.Empty()
    resultns = NamedSelection.Create(primarySelection, secondarySelection)