Goal: Given a Y location and tolerance, create a selection of all nodes within that tolerance from their global Y coordinate location.
Code:
# Get access to mesh
mesh = DataModel.MeshDataByName(ExtAPI.DataModel.MeshDataNames[0])
selected_node_ids = set() # Empty set
for node in mesh.Nodes:
tolerance = 0.0001 # 0.1 mm
y_location = 0.0130
if (node.Y >= y_location - tolerance) and (node.Y <= y_location + tolerance):
selected_node_ids.add(node.Id)
# Create selection
selection_info = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.MeshNodes)
for selected_node_id in selected_node_ids:
selection_info.Ids.Add(selected_node_id)
ExtAPI.SelectionManager.NewSelection(selection_info)