How can I select all shell bodies lying on a specific plane whose face normals are oriented along the Y-axis?
You can use the below snippet to create a named selection of bodies in XZ plane with Y normals. Modify the script to select bodies in other planes.
target_nx = 0.0 target_ny = 1.0 target_nz = 0.0 tol = 1e-6 named_selection_name = "Bodies_With_Face_Normal_010" body_ids = [] geo_data = ExtAPI.DataModel.GeoData for assembly in geo_data.Assemblies: for part in assembly.Parts: for body in part.Bodies: for face in body.Faces: centroid = face.Centroid u, v = face.ParamAtPoint((centroid[0], centroid[1], centroid[2])) normal = face.NormalAtParam(u, v) if abs(normal[0] - target_nx) <= tol and \ abs(normal[1] - target_ny) <= tol and \ abs(normal[2] - target_nz) <= tol: if body.Id not in body_ids: body_ids.append(body.Id) break if len(body_ids) > 0: selection = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities) selection.Ids = body_ids ns = ExtAPI.DataModel.Project.Model.AddNamedSelection() ns.Name = named_selection_name ns.Location = selection ExtAPI.SelectionManager.NewSelection(selection) print "Named Selection created:", named_selection_name print "Number of bodies added:", len(body_ids)